CMS 3D CMS Logo

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

#include <BPHDecayMomentum.h>

Inheritance diagram for BPHDecayMomentum:
BPHDecayVertex BPHKinematicFit BPHPlusMinusVertex BPHRecoCandidate BPHPlusMinusCandidate BPHPlusMinusCandidate

Classes

struct  Component
 

Public Member Functions

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
 
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
 
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)
 add a previously reconstructed particle giving it a name More...
 
 BPHDecayMomentum ()
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap)
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap, const std::map< std::string, BPHRecoConstCandPtr > compMap)
 
const std::vector< Component > & componentList () const
 
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
 
virtual void sumMomentum (const std::vector< const reco::Candidate * > dl) 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
 

Friends

class BPHRecoBuilder
 

Detailed Description

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

Author
Paolo Ronchese INFN Padova

Definition at line 36 of file BPHDecayMomentum.h.

Constructor & Destructor Documentation

BPHDecayMomentum::~BPHDecayMomentum ( )
virtual

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

Definition at line 64 of file BPHDecayMomentum.cc.

References dList, and gen::n.

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

Definition at line 35 of file BPHDecayMomentum.cc.

References clonesList(), cMap, dCompList(), dList, and oldMom.

35  :
36  oldMom( true ) {
37  dList.reserve( 2 );
38 }
std::vector< const reco::Candidate * > dList
BPHDecayMomentum::BPHDecayMomentum ( const std::map< std::string, Component > &  daugMap)
protected
BPHDecayMomentum::BPHDecayMomentum ( const std::map< std::string, Component > &  daugMap,
const std::map< std::string, BPHRecoConstCandPtr compMap 
)
protected

Member Function Documentation

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

add a simple particle giving it a name particles are cloned, eventually specifying a different mass

Referenced by componentList().

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

add a previously reconstructed particle giving it a name

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

Definition at line 190 of file BPHDecayMomentum.cc.

References reco::Candidate::begin(), BPHDecayMomentum::Component::cand, reco::Candidate::clone(), clonesMap, AlCaHLTBitMon_QueryRunRegistry::comp, compList, dList, dMap, mps_splice::entry, mps_fire::i, ResonanceBuilder::mass, BPHDecayMomentum::Component::mass, gen::n, dataset::name, nList, and reco::Candidate::setMass().

Referenced by BPHDecayMomentum().

190  {
191  int n = daugMap.size();
192  dList.resize( n );
193  nList.resize( n );
194  // reset and fill a list
195  // to be used in the creation of other bases of BPHRecoCandidate
196  compList.clear();
197  compList.reserve( n );
198  // loop over daughters
199  int i = 0;
200  double mass;
201  reco::Candidate* dnew;
202  map<string,Component>::const_iterator iter = daugMap.begin();
203  map<string,Component>::const_iterator iend = daugMap.end();
204  while ( iter != iend ) {
205  const pair<string,Component>& entry = *iter++;
206  const Component& comp = entry.second;
207  const reco::Candidate* cand = comp.cand;
208  // store component for usage
209  // in the creation of other bases of BPHRecoCandidate
210  compList.push_back( comp );
211  // clone particle and store it with its name
212  dList[i] = dnew = cand->clone();
213  const string& name = nList[i++] = entry.first;
214  dMap[name] = dnew;
215  clonesMap[dnew] = cand;
216  // set daughter mass if requested
217  mass = comp.mass;
218  if ( mass > 0 ) dnew->setMass( mass );
219  }
220  return;
221 }
std::vector< const reco::Candidate * > dList
virtual Candidate * clone() const =0
returns a clone of the Candidate object
std::vector< Component > compList
virtual double mass() const =0
mass
std::map< std::string, const reco::Candidate * > dMap
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
std::vector< std::string > nList
virtual void setMass(double m)=0
set particle mass
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 84 of file BPHDecayMomentum.cc.

References nComp.

84  {
85  return nComp;
86 }
std::vector< std::string > nComp
const vector< BPHDecayMomentum::Component > & BPHDecayMomentum::componentList ( ) const
protected

Definition at line 147 of file BPHDecayMomentum.cc.

References addP(), cList, reco::Candidate::clone(), clonesMap, cMap, AlCaHLTBitMon_QueryRunRegistry::comp, compList, dList, dMap, ResonanceBuilder::mass, dataset::name, nComp, nList, reco::Candidate::setMass(), and setNotUpdated().

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

147  {
148  // return an object filled in the constructor
149  // to be used in the creation of other bases of BPHRecoCandidate
150  return compList;
151 }
std::vector< Component > compList
const pat::CompositeCandidate & BPHDecayMomentum::composite ( ) const
virtual

get a composite by the simple sum of simple particles

Operations

Reimplemented in BPHPlusMinusCandidate.

Definition at line 73 of file BPHDecayMomentum.cc.

References compCand, computeMomentum(), and oldMom.

Referenced by BPHPlusMinusCandidate::composite(), and BPHMassSelect::~BPHMassSelect().

73  {
74  if ( oldMom ) computeMomentum();
75  return compCand;
76 }
virtual void computeMomentum() const
pat::CompositeCandidate compCand
void BPHDecayMomentum::computeMomentum ( ) const
privatevirtual

Definition at line 263 of file BPHDecayMomentum.cc.

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

Referenced by composite(), and daughFull().

263  {
264  // reset full list of daughters
265  dFull.clear();
266  fillDaug( dFull );
267  // reset and fill pat::CompositeCandidate
269  sumMomentum( dFull );
270  // compute the total momentum
271  AddFourMomenta addP4;
272  addP4.set( compCand );
273  oldMom = false;
274  return;
275 }
virtual void sumMomentum(const std::vector< const reco::Candidate * > dl) const
std::vector< const reco::Candidate * > dFull
virtual void fillDaug(std::vector< const reco::Candidate * > &ad) const
void clearDaughters()
clear daughters
pat::CompositeCandidate compCand
void set(reco::Candidate &c) const
set up a candidate
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 111 of file BPHDecayMomentum.cc.

References cList.

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

111  {
112  // return the list of previously reconstructed particles
113  return cList;
114 }
std::vector< BPHRecoConstCandPtr > cList
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 94 of file BPHDecayMomentum.cc.

References computeMomentum(), dFull, and oldMom.

Referenced by BPHKinematicFit::buildParticles(), BPHKinematicFit::kinematicTree(), BPHKinematicFit::kinParticles(), and BPHDecayVertex::tTracks().

94  {
95  // compute total momentum to update the full list of decay products
96  if ( oldMom ) computeMomentum();
97  return dFull;
98 }
virtual void computeMomentum() const
std::vector< const reco::Candidate * > dFull
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 89 of file BPHDecayMomentum.cc.

References dList.

Referenced by BPHDecayVertex::BPHDecayVertex(), BPHKinematicFit::BPHKinematicFit(), BPHPlusMinusVertex::cAppInRPhi(), BPHWriteSpecificDecay::fill(), BPHKinematicFit::fitMomentum(), BPHKinematicFit::p4(), BPHPlusMinusCandidate::phiDiff(), and BPHPlusMinusCandidate::~BPHPlusMinusCandidate().

89  {
90  return dList;
91 }
std::vector< const reco::Candidate * > dList
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 79 of file BPHDecayMomentum.cc.

References nList.

Referenced by BPHKinematicFit::kinematicTree().

79  {
80  return nList;
81 }
std::vector< std::string > nList
void BPHDecayMomentum::dCompList ( )
private

Definition at line 224 of file BPHDecayMomentum.cc.

References cList, clonesMap, cMap, AlCaHLTBitMon_QueryRunRegistry::comp, mps_splice::entry, mps_fire::i, gen::n, and nComp.

Referenced by BPHDecayMomentum().

224  {
225  // fill lists of previously reconstructed particles and their names
226  // and retrieve cascade decay products
227  int n = cMap.size();
228  cList.resize( n );
229  nComp.resize( n );
230  int i = 0;
231  map<string,BPHRecoConstCandPtr>::const_iterator iter = cMap.begin();
232  map<string,BPHRecoConstCandPtr>::const_iterator iend = cMap.end();
233  while ( iter != iend ) {
234  const pair<string,BPHRecoConstCandPtr>& entry = *iter++;
235  nComp[i] = entry.first;
236  BPHRecoConstCandPtr comp = entry.second;
237  cList[i++] = comp;
238  clonesMap.insert( comp->clonesMap.begin(), comp->clonesMap.end() );
239  }
240  return;
241 }
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
std::vector< BPHRecoConstCandPtr > cList
std::map< std::string, BPHRecoConstCandPtr > cMap
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
std::vector< std::string > nComp
void BPHDecayMomentum::fillDaug ( std::vector< const reco::Candidate * > &  ad) const
privatevirtual

Definition at line 253 of file BPHDecayMomentum.cc.

References cList, dList, and gen::n.

Referenced by computeMomentum().

253  {
254  // recursively fill the list of simple particles, produced
255  // directly or in cascade decays
256  ad.insert( ad.end(), dList.begin(), dList.end() );
257  int n = cList.size();
258  while ( n-- ) cList[n]->fillDaug( ad );
259  return;
260 }
std::vector< const reco::Candidate * > dList
std::vector< BPHRecoConstCandPtr > cList
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 132 of file BPHDecayMomentum.cc.

References cMap, AlCaHLTBitMon_QueryRunRegistry::comp, getComp(), genParticles_cff::map, nullptr, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComp(), getDaug(), and BPHKinematicFit::kinematicTree().

132  {
133  // return a previously reconstructed particle from the name
134  // return null pointer if not found
135  string::size_type pos = name.find( "/" );
136  if ( pos != string::npos ) {
137  const BPHRecoCandidate* comp = getComp( name.substr( 0, pos ) ).get();
138  return ( comp == nullptr ? nullptr : comp->getComp( name.substr( pos + 1 ) ) );
139  }
140  map<const string,
141  BPHRecoConstCandPtr>::const_iterator iter = cMap.find( name );
142  return ( iter != cMap.end() ? iter->second : nullptr );
143 }
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
#define nullptr
uint16_t size_type
std::map< std::string, BPHRecoConstCandPtr > cMap
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
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 117 of file BPHDecayMomentum.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, dMap, getComp(), getDaug(), genParticles_cff::map, nullptr, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BPHKx0ToKPiBuilder::build(), BPHWriteSpecificDecay::fill(), getDaug(), BPHOniaToMuMuBuilder::getOriginalCandidate(), BPHKinematicFit::kinParticles(), and BPHMassSymSelect::~BPHMassSymSelect().

118  {
119  // return a simple particle from the name
120  // return null pointer if not found
121  string::size_type pos = name.find( "/" );
122  if ( pos != string::npos ) {
123  const BPHRecoCandidate* comp = getComp( name.substr( 0, pos ) ).get();
124  return ( comp == nullptr ? nullptr : comp->getDaug( name.substr( pos + 1 ) ) );
125  }
126  map<const string,
127  const reco::Candidate*>::const_iterator iter = dMap.find( name );
128  return ( iter != dMap.end() ? iter->second : nullptr );
129 }
#define nullptr
uint16_t size_type
std::map< std::string, const reco::Candidate * > dMap
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
virtual const reco::Candidate * getDaug(const std::string &name) const
const reco::Candidate * BPHDecayMomentum::originalReco ( const reco::Candidate daug) const
virtual

get the original particle from the clone

Definition at line 101 of file BPHDecayMomentum.cc.

References clonesMap, genParticles_cff::map, and nullptr.

Referenced by BPHDecayVertex::BPHDecayVertex(), BPHKinematicFit::BPHKinematicFit(), BPHKx0ToKPiBuilder::build(), BPHWriteSpecificDecay::fill(), BPHOniaToMuMuBuilder::getOriginalCandidate(), and BPHMassSymSelect::~BPHMassSymSelect().

102  {
103  // return the original particle for a given clone
104  // return null pointer if not found
105  map<const reco::Candidate*,
106  const reco::Candidate*>::const_iterator iter = clonesMap.find( daug );
107  return ( iter != clonesMap.end() ? iter->second : nullptr );
108 }
#define nullptr
std::map< const reco::Candidate *, const reco::Candidate * > clonesMap
void BPHDecayMomentum::setNotUpdated ( ) const
protectedvirtual

Reimplemented in BPHKinematicFit, BPHDecayVertex, BPHPlusMinusCandidate, and BPHPlusMinusVertex.

Definition at line 184 of file BPHDecayMomentum.cc.

References oldMom.

Referenced by componentList(), and BPHDecayVertex::setNotUpdated().

184  {
185  oldMom = true;
186  return;
187 }
void BPHDecayMomentum::sumMomentum ( const std::vector< const reco::Candidate * >  dl) const
privatevirtual

Definition at line 244 of file BPHDecayMomentum.cc.

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

Referenced by computeMomentum().

245  {
246  // add the particles to pat::CompositeCandidate
247  int n = dl.size();
248  while ( n-- ) compCand.addDaughter( *dl[n] );
249  return;
250 }
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
pat::CompositeCandidate compCand

Friends And Related Function Documentation

friend class BPHRecoBuilder
friend

Definition at line 38 of file BPHDecayMomentum.h.

Member Data Documentation

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

Definition at line 152 of file BPHDecayMomentum.h.

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

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

Definition at line 149 of file BPHDecayMomentum.h.

Referenced by BPHDecayMomentum(), componentList(), dCompList(), and getComp().

pat::CompositeCandidate BPHDecayMomentum::compCand
mutableprivate
std::vector<Component> BPHDecayMomentum::compList
private
std::vector<const reco::Candidate*> BPHDecayMomentum::dFull
mutableprivate

Definition at line 156 of file BPHDecayMomentum.h.

Referenced by computeMomentum(), and daughFull().

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

Definition at line 139 of file BPHDecayMomentum.h.

Referenced by compNames(), componentList(), and dCompList().

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

Definition at line 138 of file BPHDecayMomentum.h.

Referenced by clonesList(), componentList(), and daugNames().

bool BPHDecayMomentum::oldMom
mutableprivate