CMS 3D CMS Logo

BPHDecayMomentum.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHDecayMomentum_h
2 #define HeavyFlavorAnalysis_RecoDecay_BPHDecayMomentum_h
3 
13 //----------------------
14 // Base Class Headers --
15 //----------------------
16 
17 //------------------------------------
18 // Collaborating Class Declarations --
19 //------------------------------------
22 class BPHRecoBuilder;
23 
24 //---------------
25 // C++ Headers --
26 //---------------
27 #include <vector>
28 #include <map>
29 #include <string>
30 
31 // ---------------------
32 // -- Class Interface --
33 // ---------------------
34 
36 public:
40  // deleted copy constructor and assignment operator
41  BPHDecayMomentum(const BPHDecayMomentum& x) = delete;
42  BPHDecayMomentum& operator=(const BPHDecayMomentum& x) = delete;
43 
46  virtual ~BPHDecayMomentum();
47 
51  virtual const pat::CompositeCandidate& composite() const;
53 
58  virtual const std::vector<std::string>& daugNames() const;
59 
64  virtual const std::vector<std::string>& compNames() const;
65 
71  virtual const std::vector<const reco::Candidate*>& daughters() const;
72 
79  virtual const std::vector<const reco::Candidate*>& daughFull() const;
80 
82  virtual const reco::Candidate* originalReco(const reco::Candidate* daug) const;
83 
88  virtual const std::vector<BPHRecoConstCandPtr>& daughComp() const;
89 
92  virtual const reco::Candidate* getDaug(const std::string& name) const;
93 
96  virtual BPHRecoConstCandPtr getComp(const std::string& name) const;
97 
98  const std::map<std::string, const reco::Candidate*>& daugMap() const { return dMap; }
99 
100  const std::map<std::string, BPHRecoConstCandPtr>& compMap() const { return cMap; }
101 
102  struct Component {
104  double mass;
105  double msig;
107  };
108 
109 protected:
110  // constructors
111  BPHDecayMomentum(int daugNum = 2, int compNum = 2);
112  BPHDecayMomentum(const std::map<std::string, Component>& daugMap, int compNum = 2);
113  BPHDecayMomentum(const std::map<std::string, Component>& daugMap,
114  const std::map<std::string, BPHRecoConstCandPtr> compMap);
115 
116  // get an object filled in the constructor
117  // to be used in the creation of other bases of BPHRecoCandidate
118  const std::vector<Component>& componentList() const;
119 
120  // add a simple particle giving it a name
121  // particles are cloned, eventually specifying a different mass
122  virtual void addP(const std::string& name, const reco::Candidate* daug, double mass = -1.0);
123  // add a previously reconstructed particle giving it a name
124  virtual void addP(const std::string& name, const BPHRecoConstCandPtr& comp);
125 
126  // utility function used to cash reconstruction results
127  virtual void setNotUpdated() const;
128 
129  // function doing the job to clone reconstructed decays:
130  // copy stable particles and clone cascade decays up to chosen level
131  virtual void fill(BPHRecoCandidate* ptr, int level) const = 0;
132 
133 private:
134  // object filled in the constructor
135  // to be used in the creation of other bases of BPHRecoCandidate
136  std::vector<Component> compList;
137 
138  // names used for simple and previously reconstructed particles
139  std::vector<std::string> nList;
140  std::vector<std::string> nComp;
141 
142  // pointers to simple and previously reconstructed particles
143  // (clones stored for simple particles)
144  std::vector<const reco::Candidate*> dList;
145  std::vector<BPHRecoConstCandPtr> cList;
146 
147  // maps linking names to decay products
148  // (simple and previously reconstructed particles)
149  std::map<std::string, const reco::Candidate*> dMap;
150  std::map<std::string, BPHRecoConstCandPtr> cMap;
151 
152  // map linking cloned particles to original ones
153  std::map<const reco::Candidate*, const reco::Candidate*> clonesMap;
154 
155  // reconstruction results cache
156  mutable bool oldMom;
157  mutable std::vector<const reco::Candidate*> dFull;
159 
160  // create clones of simple particles, store them and their names
161  void clonesList(const std::map<std::string, Component>& daugMap);
162 
163  // fill lists of previously reconstructed particles and their names
164  // and retrieve cascade decay products
165  void dCompList();
166 
167  // compute the total momentum of simple particles, produced
168  // directly or in cascade decays
169  virtual void sumMomentum(const std::vector<const reco::Candidate*>& dl, const std::vector<std::string>& dn) const;
170 
171  // recursively fill the list of simple particles, produced
172  // directly or in cascade decays
173  virtual void fillDaug(std::vector<const reco::Candidate*>& ad,
174  const std::string& name,
175  std::vector<std::string>& an) const;
176 
177  // compute the total momentum and cache it
178  virtual void computeMomentum() const;
179 };
180 
181 #endif
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
Analysis-level particle class.
const reco::Candidate * cand
std::vector< BPHRecoConstCandPtr > cList
virtual void computeMomentum() const
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
virtual ~BPHDecayMomentum()
const std::vector< Component > & componentList() const
std::map< std::string, const reco::Candidate * > dMap
virtual const std::vector< const reco::Candidate * > & daughFull() const
std::vector< const reco::Candidate * > dList
virtual const reco::Candidate * getDaug(const std::string &name) const
std::vector< Component > compList
BPHDecayMomentum & operator=(const BPHDecayMomentum &x)=delete
std::vector< const reco::Candidate * > dFull
BPHDecayMomentum(const BPHDecayMomentum &x)=delete
virtual void addP(const std::string &name, const reco::Candidate *daug, double mass=-1.0)
virtual void sumMomentum(const std::vector< const reco::Candidate *> &dl, const std::vector< std::string > &dn) const
const std::map< std::string, BPHRecoConstCandPtr > & compMap() const
virtual const std::vector< std::string > & compNames() const
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
void clonesList(const std::map< std::string, Component > &daugMap)
virtual void fillDaug(std::vector< const reco::Candidate *> &ad, const std::string &name, std::vector< std::string > &an) const
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
virtual const std::vector< std::string > & daugNames() const
virtual void setNotUpdated() const
pat::CompositeCandidate compCand
virtual void fill(BPHRecoCandidate *ptr, int level) const =0
const std::map< std::string, const reco::Candidate * > & daugMap() const
virtual const std::vector< const reco::Candidate * > & daughters() const
std::vector< std::string > nList
std::vector< std::string > nComp
std::map< std::string, BPHRecoConstCandPtr > cMap
virtual const pat::CompositeCandidate & composite() const
get a composite by the simple sum of simple particles