Fork me on GitHub

source: svn/trunk/src/LHCOConverter.cc@ 273

Last change on this file since 273 was 271, checked in by Xavier Rouby, 16 years ago

convert ExRoot to LHCO

File size: 3.9 KB
RevLine 
[271]1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \----------------------------------------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
12** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
13** FROG: [hep-ex/0901.2718v1] **
14** **
15** ------------------------------------------------------------------ **
16** **
17** Main authors: **
18** ------------- **
19** **
20** Severine Ovyn Xavier Rouby **
21** severine.ovyn@uclouvain.be xavier.rouby@cern **
22** **
23** Center for Particle Physics and Phenomenology (CP3) **
24** Universite catholique de Louvain (UCL) **
25** Louvain-la-Neuve, Belgium **
26** **
27** Copyright (C) 2008-2009, **
28** All rights reserved. **
29** **
30***********************************************************************/
31
32#include "LHCOConverter.h"
33#include <iostream>
34#include <string>
35#include <fstream>
36#include <sstream>
37using namespace std;
38
39
40//------------------------------------------------------------------------------
41extern const float UNDEFINED;
42
43LHCOConverter::LHCOConverter(const string& inputroot, const string& inputlog):
44 inputfilename_(inputroot), inputlogname_(inputlog), outputfilename_(inputroot), valid_(true) {
45 if (inputfilename_ == "") {valid_ = false;}
46 else {
47 const unsigned int r_find = outputfilename_.rfind(".root");
48 if(r_find > outputfilename_.size()) {
49 cout << "ERROR: the extension of the input file is not '.root'. Exiting...\n"; valid_=false;
50 }
51 outputfilename_.replace(r_find,5,".lhco");
52 ofstream outfile( outputfilename_.c_str());
53 outfile.close();
54 cout << "INFO: " << outputfilename_ << " has been created\n";
55 }
56}
57
58void LHCOConverter::CopyRunLogFile() {
59 if(!valid_) {cout << "Nothing done\n"; return; }
60 if(inputlogname_ == "") {
61 // re-creates the logrun file name from the rootfile name
62 inputlogname_ = inputfilename_;
63 const unsigned int r_find = inputlogname_.rfind(".root");
64 inputlogname_.replace(r_find,5,"_run.log");
65 }
66 ifstream infile( inputlogname_.c_str() );
67 if (!infile.good()) { cout << "Warning: no input logfile found\n"; return; }
68
69 ofstream outfile( outputfilename_.c_str(),ios_base::app);
70
71 // else, if find is found
72 string linereader;
73 while ( getline(infile,linereader) ) {
74 outfile << "## " << linereader << endl;
75 }
76 outfile << "##" << endl;
77 infile.close();
78 outfile.close();
79}
80
81void LHCOConverter::ConvertExRootAnalysisToLHCO() {
82 if(!valid_) {cout << "Nothing done\n"; return; }
83 cout << "Creating " << outputfilename_ << endl;
84
85}
Note: See TracBrowser for help on using the repository browser.