Changeset 466 in svn
- Timestamp:
- Jul 10, 2009, 4:54:59 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGELOG
r457 r466 6 6 (input event files, detector card, trigger card, beam files, particle table) 7 7 - it is now possible to read "delphes root files" as an input for Delphes (GEN tree) 8 - bug fix: number of events to process is correct event if multiple files in the inputlist 8 9 9 10 /-----------------------------------------\ -
trunk/src/HEPEVTConverter.cc
r443 r466 57 57 //------------------------------------------------------------------------------ 58 58 59 //Nevents not yet implemented! 08.03.200960 61 59 HEPTreeReader::HEPTreeReader(TTree *tree, HEPEvent *event) : fChain(tree), fCurrentTree(-1), fEvent(event) 62 60 { … … 174 172 { 175 173 string buffer; 174 int nevt_already_processed=0; 176 175 177 176 gROOT->SetBatch(); … … 190 189 while(1) 191 190 { 192 191 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 193 192 TChain *chain = new TChain("h101"); 194 193 infile >> buffer; … … 203 202 else checking_the_file.close(); 204 203 205 if(!infile.good()) break; 204 if(!infile.good()) break; // end of the list 206 205 chain->Add(buffer.c_str()); 207 206 … … 214 213 215 214 TRootC::GenParticle *element; 216 allEntries = (Nevt<0)?allEntries:min((int)allEntries,Nevt); // do not miss the "+1"215 allEntries = (Nevt<0)?allEntries:min((int)allEntries,Nevt); 217 216 // Loop over all events 218 217 for(entry = 0; entry < allEntries; ++entry) 219 218 { 219 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 220 220 // Load selected branches with data from specified event 221 221 treeReader->ReadEntry(entry); … … 253 253 } 254 254 treeWriter->Fill(); 255 ++nevt_already_processed; 255 256 } 256 257 delete chain; -
trunk/src/HepMCConverter.cc
r443 r466 270 270 // generated particles from HEPEVT 271 271 ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class()); 272 272 273 int nevt_already_processed=0; 274 273 275 // Open a stream connected to an event file: 274 276 ifstream infile(inputFileList.c_str()); … … 285 287 { 286 288 infile >> filename; 287 if(!infile.good()) break; 289 if(!infile.good()) break; // end of listfile reached 290 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 291 288 292 ifstream checking_the_file(filename.c_str()); 289 293 if(!checking_the_file.good()) … … 305 309 { 306 310 if(Nevt>0 && entry>=Nevt) break; 311 if(Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 307 312 308 313 treeWriter->Clear(); … … 314 319 treeWriter->Fill(); 315 320 ++entry; 321 ++nevt_already_processed; 316 322 } 317 323 } … … 322 328 } 323 329 324 325 326 -
trunk/src/LHEFConverter.cc
r450 r466 171 171 ExRootTreeBranch *branchParticle = treeWriter->NewBranch("Particle", TRootLHEFParticle::Class()); 172 172 //ExRootTreeBranch *branchParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class()); 173 174 int nevt_already_processed=0; 173 175 174 176 // Open a stream connected to an event file: … … 186 188 infile >> filename; 187 189 if(!infile.good()) break; 190 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 191 188 192 ifstream checking_the_file(filename.c_str()); 189 193 if(!checking_the_file.good()) … … 206 210 Long64_t entry = 0; 207 211 while(inputReader->readEvent()) { 212 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 208 213 treeWriter->Clear(); 209 214 AnalyseEvent(inputReader, branchEvent, entry + 1); … … 211 216 treeWriter->Fill(); 212 217 ++entry; 218 ++nevt_already_processed; 213 219 if(allEntries<entry+1) break; 214 220 } -
trunk/src/STDHEPConverter.cc
r443 r466 60 60 //--------------------------------------------------------------------------- 61 61 62 void STDHEPConverter::AnalyseParticles(ExRootTreeBranch *branch) 63 { 64 int Nmax = -1; // useless for the moment -- should be changed in order 65 if(Nmax>0) Nmax = min(Nmax,myhepevt.nhep); // to use Nevt in DataConverter 66 else Nmax = myhepevt.nhep; 67 62 void STDHEPConverter::AnalyseParticles(ExRootTreeBranch *branch) 63 { 68 64 TRootC::GenParticle *element; 69 65 … … 72 68 Int_t number; 73 69 74 for(number = 0; number < Nmax; ++number)70 for(number = 0; number < myhepevt.nhep; ++number) 75 71 { 76 72 element = static_cast<TRootC::GenParticle*>(branch->NewEntry()); … … 119 115 int ierr, entryType; 120 116 int istr = 0; 121 int nevt = 0 ;117 int nevt = 0, nevt_already_processed=0; 122 118 123 119 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN"); … … 136 132 << left << setw(20) << inputFileList <<"" 137 133 << right << setw(19) <<"for input **"<<""<<endl; 138 139 134 exit(1); 140 135 } 136 137 // Parsing the input list 141 138 while(1) 142 139 { 143 140 infile >> filename; 144 if(!infile.good()) break; 145 ifstream checking_the_file(filename.c_str()); 146 if(!checking_the_file.good()) 147 { 141 if(!infile.good()) break; // end of the list 142 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 143 144 ifstream checking_the_file(filename.c_str()); 145 if(!checking_the_file.good()) { 148 146 cerr << left << setw(30) <<"** ERROR: Can't find file "<<"" 149 147 << left << setw(20) << filename <<"" 150 148 << right << setw(19) <<"for input **"<<""<<endl; 151 149 continue; 152 } 153 else checking_the_file.close(); 150 } else checking_the_file.close(); 154 151 155 152 ierr = StdHepXdrReadInit(const_cast<char*>(filename.c_str()), &nevt, istr); 156 157 if(ierr != 0) 158 { 153 154 if(ierr != 0) { 159 155 cerr <<"** ERROR: Can't open file for input **"<<endl; 160 156 break; 161 } 157 } 158 162 159 163 160 Long64_t allEntries = (Nevt<0)?nevt:min(nevt,Nevt+1); // do not miss the "+1" … … 170 167 { 171 168 ierr = StdHepXdrRead(&entryType, istr); 169 if (Nevt>0 && nevt_already_processed >=Nevt) break; // enough events already processed 172 170 173 if(ierr != 0) 174 { 171 if(ierr != 0) { 175 172 cerr << left << setw(49) <<"** ERROR: Unexpected end of file after"<<"" 176 173 << left << setw(10) << entry <<"" 177 174 << right << setw(10) <<"entries **"<<""<<endl; 178 175 break; 179 }176 } // if error 180 177 181 178 // analyse only entries with standard HEPEVT common block 182 if(entryType == 1) 183 { 179 if(entryType == 1) { 184 180 // add empty events for missing event numbers 185 while(recordNumber < myhepevt.nevhep) 186 { 181 while(recordNumber < myhepevt.nevhep) { 187 182 treeWriter->Clear(); 188 183 AnalyseEvent(branchGenEvent, recordNumber); 189 184 treeWriter->Fill(); 190 185 ++recordNumber; 191 } 186 ++nevt_already_processed; 187 } // while 192 188 193 189 treeWriter->Clear(); 194 195 190 AnalyseEvent(branchGenEvent, myhepevt.nevhep); 196 191 AnalyseParticles(branchGenParticle); 197 198 192 treeWriter->Fill(); 199 200 193 ++recordNumber; 201 202 } 203 } 204 } 194 ++nevt_already_processed; 195 } // if 196 } // for 197 } // if allEntries >0 205 198 StdHepXdrEnd(istr); 206 } 199 } // while inputlist not empty 207 200 treeWriter->Write(); 208 201
Note:
See TracChangeset
for help on using the changeset viewer.