CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  * $Id $
25  */
26 
33 
34 namespace reco { namespace tau {
35 
37  public:
38  enum Region {
41  };
42 
43  enum ParticleType {
48  };
49 
51  RecoTauConstructor(const PFJetRef& jetRef,
53  bool copyGammasFromPiZeros=false);
54 
55  /*
56  * Code to set leading candidates. These are just wrappers about
57  * the embedded taus methods, but with the ability to convert Ptrs
58  * to Refs.
59  */
60 
62  template<typename T> void setleadPFChargedHadrCand(const T& cand) {
63  tau_->setleadPFChargedHadrCand(convertToRef(cand));
64  }
65 
67  template<typename T> void setleadPFNeutralCand(const T& cand) {
68  tau_->setleadPFNeutralCand(convertToRef(cand));
69  }
70 
72  template<typename T> void setleadPFCand(const T& cand) {
73  tau_->setleadPFCand(convertToRef(cand));
74  }
75 
77  void addPFCand(Region region, ParticleType type, const PFCandidateRef& ref);
78 
80  void reserve(Region region, ParticleType type, size_t size);
81 
82  // Add a collection of objects to the charged hadrons collection
83  template<typename InputIterator>
85  const InputIterator& begin, const InputIterator& end) {
86  for(InputIterator iter = begin; iter != end; ++iter) {
87  addPFCand(region, type, convertToRef(*iter));
88  }
89  }
90 
92  void reservePiZero(Region region, size_t size);
93 
95  void addPiZero(Region region, const RecoTauPiZero& piZero);
96 
98  template<typename InputIterator>
99  void addPiZeros(Region region,
100  const InputIterator& begin, const InputIterator& end)
101  {
102  for(InputIterator iter = begin; iter != end; ++iter)
103  {
104  addPiZero(region, *iter);
105  }
106  }
107 
108  // Build and return the associated tau
109  std::auto_ptr<reco::PFTau> get(bool setupLeadingCandidates=true);
110 
111  // Get the four vector of the signal objects added so far
112  const reco::Candidate::LorentzVector& p4() const { return p4_; }
113 
114 
115  private:
116  typedef std::pair<Region, ParticleType> CollectionKey;
117  typedef std::map<CollectionKey, PFCandidateRefVector*> CollectionMap;
118  typedef boost::shared_ptr<std::vector<PFCandidateRef> > SortedListPtr;
119  typedef std::map<CollectionKey, SortedListPtr> SortedCollectionMap;
120 
122  // Retrieve collection associated to signal/iso and type
125 
126  // Sort all our collections by PT and copy them into the tau
127  void sortAndCopyIntoTau();
128 
129  // Helper functions for dealing with refs
130  PFCandidateRef convertToRef(const PFCandidatePtr& pfPtr) const;
131  PFCandidateRef convertToRef(const CandidatePtr& candPtr) const;
132  PFCandidateRef convertToRef(const PFCandidateRef& pfRef) const;
133 
135  std::auto_ptr<reco::PFTau> tau_;
137 
138  // Keep sorted (by descending pt) collections
140 
141  // Keep track of the signal cone four vector in case we want it
143 };
144 } } // end reco::tau namespace
145 #endif
type
Definition: HCALResponse.h:22
reco::Candidate::LorentzVector p4_
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
std::map< CollectionKey, SortedListPtr > SortedCollectionMap
void addPFCand(Region region, ParticleType type, const PFCandidateRef &ref)
Append a PFCandidateRef to a given collection.
void addPiZeros(Region region, const InputIterator &begin, const InputIterator &end)
Add a list of pi zeros to the input collection.
SortedCollectionMap sortedCollections_
const edm::Handle< PFCandidateCollection > & pfCands_
PFCandidateRef convertToRef(const PFCandidatePtr &pfPtr) const
SortedListPtr getSortedCollection(Region region, ParticleType type)
const reco::Candidate::LorentzVector & p4() const
#define end
Definition: vmac.h:38
std::pair< Region, ParticleType > CollectionKey
void setleadPFCand(const T &cand)
Set leading PF candidate.
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
boost::shared_ptr< std::vector< PFCandidateRef > > SortedListPtr
PFCandidateRefVector * getCollection(Region region, ParticleType type)
std::map< CollectionKey, PFCandidateRefVector * > CollectionMap
std::auto_ptr< reco::PFTau > tau_
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
void setleadPFChargedHadrCand(const T &cand)
Set leading PFChargedHadron candidate.
#define begin
Definition: vmac.h:31
RecoTauConstructor(const PFJetRef &jetRef, const edm::Handle< PFCandidateCollection > &pfCands, bool copyGammasFromPiZeros=false)
Constructor with PFCandidate Handle.
void setleadPFNeutralCand(const T &cand)
Set leading PFGamma candidate.
void addPiZero(Region region, const RecoTauPiZero &piZero)
Add a PiZero to the given collection.
long double T
tuple size
Write out results.