CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
TauSpinnerCMS Class Reference

#include <TauSpinnerCMS.h>

Inheritance diagram for TauSpinnerCMS:
edm::one::EDProducer< edm::EndRunProducer, edm::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob () overridefinal
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void endJob () overridefinal
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endLuminosityBlockProduce (edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup)
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
virtual void endRunProduce (edm::Run &, edm::EventSetup const &)
 
virtual void initialize ()
 
virtual void produce (edm::Event &, const edm::EventSetup &) overridefinal
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
 TauSpinnerCMS (const edm::ParameterSet &)
 
virtual ~TauSpinnerCMS ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer, edm::one::SharedResources >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static double flat ()
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void GetLastSelf (const reco::GenParticle *Particle)
 
void GetRecoDaughters (const reco::GenParticle *Particle, std::vector< TauSpinner::SimpleParticle > &daughters, int parentpdgid)
 
bool isFirst (const reco::GenParticle *Particle)
 
int readParticlesfromReco (edm::Event &e, TauSpinner::SimpleParticle &X, TauSpinner::SimpleParticle &tau, TauSpinner::SimpleParticle &tau2, std::vector< TauSpinner::SimpleParticle > &tau_daughters, std::vector< TauSpinner::SimpleParticle > &tau2_daughters)
 

Private Attributes

double CMSEnergy_
 
edm::EDGetTokenT
< reco::GenParticleCollection
GenParticleCollectionToken_
 
edm::InputTag gensrc_
 
edm::EDGetTokenT
< edm::HepMCProduct
hepmcCollectionToken_
 
int Ipol_
 
bool isLHPDFConfigured_
 
bool isReco_
 
bool isTauolaConfigured_
 
std::string LHAPDFname_
 
int MotherPDGID_
 
int nonSM2_
 
int nonSMN_
 
double roundOff_
 

Static Private Attributes

static bool fInitialized =false
 
static CLHEP::HepRandomEngine * fRandomEngine = nullptr
 
static bool isTauSpinnerConfigure =false
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 49 of file TauSpinnerCMS.h.

Constructor & Destructor Documentation

TauSpinnerCMS::TauSpinnerCMS ( const edm::ParameterSet pset)
explicit

Definition at line 24 of file TauSpinnerCMS.cc.

References GenParticleCollectionToken_, gensrc_, hepmcCollectionToken_, isReco_, and edm::SharedResourceNames::kTauola.

24  :
25  EDProducer()
26  ,isReco_(pset.getParameter<bool>("isReco"))
27  ,isTauolaConfigured_(pset.getParameter<bool>("isTauolaConfigured" ))
28  ,isLHPDFConfigured_(pset.getParameter<bool>("isLHPDFConfigured" ))
29  ,LHAPDFname_(pset.getUntrackedParameter("LHAPDFname",(string)("MSTW2008nnlo90cl.LHgrid")))
30  ,CMSEnergy_(pset.getParameter<double>("CMSEnergy"))//GeV
31  ,gensrc_(pset.getParameter<edm::InputTag>("gensrc"))
32  ,MotherPDGID_(pset.getUntrackedParameter("MotherPDGID",(int)(-1)))
33  ,Ipol_(pset.getUntrackedParameter("Ipol",(int)(0)))
34  ,nonSM2_(pset.getUntrackedParameter("nonSM2",(int)(0)))
35  ,nonSMN_(pset.getUntrackedParameter("nonSMN",(int)(0)))
36  ,roundOff_(pset.getUntrackedParameter("roundOff",(double)(0.01)))
37 {
38  //usesResource(edm::uniqueSharedResourceName());
40 
41  produces<bool>("TauSpinnerWTisValid").setBranchAlias("TauSpinnerWTisValid");
42  produces<double>("TauSpinnerWT").setBranchAlias("TauSpinnerWT");
43  produces<double>("TauSpinnerWTFlip").setBranchAlias("TauSpinnerWTFlip");
44  produces<double>("TauSpinnerWThplus").setBranchAlias("TauSpinnerWThplus");
45  produces<double>("TauSpinnerWThminus").setBranchAlias("TauSpinnerWThminus");
46 
47  if(isReco_){
48  GenParticleCollectionToken_=consumes<reco::GenParticleCollection>(gensrc_);
49  }
50  else{
51  hepmcCollectionToken_=consumes<HepMCProduct>(gensrc_);
52  }
53 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: TauSpinnerCMS.h:92
static const std::string kTauola
double roundOff_
Definition: TauSpinnerCMS.h:89
edm::EDGetTokenT< reco::GenParticleCollection > GenParticleCollectionToken_
Definition: TauSpinnerCMS.h:93
bool isTauolaConfigured_
Definition: TauSpinnerCMS.h:69
std::string LHAPDFname_
Definition: TauSpinnerCMS.h:71
edm::InputTag gensrc_
Definition: TauSpinnerCMS.h:73
double CMSEnergy_
Definition: TauSpinnerCMS.h:72
bool isLHPDFConfigured_
Definition: TauSpinnerCMS.h:70
virtual TauSpinnerCMS::~TauSpinnerCMS ( )
inlinevirtual

Definition at line 52 of file TauSpinnerCMS.h.

52 {} // no need to delete ROOT stuff

Member Function Documentation

void TauSpinnerCMS::beginJob ( void  )
finaloverridevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 78 of file TauSpinnerCMS.cc.

78  {
79 
80 }
virtual void TauSpinnerCMS::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlinevirtual

Definition at line 55 of file TauSpinnerCMS.h.

55 {}
virtual void TauSpinnerCMS::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlinevirtual

Definition at line 54 of file TauSpinnerCMS.h.

54 {}
void TauSpinnerCMS::endJob ( void  )
finaloverridevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 181 of file TauSpinnerCMS.cc.

181 {}
virtual void TauSpinnerCMS::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlinevirtual

Definition at line 56 of file TauSpinnerCMS.h.

56 {}
void TauSpinnerCMS::endLuminosityBlockProduce ( edm::LuminosityBlock lumiSeg,
const edm::EventSetup iSetup 
)
virtual

Definition at line 76 of file TauSpinnerCMS.cc.

76 {}
void TauSpinnerCMS::endRun ( const edm::Run r,
const edm::EventSetup  
)
virtual

Definition at line 179 of file TauSpinnerCMS.cc.

179 {}
virtual void TauSpinnerCMS::endRunProduce ( edm::Run ,
edm::EventSetup const &   
)
inlinevirtual

Definition at line 57 of file TauSpinnerCMS.h.

57 {}
double TauSpinnerCMS::flat ( void  )
static

Definition at line 270 of file TauSpinnerCMS.cc.

References edm::hlt::Exception, and fRandomEngine.

Referenced by initialize(), and produce().

271 {
272  if ( !fRandomEngine ) {
273  throw cms::Exception("LogicError")
274  << "TauSpinnerCMS::flat: Attempt to generate random number when engine pointer is null\n"
275  << "This might mean that the code was modified to generate a random number outside the\n"
276  << "event and beginLuminosityBlock methods, which is not allowed.\n";
277  }
278  return fRandomEngine->flat();
279 }
static CLHEP::HepRandomEngine * fRandomEngine
Definition: TauSpinnerCMS.h:91
void TauSpinnerCMS::GetLastSelf ( const reco::GenParticle Particle)
private

Definition at line 238 of file TauSpinnerCMS.cc.

References reco::CompositeRefCandidateT< D >::daughter(), i, reco::CompositeRefCandidateT< D >::numberOfDaughters(), and reco::LeafCandidate::pdgId().

Referenced by readParticlesfromReco().

238  {
239  for (unsigned int i=0; i< Particle->numberOfDaughters(); i++){
240  const reco::GenParticle *dau=static_cast<const reco::GenParticle*>(Particle->daughter(i));
241  if(Particle->pdgId()==dau->pdgId()){
242  Particle=dau;
243  GetLastSelf(Particle);
244  }
245  }
246 }
int i
Definition: DBlmapReader.cc:9
void GetLastSelf(const reco::GenParticle *Particle)
virtual int pdgId() const GCC11_FINAL
PDG identifier.
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void TauSpinnerCMS::GetRecoDaughters ( const reco::GenParticle Particle,
std::vector< TauSpinner::SimpleParticle > &  daughters,
int  parentpdgid 
)
private

Definition at line 258 of file TauSpinnerCMS.cc.

References funct::abs(), reco::CompositeRefCandidateT< D >::daughter(), i, reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::LeafCandidate::p4(), and reco::LeafCandidate::pdgId().

Referenced by readParticlesfromReco().

258  {
259  if( Particle->numberOfDaughters()==0 || abs(Particle->pdgId())==111){
260  SimpleParticle tp(Particle->p4().Px(), Particle->p4().Py(), Particle->p4().Pz(), Particle->p4().E(), Particle->pdgId());
261  daughters.push_back(tp);
262  return;
263  }
264  for (unsigned int i=0; i< Particle->numberOfDaughters(); i++){
265  const reco::Candidate *dau=Particle->daughter(i);
266  GetRecoDaughters(static_cast<const reco::GenParticle*>(dau),daughters,Particle->pdgId());
267  }
268 }
int i
Definition: DBlmapReader.cc:9
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual int pdgId() const GCC11_FINAL
PDG identifier.
void GetRecoDaughters(const reco::GenParticle *Particle, std::vector< TauSpinner::SimpleParticle > &daughters, int parentpdgid)
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void TauSpinnerCMS::initialize ( )
virtual

Definition at line 55 of file TauSpinnerCMS.cc.

References CMSEnergy_, fInitialized, flat(), initialize(), Ipol_, isLHPDFConfigured_, isTauolaConfigured_, isTauSpinnerConfigure, LHAPDFname_, nonSM2_, and nonSMN_.

Referenced by produce().

55  {
56  // Now for Tauola and TauSpinner
58  Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat);
60  }
61  if(!isLHPDFConfigured_){
62  LHAPDF::initPDFSetByName(LHAPDFname_);
63  }
66  bool Ipp = true; // for pp collisions
67  // Initialize TauSpinner
68  //Ipol - polarization of input sample
69  //nonSM2 - nonstandard model calculations
70  //nonSMN
71  TauSpinner::initialize_spinner(Ipp,Ipol_,nonSM2_,nonSMN_,CMSEnergy_);
72  }
73  fInitialized=true;
74 }
static AlgebraicMatrix initialize()
static double flat()
static bool isTauSpinnerConfigure
Definition: TauSpinnerCMS.h:75
bool isTauolaConfigured_
Definition: TauSpinnerCMS.h:69
std::string LHAPDFname_
Definition: TauSpinnerCMS.h:71
static bool fInitialized
Definition: TauSpinnerCMS.h:94
double CMSEnergy_
Definition: TauSpinnerCMS.h:72
bool isLHPDFConfigured_
Definition: TauSpinnerCMS.h:70
bool TauSpinnerCMS::isFirst ( const reco::GenParticle Particle)
private

Definition at line 248 of file TauSpinnerCMS.cc.

References i, reco::CompositeRefCandidateT< D >::mother(), reco::CompositeRefCandidateT< D >::numberOfMothers(), and reco::LeafCandidate::pdgId().

Referenced by readParticlesfromReco().

248  {
249  for (unsigned int i=0; i< Particle->numberOfMothers(); i++){
250  const reco::GenParticle *moth=static_cast<const reco::GenParticle*>(Particle->mother(i));
251  if(Particle->pdgId()==moth->pdgId()){
252  return false;
253  }
254  }
255  return true;
256 }
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const GCC11_FINAL
PDG identifier.
virtual size_t numberOfMothers() const
number of mothers
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void TauSpinnerCMS::produce ( edm::Event e,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Implements edm::one::EDProducerBase.

Definition at line 82 of file TauSpinnerCMS.cc.

References funct::abs(), gather_cfg::cout, fInitialized, flat(), edm::Event::getByToken(), hepmcCollectionToken_, i, initialize(), isReco_, MotherPDGID_, edm::Event::put(), readParticlesFromHepMC(), readParticlesfromReco(), reco::return(), roundOff_, edm::Event::streamID(), metsig::tau, and X.

82  {
83  RandomEngineSentry<TauSpinnerCMS> randomEngineSentry(this, e.streamID());
84  if(!fInitialized) initialize();
85 
86  Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat); // rest tauola++ random number incase other modules use tauola++
87 
88  double WT=1.0;
89  double WTFlip=1.0;
90  double polSM=-999; //range [-1,1]
91  SimpleParticle X, tau, tau2;
92  std::vector<SimpleParticle> tau_daughters, tau_daughters2;
93  int stat(0);
94  if(isReco_){
95  stat=readParticlesfromReco(e,X,tau,tau2,tau_daughters,tau_daughters2);
96  }
97  else{
100  //Get EVENT
101  HepMC::GenEvent *Evt = new HepMC::GenEvent(*(evt->GetEvent()));
102  stat=readParticlesFromHepMC(Evt,X,tau,tau2,tau_daughters,tau_daughters2);
103  }
104  if(MotherPDGID_<0 || abs(X.pdgid())==MotherPDGID_){
105  if(stat!=1){
106  // Determine the weight
107  if( abs(X.pdgid())==24 || abs(X.pdgid())==37 ){
108  TLorentzVector tau_1r(0,0,0,0);
109  TLorentzVector tau_1(tau.px(),tau.py(),tau.pz(),tau.e());
110  for(unsigned int i=0; i<tau_daughters.size();i++){
111  tau_1r+=TLorentzVector(tau_daughters.at(i).px(),tau_daughters.at(i).py(),tau_daughters.at(i).pz(),tau_daughters.at(i).e());
112  }
113  if(fabs(tau_1r.M()-tau_1.M())<roundOff_){
114  WT = TauSpinner::calculateWeightFromParticlesWorHpn(X, tau, tau2, tau_daughters); // note that tau2 is tau neutrino
115  polSM=getTauSpin();
116  WTFlip=(2.0-WT)/WT;
117  }
118  }
119  else if( X.pdgid()==25 || X.pdgid()==36 || X.pdgid()==22 || X.pdgid()==23 ){
120  TLorentzVector tau_1r(0,0,0,0), tau_2r(0,0,0,0);
121  TLorentzVector tau_1(tau.px(),tau.py(),tau.pz(),tau.e()), tau_2(tau2.px(),tau2.py(),tau2.pz(),tau2.e());
122  for(unsigned int i=0; i<tau_daughters.size();i++){
123  tau_1r+=TLorentzVector(tau_daughters.at(i).px(),tau_daughters.at(i).py(),tau_daughters.at(i).pz(),tau_daughters.at(i).e());
124  }
125  for(unsigned int i=0; i<tau_daughters2.size();i++){
126  tau_2r+=TLorentzVector(tau_daughters2.at(i).px(),tau_daughters2.at(i).py(),tau_daughters2.at(i).pz(),tau_daughters2.at(i).e());
127  }
128 
129  if(fabs(tau_1r.M()-tau_1.M())<roundOff_ && fabs(tau_2r.M()-tau_2.M())<roundOff_){
130  WT = TauSpinner::calculateWeightFromParticlesH(X, tau, tau2, tau_daughters,tau_daughters2);
131  //std::cout << "WT " << WT << std::endl;
132  polSM=getTauSpin();
133  if(X.pdgid()==25 || X.pdgid()==22 || X.pdgid()==23 ){
134  if(X.pdgid()==25) X.setPdgid(23);
135  if( X.pdgid()==22 || X.pdgid()==23 ) X.setPdgid(25);
136 
137  double WTother=TauSpinner::calculateWeightFromParticlesH(X, tau, tau2, tau_daughters,tau_daughters2);
138  WTFlip=WTother/WT;
139  }
140  }
141  }
142  else{
143  cout<<"TauSpinner: WARNING: Unexpected PDG for tau mother: "<<X.pdgid()<<endl;
144  }
145  }
146  }
147  bool isValid=true;
148  if(!(0<=WT && WT<10)){isValid=false; WT=1.0; WTFlip=1.0;}
149  std::auto_ptr<bool> TauSpinnerWeightisValid(new bool);
150  *TauSpinnerWeightisValid =isValid;
151  e.put(TauSpinnerWeightisValid,"TauSpinnerWTisValid");
152 
153  // regular weight
154  std::auto_ptr<double> TauSpinnerWeight(new double);
155  *TauSpinnerWeight =WT;
156  e.put(TauSpinnerWeight,"TauSpinnerWT");
157 
158  // flipped weight (ie Z->H or H->Z)
159  std::auto_ptr<double> TauSpinnerWeightFlip(new double);
160  *TauSpinnerWeightFlip =WTFlip;
161  e.put(TauSpinnerWeightFlip,"TauSpinnerWTFlip");
162 
163  // h+ polarization
164  double WThplus=WT;
165  if(polSM<0.0 && polSM!=-999 && isValid) WThplus=0;
166  std::auto_ptr<double> TauSpinnerWeighthplus(new double);
167  *TauSpinnerWeighthplus = WThplus;
168  e.put(TauSpinnerWeighthplus,"TauSpinnerWThplus");
169 
170  // h- polarization
171  double WThminus=WT;
172  if(polSM>0.0&& polSM!=-999 && isValid) WThminus=0;
173  std::auto_ptr<double> TauSpinnerWeighthminus(new double);
174  *TauSpinnerWeighthminus = WThminus;
175  e.put(TauSpinnerWeighthminus,"TauSpinnerWThminus");
176  return ;
177 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: TauSpinnerCMS.h:92
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void initialize()
static double flat()
int readParticlesFromHepMC(const HepMC::GenEvent *event, SimpleParticle &X, SimpleParticle &tau, SimpleParticle &tau2, std::vector< SimpleParticle > &tau_daughters, std::vector< SimpleParticle > &tau2_daughters)
#define X(str)
Definition: MuonsGrabber.cc:48
double roundOff_
Definition: TauSpinnerCMS.h:89
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int readParticlesfromReco(edm::Event &e, TauSpinner::SimpleParticle &X, TauSpinner::SimpleParticle &tau, TauSpinner::SimpleParticle &tau2, std::vector< TauSpinner::SimpleParticle > &tau_daughters, std::vector< TauSpinner::SimpleParticle > &tau2_daughters)
static bool fInitialized
Definition: TauSpinnerCMS.h:94
return(e1-e2)*(e1-e2)+dp *dp
StreamID streamID() const
Definition: Event.h:75
tuple cout
Definition: gather_cfg.py:121
int TauSpinnerCMS::readParticlesfromReco ( edm::Event e,
TauSpinner::SimpleParticle &  X,
TauSpinner::SimpleParticle &  tau,
TauSpinner::SimpleParticle &  tau2,
std::vector< TauSpinner::SimpleParticle > &  tau_daughters,
std::vector< TauSpinner::SimpleParticle > &  tau2_daughters 
)
private

Definition at line 183 of file TauSpinnerCMS.cc.

References funct::abs(), reco::Candidate::daughter(), GenParticleCollectionToken_, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), GetLastSelf(), GetRecoDaughters(), i, isFirst(), NULL, reco::LeafCandidate::p4(), reco::Candidate::pdgId(), and reco::LeafCandidate::pdgId().

Referenced by produce().

184  {
186  e.getByToken(GenParticleCollectionToken_, genParticles);
187  for(reco::GenParticleCollection::const_iterator itr = genParticles->begin(); itr!= genParticles->end(); ++itr){
188  int pdgid=abs(itr->pdgId());
189  if(pdgid==24 || pdgid==37 || pdgid ==25 || pdgid==36 || pdgid==22 || pdgid==23 ){
190  const reco::GenParticle *hx=&(*itr);
191  if(!isFirst(hx)) continue;
192  GetLastSelf(hx);
193  const reco::GenParticle *recotau1=NULL;
194  const reco::GenParticle *recotau2=NULL;
195  unsigned int ntau(0),ntauornu(0);
196  for(unsigned int i=0; i<itr->numberOfDaughters(); i++){
197  const reco::Candidate *dau=itr->daughter(i);
198  if(abs(dau->pdgId())!=pdgid){
199  if(abs(dau->pdgId())==15 || abs(dau->pdgId())==16){
200  if(ntau==0 && abs(dau->pdgId())==15){
201  recotau1=static_cast<const reco::GenParticle*>(dau);
202  GetLastSelf(recotau1);
203  ntau++;
204  }
205  else if((ntau==1 && abs(dau->pdgId())==15) || abs(dau->pdgId())==16){
206  recotau2=static_cast<const reco::GenParticle*>(dau);
207  if(abs(dau->pdgId())==15){ntau++;GetLastSelf(recotau2);}
208  }
209  ntauornu++;
210  }
211  }
212  }
213  if((ntau==2 && ntauornu==2) || (ntau==1 && ntauornu==2)){
214  X.setPx(itr->p4().Px());
215  X.setPy(itr->p4().Py());
216  X.setPz(itr->p4().Pz());
217  X.setE (itr->p4().E());
218  X.setPdgid(itr->pdgId());
219  tau.setPx(recotau1->p4().Px());
220  tau.setPy(recotau1->p4().Py());
221  tau.setPz(recotau1->p4().Pz());
222  tau.setE (recotau1->p4().E());
223  tau.setPdgid(recotau1->pdgId());
224  GetRecoDaughters(recotau1,tau_daughters,recotau1->pdgId());
225  tau2.setPx(recotau2->p4().Px());
226  tau2.setPy(recotau2->p4().Py());
227  tau2.setPz(recotau2->p4().Pz());
228  tau2.setE (recotau2->p4().E());
229  tau2.setPdgid(recotau2->pdgId());
230  if(ntau==2)GetRecoDaughters(recotau2,tau2_daughters,recotau2->pdgId());
231  return 0;
232  }
233  }
234  }
235  return 1;
236 }
int i
Definition: DBlmapReader.cc:9
void GetLastSelf(const reco::GenParticle *Particle)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual int pdgId() const GCC11_FINAL
PDG identifier.
bool isFirst(const reco::GenParticle *Particle)
#define X(str)
Definition: MuonsGrabber.cc:48
#define NULL
Definition: scimark2.h:8
edm::EDGetTokenT< reco::GenParticleCollection > GenParticleCollectionToken_
Definition: TauSpinnerCMS.h:93
void GetRecoDaughters(const reco::GenParticle *Particle, std::vector< TauSpinner::SimpleParticle > &daughters, int parentpdgid)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int pdgId() const =0
PDG identifier.
void TauSpinnerCMS::setRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

Definition at line 64 of file TauSpinnerCMS.h.

References fRandomEngine, and findQualityFiles::v.

64 { fRandomEngine = v; }
static CLHEP::HepRandomEngine * fRandomEngine
Definition: TauSpinnerCMS.h:91

Member Data Documentation

double TauSpinnerCMS::CMSEnergy_
private

Definition at line 72 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::fInitialized =false
staticprivate

Definition at line 94 of file TauSpinnerCMS.h.

Referenced by initialize(), and produce().

CLHEP::HepRandomEngine * TauSpinnerCMS::fRandomEngine = nullptr
staticprivate

Definition at line 91 of file TauSpinnerCMS.h.

Referenced by flat(), and setRandomEngine().

edm::EDGetTokenT<reco::GenParticleCollection> TauSpinnerCMS::GenParticleCollectionToken_
private

Definition at line 93 of file TauSpinnerCMS.h.

Referenced by readParticlesfromReco(), and TauSpinnerCMS().

edm::InputTag TauSpinnerCMS::gensrc_
private

Definition at line 73 of file TauSpinnerCMS.h.

Referenced by TauSpinnerCMS().

edm::EDGetTokenT<edm::HepMCProduct> TauSpinnerCMS::hepmcCollectionToken_
private

Definition at line 92 of file TauSpinnerCMS.h.

Referenced by produce(), and TauSpinnerCMS().

int TauSpinnerCMS::Ipol_
private

Definition at line 74 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isLHPDFConfigured_
private

Definition at line 70 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isReco_
private

Definition at line 68 of file TauSpinnerCMS.h.

Referenced by produce(), and TauSpinnerCMS().

bool TauSpinnerCMS::isTauolaConfigured_
private

Definition at line 69 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isTauSpinnerConfigure =false
staticprivate

Definition at line 75 of file TauSpinnerCMS.h.

Referenced by initialize().

std::string TauSpinnerCMS::LHAPDFname_
private

Definition at line 71 of file TauSpinnerCMS.h.

Referenced by initialize().

int TauSpinnerCMS::MotherPDGID_
private

Definition at line 74 of file TauSpinnerCMS.h.

Referenced by produce().

int TauSpinnerCMS::nonSM2_
private

Definition at line 74 of file TauSpinnerCMS.h.

Referenced by initialize().

int TauSpinnerCMS::nonSMN_
private

Definition at line 74 of file TauSpinnerCMS.h.

Referenced by initialize().

double TauSpinnerCMS::roundOff_
private

Definition at line 89 of file TauSpinnerCMS.h.

Referenced by produce().