CMS 3D CMS Logo

RecoTauConstructor.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_RecoTauConstructor_h
2 #define RecoTauTag_RecoTau_RecoTauConstructor_h
3 
4 /*
5  * RecoTauConstructor
6  *
7  * A generalized builder of reco::PFTau objects. Takes a variety of
8  * different collections and converts them to the proper Ref format
9  * needed for PFTau storage. Automatically sets the p4, charge, and
10  * other properties correctly. Optionally, it can determine the
11  * lead track information, and copy the gamma candidates owned by the
12  * reconstructed pi zeros into the appropriate PiZero collection.
13  *
14  * If the gammas are copied from the PiZeros, the four vector will be
15  * built using the PiZeros + Charged Hadrons. This can be different than
16  * the Gammas + Charged Hadrons, as the PiZero may have a mass hypothesis set by
17  * the RecoTauPiZeroProducer
18  *
19  * Note that the p4 of the tau is *always* set as the sum of objects in
20  * signal cone.
21  *
22  * Author: Evan K. Friis, UC Davis
23  *
24  */
25 
34 
35 #include <vector>
36 
37 namespace reco {
38  namespace tau {
39 
41  public:
43 
45 
47  RecoTauConstructor(const JetBaseRef& jetRef,
48  const edm::Handle<edm::View<reco::Candidate> >& pfCands,
49  bool copyGammasFromPiZeros = false,
55 
56  /*
57  * Code to set leading candidates. These are just wrappers about
58  * the embedded taus methods, but with the ability to convert Ptrs
59  * to Refs.
60  */
61 
63  template <typename T>
64  void setleadChargedHadrCand(const T& cand) {
65  tau_->setleadChargedHadrCand(convertToPtr(cand));
66  }
67 
69  template <typename T>
70  void setleadNeutralCand(const T& cand) {
71  tau_->setleadNeutralCand(convertToPtr(cand));
72  }
73 
75  template <typename T>
76  void setleadCand(const T& cand) {
77  tau_->setleadCand(convertToPtr(cand));
78  }
79 
81  void addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4 = false);
82 
84  void reserve(Region region, ParticleType type, size_t size);
85 
86  // Add a collection of objects to a given collection
87  template <typename InputIterator>
88  void addPFCands(Region region, ParticleType type, const InputIterator& begin, const InputIterator& end) {
89  for (InputIterator iter = begin; iter != end; ++iter) {
91  }
92  }
93 
96 
99 
101  template <typename InputIterator>
102  void addTauChargedHadrons(Region region, const InputIterator& begin, const InputIterator& end) {
103  for (InputIterator iter = begin; iter != end; ++iter) {
104  addTauChargedHadron(region, *iter);
105  }
106  }
107 
109  void reservePiZero(Region region, size_t size);
110 
112  void addPiZero(Region region, const RecoTauPiZero& piZero);
113 
115  template <typename InputIterator>
116  void addPiZeros(Region region, const InputIterator& begin, const InputIterator& end) {
117  for (InputIterator iter = begin; iter != end; ++iter) {
118  addPiZero(region, *iter);
119  }
120  }
121 
122  // Build and return the associated tau
123  std::unique_ptr<reco::PFTau> get(bool setupLeadingCandidates = true);
124 
125  // Get the four vector of the signal objects added so far
126  const reco::Candidate::LorentzVector& p4() const { return p4_; }
127 
128  private:
129  typedef std::pair<Region, ParticleType> CollectionKey;
130  typedef std::map<CollectionKey, std::vector<CandidatePtr>*> CollectionMap;
131  typedef std::shared_ptr<std::vector<CandidatePtr> > SortedListPtr;
132  typedef std::map<CollectionKey, SortedListPtr> SortedCollectionMap;
133 
135 
141 
142  // Retrieve collection associated to signal/iso and type
143  std::vector<CandidatePtr>* getCollection(Region region, ParticleType type);
145 
146  // Sort all our collections by PT and copy them into the tau
147  void sortAndCopyIntoTau();
148 
149  // Helper functions for dealing with refs
150  CandidatePtr convertToPtr(const PFCandidatePtr& pfPtr) const;
151  CandidatePtr convertToPtr(const CandidatePtr& candPtr) const;
152 
154  std::unique_ptr<reco::PFTau> tau_;
156 
157  // Keep sorted (by descending pt) collections
159 
160  // Keep track of the signal cone four vector in case we want it
162  };
163  } // namespace tau
164 } // namespace reco
165 #endif
reco::tau::RecoTauConstructor::SortedCollectionMap
std::map< CollectionKey, SortedListPtr > SortedCollectionMap
Definition: RecoTauConstructor.h:132
Handle.h
reco::tau::RecoTauConstructor::minAbsPhotonSumPt_insideSignalCone_
double minAbsPhotonSumPt_insideSignalCone_
Definition: RecoTauConstructor.h:137
reco::tau::RecoTauConstructor::collections_
CollectionMap collections_
Definition: RecoTauConstructor.h:155
reco::tau::RecoTauConstructor::signalConeSize_
const StringObjectFunction< reco::PFTau > * signalConeSize_
Definition: RecoTauConstructor.h:136
StringObjectFunction< reco::PFTau >
reco::tau::RecoTauConstructor
Definition: RecoTauConstructor.h:40
reco::tau::RecoTauConstructor::setleadNeutralCand
void setleadNeutralCand(const T &cand)
Set leading PFGamma candidate.
Definition: RecoTauConstructor.h:70
reco::tau::RecoTauConstructor::kAll
Definition: RecoTauConstructor.h:44
metsig::tau
Definition: SignAlgoResolutions.h:49
reco::tau::RecoTauConstructor::kSignal
Definition: RecoTauConstructor.h:42
PFCandidate.h
reco::tau::RecoTauConstructor::addPFCand
void addPFCand(Region region, ParticleType type, const CandidatePtr &ptr, bool skipAddToP4=false)
Append a PFCandidateRef/Ptr to a given collection.
Definition: RecoTauConstructor.cc:54
muons2muons_cfi.chargedHadron
chargedHadron
Definition: muons2muons_cfi.py:26
reco::tau::RecoTauConstructor::reservePiZero
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
Definition: RecoTauConstructor.cc:172
reco::tau::RecoTauConstructor::p4
const reco::Candidate::LorentzVector & p4() const
Definition: RecoTauConstructor.h:126
reco::tau::RecoTauConstructor::ParticleType
ParticleType
Definition: RecoTauConstructor.h:44
reco::tau::RecoTauConstructor::copyGammas_
bool copyGammas_
Definition: RecoTauConstructor.h:134
reco::tau::RecoTauConstructor::RecoTauConstructor
RecoTauConstructor(const JetBaseRef &jetRef, const edm::Handle< edm::View< reco::Candidate > > &pfCands, bool copyGammasFromPiZeros=false, const StringObjectFunction< reco::PFTau > *signalConeSize=nullptr, double minAbsPhotonSumPt_insideSignalCone=2.5, double minRelPhotonSumPt_insideSignalCone=0., double minAbsPhotonSumPt_outsideSignalCone=1.e+9, double minRelPhotonSumPt_outsideSignalCone=1.e+9)
Constructor with PFCandidate Handle.
Definition: RecoTauConstructor.cc:15
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::tau::RecoTauConstructor::addPiZeros
void addPiZeros(Region region, const InputIterator &begin, const InputIterator &end)
Add a list of pizeros to the input collection.
Definition: RecoTauConstructor.h:116
edm::Handle
Definition: AssociativeIterator.h:50
RecoTauPiZero.h
HLT_FULL_cff.minAbsPhotonSumPt_insideSignalCone
minAbsPhotonSumPt_insideSignalCone
Definition: HLT_FULL_cff.py:32713
reco::tau::RecoTauConstructor::sortedCollections_
SortedCollectionMap sortedCollections_
Definition: RecoTauConstructor.h:158
reco::PFRecoTauChargedHadron
Definition: PFRecoTauChargedHadron.h:23
reco::tau::RecoTauConstructor::addTauChargedHadron
void addTauChargedHadron(Region region, const PFRecoTauChargedHadron &chargedHadron)
Add a ChargedHadron to the given collection.
Definition: RecoTauConstructor.cc:113
reco::tau::RecoTauConstructor::kGamma
Definition: RecoTauConstructor.h:44
reco::tau::RecoTauConstructor::addTauChargedHadrons
void addTauChargedHadrons(Region region, const InputIterator &begin, const InputIterator &end)
Add a list of charged hadrons to the input collection.
Definition: RecoTauConstructor.h:102
reco::tau::RecoTauConstructor::addPiZero
void addPiZero(Region region, const RecoTauPiZero &piZero)
Add a PiZero to the given collection.
Definition: RecoTauConstructor.cc:186
mps_fire.end
end
Definition: mps_fire.py:242
reco::tau::RecoTauConstructor::get
std::unique_ptr< reco::PFTau > get(bool setupLeadingCandidates=true)
Definition: RecoTauConstructor.cc:330
reco::tau::RecoTauConstructor::p4_
reco::Candidate::LorentzVector p4_
Definition: RecoTauConstructor.h:161
JetCollection.h
reco::tau::RecoTauConstructor::Region
Region
Definition: RecoTauConstructor.h:42
reco::tau::RecoTauConstructor::addPFCands
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
Definition: RecoTauConstructor.h:88
HLT_FULL_cff.minRelPhotonSumPt_outsideSignalCone
minRelPhotonSumPt_outsideSignalCone
Definition: HLT_FULL_cff.py:33287
edm::View
Definition: CaloClusterFwd.h:14
reco::tau::RecoTauConstructor::tau_
std::unique_ptr< reco::PFTau > tau_
Definition: RecoTauConstructor.h:154
reco::tau::RecoTauConstructor::minRelPhotonSumPt_insideSignalCone_
double minRelPhotonSumPt_insideSignalCone_
Definition: RecoTauConstructor.h:138
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
HLT_FULL_cff.minRelPhotonSumPt_insideSignalCone
minRelPhotonSumPt_insideSignalCone
Definition: HLT_FULL_cff.py:32749
cand
Definition: decayParser.h:32
HLT_FULL_cff.signalConeSize
signalConeSize
Definition: HLT_FULL_cff.py:33328
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88267
reco::tau::RecoTauConstructor::SortedListPtr
std::shared_ptr< std::vector< CandidatePtr > > SortedListPtr
Definition: RecoTauConstructor.h:131
reco::tau::RecoTauConstructor::kIsolation
Definition: RecoTauConstructor.h:42
reco::tau::RecoTauConstructor::kChargedHadron
Definition: RecoTauConstructor.h:44
reco::tau::RecoTauConstructor::getCollection
std::vector< CandidatePtr > * getCollection(Region region, ParticleType type)
Definition: RecoTauConstructor.cc:206
reco::tau::RecoTauConstructor::kNeutralHadron
Definition: RecoTauConstructor.h:44
reco::tau::RecoTauConstructor::sortAndCopyIntoTau
void sortAndCopyIntoTau()
Definition: RecoTauConstructor.cc:251
edm::Ptr< Candidate >
reco::tau::RecoTauConstructor::getSortedCollection
SortedListPtr getSortedCollection(Region region, ParticleType type)
Definition: RecoTauConstructor.cc:210
reco::RecoTauPiZero
Definition: RecoTauPiZero.h:7
reco::tau::RecoTauConstructor::reserveTauChargedHadron
void reserveTauChargedHadron(Region region, size_t size)
Reserve a set amount of space for the ChargedHadrons.
Definition: RecoTauConstructor.cc:78
reco::tau::RecoTauConstructor::convertToPtr
CandidatePtr convertToPtr(const PFCandidatePtr &pfPtr) const
Definition: RecoTauConstructor.cc:232
reco::tau::RecoTauConstructor::setleadCand
void setleadCand(const T &cand)
Set leading PF candidate.
Definition: RecoTauConstructor.h:76
reco::tau::RecoTauConstructor::minRelPhotonSumPt_outsideSignalCone_
double minRelPhotonSumPt_outsideSignalCone_
Definition: RecoTauConstructor.h:140
reco::tau::RecoTauConstructor::minAbsPhotonSumPt_outsideSignalCone_
double minAbsPhotonSumPt_outsideSignalCone_
Definition: RecoTauConstructor.h:139
T
long double T
Definition: Basic3DVectorLD.h:48
reco::tau::RecoTauConstructor::reserve
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
Definition: RecoTauConstructor.cc:70
PFTau.h
HLT_FULL_cff.minAbsPhotonSumPt_outsideSignalCone
minAbsPhotonSumPt_outsideSignalCone
Definition: HLT_FULL_cff.py:33285
reco::tau::RecoTauConstructor::CollectionKey
std::pair< Region, ParticleType > CollectionKey
Definition: RecoTauConstructor.h:129
edm::RefToBase< Jet >
reco::tau::RecoTauConstructor::setleadChargedHadrCand
void setleadChargedHadrCand(const T &cand)
Set leading PFChargedHadron candidate.
Definition: RecoTauConstructor.h:64
reco::tau::RecoTauConstructor::pfCands_
const edm::Handle< edm::View< reco::Candidate > > & pfCands_
Definition: RecoTauConstructor.h:153
PFRecoTauChargedHadron.h
reco::tau::RecoTauConstructor::CollectionMap
std::map< CollectionKey, std::vector< CandidatePtr > * > CollectionMap
Definition: RecoTauConstructor.h:130
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
StringObjectFunction.h
PFCandidateFwd.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37