CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BPHDecayToChargedXXbarBuilder.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //-----------------------
9 // This Class' Header --
10 //-----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
26 
27 //---------------
28 // C++ Headers --
29 //---------------
30 using namespace std;
31 
32 //-------------------
33 // Initializations --
34 //-------------------
35 
36 //----------------
37 // Constructors --
38 //----------------
40  const std::string& dPosName,
41  const std::string& dNegName,
42  double daugMass,
43  double daugSigma,
44  const BPHRecoBuilder::BPHGenericCollection* posCollection,
45  const BPHRecoBuilder::BPHGenericCollection* negCollection)
47  pName(dPosName),
48  nName(dNegName),
49  dMass(daugMass),
50  dSigma(daugSigma),
51  pCollection(posCollection),
52  nCollection(negCollection),
53  ptMin(-1.0),
54  etaMax(10.0),
55  dzMax(1.0) {}
56 
57 //--------------
58 // Destructor --
59 //--------------
61 
62 //--------------
63 // Operations --
64 //--------------
65 vector<BPHPlusMinusConstCandPtr> BPHDecayToChargedXXbarBuilder::build() {
66  if (updated)
67  return recList;
68 
69  recList.clear();
70 
71  // extract basic informations from input collections
72 
73  vector<Particle*> pList;
74  vector<Particle*> nList;
75 
76  addParticle(pCollection, +1, pList);
77  addParticle(nCollection, -1, nList);
78  int iPos;
79  int iNeg;
80  int nPos = pList.size();
81  int nNeg = nList.size();
82  double massMin = getMassMin();
83  double massMax = getMassMax();
84  double mSqMin = massMin * massMin * 0.9;
85  double mSqMax = massMax * massMax * 1.1;
86  if (mSqMin < 0.0)
87  mSqMin = 0.0;
88 
89  for (iPos = 0; iPos < nPos; ++iPos) {
90  Particle* pc = pList[iPos];
91  const reco::Track* pt = pc->track;
92  double px = pc->px;
93  double py = pc->py;
94  double pz = pc->pz;
95  double pe = pc->en;
96  for (iNeg = 0; iNeg < nNeg; ++iNeg) {
97  Particle* nc = nList[iNeg];
98  const reco::Track* nt = nc->track;
99  if (fabs(nt->dz() - pt->dz()) > 1.0)
100  continue;
101  double nx = nc->px;
102  double ny = nc->py;
103  double nz = nc->pz;
104  double ne = nc->en;
105  const float tx = px + nx;
106  const float ty = py + ny;
107  const float tz = pz + nz;
108  const float te = pe + ne;
109  const float m2 = (te * te) - ((tx * tx) + (ty * ty) + (tz * tz));
110  if (m2 < mSqMin)
111  continue;
112  if (m2 > mSqMax)
113  continue;
115  rc->add(pName, pc->cand, dMass, dSigma);
116  rc->add(nName, nc->cand, dMass, dSigma);
117  double mass = rc->composite().mass();
118  if (mass < massMin)
119  continue;
120  if (mass > massMax)
121  continue;
122  if (!chi2Sel->accept(*rc))
123  continue;
124  recList.push_back(rc);
125  }
126  }
127 
128  for (iPos = 0; iPos < nPos; ++iPos)
129  delete pList[iPos];
130  for (iNeg = 0; iNeg < nNeg; ++iNeg)
131  delete nList[iNeg];
132 
133  updated = true;
134  return recList;
135 }
136 
139  updated = false;
140  ptMin = pt;
141  return;
142 }
143 
145  updated = false;
146  etaMax = eta;
147  return;
148 }
149 
151  updated = false;
152  dzMax = dz;
153  return;
154 }
155 
157  int charge,
158  vector<Particle*>& list) {
159  int i;
160  int n = collection->size();
161  list.reserve(n);
162  for (i = 0; i < n; ++i) {
163  const reco::Candidate& cand = collection->get(i);
164  int q = cand.charge();
165  if ((charge > 0) && (q <= 0))
166  continue;
167  if ((charge < 0) && (q >= 0))
168  continue;
169  const reco::Candidate::LorentzVector p4 = cand.p4();
170  if (p4.pt() < ptMin)
171  continue;
172  if (p4.eta() > etaMax)
173  continue;
174  const reco::Track* tk = BPHTrackReference::getTrack(cand, "cfhp");
175  if (tk == nullptr)
176  continue;
177  double px = p4.px();
178  double py = p4.py();
179  double pz = p4.pz();
180  list.push_back(new Particle(&cand, tk, px, py, pz, sqrt((px * px) + (py * py) + (pz * pz) + (dMass * dMass))));
181  }
182  return;
183 }
std::vector< BPHPlusMinusConstCandPtr > recList
constexpr float ptMin
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
void addParticle(const BPHRecoBuilder::BPHGenericCollection *collection, int charge, std::vector< Particle * > &list)
BPHDecayToChargedXXbarBuilder(const edm::EventSetup &es, const std::string &dPosName, const std::string &dNegName, double daugMass, double daugSigma, const BPHRecoBuilder::BPHGenericCollection *posCollection, const BPHRecoBuilder::BPHGenericCollection *negCollection)
constexpr float dzMax
tuple m2
Definition: callgraph.py:57
std::vector< BPHPlusMinusConstCandPtr > build()
build Phi candidates
T sqrt(T t)
Definition: SSEVec.h:19
BPHGenericPtr< BPHPlusMinusCandidate >::type BPHPlusMinusCandidatePtr
static const reco::Track * getTrack(const reco::Candidate &rc, const char *modeList="cfhbpmnigset", char *modeFlag=nullptr)
virtual const reco::Candidate & get(int i) const =0
const BPHRecoBuilder::BPHGenericCollection * pCollection
virtual int charge() const =0
electric charge
double getMassMin() const
get current cuts
int nt
Definition: AMPTWrapper.h:42
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:622
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
static type create(Args &&...args)
Definition: BPHGenericPtr.h:10
tuple etaMax
Definition: Puppi_cff.py:46
const BPHRecoBuilder::BPHGenericCollection * nCollection
const edm::EventSetup * evSetup
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector