CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauObjectEmbedderPlugin.cc
Go to the documentation of this file.
1 /*
2  * ===========================================================================
3  *
4  * Filename: RecoTauObjectEmbedder
5  *
6  * Description: Embed truth information into (currently unused)
7  * tau variables. This is a hack to allow some PAT-like
8  * operations on taus without introducing new dependencies.
9  *
10  * Author: Evan K. Friis (UC Davis)
11  *
12  * ===========================================================================
13  */
14 
15 #include <boost/foreach.hpp>
16 
22 
25 
26 namespace reco { namespace tau {
27 
28 namespace helpers {
29 unsigned int nCharged(const GenJet& jet) {
30  unsigned int output = 0;
31  BOOST_FOREACH(const CandidatePtr &cand, jet.getJetConstituents()) {
32  if (cand->charge())
33  ++output;
34  }
35  return output;
36 }
37 
38 unsigned int nGammas(const GenJet& jet) {
39  unsigned int output = 0;
40  BOOST_FOREACH(const CandidatePtr &cand, jet.getJetConstituents()) {
41  if (cand->pdgId()==22)
42  ++output;
43  }
44  return output;
45 }
46 
47 unsigned int nCharged(const PFTau& tau) {
48  return tau.signalPFChargedHadrCands().size();
49 }
50 unsigned int nGammas(const PFTau& tau) {
51  return tau.signalPiZeroCandidates().size();
52 }
53 }
54 
55 template<typename T>
57  public:
59  :RecoTauModifierPlugin(pset,std::move(iC)),
60  jetMatchSrc_(pset.getParameter<edm::InputTag>("jetTruthMatch")) {}
62  virtual void operator()(PFTau&) const override;
63  virtual void beginEvent() override;
64  private:
67 };
68 
69 // Update our handle to the matching
70 template<typename T>
72  evt()->getByLabel(jetMatchSrc_, jetMatch_);
73 }
74 
75 template<typename T>
77  // Get the matched object that is matched to the same jet as the current tau,
78  // if it exists
79  edm::Ref<T> matchedObject = (*jetMatch_)[tau.jetRef()];
80  if (matchedObject.isNonnull()) {
81  // Store our matched object information
82  tau.setalternatLorentzVect(matchedObject->p4());
83  // Store our generator decay mode
86  helpers::nCharged(*matchedObject),
87  helpers::nGammas(*matchedObject)/2)
88  );
89  } else {
91  }
92 }
93 }} // end namespace reco::tau
94 
98  "RecoTauTruthEmbedder");
99 
102  "RecoTauPFTauEmbedder");
unsigned int nGammas(const GenJet &jet)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
const PFJetRef & jetRef() const
Definition: PFTau.cc:54
PFTau::hadronicDecayMode translateDecayMode(unsigned int nCharged, unsigned int nPiZero)
virtual Constituents getJetConstituents() const
list of constituents
virtual void operator()(PFTau &) const override
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:93
void setalternatLorentzVect(const math::XYZTLorentzVector &)
Definition: BaseTau.cc:24
Jets made from MC generator particles.
Definition: GenJet.h:24
void setbremsRecoveryEOverPLead(const float &)
Definition: PFTau.cc:224
unsigned int nCharged(const GenJet &jet)
edm::Handle< edm::Association< T > > jetMatch_
RecoTauObjectEmbedder(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
#define DEFINE_EDM_PLUGIN(factory, type, name)
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:76