CMS 3D CMS Logo

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

#include <TruthTauDecayModeProducer.cc>

Inheritance diagram for TruthTauDecayModeProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  tauObjectsHolder
 

Public Member Functions

 TruthTauDecayModeProducer (const edm::ParameterSet &)
 
 ~TruthTauDecayModeProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- 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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

AddFourMomenta addP4
 
bool iAmSignal_
 
edm::InputTag inputTag_
 
double leadTrackEtaCut_
 
double leadTrackPtCut_
 
double totalEtaCut_
 
double totalPtCut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

Description: Produces reco::PFTauDecayModes corresponding to MonteCarlo objects For signal, it uses decayed MC taus For background, it uses GenJets

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file TruthTauDecayModeProducer.cc.

Constructor & Destructor Documentation

TruthTauDecayModeProducer::TruthTauDecayModeProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 69 of file TruthTauDecayModeProducer.cc.

References edm::ParameterSet::getParameter(), iAmSignal_, inputTag_, leadTrackEtaCut_, leadTrackPtCut_, totalEtaCut_, and totalPtCut_.

70 {
71  edm::LogInfo("TruthTauDecayModeProducer") << "Initializing ctor of TruthTauDecayModeProducer";
72  iAmSignal_ = iConfig.getParameter<bool>("iAmSignal");
73  inputTag_ = iConfig.getParameter<edm::InputTag>("inputTag");
74  leadTrackPtCut_ = iConfig.getParameter<double>("leadTrackPtCut");
75  leadTrackEtaCut_ = iConfig.getParameter<double>("leadTrackEtaCut");
76  totalPtCut_ = iConfig.getParameter<double>("totalPtCut");
77  totalEtaCut_ = iConfig.getParameter<double>("totalEtaCut");
78  //register your products
79  edm::LogInfo("TruthTauDecayModeProducer") << "Registering products";
80  produces<std::vector<reco::PFTauDecayMode> >();
81  edm::LogInfo("TruthTauDecayModeProducer") << "TruthTauDecayModeProducer initialized";
82 }
T getParameter(std::string const &) const
TruthTauDecayModeProducer::~TruthTauDecayModeProducer ( )

Definition at line 85 of file TruthTauDecayModeProducer.cc.

86 {
87 }

Member Function Documentation

void TruthTauDecayModeProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 213 of file TruthTauDecayModeProducer.cc.

214 {
215 }
void TruthTauDecayModeProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 219 of file TruthTauDecayModeProducer.cc.

219  {
220 }
void TruthTauDecayModeProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 90 of file TruthTauDecayModeProducer.cc.

References abs, reco::CompositeCandidate::addDaughter(), addP4, TruthTauDecayModeProducer::tauObjectsHolder::chargedObjects, edm::Event::getByLabel(), GeneratorTau::getGenChargedPions(), GeneratorTau::getGenNeutralPions(), iAmSignal_, GeneratorTau::init(), inputTag_, GeneratorTau::isFinalStateTau(), leadTrackEtaCut_, leadTrackPtCut_, TruthTauDecayModeProducer::tauObjectsHolder::neutralObjects, reco::LeafCandidate::p4(), benchmark_cfg::pdgId, edm::Event::put(), L1Trigger_dataformats::reco, AddFourMomenta::set(), reco::PFTauDecayMode::setPFTauRef(), totalEtaCut_, totalPtCut_, and listHistos::trackPt.

91 {
92  using namespace edm;
93  using namespace std;
94  using namespace reco;
95 
96  std::vector<tauObjectsHolder> tausToAdd_;
97 
98  /* **********************************************
99  * ********** True Tau Case ***********
100  * ********************************************** */
101  if (iAmSignal_)
102  {
104  iEvent.getByLabel(inputTag_, decayedMCTaus);
105  for(edm::RefToBaseVector<reco::Candidate>::const_iterator iterGen = decayedMCTaus->begin();
106  iterGen != decayedMCTaus->end();
107  ++iterGen)
108  {
109  //copy into custom format (this casting is bullshit)
110  GeneratorTau tempTau = static_cast<const GenParticle&>(*(*iterGen));
111  //LogInfo("MCTauCandidateProducer") << "Generator tau produced, initializing.. ";
112  tempTau.init();
113  //LogInfo("MCTauCandidateProducer") << "GenTau initialization done";
114  if (tempTau.isFinalStateTau())
115  {
116  // Build a Tau Candidate from the information contained in the parsing class
117  tauObjectsHolder tempTauHolder;
118  tempTauHolder.chargedObjects = tempTau.getGenChargedPions();
119  tempTauHolder.neutralObjects = tempTau.getGenNeutralPions();
120  tausToAdd_.push_back(tempTauHolder);
121  }
122  }
123  } else
124  {
125  /* **********************************************
126  * ********** QCD Case ***********
127  * ********************************************** */
129  iEvent.getByLabel(inputTag_, genJets);
130  for(GenJetCollection::const_iterator aGenJet = genJets->begin(); aGenJet != genJets->end(); ++aGenJet)
131  {
132  // get all constituents
133  std::vector<const GenParticle*> theJetConstituents = aGenJet->getGenConstituents();
134 
135  tauObjectsHolder tempTauHolder;
136  // filter the constituents
137  for( std::vector<const GenParticle*>::const_iterator aCandidate = theJetConstituents.begin();
138  aCandidate != theJetConstituents.end();
139  ++aCandidate)
140  {
141  int pdgId = std::abs((*aCandidate)->pdgId());
142  const Candidate* theCandidate = static_cast<const Candidate*>(*aCandidate);
143  //filter nus
144  if (pdgId == 16 || pdgId == 12 || pdgId == 14)
145  {
146  //do nothing
147  } else
148  {
149  // call everything charged a pion
150  // call everything neutral a neutral pion
151  if (theCandidate->charge() != 0)
152  tempTauHolder.chargedObjects.push_back(theCandidate);
153  else
154  tempTauHolder.neutralObjects.push_back(theCandidate);
155  }
156  }
157  tausToAdd_.push_back(tempTauHolder);
158  }
159  }
160 
161  //output collection
162  std::auto_ptr<vector<PFTauDecayMode> > pOut( new std::vector<PFTauDecayMode> );
163  for(std::vector<tauObjectsHolder>::const_iterator iTempTau = tausToAdd_.begin();
164  iTempTau != tausToAdd_.end();
165  ++iTempTau)
166  {
167  double leadTrackPt = 0.;
168  double leadTrackEta = 0.;
169  VertexCompositeCandidate chargedObjectsToAdd;
170  const std::vector<const Candidate*>* chargedObjects = &(iTempTau->chargedObjects);
171  for(std::vector<const Candidate*>::const_iterator iCharged = chargedObjects->begin();
172  iCharged != chargedObjects->end();
173  ++iCharged)
174  {
175  chargedObjectsToAdd.addDaughter(**iCharged);
176  double trackPt = (*iCharged)->pt();
177  if (trackPt > leadTrackPt)
178  {
179  leadTrackPt = trackPt;
180  leadTrackEta = (*iCharged)->eta();
181  }
182  }
183  //update the composite four vector
184  addP4.set(chargedObjectsToAdd);
185 
186  CompositeCandidate neutralPionsToAdd;
187  const std::vector<const Candidate*>* neutralObjects = &(iTempTau->neutralObjects);
188  for(std::vector<const Candidate*>::const_iterator iNeutral = neutralObjects->begin();
189  iNeutral != neutralObjects->end();
190  ++iNeutral)
191  {
192  neutralPionsToAdd.addDaughter(**iNeutral);
193  }
194  addP4.set(neutralPionsToAdd);
195 
196  Particle::LorentzVector myFourVector = chargedObjectsToAdd.p4();
197  myFourVector += neutralPionsToAdd.p4();
198 
199  if(leadTrackPt > leadTrackPtCut_ && std::abs(leadTrackEta) < leadTrackEtaCut_ && myFourVector.pt() > totalPtCut_ && std::abs(myFourVector.eta()) < totalEtaCut_)
200  {
201  //TODO: add vertex fitting
202  CompositeCandidate theOutliers;
203  PFTauRef noPFTau; //empty REF to PFTau
204  PFTauDecayMode decayModeToAdd(chargedObjectsToAdd, neutralPionsToAdd, theOutliers);
205  decayModeToAdd.setPFTauRef(noPFTau);
206  pOut->push_back(decayModeToAdd);
207  }
208  }
209  iEvent.put(pOut);
210 }
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
tuple trackPt
Definition: listHistos.py:120
bool isFinalStateTau() const
Definition: GeneratorTau.h:51
#define abs(x)
Definition: mlp_lapack.h:159
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
std::vector< const reco::Candidate * > getGenNeutralPions() const
std::vector< const reco::Candidate * > getGenChargedPions() const
void set(reco::Candidate &c) const
set up a candidate
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25

Member Data Documentation

AddFourMomenta TruthTauDecayModeProducer::addP4
private

Definition at line 66 of file TruthTauDecayModeProducer.cc.

Referenced by produce().

bool TruthTauDecayModeProducer::iAmSignal_
private

Definition at line 60 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

edm::InputTag TruthTauDecayModeProducer::inputTag_
private

Definition at line 61 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackEtaCut_
private

Definition at line 63 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackPtCut_
private

Definition at line 62 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalEtaCut_
private

Definition at line 65 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalPtCut_
private

Definition at line 64 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().