CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginJob () final
 
void endJob () final
 
virtual void initialize ()
 
void produce (edm::Event &, const edm::EventSetup &) final
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
 TauSpinnerCMS (const edm::ParameterSet &)
 
 ~TauSpinnerCMS () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::SharedResources >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 48 of file TauSpinnerCMS.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file TauSpinnerCMS.cc.

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

24  : EDProducer(),
25  isReco_(pset.getParameter<bool>("isReco")),
26  isTauolaConfigured_(pset.getParameter<bool>("isTauolaConfigured")),
27  isLHPDFConfigured_(pset.getParameter<bool>("isLHPDFConfigured")),
28  LHAPDFname_(pset.getUntrackedParameter("LHAPDFname", (string)("MSTW2008nnlo90cl.LHgrid"))),
29  CMSEnergy_(pset.getParameter<double>("CMSEnergy")) //GeV
30  ,
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  //usesResource(edm::uniqueSharedResourceName());
39 
40  produces<bool>("TauSpinnerWTisValid").setBranchAlias("TauSpinnerWTisValid");
41  produces<double>("TauSpinnerWT").setBranchAlias("TauSpinnerWT");
42  produces<double>("TauSpinnerWTFlip").setBranchAlias("TauSpinnerWTFlip");
43  produces<double>("TauSpinnerWThplus").setBranchAlias("TauSpinnerWThplus");
44  produces<double>("TauSpinnerWThminus").setBranchAlias("TauSpinnerWThminus");
45 
46  if (isReco_) {
47  GenParticleCollectionToken_ = consumes<reco::GenParticleCollection>(gensrc_);
48  } else {
49  hepmcCollectionToken_ = consumes<HepMCProduct>(gensrc_);
50  }
51 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: TauSpinnerCMS.h:85
static const std::string kTauola
double roundOff_
Definition: TauSpinnerCMS.h:82
edm::EDGetTokenT< reco::GenParticleCollection > GenParticleCollectionToken_
Definition: TauSpinnerCMS.h:86
bool isTauolaConfigured_
Definition: TauSpinnerCMS.h:62
std::string LHAPDFname_
Definition: TauSpinnerCMS.h:64
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::InputTag gensrc_
Definition: TauSpinnerCMS.h:66
double CMSEnergy_
Definition: TauSpinnerCMS.h:65
bool isLHPDFConfigured_
Definition: TauSpinnerCMS.h:63
TauSpinnerCMS::~TauSpinnerCMS ( )
inlineoverride

Definition at line 51 of file TauSpinnerCMS.h.

51 {}; // no need to delete ROOT stuff

Member Function Documentation

void TauSpinnerCMS::beginJob ( void  )
finalvirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 53 of file TauSpinnerCMS.cc.

53 {};
void TauSpinnerCMS::endJob ( void  )
finalvirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 54 of file TauSpinnerCMS.cc.

54 {};
double TauSpinnerCMS::flat ( void  )
static

Definition at line 285 of file TauSpinnerCMS.cc.

References Exception, and fRandomEngine.

Referenced by initialize(), and produce().

285  {
286  if (!fRandomEngine) {
287  throw cms::Exception("LogicError")
288  << "TauSpinnerCMS::flat: Attempt to generate random number when engine pointer is null\n"
289  << "This might mean that the code was modified to generate a random number outside the\n"
290  << "event and beginLuminosityBlock methods, which is not allowed.\n";
291  }
292  return fRandomEngine->flat();
293 }
static CLHEP::HepRandomEngine * fRandomEngine
Definition: TauSpinnerCMS.h:84
void TauSpinnerCMS::GetLastSelf ( const reco::GenParticle Particle)
private

Definition at line 250 of file TauSpinnerCMS.cc.

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

Referenced by readParticlesfromReco().

250  {
251  for (unsigned int i = 0; i < Particle->numberOfDaughters(); i++) {
252  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(Particle->daughter(i));
253  if (Particle->pdgId() == dau->pdgId()) {
254  Particle = dau;
255  GetLastSelf(Particle);
256  }
257  }
258 }
void GetLastSelf(const reco::GenParticle *Particle)
size_t numberOfDaughters() const override
number of daughters
int pdgId() const final
PDG identifier.
const Candidate * daughter(size_type) const override
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 270 of file TauSpinnerCMS.cc.

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

Referenced by readParticlesfromReco().

272  {
273  if (Particle->numberOfDaughters() == 0 || abs(Particle->pdgId()) == 111) {
274  SimpleParticle tp(
275  Particle->p4().Px(), Particle->p4().Py(), Particle->p4().Pz(), Particle->p4().E(), Particle->pdgId());
276  daughters.push_back(tp);
277  return;
278  }
279  for (unsigned int i = 0; i < Particle->numberOfDaughters(); i++) {
280  const reco::Candidate *dau = Particle->daughter(i);
281  GetRecoDaughters(static_cast<const reco::GenParticle *>(dau), daughters, Particle->pdgId());
282  }
283 }
size_t numberOfDaughters() const override
number of daughters
const LorentzVector & p4() const final
four-momentum Lorentz vector
int pdgId() const final
PDG identifier.
void GetRecoDaughters(const reco::GenParticle *Particle, std::vector< TauSpinner::SimpleParticle > &daughters, int parentpdgid)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void TauSpinnerCMS::initialize ( )
virtual

Definition at line 56 of file TauSpinnerCMS.cc.

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

Referenced by produce().

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

Definition at line 260 of file TauSpinnerCMS.cc.

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

Referenced by readParticlesfromReco().

260  {
261  for (unsigned int i = 0; i < Particle->numberOfMothers(); i++) {
262  const reco::GenParticle *moth = static_cast<const reco::GenParticle *>(Particle->mother(i));
263  if (Particle->pdgId() == moth->pdgId()) {
264  return false;
265  }
266  }
267  return true;
268 }
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
size_t numberOfMothers() const override
number of mothers
int pdgId() const final
PDG identifier.
void TauSpinnerCMS::produce ( edm::Event e,
const edm::EventSetup iSetup 
)
finalvirtual

Implements edm::one::EDProducerBase.

Definition at line 77 of file TauSpinnerCMS.cc.

References funct::abs(), gather_cfg::cout, fInitialized, flat(), edm::Event::getByToken(), hepmcCollectionToken_, mps_fire::i, initialize(), isReco_, sistrip::SpyUtilities::isValid(), MotherPDGID_, eostools::move(), edm::Event::put(), readParticlesFromHepMC(), readParticlesfromReco(), roundOff_, edm_modernize_messagelogger::stat, edm::Event::streamID(), metsig::tau, and X.

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

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

Referenced by produce().

192  {
194  e.getByToken(GenParticleCollectionToken_, genParticles);
195  for (reco::GenParticleCollection::const_iterator itr = genParticles->begin(); itr != genParticles->end(); ++itr) {
196  int pdgid = abs(itr->pdgId());
197  if (pdgid == 24 || pdgid == 37 || pdgid == 25 || pdgid == 36 || pdgid == 22 || pdgid == 23) {
198  const reco::GenParticle *hx = &(*itr);
199  if (!isFirst(hx))
200  continue;
201  GetLastSelf(hx);
202  const reco::GenParticle *recotau1 = nullptr;
203  const reco::GenParticle *recotau2 = nullptr;
204  unsigned int ntau(0), ntauornu(0);
205  for (unsigned int i = 0; i < itr->numberOfDaughters(); i++) {
206  const reco::Candidate *dau = itr->daughter(i);
207  if (abs(dau->pdgId()) != pdgid) {
208  if (abs(dau->pdgId()) == 15 || abs(dau->pdgId()) == 16) {
209  if (ntau == 0 && abs(dau->pdgId()) == 15) {
210  recotau1 = static_cast<const reco::GenParticle *>(dau);
211  GetLastSelf(recotau1);
212  ntau++;
213  } else if ((ntau == 1 && abs(dau->pdgId()) == 15) || abs(dau->pdgId()) == 16) {
214  recotau2 = static_cast<const reco::GenParticle *>(dau);
215  if (abs(dau->pdgId()) == 15) {
216  ntau++;
217  GetLastSelf(recotau2);
218  }
219  }
220  ntauornu++;
221  }
222  }
223  }
224  if ((ntau == 2 && ntauornu == 2) || (ntau == 1 && ntauornu == 2)) {
225  X.setPx(itr->p4().Px());
226  X.setPy(itr->p4().Py());
227  X.setPz(itr->p4().Pz());
228  X.setE(itr->p4().E());
229  X.setPdgid(itr->pdgId());
230  tau.setPx(recotau1->p4().Px());
231  tau.setPy(recotau1->p4().Py());
232  tau.setPz(recotau1->p4().Pz());
233  tau.setE(recotau1->p4().E());
234  tau.setPdgid(recotau1->pdgId());
235  GetRecoDaughters(recotau1, tau_daughters, recotau1->pdgId());
236  tau2.setPx(recotau2->p4().Px());
237  tau2.setPy(recotau2->p4().Py());
238  tau2.setPz(recotau2->p4().Pz());
239  tau2.setE(recotau2->p4().E());
240  tau2.setPdgid(recotau2->pdgId());
241  if (ntau == 2)
242  GetRecoDaughters(recotau2, tau2_daughters, recotau2->pdgId());
243  return 0;
244  }
245  }
246  }
247  return 1;
248 }
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) ...
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
bool isFirst(const reco::GenParticle *Particle)
#define X(str)
Definition: MuonsGrabber.cc:38
const LorentzVector & p4() const final
four-momentum Lorentz vector
edm::EDGetTokenT< reco::GenParticleCollection > GenParticleCollectionToken_
Definition: TauSpinnerCMS.h:86
int pdgId() const final
PDG identifier.
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 57 of file TauSpinnerCMS.h.

References fRandomEngine, and findQualityFiles::v.

57 { fRandomEngine = v; }
static CLHEP::HepRandomEngine * fRandomEngine
Definition: TauSpinnerCMS.h:84

Member Data Documentation

double TauSpinnerCMS::CMSEnergy_
private

Definition at line 65 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::fInitialized = false
staticprivate

Definition at line 87 of file TauSpinnerCMS.h.

Referenced by initialize(), and produce().

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

Definition at line 84 of file TauSpinnerCMS.h.

Referenced by flat(), and setRandomEngine().

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

Definition at line 86 of file TauSpinnerCMS.h.

Referenced by readParticlesfromReco(), and TauSpinnerCMS().

edm::InputTag TauSpinnerCMS::gensrc_
private

Definition at line 66 of file TauSpinnerCMS.h.

Referenced by TauSpinnerCMS().

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

Definition at line 85 of file TauSpinnerCMS.h.

Referenced by produce(), and TauSpinnerCMS().

int TauSpinnerCMS::Ipol_
private

Definition at line 67 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isLHPDFConfigured_
private

Definition at line 63 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isReco_
private

Definition at line 61 of file TauSpinnerCMS.h.

Referenced by produce(), and TauSpinnerCMS().

bool TauSpinnerCMS::isTauolaConfigured_
private

Definition at line 62 of file TauSpinnerCMS.h.

Referenced by initialize().

bool TauSpinnerCMS::isTauSpinnerConfigure = false
staticprivate

Definition at line 68 of file TauSpinnerCMS.h.

Referenced by initialize().

std::string TauSpinnerCMS::LHAPDFname_
private

Definition at line 64 of file TauSpinnerCMS.h.

Referenced by initialize().

int TauSpinnerCMS::MotherPDGID_
private

Definition at line 67 of file TauSpinnerCMS.h.

Referenced by produce().

int TauSpinnerCMS::nonSM2_
private

Definition at line 67 of file TauSpinnerCMS.h.

Referenced by initialize().

int TauSpinnerCMS::nonSMN_
private

Definition at line 67 of file TauSpinnerCMS.h.

Referenced by initialize().

double TauSpinnerCMS::roundOff_
private

Definition at line 82 of file TauSpinnerCMS.h.

Referenced by produce().