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 ()
 
ModuleDescription const & moduleDescription () const
 
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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
 
- 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::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 43 of file TruthTauDecayModeProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 68 of file TruthTauDecayModeProducer.cc.

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

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

Definition at line 84 of file TruthTauDecayModeProducer.cc.

85 {
86 }

Member Function Documentation

void TruthTauDecayModeProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 212 of file TruthTauDecayModeProducer.cc.

213 {
214 }
void TruthTauDecayModeProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 218 of file TruthTauDecayModeProducer.cc.

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

Implements edm::EDProducer.

Definition at line 89 of file TruthTauDecayModeProducer.cc.

References funct::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(), dt_dqm_sourceclient_common_cff::reco, AddFourMomenta::set(), reco::PFTauDecayMode::setPFTauRef(), totalEtaCut_, totalPtCut_, and listHistos::trackPt.

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

Member Data Documentation

AddFourMomenta TruthTauDecayModeProducer::addP4
private

Definition at line 65 of file TruthTauDecayModeProducer.cc.

Referenced by produce().

bool TruthTauDecayModeProducer::iAmSignal_
private

Definition at line 59 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

edm::InputTag TruthTauDecayModeProducer::inputTag_
private

Definition at line 60 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackEtaCut_
private

Definition at line 62 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackPtCut_
private

Definition at line 61 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalEtaCut_
private

Definition at line 64 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalPtCut_
private

Definition at line 63 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().