Changeset 466 in svn for trunk/src/STDHEPConverter.cc
- Timestamp:
- Jul 10, 2009, 4:54:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.