CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BPHOniaToMuMuBuilder.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 //-------------------------------
25 
26 //---------------
27 // C++ Headers --
28 //---------------
29 using namespace std;
30 
31 //-------------------
32 // Initializations --
33 //-------------------
34 
35 //----------------
36 // Constructors --
37 //----------------
39  const BPHRecoBuilder::BPHGenericCollection* muPosCollection,
40  const BPHRecoBuilder::BPHGenericCollection* muNegCollection)
41  : muPosName("MuPos"),
42  muNegName("MuNeg"),
43  evSetup(&es),
44  posCollection(muPosCollection),
45  negCollection(muNegCollection) {
49  setParameters(Ups, 2.0, 10.0, 6.00, 12.00, 0.0, -1.0, 0.0);
53  updated = false;
54 }
55 
56 //--------------
57 // Destructor --
58 //--------------
60  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
61  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
62  while (iter != iend) {
63  OniaParameters& par = iter++->second;
64  delete par.ptSel;
65  delete par.etaSel;
66  delete par.massSel;
67  delete par.chi2Sel;
68  }
69 }
70 
71 //--------------
72 // Operations --
73 //--------------
74 vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::build() {
75  if (updated)
76  return fullList;
77 
78  fullList.clear();
79 
84 
85  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
86  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
87  while (iter != iend) {
88  OniaParameters& par = iter++->second;
89  ptSel.include(*par.ptSel);
90  etaSel.include(*par.etaSel);
91  mSel.include(*par.massSel);
92  vSel.include(*par.chi2Sel);
93  }
94 
95  BPHRecoBuilder bOnia(*evSetup);
98  bOnia.filter(muPosName, ptSel);
99  bOnia.filter(muNegName, ptSel);
100  bOnia.filter(muPosName, etaSel);
101  bOnia.filter(muNegName, etaSel);
102  bOnia.filter(mSel);
103  bOnia.filter(vSel);
104 
106  updated = true;
107  return fullList;
108 }
109 
110 vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::getList(
112  extractList(type);
113  vector<BPHPlusMinusConstCandPtr>& list = oniaList[type];
114  int i;
115  int n = list.size();
116  vector<BPHPlusMinusConstCandPtr> lsub;
117  lsub.reserve(n);
118  for (i = 0; i < n; ++i) {
119  BPHPlusMinusConstCandPtr ptr = list[i];
120  const reco::Candidate* muPos = ptr->originalReco(ptr->getDaug(muPosName));
121  const reco::Candidate* muNeg = ptr->originalReco(ptr->getDaug(muNegName));
122  if ((dSel != nullptr) && (!dSel->accept(*muPos)))
123  continue;
124  if ((dSel != nullptr) && (!dSel->accept(*muNeg)))
125  continue;
126  if ((mSel != nullptr) && (!mSel->accept(*ptr)))
127  continue;
128  if ((vSel != nullptr) && (!vSel->accept(*ptr)))
129  continue;
130  if ((kSel != nullptr) && (!kSel->accept(*ptr)))
131  continue;
132  lsub.push_back(list[i]);
133  }
134  return lsub;
135 }
136 
138  const reco::Candidate* mp = cand.originalReco(cand.getDaug(muPosName));
139  const reco::Candidate* mn = cand.originalReco(cand.getDaug(muNegName));
140  int nc = fullList.size();
141  int ic;
142  for (ic = 0; ic < nc; ++ic) {
144  const BPHPlusMinusCandidate* pmc = pmp.get();
145  if (pmc->originalReco(pmc->getDaug(muPosName)) != mp)
146  continue;
147  if (pmc->originalReco(pmc->getDaug(muNegName)) != mn)
148  continue;
149  return pmp;
150  }
151  return BPHPlusMinusConstCandPtr(nullptr);
152 }
153 
156  setNotUpdated();
157  OniaParameters& par = oniaPar[type];
158  par.ptSel->setPtMin(pt);
159  return;
160 }
161 
163  setNotUpdated();
164  OniaParameters& par = oniaPar[type];
165  par.etaSel->setEtaMax(eta);
166  return;
167 }
168 
170  setNotUpdated();
171  OniaParameters& par = oniaPar[type];
172  par.massSel->setMassMin(m);
173  return;
174 }
175 
177  setNotUpdated();
178  OniaParameters& par = oniaPar[type];
179  par.massSel->setMassMax(m);
180  return;
181 }
182 
184  setNotUpdated();
185  OniaParameters& par = oniaPar[type];
186  par.chi2Sel->setProbMin(p);
187  return;
188 }
189 
190 void BPHOniaToMuMuBuilder::setConstr(oniaType type, double mass, double sigma) {
191  setNotUpdated();
192  OniaParameters& par = oniaPar[type];
193  par.mass = mass;
194  par.sigma = sigma;
195  return;
196 }
197 
200  const OniaParameters& par = oniaPar.at(type);
201  return par.ptSel->getPtMin();
202 }
203 
205  const OniaParameters& par = oniaPar.at(type);
206  return par.etaSel->getEtaMax();
207 }
208 
210  const OniaParameters& par = oniaPar.at(type);
211  return par.massSel->getMassMin();
212 }
213 
215  const OniaParameters& par = oniaPar.at(type);
216  return par.massSel->getMassMax();
217 }
218 
220  const OniaParameters& par = oniaPar.at(type);
221  return par.chi2Sel->getProbMin();
222 }
223 
225  const OniaParameters& par = oniaPar.at(type);
226  return par.mass;
227 }
228 
230  const OniaParameters& par = oniaPar.at(type);
231  return par.sigma;
232 }
233 
235  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
236  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
237  while (iter != iend)
238  iter++->second.updated = false;
239  updated = false;
240  return;
241 }
242 
244  double ptMin,
245  double etaMax,
246  double massMin,
247  double massMax,
248  double probMin,
249  double mass,
250  double sigma) {
251  OniaParameters& par = oniaPar[type];
252  par.ptSel = new BPHMuonPtSelect(ptMin);
253  par.etaSel = new BPHMuonEtaSelect(etaMax);
254  par.massSel = new BPHMassSelect(massMin, massMax);
255  par.chi2Sel = new BPHChi2Select(probMin);
256  par.mass = mass;
257  par.sigma = sigma;
258  par.updated = false;
259  return;
260 }
261 
263  if (!updated)
264  build();
265  OniaParameters& par = oniaPar[type];
266  vector<BPHPlusMinusConstCandPtr>& list = oniaList[type];
267  if (par.updated)
268  return;
269  int i;
270  int n = fullList.size();
271  list.clear();
272  list.reserve(n);
273  for (i = 0; i < n; ++i) {
275  const reco::Candidate* mcPos = ptr->getDaug("MuPos");
276  const reco::Candidate* mcNeg = ptr->getDaug("MuNeg");
277  const reco::Candidate* muPos = ptr->originalReco(mcPos);
278  const reco::Candidate* muNeg = ptr->originalReco(mcNeg);
279  if (!par.massSel->accept(*ptr))
280  continue;
281  if (!par.ptSel->accept(*muPos))
282  continue;
283  if (!par.etaSel->accept(*muPos))
284  continue;
285  if (!par.ptSel->accept(*muNeg))
286  continue;
287  if (!par.etaSel->accept(*muNeg))
288  continue;
289  if (!par.chi2Sel->accept(*ptr))
290  continue;
292  np->add("MuPos", muPos, ptr->getTrackSearchList(mcPos), BPHParticleMasses::muonMass, BPHParticleMasses::muonMSigma);
293  np->add("MuNeg", muNeg, ptr->getTrackSearchList(mcNeg), BPHParticleMasses::muonMass, BPHParticleMasses::muonMSigma);
294  if (par.mass > 0.0)
295  np->setConstraint(par.mass, par.sigma);
296  list.push_back(BPHPlusMinusConstCandPtr(np));
297  }
298  par.updated = true;
299  return;
300 }
static const double ups2MWidth
static std::vector< BPHPlusMinusConstCandPtr > build(const BPHRecoBuilder &builder, const std::string &nPos, const std::string &nNeg, double mass=-1, double msig=-1)
const BPHRecoBuilder::BPHGenericCollection * posCollection
void setMassMax(double m)
Definition: BPHMassCuts.h:52
double getMassMax(oniaType type) const
void setMassMax(oniaType type, double m)
static const double ups3Mass
static const double ups2Mass
static const double jPsiMWidth
virtual bool accept(const BPHKinematicFit &cand) const =0
accept function
double getConstrMass(oniaType type) const
static const double muonMSigma
double getProbMin(oniaType type) const
constexpr float ptMin
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
bool accept(const reco::Candidate &cand) const override
select muon
static const double jPsiMass
void setPtMin(double pt)
set pt min
virtual bool accept(const BPHDecayMomentum &cand) const =0
accept function
BPHPlusMinusConstCandPtr getOriginalCandidate(const BPHRecoCandidate &cand)
bool accept(const BPHDecayMomentum &cand) const override
select particle
Definition: BPHMassSelect.h:48
void setProbMin(oniaType type, double p)
std::map< oniaType, std::vector< BPHPlusMinusConstCandPtr > > oniaList
double getMassMin(oniaType type) const
void setParameters(oniaType type, double ptMin, double etaMax, double massMin, double massMax, double probMin, double mass, double sigma)
void add(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0) override
BPHGenericPtr< const BPHPlusMinusCandidate >::type BPHPlusMinusConstCandPtr
static const double ups1MWidth
double getPtMin() const
get current pt min
void setProbMin(double p)
set prob min
Definition: BPHChi2Select.h:60
int np
Definition: AMPTWrapper.h:43
std::vector< BPHPlusMinusConstCandPtr > getList(oniaType type, BPHRecoSelect *dSel=nullptr, BPHMomentumSelect *mSel=nullptr, BPHVertexSelect *vSel=nullptr, BPHFitSelect *kSel=nullptr)
double getConstrSigma(oniaType type) const
void extractList(oniaType type)
virtual bool accept(const BPHDecayVertex &cand) const =0
accept function
BPHOniaToMuMuBuilder(const edm::EventSetup &es, const BPHRecoBuilder::BPHGenericCollection *muPosCollection, const BPHRecoBuilder::BPHGenericCollection *muNegCollection)
static const double phiMWidth
double getEtaMax(oniaType type) const
void setEtaMax(double eta)
set eta max
double getProbMin() const
get current prob min
Definition: BPHChi2Select.h:66
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
static const double phiMass
void setMassMin(double m)
set mass cuts
Definition: BPHMassCuts.h:48
void add(const std::string &name, const BPHGenericCollection *collection, double mass=-1.0, double msig=-1.0)
double getMassMax() const
Definition: BPHMassCuts.h:59
static const double psi2Mass
double getMassMin() const
get current mass cuts
Definition: BPHMassCuts.h:58
static const double ups1Mass
const BPHRecoBuilder::BPHGenericCollection * negCollection
double getPtMin(oniaType type) const
get current cuts
static const double muonMass
void filter(const std::string &name, const BPHRecoSelect &sel) const
static const double ups3MWidth
std::vector< BPHPlusMinusConstCandPtr > build()
build resonance candidates
std::map< oniaType, OniaParameters > oniaPar
void setConstr(oniaType type, double mass, double sigma)
void setEtaMax(oniaType type, double eta)
std::vector< BPHPlusMinusConstCandPtr > fullList
virtual bool accept(const reco::Candidate &cand) const =0
bool accept(const reco::Candidate &cand) const override
select muon
void setConstraint(double mass, double sigma)
apply a mass constraint
double getEtaMax() const
get current eta max
virtual const reco::Candidate * getDaug(const std::string &name) const
void setMassMin(oniaType type, double m)
tuple etaMax
Definition: Puppi_cff.py:46
const edm::EventSetup * evSetup
static const double psi2MWidth
void setPtMin(oniaType type, double pt)
set cuts