CMS 3D CMS Logo

BPHX3872ToJPsiPiPiBuilder.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 //-------------------------------
23 
24 //---------------
25 // C++ Headers --
26 //---------------
27 using namespace std;
28 
29 //-------------------
30 // Initializations --
31 //-------------------
32 
33 //----------------
34 // Constructors --
35 //----------------
37  const std::vector<BPHPlusMinusConstCandPtr>& jpsiCollection,
38  const BPHRecoBuilder::BPHGenericCollection* posCollection,
39  const BPHRecoBuilder::BPHGenericCollection* negCollection)
40  : jPsiName("JPsi"),
41  pionPosName("PionPos"),
42  pionNegName("PionNeg"),
43  evSetup(&es),
44  jCollection(&jpsiCollection),
45  pCollection(posCollection),
46  nCollection(negCollection) {
47  jpsiSel = new BPHMassSelect(2.80, 3.40);
48  ptMin = 1.0;
49  etaMax = 10.0;
50  massSel = new BPHMassSelect(3.00, 4.50);
51  chi2Sel = new BPHChi2Select(0.02);
53  massConstr = true;
54  minPDiff = 1.0e-4;
55  updated = false;
56 }
57 
58 //--------------
59 // Destructor --
60 //--------------
62  delete jpsiSel;
63  delete massSel;
64  delete chi2Sel;
65  delete mFitSel;
66 }
67 
68 //--------------
69 // Operations --
70 //--------------
71 vector<BPHRecoConstCandPtr> BPHX3872ToJPsiPiPiBuilder::build() {
72  if (updated)
73  return x3872List;
74 
75  x3872List.clear();
76 
77  // extract basic informations from input collections
78 
79  class Particle {
80  public:
81  Particle(const reco::Candidate* c, const reco::Track* tk, double x, double y, double z, double p)
82  : cand(c), track(tk), px(x), py(y), pz(z), ePion(p) {}
83  const reco::Candidate* cand;
84  const reco::Track* track;
85  double px;
86  double py;
87  double pz;
88  double ePion;
89  };
90 
91  vector<Particle> pList;
92  vector<Particle> nList;
93 
94  int nPos = pCollection->size();
95  int nNeg = nCollection->size();
96 
97  pList.reserve(nPos);
98  nList.reserve(nNeg);
99 
100  // filter input collections
101 
102  int iPos;
103  int iNeg;
104 
105  for (iPos = 0; iPos < nPos; ++iPos) {
106  const reco::Candidate& cand = pCollection->get(iPos);
107  if (cand.charge() != +1)
108  continue;
109  const reco::Candidate::LorentzVector p4 = cand.p4();
110  if (p4.pt() < ptMin)
111  continue;
112  if (p4.eta() > etaMax)
113  continue;
114  const reco::Track* tk = BPHTrackReference::getTrack(cand, "cfhp");
115  if (tk == nullptr)
116  continue;
117  double px = p4.px();
118  double py = p4.py();
119  double pz = p4.pz();
120  double p2 = (px * px) + (py * py) + (pz * pz);
121  pList.push_back(
123  }
124 
125  for (iNeg = 0; iNeg < nNeg; ++iNeg) {
126  const reco::Candidate& cand = nCollection->get(iNeg);
127  if (cand.charge() != -1)
128  continue;
129  const reco::Candidate::LorentzVector p4 = cand.p4();
130  if (p4.pt() < ptMin)
131  continue;
132  if (p4.eta() > etaMax)
133  continue;
134  const reco::Track* tk = BPHTrackReference::getTrack(cand, "cfhp");
135  if (tk == nullptr)
136  continue;
137  double px = p4.px();
138  double py = p4.py();
139  double pz = p4.pz();
140  double p2 = (px * px) + (py * py) + (pz * pz);
141  nList.push_back(
143  }
144 
145  // filter basic candidates
146 
147  nPos = pList.size();
148  nNeg = nList.size();
149 
150  double mMax = getMassMax() - (0.8 * BPHParticleMasses::jPsiMass);
151 
152  struct PionPair {
153  const reco::Candidate* posPion;
154  const reco::Candidate* negPion;
155  };
156  vector<const PionPair*> pionPairs;
157  pionPairs.reserve(nPos * nNeg);
158 
159  for (iPos = 0; iPos < nPos; ++iPos) {
160  Particle& pc = pList[iPos];
161  const reco::Track* pt = pc.track;
162  double px = pc.px;
163  double py = pc.py;
164  double pz = pc.pz;
165  double pe = pc.ePion;
166  for (iNeg = 0; iNeg < nNeg; ++iNeg) {
167  Particle& nc = nList[iNeg];
168  const reco::Track* nt = nc.track;
169  if (fabs(nt->dz() - pt->dz()) > 1.0)
170  continue;
171  double nx = nc.px;
172  double ny = nc.py;
173  double nz = nc.pz;
174  double ne = nc.ePion;
175  const float tx = px + nx;
176  const float ty = py + ny;
177  const float tz = pz + nz;
178  const float te = pe + ne;
179  float mass = (te * te) - ((tx * tx) + (ty * ty) + (tz * tz));
180  if (mass > mMax)
181  continue;
182  PionPair* pp = new PionPair;
183  pp->posPion = pc.cand;
184  pp->negPion = nc.cand;
185  pionPairs.push_back(pp);
186  }
187  }
188 
189  vector<BPHPlusMinusConstCandPtr> jPsi;
190  int nJPsi = jCollection->size();
191  int iJPsi;
192  jPsi.reserve(nJPsi);
193  for (iJPsi = 0; iJPsi < nJPsi; ++iJPsi) {
194  const BPHPlusMinusConstCandPtr& jpCand = jCollection->at(iJPsi);
195  if (jpsiSel->accept(*jpCand))
196  jPsi.push_back(jpCand);
197  }
198  nJPsi = jPsi.size();
199 
200  int nPair = pionPairs.size();
201  int iPair;
202  for (iPair = 0; iPair < nPair; ++iPair) {
203  const PionPair* pp = pionPairs[iPair];
204  for (iJPsi = 0; iJPsi < nJPsi; ++iJPsi) {
206  BPHRecoCandidatePtr xPtr(x3872);
207  x3872->add(jPsiName, jPsi[iJPsi]);
210  if (!massSel->accept(*x3872))
211  continue;
212  if ((chi2Sel != nullptr) && !chi2Sel->accept(*x3872))
213  continue;
214  if (!mFitSel->accept(*x3872))
215  continue;
216  x3872List.push_back(xPtr);
217  }
218  delete pp;
219  }
220 
221  updated = true;
222  return x3872List;
223 }
224 
227  updated = false;
228  jpsiSel->setMassMin(m);
229  return;
230 }
231 
233  updated = false;
234  jpsiSel->setMassMax(m);
235  return;
236 }
237 
239  updated = false;
240  ptMin = pt;
241  return;
242 }
243 
245  updated = false;
246  etaMax = eta;
247  return;
248 }
249 
251  updated = false;
252  massSel->setMassMin(m);
253  return;
254 }
255 
257  updated = false;
258  massSel->setMassMax(m);
259  return;
260 }
261 
263  updated = false;
264  delete chi2Sel;
265  chi2Sel = (p < 0.0 ? nullptr : new BPHChi2Select(p));
266  return;
267 }
268 
270  updated = false;
271  mFitSel->setMassMin(m);
272  return;
273 }
274 
276  updated = false;
277  mFitSel->setMassMax(m);
278  return;
279 }
280 
282  updated = false;
283  massConstr = flag;
284  return;
285 }
286 
289 
291 
293 
295 
297 
299 
300 double BPHX3872ToJPsiPiPiBuilder::getProbMin() const { return (chi2Sel == nullptr ? -1.0 : chi2Sel->getProbMin()); }
301 
303 
305 
double getProbMin() const
get current prob min
Definition: BPHChi2Select.h:66
double getMassMin() const
get current mass cuts
Definition: BPHMassCuts.h:58
BPHX3872ToJPsiPiPiBuilder(const edm::EventSetup &es, const std::vector< BPHPlusMinusConstCandPtr > &jpsiCollection, const BPHRecoBuilder::BPHGenericCollection *posCollection, const BPHRecoBuilder::BPHGenericCollection *negCollection)
void setMassMax(double m)
Definition: BPHMassCuts.h:52
BPHGenericPtr< BPHRecoCandidate >::type BPHRecoCandidatePtr
const edm::EventSetup * evSetup
static const double jPsiMWidth
void setPiPtMin(double pt)
set cuts
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
const BPHRecoBuilder::BPHGenericCollection * pCollection
const std::vector< BPHPlusMinusConstCandPtr > * jCollection
static const double jPsiMass
const BPHRecoBuilder::BPHGenericCollection * nCollection
bool accept(const BPHDecayMomentum &cand) const override
select particle
Definition: BPHMassSelect.h:48
BPHGenericPtr< const BPHPlusMinusCandidate >::type BPHPlusMinusConstCandPtr
double getPiPtMin() const
get current cuts
static const double pionMSigma
T sqrt(T t)
Definition: SSEVec.h:19
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
virtual void add(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
double getMassMax() const
Definition: BPHMassCuts.h:59
int nt
Definition: AMPTWrapper.h:42
static const double pionMass
void setMassMin(double m)
set mass cuts
Definition: BPHMassCuts.h:48
std::vector< BPHRecoConstCandPtr > x3872List
double getJPsiMassMin() const
get current cuts
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
std::vector< BPHRecoConstCandPtr > build()
build X3872 candidates
void setJPsiMassMin(double m)
set cuts
bool accept(const BPHKinematicFit &cand) const override
select particle