Fork me on GitHub

Changeset 386f526 in git


Ignore:
Timestamp:
Oct 7, 2016, 9:33:22 PM (8 years ago)
Author:
Geonmo <ry840901@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
837fa70
Parents:
06a83b3
Message:

bugfix "prunedGenParticle" to "packedGenParticle"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • readers/DelphesCMSFWLite.cpp

    r06a83b3 r386f526  
    5353#include "DataFormats/FWLite/interface/Handle.h"
    5454#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
     55#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
    5556#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
    5657#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
     
    6364
    6465void 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)
    6869{
    6970
     
    7172  fwlite::Handle< LHEEventProduct > handleLHEEvent;
    7273  fwlite::Handle< vector< reco::GenParticle > > handleParticle;
     74  fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle;
    7375
    7476  vector< reco::GenParticle >::const_iterator itParticle;
     77  vector< pat::PackedGenParticle >::const_iterator itPackedParticle;
    7578
    7679  vector< const reco::Candidate * > vectorCandidate;
     
    9699    handleParticle.getByLabel(event, "genParticles");
    97100  }
    98   else if (!((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))
    99   {
    100     handleParticle.getByLabel(event, "prunedGenParticles");
     101  else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()))
     102  {
     103    handlePackedParticle.getByLabel(event, "packedGenParticles");
    101104  }
    102105  else
     
    107110
    108111  Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
     112  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ;
    109113
    110114  HepMCEvent *element;
     
    146150    const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
    147151    vector< gen::WeightsInfo >::const_iterator itWeightsInfo;
    148    
     152
    149153    for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
    150154    {
     
    155159
    156160  pdg = TDatabasePDG::Instance();
    157 
    158   for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
    159   {
    160     vectorCandidate.push_back(&*itParticle);
    161   }
    162 
    163   for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
    164   {
    165     const reco::GenParticle &particle = *itParticle;
    166 
    167     pid = particle.pdgId();
    168     status = particle.status();
    169     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    170     x = particle.vx(); y = particle.vy(); z = particle.vz();
    171 
    172     candidate = factory->NewCandidate();
    173 
    174     candidate->PID = pid;
    175     pdgCode = TMath::Abs(candidate->PID);
    176 
    177     candidate->Status = status;
    178 
    179     if(particle.mother())
    180     {
    181       itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
    182       if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
    183     }
    184 
    185     itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
    186     if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
    187 
    188     itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
    189     if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
    190 
    191     pdgParticle = pdg->GetParticle(pid);
    192     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    193     candidate->Mass = mass;
    194 
    195     candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    196 
    197     candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
    198 
    199     allParticleOutputArray->Add(candidate);
    200 
    201     if(!pdgParticle) continue;
    202 
    203     if(status == 1)
    204     {
    205       stableParticleOutputArray->Add(candidate);
    206     }
    207     else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    208     {
    209       partonOutputArray->Add(candidate);
     161  if( !isMiniAOD) {
     162    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
     163    {
     164      vectorCandidate.push_back(&*itParticle);
     165    }
     166
     167    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
     168    {
     169      const reco::GenParticle &particle = *itParticle;
     170
     171      pid = particle.pdgId();
     172      status = particle.status();
     173      px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
     174      x = particle.vx(); y = particle.vy(); z = particle.vz();
     175
     176      candidate = factory->NewCandidate();
     177
     178      candidate->PID = pid;
     179      pdgCode = TMath::Abs(candidate->PID);
     180
     181      candidate->Status = status;
     182
     183      if(particle.mother())
     184      {
     185        itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
     186        if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
     187      }
     188
     189      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
     190      if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
     191
     192      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
     193      if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
     194
     195      pdgParticle = pdg->GetParticle(pid);
     196      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     197      candidate->Mass = mass;
     198
     199      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
     200
     201      candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     202
     203      allParticleOutputArray->Add(candidate);
     204
     205      if(!pdgParticle) continue;
     206
     207      if(status == 1)
     208      {
     209        stableParticleOutputArray->Add(candidate);
     210      }
     211      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
     212      {
     213        partonOutputArray->Add(candidate);
     214      }
     215    }
     216  }
     217  else {
     218    for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
     219    {
     220      vectorCandidate.push_back(&*itPackedParticle);
     221    }
     222
     223    for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
     224    {
     225      const pat::PackedGenParticle &particle = *itPackedParticle;
     226 
     227      pid = particle.pdgId();
     228      status = particle.status();
     229      px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
     230      x = particle.vx(); y = particle.vy(); z = particle.vz();
     231
     232      candidate = factory->NewCandidate();
     233
     234      candidate->PID = pid;
     235      pdgCode = TMath::Abs(candidate->PID);
     236
     237      candidate->Status = status;
     238
     239      if(particle.mother(0))
     240      {
     241        itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother(0));
     242        if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
     243      }
     244
     245      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
     246      if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
     247
     248      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
     249      if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
     250
     251      pdgParticle = pdg->GetParticle(pid);
     252      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     253      candidate->Mass = mass;
     254
     255      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
     256
     257      candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     258
     259      allParticleOutputArray->Add(candidate);
     260
     261      if(!pdgParticle) continue;
     262
     263      if(status == 1)
     264      {
     265        stableParticleOutputArray->Add(candidate);
     266      }
     267      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
     268      {
     269        partonOutputArray->Add(candidate);
     270      }
    210271    }
    211272  }
     
    258319
    259320  FWLiteEnabler::enable();
    260  
     321
    261322  try
    262323  {
     
    317378      {
    318379        ConvertInput(event, eventCounter, branchEvent, branchRwgt, factory,
    319           allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
     380            allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
    320381        modularDelphes->ProcessTask();
    321          
     382
    322383        firstEvent = kFALSE;
    323384
Note: See TracChangeset for help on using the changeset viewer.