CMS 3D CMS Logo

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 
20 
23 
24 namespace reco { namespace tau {
25 
26 namespace helpers {
27 unsigned int nCharged(const GenJet& jet) {
28  unsigned int output = 0;
29  for(auto const& cand : jet.getJetConstituents()) {
30  if (cand->charge())
31  ++output;
32  }
33  return output;
34 }
35 
36 unsigned int nGammas(const GenJet& jet) {
37  unsigned int output = 0;
38  for(auto const& cand : jet.getJetConstituents()) {
39  if (cand->pdgId()==22)
40  ++output;
41  }
42  return output;
43 }
44 
45 unsigned int nCharged(const PFTau& tau) {
46  return tau.signalChargedHadrCands().size();
47 }
48 unsigned int nGammas(const PFTau& tau) {
49  return tau.signalPiZeroCandidates().size();
50 }
51 }
52 
53 template<typename T>
55  public:
57  :RecoTauModifierPlugin(pset,std::move(iC)),
58  jetMatchSrc_(pset.getParameter<edm::InputTag>("jetTruthMatch")) {}
59  ~RecoTauObjectEmbedder() override {}
60  void operator()(PFTau&) const override;
61  void beginEvent() override;
62  private:
65 };
66 
67 // Update our handle to the matching
68 template<typename T>
70  evt()->getByLabel(jetMatchSrc_, jetMatch_);
71 }
72 
73 template<typename T>
75  // Get the matched object that is matched to the same jet as the current tau,
76  // if it exists
77  edm::Ref<T> matchedObject = (*jetMatch_)[tau.jetRef()];
78  if (matchedObject.isNonnull()) {
79  // Store our matched object information
80  tau.setalternatLorentzVect(matchedObject->p4());
81  // Store our generator decay mode
84  helpers::nCharged(*matchedObject),
85  helpers::nGammas(*matchedObject)/2)
86  );
87  } else {
89  }
90 }
91 }} // end namespace reco::tau
92 
96  "RecoTauTruthEmbedder");
97 
100  "RecoTauPFTauEmbedder");
unsigned int nGammas(const GenJet &jet)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
PFTau::hadronicDecayMode translateDecayMode(unsigned int nCharged, unsigned int nPiZero)
virtual Constituents getJetConstituents() const
list of constituents
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:230
const JetBaseRef & jetRef() const
Definition: PFTau.cc:58
void setalternatLorentzVect(const math::XYZTLorentzVector &)
Definition: BaseTau.cc:24
Jets made from MC generator particles.
Definition: GenJet.h:25
void setbremsRecoveryEOverPLead(const float &)
Definition: PFTau.cc:345
unsigned int nCharged(const GenJet &jet)
edm::Handle< edm::Association< T > > jetMatch_
RecoTauObjectEmbedder(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:80
fixed size matrix
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
def move(src, dest)
Definition: eostools.py:511