Changeset 380 in svn for trunk/Examples
- Timestamp:
- May 12, 2009, 9:47:12 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Examples/Convertors_Only.cpp
r266 r380 45 45 #include "DataConverter.h" 46 46 #include "HEPEVTConverter.h" 47 #include "HepMCConverter.h" 47 48 #include "LHEFConverter.h" 48 49 #include "STDHEPConverter.h" … … 60 61 61 62 using namespace std; 62 63 //------------------------------------------------------------------------------64 void todo(string filename) {65 ifstream infile(filename.c_str());66 cout << "** TODO list ..." << endl;67 while(infile.good()) {68 string temp;69 getline(infile,temp);70 cout << "*" << temp << endl;71 }72 cout << "** done...\n";73 }74 63 75 64 //------------------------------------------------------------------------------ … … 88 77 delete [] appOpt; 89 78 90 if(argc != 3) {91 cout << " Usage: " << argv[0] << " input_file output_file " << endl;79 if(argc != 4) { 80 cout << " Usage: " << argv[0] << " input_file output_file PDG_Table" << endl; 92 81 cout << " input_list - list of files in Ntpl, StdHep of LHEF format," << endl; 93 cout << " output_file - output file." << endl; 82 cout << " output_file - output file," << endl; 83 cout << " PDG_Table - file with PDG particle table" << endl; 94 84 exit(1); 95 85 } … … 160 150 161 151 //read the output TROOT file 162 string inputFileList(argv[1]), outputfilename(argv[2]) ;152 string inputFileList(argv[1]), outputfilename(argv[2]), pdgtablefilename(argv[3]); 163 153 if(outputfilename.find(".root") > outputfilename.length()) { 164 154 cout <<"** ERROR: 'output_file' should be a .root file. Exiting... **"<< endl; 165 155 exit(1); 166 156 } 167 157 158 RESOLution DET; 159 DET.PdgTableFilename = pdgtablefilename; 160 DET.ReadParticleDataGroupTable(); // DET.PDGtable.print(); 161 168 162 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after 169 163 outputFile->Close(); … … 174 168 175 169 // data converters 176 DataConverter *converter=NULL;177 170 cout <<"** **"<<endl; 178 171 cout <<"** ####### Start convertion to TRoot format ######## **"<< endl; 179 172 180 if( strstr(line.c_str(),".hep"))181 { 173 if(line.length() == 1+line.find_last_of(".hep")) 174 { 182 175 cout <<"** StdHEP file format detected **"<<endl; 183 176 cout <<"** This can take several minutes **"<< endl; 184 converter = new STDHEPConverter(inputFileList,outputfilename);//case ntpl file in input list185 } 186 else if( strstr(line.c_str(),".lhe"))177 STDHEPConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list 178 } 179 else if(line.length() == 1+line.find_last_of(".lhe")) 187 180 { 188 181 cout <<"** LHEF file format detected **"<<endl; 189 182 cout <<"** This can take several minutes **"<< endl; 190 converter = new LHEFConverter(inputFileList,outputfilename);//case ntpl file in input list191 } 192 else if( strstr(line.c_str(),".root"))183 LHEFConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list 184 } 185 else if(line.length() == 1+line.find_last_of(".root")) 193 186 { 194 187 cout <<"** h2root file format detected **"<<endl; 195 188 cout <<"** This can take several minutes **"<< endl; 196 converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list 189 HEPEVTConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list 190 } 191 else if(line.length() == 1+line.find_last_of(".hepmc")) 192 { 193 cout <<"** HepMC ASCII file format detected **"<<endl; 194 cout <<"** This can take several minutes **"<< endl; 195 HepMCConverter converter(inputFileList,outputfilename,DET.PDGtable); 197 196 } 198 197 else { 199 cerr << left << setw(4) <<"** "<<"" 200 << left << setw(63) << line.c_str() <<"" 201 << right << setw(2) <<"**"<<endl; 202 cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl; 203 cout <<"** **"<< endl; 204 cout <<"*********************************************************************"<< endl; 205 return -1;}; 198 cerr << left << setw(4) <<"** "<<"" 199 << left << setw(63) << line.c_str() <<"" 200 << right << setw(2) <<"**"<<endl; 201 cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl; 202 cout <<"** **"<< endl; 203 cout <<"*********************************************************************"<< endl; 204 return -1;}; 205 206 206 cout <<"** Exiting conversion... **"<< endl; 207 207 cout <<"*********************************************************************"<< endl; … … 209 209 210 210 211 delete converter;212 211 213 212 }
Note:
See TracChangeset
for help on using the changeset viewer.