Changeset a7c9002 in git
- Timestamp:
- Nov 10, 2016, 3:06:18 PM (8 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 5df97ac
- Parents:
- a0f2226 (diff), 837fa70 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Pavel Demin <pavel-demin@…> (11/10/16 15:06:18)
- git-committer:
- GitHub <noreply@…> (11/10/16 15:06:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
readers/DelphesCMSFWLite.cpp
ra0f2226 ra7c9002 53 53 #include "DataFormats/FWLite/interface/Handle.h" 54 54 #include "DataFormats/HepMCCandidate/interface/GenParticle.h" 55 #include "DataFormats/PatCandidates/interface/PackedGenParticle.h" 55 56 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" 56 57 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" … … 63 64 64 65 void ConvertInput(fwlite::Event &event, Long64_t eventCounter, 65 ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt,66 DelphesFactory *factory, TObjArray *allParticleOutputArray,67 TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent)66 ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt, 67 DelphesFactory *factory, TObjArray *allParticleOutputArray, 68 TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent) 68 69 { 69 70 … … 71 72 fwlite::Handle< LHEEventProduct > handleLHEEvent; 72 73 fwlite::Handle< vector< reco::GenParticle > > handleParticle; 74 fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle; 73 75 74 76 vector< reco::GenParticle >::const_iterator itParticle; 77 vector< pat::PackedGenParticle >::const_iterator itPackedParticle; 75 78 76 79 vector< const reco::Candidate * > vectorCandidate; … … 96 99 handleParticle.getByLabel(event, "genParticles"); 97 100 } 98 else if (!((handlePa rticle.getBranchNameFor(event,"prunedGenParticles")).empty()))101 else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event,"prunedGenParticles")).empty())) 99 102 { 100 103 handleParticle.getByLabel(event, "prunedGenParticles"); 104 handlePackedParticle.getByLabel(event, "packedGenParticles"); 101 105 } 102 106 else … … 107 111 108 112 Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty()); 113 Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ; 109 114 110 115 HepMCEvent *element; … … 146 151 const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights(); 147 152 vector< gen::WeightsInfo >::const_iterator itWeightsInfo; 148 153 149 154 for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo) 150 155 { … … 158 163 for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle) 159 164 { 160 vectorCandidate.push_back(&*itParticle); 165 const reco::GenParticle &particle = *itParticle; 166 if( !isMiniAOD || particle.status() != 1 ) vectorCandidate.push_back(&*itParticle); 161 167 } 162 168 … … 164 170 { 165 171 const reco::GenParticle &particle = *itParticle; 172 173 pid = particle.pdgId(); 174 status = particle.status(); 175 if( isMiniAOD && particle.status() == 1 ) continue; 176 px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass(); 177 x = particle.vx(); y = particle.vy(); z = particle.vz(); 178 179 candidate = factory->NewCandidate(); 180 181 candidate->PID = pid; 182 pdgCode = TMath::Abs(candidate->PID); 183 184 candidate->Status = status; 185 186 if(particle.mother()) 187 { 188 itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother()); 189 if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate); 190 } 191 192 itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0)); 193 if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate); 194 195 itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1)); 196 if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate); 197 198 pdgParticle = pdg->GetParticle(pid); 199 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999; 200 candidate->Mass = mass; 201 202 candidate->Momentum.SetPxPyPzE(px, py, pz, e); 203 204 candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0); 205 206 allParticleOutputArray->Add(candidate); 207 208 if(!pdgParticle) continue; 209 210 if( status == 1) 211 { 212 // Prevent duplicated particle. 213 if ( !isMiniAOD ) stableParticleOutputArray->Add(candidate); 214 } 215 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) 216 { 217 partonOutputArray->Add(candidate); 218 } 219 } 220 if ( !isMiniAOD) return ; 221 // For MiniAOD sample, 222 // Only status==1 particles are saved to packedGenParticles. 223 for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle) 224 { 225 vectorCandidate.push_back(&*itPackedParticle); 226 } 227 228 for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle) 229 { 230 const pat::PackedGenParticle &particle = *itPackedParticle; 166 231 167 232 pid = particle.pdgId(); … … 177 242 candidate->Status = status; 178 243 179 if(particle.mother( ))180 { 181 itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother( ));244 if(particle.mother(0)) 245 { 246 itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother(0)); 182 247 if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate); 183 248 } … … 204 269 { 205 270 stableParticleOutputArray->Add(candidate); 206 }207 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)208 {209 partonOutputArray->Add(candidate);210 271 } 211 272 } … … 258 319 259 320 FWLiteEnabler::enable(); 260 321 261 322 try 262 323 { … … 317 378 { 318 379 ConvertInput(event, eventCounter, branchEvent, branchRwgt, factory, 319 allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);380 allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent); 320 381 modularDelphes->ProcessTask(); 321 382 322 383 firstEvent = kFALSE; 323 384
Note:
See TracChangeset
for help on using the changeset viewer.