CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
BPHDecayMomentum Class Referenceabstract

#include <BPHDecayMomentum.h>

Inheritance diagram for BPHDecayMomentum:
BPHDecayVertex BPHKinematicFit BPHPlusMinusVertex BPHRecoCandidate BPHPlusMinusCandidate BPHPlusMinusCandidate

Classes

struct  Component
 

Public Member Functions

 BPHDecayMomentum (const BPHDecayMomentum &x)=delete
 
const std::map< std::string, BPHRecoConstCandPtr > & compMap () const
 
virtual const std::vector< std::string > & compNames () const
 
virtual const pat::CompositeCandidatecomposite () const
 get a composite by the simple sum of simple particles More...
 
virtual const std::vector< BPHRecoConstCandPtr > & daughComp () const
 
virtual const std::vector< const reco::Candidate * > & daughFull () const
 
virtual const std::vector< const reco::Candidate * > & daughters () const
 
const std::map< std::string, const reco::Candidate * > & daugMap () const
 
virtual const std::vector< std::string > & daugNames () const
 
virtual BPHRecoConstCandPtr getComp (const std::string &name) const
 
virtual const reco::CandidategetDaug (const std::string &name) const
 
BPHDecayMomentumoperator= (const BPHDecayMomentum &x)=delete
 
virtual const reco::CandidateoriginalReco (const reco::Candidate *daug) const
 get the original particle from the clone More...
 
virtual ~BPHDecayMomentum ()
 

Protected Member Functions

virtual void addP (const std::string &name, const reco::Candidate *daug, double mass=-1.0)
 
virtual void addP (const std::string &name, const BPHRecoConstCandPtr &comp)
 
 BPHDecayMomentum (int daugNum=2, int compNum=2)
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap, int compNum=2)
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap, const std::map< std::string, BPHRecoConstCandPtr > compMap)
 
const std::vector< Component > & componentList () const
 
virtual void fill (BPHRecoCandidate *ptr, int level) const =0
 
virtual void setNotUpdated () const
 

Private Member Functions

void clonesList (const std::map< std::string, Component > &daugMap)
 
virtual void computeMomentum () const
 
void dCompList ()
 
virtual void fillDaug (std::vector< const reco::Candidate *> &ad, const std::string &name, std::vector< std::string > &an) const
 
virtual void sumMomentum (const std::vector< const reco::Candidate *> &dl, const std::vector< std::string > &dn) const
 

Private Attributes

std::vector< BPHRecoConstCandPtrcList
 
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
 
std::map< std::string, BPHRecoConstCandPtrcMap
 
pat::CompositeCandidate compCand
 
std::vector< ComponentcompList
 
std::vector< const reco::Candidate * > dFull
 
std::vector< const reco::Candidate * > dList
 
std::map< std::string, const reco::Candidate * > dMap
 
std::vector< std::string > nComp
 
std::vector< std::string > nList
 
bool oldMom
 

Detailed Description

Description: Lowest-level base class to contain decay products and compute total momentum

Author
Paolo Ronchese INFN Padova

Definition at line 35 of file BPHDecayMomentum.h.

Constructor & Destructor Documentation

◆ BPHDecayMomentum() [1/4]

BPHDecayMomentum::BPHDecayMomentum ( const BPHDecayMomentum x)
delete

Constructors are protected this object can exist only as part of a derived class

◆ ~BPHDecayMomentum()

BPHDecayMomentum::~BPHDecayMomentum ( )
virtual

Destructor

Definition at line 61 of file BPHDecayMomentum.cc.

References dList, and create_idmaps::n.

61  {
62  // delete all clones
63  int n = dList.size();
64  while (n--)
65  delete dList[n];
66 }
std::vector< const reco::Candidate * > dList

◆ BPHDecayMomentum() [2/4]

BPHDecayMomentum::BPHDecayMomentum ( int  daugNum = 2,
int  compNum = 2 
)
protected

Definition at line 32 of file BPHDecayMomentum.cc.

References cList, dList, nComp, and nList.

32  : oldMom(true) {
33  nList.reserve(daugNum);
34  dList.reserve(daugNum);
35  nComp.reserve(compNum);
36  cList.reserve(compNum);
37 }
std::vector< BPHRecoConstCandPtr > cList
std::vector< const reco::Candidate * > dList
std::vector< std::string > nList
std::vector< std::string > nComp

◆ BPHDecayMomentum() [3/4]

BPHDecayMomentum::BPHDecayMomentum ( const std::map< std::string, Component > &  daugMap,
int  compNum = 2 
)
protected

◆ BPHDecayMomentum() [4/4]

BPHDecayMomentum::BPHDecayMomentum ( const std::map< std::string, Component > &  daugMap,
const std::map< std::string, BPHRecoConstCandPtr compMap 
)
protected

Member Function Documentation

◆ addP() [1/2]

virtual void BPHDecayMomentum::addP ( const std::string &  name,
const reco::Candidate daug,
double  mass = -1.0 
)
protectedvirtual

◆ addP() [2/2]

virtual void BPHDecayMomentum::addP ( const std::string &  name,
const BPHRecoConstCandPtr comp 
)
protectedvirtual

◆ clonesList()

void BPHDecayMomentum::clonesList ( const std::map< std::string, Component > &  daugMap)
private

Definition at line 162 of file BPHDecayMomentum.cc.

References clonesMap, AlCaHLTBitMon_QueryRunRegistry::comp, compList, daugMap(), dList, dMap, mps_splice::entry, mps_fire::i, EgHLTOffHistBins_cfi::mass, create_idmaps::n, mergeVDriftHistosByStation::name, nList, and reco::Candidate::setMass().

162  {
163  int n = daugMap.size();
164  dList.resize(n);
165  nList.resize(n);
166  // reset and fill a list
167  // to be used in the creation of other bases of BPHRecoCandidate
168  compList.clear();
169  compList.reserve(n);
170  // loop over daughters
171  int i = 0;
172  double mass;
173  reco::Candidate* dnew;
174  map<string, Component>::const_iterator iter = daugMap.begin();
175  map<string, Component>::const_iterator iend = daugMap.end();
176  while (iter != iend) {
177  const map<string, Component>::value_type& entry = *iter++;
178  const Component& comp = entry.second;
179  const reco::Candidate* cand = comp.cand;
180  // store component for usage
181  // in the creation of other bases of BPHRecoCandidate
182  compList.push_back(comp);
183  // clone particle and store it with its name
184  dList[i] = dnew = cand->clone();
185  const string& name = nList[i++] = entry.first;
186  dMap[name] = dnew;
187  clonesMap[dnew] = cand;
188  // set daughter mass if requested
189  mass = comp.mass;
190  if (mass > 0)
191  dnew->setMass(mass);
192  }
193  return;
194 }
std::map< std::string, const reco::Candidate * > dMap
std::vector< const reco::Candidate * > dList
std::vector< Component > compList
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
const std::map< std::string, const reco::Candidate * > & daugMap() const
std::vector< std::string > nList
virtual void setMass(double m)=0
set particle mass

◆ compMap()

const std::map<std::string, BPHRecoConstCandPtr>& BPHDecayMomentum::compMap ( ) const
inline

Definition at line 100 of file BPHDecayMomentum.h.

References cMap.

100 { return cMap; }
std::map< std::string, BPHRecoConstCandPtr > cMap

◆ compNames()

const vector< string > & BPHDecayMomentum::compNames ( ) const
virtual

get the list of names of previously reconstructed particles e.g. in JPsi -> mu+mu- returns an empty list in B+ -> JPsi K+ returns the name used for the JPsi in Bs -> JPsi Phi returns the two names used for JPsi and Phi

Definition at line 79 of file BPHDecayMomentum.cc.

References nComp.

Referenced by BPHRecoCandidate::fill().

79 { return nComp; }
std::vector< std::string > nComp

◆ componentList()

const vector< BPHDecayMomentum::Component > & BPHDecayMomentum::componentList ( ) const
protected

Definition at line 126 of file BPHDecayMomentum.cc.

References compList.

Referenced by BPHDecayVertex::BPHDecayVertex(), and BPHKinematicFit::BPHKinematicFit().

126  {
127  // return an object filled in the constructor
128  // to be used in the creation of other bases of BPHRecoCandidate
129  return compList;
130 }
std::vector< Component > compList

◆ composite()

const pat::CompositeCandidate & BPHDecayMomentum::composite ( ) const
virtual

get a composite by the simple sum of simple particles

Operations

Reimplemented in BPHPlusMinusCandidate.

Definition at line 71 of file BPHDecayMomentum.cc.

References compCand, computeMomentum(), and oldMom.

Referenced by BPHPlusMinusCandidate::composite().

71  {
72  if (oldMom)
74  return compCand;
75 }
virtual void computeMomentum() const
pat::CompositeCandidate compCand

◆ computeMomentum()

void BPHDecayMomentum::computeMomentum ( ) const
privatevirtual

Definition at line 237 of file BPHDecayMomentum.cc.

References reco::CompositeCandidate::clearDaughters(), compCand, dFull, fillDaug(), oldMom, AddFourMomenta::set(), and sumMomentum().

Referenced by composite(), and daughFull().

237  {
238  // reset full list of daughters
239  dFull.clear();
240  dFull.reserve(10);
241  vector<string> nFull;
242  nFull.reserve(10);
243  fillDaug(dFull, "", nFull);
244  // reset and fill pat::CompositeCandidate
246  sumMomentum(dFull, nFull);
247  // compute the total momentum
248  AddFourMomenta addP4;
249  addP4.set(compCand);
250  oldMom = false;
251  return;
252 }
void set(reco::Candidate &c) const
set up a candidate
std::vector< const reco::Candidate * > dFull
virtual void sumMomentum(const std::vector< const reco::Candidate *> &dl, const std::vector< std::string > &dn) const
void clearDaughters()
clear daughters
virtual void fillDaug(std::vector< const reco::Candidate *> &ad, const std::string &name, std::vector< std::string > &an) const
pat::CompositeCandidate compCand

◆ daughComp()

const vector< BPHRecoConstCandPtr > & BPHDecayMomentum::daughComp ( ) const
virtual

get the list of previously reconstructed particles e.g. in JPsi -> mu+mu- returns an empty list in B+ -> JPsi K+ returns the JPsi in Bs -> JPsi Phi returns the JPsi and Phi

Definition at line 97 of file BPHDecayMomentum.cc.

References cList.

Referenced by BPHKinematicFit::addParticles(), BPHDecayVertex::BPHDecayVertex(), BPHKinematicFit::BPHKinematicFit(), and BPHKinematicFit::fitMomentum().

97  {
98  // return the list of previously reconstructed particles
99  return cList;
100 }
std::vector< BPHRecoConstCandPtr > cList

◆ daughFull()

const vector< const reco::Candidate * > & BPHDecayMomentum::daughFull ( ) const
virtual

get the full list of simple particles produced in the decay, directly or through cascade decays e.g. in B+ -> JPsi K+ ; JPsi -> mu+mu- returns the mu+, mu-, K+ in Bs -> JPsi Phi; JPsi -> mu+mu-; Phi -> K+K- returns the mu+, mu-, K+, K- (clones are actually returned)

Definition at line 83 of file BPHDecayMomentum.cc.

References computeMomentum(), dFull, and oldMom.

Referenced by BPHKinematicFit::buildParticles(), BPHDecayVertex::fTracks(), and BPHDecayVertex::fTTracks().

83  {
84  // compute total momentum to update the full list of decay products
85  if (oldMom)
87  return dFull;
88 }
virtual void computeMomentum() const
std::vector< const reco::Candidate * > dFull

◆ daughters()

const vector< const reco::Candidate * > & BPHDecayMomentum::daughters ( ) const
virtual

get the list of simple particles directly produced in the decay e.g. in JPsi -> mu+mu- returns the two muons in B+ -> JPsi K+ returns the K+ in Bs -> JPsi Phi returns an empty list (clones are actually returned)

Definition at line 81 of file BPHDecayMomentum.cc.

References dList.

Referenced by BPHKinematicFit::addParticles(), BPHDecayVertex::BPHDecayVertex(), BPHKinematicFit::BPHKinematicFit(), BPHWriteSpecificDecay::fill(), BPHKinematicFit::fitMomentum(), and BPHPlusMinusCandidate::phiDiff().

81 { return dList; }
std::vector< const reco::Candidate * > dList

◆ daugMap()

const std::map<std::string, const reco::Candidate*>& BPHDecayMomentum::daugMap ( ) const
inline

Definition at line 98 of file BPHDecayMomentum.h.

References dMap.

Referenced by clonesList().

98 { return dMap; }
std::map< std::string, const reco::Candidate * > dMap

◆ daugNames()

const vector< string > & BPHDecayMomentum::daugNames ( ) const
virtual

get the list of names of simple particles directly produced in the decay e.g. in JPsi -> mu+mu- returns the two names used for muons in B+ -> JPsi K+ returns the name used for the K+ in Bs -> JPsi Phi returns an empty list

Definition at line 77 of file BPHDecayMomentum.cc.

References nList.

Referenced by BPHRecoCandidate::fill().

77 { return nList; }
std::vector< std::string > nList

◆ dCompList()

void BPHDecayMomentum::dCompList ( )
private

Definition at line 196 of file BPHDecayMomentum.cc.

References cList, clonesMap, cMap, AlCaHLTBitMon_QueryRunRegistry::comp, mps_fire::i, create_idmaps::n, and nComp.

196  {
197  // fill lists of previously reconstructed particles and their names
198  // and retrieve cascade decay products
199  int n = cMap.size();
200  cList.resize(n);
201  nComp.resize(n);
202  int i = 0;
203  map<string, BPHRecoConstCandPtr>::const_iterator c_iter = cMap.begin();
204  map<string, BPHRecoConstCandPtr>::const_iterator c_iend = cMap.end();
205  while (c_iter != c_iend) {
206  const map<string, BPHRecoConstCandPtr>::value_type& c_entry = *c_iter++;
207  nComp[i] = c_entry.first;
208  BPHRecoConstCandPtr comp = c_entry.second;
209  cList[i++] = comp;
210  clonesMap.insert(comp->clonesMap.begin(), comp->clonesMap.end());
211  }
212  return;
213 }
std::vector< BPHRecoConstCandPtr > cList
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
std::vector< std::string > nComp
std::map< std::string, BPHRecoConstCandPtr > cMap

◆ fill()

virtual void BPHDecayMomentum::fill ( BPHRecoCandidate ptr,
int  level 
) const
protectedpure virtual

Implemented in BPHRecoCandidate.

◆ fillDaug()

void BPHDecayMomentum::fillDaug ( std::vector< const reco::Candidate *> &  ad,
const std::string &  name,
std::vector< std::string > &  an 
) const
privatevirtual

Definition at line 223 of file BPHDecayMomentum.cc.

References cList, dList, create_idmaps::n, mergeVDriftHistosByStation::name, nComp, and nList.

Referenced by computeMomentum().

223  {
224  // recursively fill the list of simple particles, produced
225  // directly or in cascade decays
226  ad.insert(ad.end(), dList.begin(), dList.end());
227  vector<string>::const_iterator iter = nList.begin();
228  vector<string>::const_iterator iend = nList.end();
229  while (iter != iend)
230  an.push_back(name + *iter++);
231  int n = cList.size();
232  while (n--)
233  cList[n]->fillDaug(ad, name + nComp[n] + "/", an);
234  return;
235 }
std::vector< BPHRecoConstCandPtr > cList
std::vector< const reco::Candidate * > dList
std::vector< std::string > nList
std::vector< std::string > nComp

◆ getComp()

BPHRecoConstCandPtr BPHDecayMomentum::getComp ( const std::string &  name) const
virtual

get a previously reconstructed particle from the name return null pointer if not found

Definition at line 114 of file BPHDecayMomentum.cc.

References cMap, AlCaHLTBitMon_QueryRunRegistry::comp, and mergeVDriftHistosByStation::name.

Referenced by BPHRecoCandidate::fill(), getDaug(), BPHKinematicFit::getIndependentFit(), BPHKinematicFit::setIndependentFit(), BPHKinematicFit::splitKP(), and BPHWriteSpecificDecay::write().

114  {
115  // return a previously reconstructed particle from the name
116  // return null pointer if not found
117  string::size_type pos = name.find('/');
118  if (pos != string::npos) {
119  const BPHRecoCandidate* comp = getComp(name.substr(0, pos)).get();
120  return (comp == nullptr ? nullptr : comp->getComp(name.substr(pos + 1)));
121  }
122  map<const string, BPHRecoConstCandPtr>::const_iterator iter = cMap.find(name);
123  return (iter != cMap.end() ? iter->second : nullptr);
124 }
uint16_t size_type
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
std::map< std::string, BPHRecoConstCandPtr > cMap

◆ getDaug()

const reco::Candidate * BPHDecayMomentum::getDaug ( const std::string &  name) const
virtual

get a simple particle from the name return null pointer if not found

Definition at line 102 of file BPHDecayMomentum.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, dMap, getComp(), and mergeVDriftHistosByStation::name.

Referenced by BPHWriteSpecificDecay::fill(), BPHRecoCandidate::fill(), and BPHOniaToMuMuBuilder::getOriginalCandidate().

102  {
103  // return a simple particle from the name
104  // return null pointer if not found
105  string::size_type pos = name.find('/');
106  if (pos != string::npos) {
107  const BPHRecoCandidate* comp = getComp(name.substr(0, pos)).get();
108  return (comp == nullptr ? nullptr : comp->getDaug(name.substr(pos + 1)));
109  }
110  map<const string, const reco::Candidate*>::const_iterator iter = dMap.find(name);
111  return (iter != dMap.end() ? iter->second : nullptr);
112 }
std::map< std::string, const reco::Candidate * > dMap
uint16_t size_type
virtual BPHRecoConstCandPtr getComp(const std::string &name) const

◆ operator=()

BPHDecayMomentum& BPHDecayMomentum::operator= ( const BPHDecayMomentum x)
delete

◆ originalReco()

const reco::Candidate * BPHDecayMomentum::originalReco ( const reco::Candidate daug) const
virtual

get the original particle from the clone

Definition at line 90 of file BPHDecayMomentum.cc.

References clonesMap.

Referenced by BPHDecayVertex::BPHDecayVertex(), BPHKinematicFit::BPHKinematicFit(), BPHWriteSpecificDecay::fill(), BPHRecoCandidate::fill(), BPHDecayVertex::fTracks(), and BPHOniaToMuMuBuilder::getOriginalCandidate().

90  {
91  // return the original particle for a given clone
92  // return null pointer if not found
93  map<const reco::Candidate*, const reco::Candidate*>::const_iterator iter = clonesMap.find(daug);
94  return (iter != clonesMap.end() ? iter->second : nullptr);
95 }
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap

◆ setNotUpdated()

void BPHDecayMomentum::setNotUpdated ( ) const
protectedvirtual

Reimplemented in BPHKinematicFit, BPHDecayVertex, BPHPlusMinusCandidate, and BPHPlusMinusVertex.

Definition at line 157 of file BPHDecayMomentum.cc.

References oldMom.

Referenced by BPHDecayVertex::setNotUpdated().

157  {
158  oldMom = true;
159  return;
160 }

◆ sumMomentum()

void BPHDecayMomentum::sumMomentum ( const std::vector< const reco::Candidate *> &  dl,
const std::vector< std::string > &  dn 
) const
privatevirtual

Definition at line 215 of file BPHDecayMomentum.cc.

References reco::CompositeCandidate::addDaughter(), compCand, and create_idmaps::n.

Referenced by computeMomentum().

215  {
216  // add the particles to pat::CompositeCandidate
217  int n = dl.size();
218  while (n--)
219  compCand.addDaughter(*dl[n], dn[n]);
220  return;
221 }
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
pat::CompositeCandidate compCand

Member Data Documentation

◆ cList

std::vector<BPHRecoConstCandPtr> BPHDecayMomentum::cList
private

◆ clonesMap

std::map<const reco::Candidate*, const reco::Candidate*> BPHDecayMomentum::clonesMap
private

Definition at line 153 of file BPHDecayMomentum.h.

Referenced by clonesList(), dCompList(), and originalReco().

◆ cMap

std::map<std::string, BPHRecoConstCandPtr> BPHDecayMomentum::cMap
private

Definition at line 150 of file BPHDecayMomentum.h.

Referenced by BPHKinematicFit::BPHKinematicFit(), compMap(), dCompList(), and getComp().

◆ compCand

pat::CompositeCandidate BPHDecayMomentum::compCand
mutableprivate

◆ compList

std::vector<Component> BPHDecayMomentum::compList
private

Definition at line 136 of file BPHDecayMomentum.h.

Referenced by clonesList(), and componentList().

◆ dFull

std::vector<const reco::Candidate*> BPHDecayMomentum::dFull
mutableprivate

Definition at line 157 of file BPHDecayMomentum.h.

Referenced by computeMomentum(), and daughFull().

◆ dList

std::vector<const reco::Candidate*> BPHDecayMomentum::dList
private

◆ dMap

std::map<std::string, const reco::Candidate*> BPHDecayMomentum::dMap
private

◆ nComp

std::vector<std::string> BPHDecayMomentum::nComp
private

◆ nList

std::vector<std::string> BPHDecayMomentum::nList
private

Definition at line 139 of file BPHDecayMomentum.h.

Referenced by BPHDecayMomentum(), clonesList(), daugNames(), and fillDaug().

◆ oldMom

bool BPHDecayMomentum::oldMom
mutableprivate

Definition at line 156 of file BPHDecayMomentum.h.

Referenced by composite(), computeMomentum(), daughFull(), and setNotUpdated().