Skip to content

Commit

Permalink
Merge pull request cms-sw#668 from inugent/myMultiThreadPatch
Browse files Browse the repository at this point in the history
Use consumes API in TauSpinner
  • Loading branch information
ktf committed Aug 30, 2013
2 parents d51a254 + 5621b84 commit 6d0984b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions GeneratorInterface/ExternalDecays/interface/TauSpinnerCMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ class TauSpinnerCMS : public edm::EDProducer
int MotherPDGID_,Ipol_,nonSM2_,nonSMN_;
static bool isTauSpinnerConfigure;

edm::EDGetTokenT<HepMCProduct> EvtHandleToken_;
edm::EDGetTokenT<reco::GenParticleCollection> gensrcToken_;

// Additional funtionms for Reco (not provided by Tauola/TauSpinner authors)
int readParticlesfromReco(edm::Event& e,SimpleParticle &X,SimpleParticle &tau,SimpleParticle &tau2,
std::vector<SimpleParticle> &tau_daughters,std::vector<SimpleParticle> &tau2_daughters);
void GetLastSelf(const reco::GenParticle *Particle);
void GetRecoDaughters(const reco::GenParticle *Particle,std::vector<SimpleParticle> &daughters,int parentpdgid);
bool isFirst(const reco::GenParticle *Particle);
double roundOff_;

};
#endif
7 changes: 5 additions & 2 deletions GeneratorInterface/ExternalDecays/plugins/TauSpinnerCMS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ TauSpinnerCMS::TauSpinnerCMS( const ParameterSet& pset ) :
produces<double>("TauSpinnerWTFlip").setBranchAlias("TauSpinnerWTFlip");
produces<double>("TauSpinnerWThplus").setBranchAlias("TauSpinnerWThplus");
produces<double>("TauSpinnerWThminus").setBranchAlias("TauSpinnerWThminus");

if(isReco_) EvtHandleToken_ = consumes<HepMCProduct>(gensrc_);
if(isReco_) gensrcToken_= consumes<reco::GenParticleCollection>(gensrc_);
}

void TauSpinnerCMS::beginJob()
Expand Down Expand Up @@ -60,7 +63,7 @@ void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){
}
else{
Handle< HepMCProduct > EvtHandle ;
e.getByLabel( "generator", EvtHandle ) ;
e.getByToken(EvtHandleToken_, EvtHandle ) ;
const HepMC::GenEvent* Evt = EvtHandle->GetEvent() ;
stat=readParticlesFromHepMC(Evt,X,tau,tau2,tau_daughters,tau_daughters2);
}
Expand Down Expand Up @@ -147,7 +150,7 @@ void TauSpinnerCMS::endJob(){}
int TauSpinnerCMS::readParticlesfromReco(edm::Event& e,SimpleParticle &X,SimpleParticle &tau,SimpleParticle &tau2,
std::vector<SimpleParticle> &tau_daughters,std::vector<SimpleParticle> &tau2_daughters){
edm::Handle<reco::GenParticleCollection> genParticles;
e.getByLabel(gensrc_, genParticles);
e.getByToken(gensrcToken_, genParticles);
for(reco::GenParticleCollection::const_iterator itr = genParticles->begin(); itr!= genParticles->end(); ++itr){
int pdgid=abs(itr->pdgId());
if(pdgid==24 || pdgid==37 || pdgid ==25 || pdgid==36 || pdgid==22 || pdgid==23 ){
Expand Down

0 comments on commit 6d0984b

Please sign in to comment.