CMS 3D CMS Logo

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)
42  muPosName("MuPos"),
43  muNegName("MuNeg"),
44  posCollection(muPosCollection),
45  negCollection(muNegCollection) {
46  setParameters(NRes, 2.0, 10.0, 0.01, 50.00, 2.0, -1.0, 0.0);
50  setParameters(Ups, 2.0, 10.0, 6.00, 12.00, 0.0, -1.0, 0.0);
54  outdated = true;
55 }
56 
57 //--------------
58 // Destructor --
59 //--------------
61  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
62  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
63  while (iter != iend) {
64  OniaParameters& par = iter++->second;
65  delete par.ptSel;
66  delete par.etaSel;
67  delete par.massSel;
68  delete par.chi2Sel;
69  }
70 }
71 
72 //--------------
73 // Operations --
74 //--------------
76  double ptMin = 9.99e+30;
77  double etaMax = -1.0;
80 
81  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
82  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
83  while (iter != iend) {
84  OniaParameters& par = iter++->second;
85  double ptCur = par.ptSel->getPtMin();
86  double etaCur = par.etaSel->getEtaMax();
87  if (ptCur < ptMin)
88  ptMin = ptCur;
89  if (etaCur > etaMax)
90  etaMax = etaCur;
91  mSel.include(*par.massSel);
92  vSel.include(*par.chi2Sel);
93  }
94  BPHMuonPtSelect ptSel(ptMin);
95  BPHMuonEtaSelect etaSel(etaMax);
96 
97  BPHRecoBuilder bOnia(*evSetup);
100  bOnia.filter(muPosName, ptSel);
101  bOnia.filter(muNegName, ptSel);
102  bOnia.filter(muPosName, etaSel);
103  bOnia.filter(muNegName, etaSel);
104  bOnia.filter(mSel);
105  bOnia.filter(vSel);
106 
108 
109  decltype(recList) tmpList;
110  tmpList.reserve(recList.size());
111  for (auto& c : recList) {
112  auto p = c->originalReco(c->getDaug(muPosName));
113  auto n = c->originalReco(c->getDaug(muNegName));
114  bool accept = false;
115  for (auto& e : oniaPar) {
116  if (e.first == NRes)
117  continue;
118  auto& s = e.second;
119  if ((s.ptSel->accept(*p)) && (s.ptSel->accept(*n)) && (s.etaSel->accept(*p)) && (s.etaSel->accept(*n)) &&
120  (s.massSel->accept(*c)) && (s.chi2Sel->accept(*c))) {
121  accept = true;
122  break;
123  }
124  }
125  if (accept)
126  tmpList.push_back(c);
127  }
128  recList = tmpList;
129 
130  return;
131 }
132 
133 vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::getList(
135  extractList(type);
136  vector<BPHPlusMinusConstCandPtr>& list = oniaList[type];
137  int i;
138  int n = list.size();
139  vector<BPHPlusMinusConstCandPtr> lsub;
140  lsub.reserve(n);
141  for (i = 0; i < n; ++i) {
142  BPHPlusMinusConstCandPtr ptr = list[i];
143  const reco::Candidate* muPos = ptr->originalReco(ptr->getDaug(muPosName));
144  const reco::Candidate* muNeg = ptr->originalReco(ptr->getDaug(muNegName));
145  if ((dSel != nullptr) && (!dSel->accept(*muPos)))
146  continue;
147  if ((dSel != nullptr) && (!dSel->accept(*muNeg)))
148  continue;
149  if ((mSel != nullptr) && (!mSel->accept(*ptr)))
150  continue;
151  if ((vSel != nullptr) && (!vSel->accept(*ptr)))
152  continue;
153  if ((kSel != nullptr) && (!kSel->accept(*ptr)))
154  continue;
155  lsub.push_back(list[i]);
156  }
157  return lsub;
158 }
159 
161  const reco::Candidate* mp = cand.originalReco(cand.getDaug(muPosName));
162  const reco::Candidate* mn = cand.originalReco(cand.getDaug(muNegName));
163  int nc = recList.size();
164  int ic;
165  for (ic = 0; ic < nc; ++ic) {
167  const BPHPlusMinusCandidate* pmc = pmp.get();
168  if (pmc->originalReco(pmc->getDaug(muPosName)) != mp)
169  continue;
170  if (pmc->originalReco(pmc->getDaug(muNegName)) != mn)
171  continue;
172  return pmp;
173  }
174  return BPHPlusMinusConstCandPtr(nullptr);
175 }
176 
179  setNotUpdated();
180  OniaParameters& par = oniaPar[type];
181  par.ptSel->setPtMin(pt);
182  return;
183 }
184 
186  setNotUpdated();
187  OniaParameters& par = oniaPar[type];
188  par.etaSel->setEtaMax(eta);
189  return;
190 }
191 
193  setNotUpdated();
194  OniaParameters& par = oniaPar[type];
195  par.massSel->setMassMin(m);
196  return;
197 }
198 
200  setNotUpdated();
201  OniaParameters& par = oniaPar[type];
202  par.massSel->setMassMax(m);
203  return;
204 }
205 
207  setNotUpdated();
208  OniaParameters& par = oniaPar[type];
209  par.chi2Sel->setProbMin(p);
210  return;
211 }
212 
213 void BPHOniaToMuMuBuilder::setConstr(oniaType type, double mass, double sigma) {
214  setNotUpdated();
215  OniaParameters& par = oniaPar[type];
216  par.mass = mass;
217  par.sigma = sigma;
218  return;
219 }
220 
223  const OniaParameters& par = oniaPar.at(type);
224  return par.ptSel->getPtMin();
225 }
226 
228  const OniaParameters& par = oniaPar.at(type);
229  return par.etaSel->getEtaMax();
230 }
231 
233  const OniaParameters& par = oniaPar.at(type);
234  return par.massSel->getMassMin();
235 }
236 
238  const OniaParameters& par = oniaPar.at(type);
239  return par.massSel->getMassMax();
240 }
241 
243  const OniaParameters& par = oniaPar.at(type);
244  return par.chi2Sel->getProbMin();
245 }
246 
248  const OniaParameters& par = oniaPar.at(type);
249  return par.mass;
250 }
251 
253  const OniaParameters& par = oniaPar.at(type);
254  return par.sigma;
255 }
256 
258  map<oniaType, OniaParameters>::iterator iter = oniaPar.begin();
259  map<oniaType, OniaParameters>::iterator iend = oniaPar.end();
260  while (iter != iend)
261  iter++->second.outdated = true;
262  return;
263 }
264 
266  double ptMin,
267  double etaMax,
268  double massMin,
269  double massMax,
270  double probMin,
271  double mass,
272  double sigma) {
273  OniaParameters& par = oniaPar[type];
274  par.ptSel = new BPHMuonPtSelect(ptMin);
275  par.etaSel = new BPHMuonEtaSelect(etaMax);
276  par.massSel = new BPHMassSelect(massMin, massMax);
277  par.chi2Sel = new BPHChi2Select(probMin);
278  par.mass = mass;
279  par.sigma = sigma;
280  par.outdated = true;
281  return;
282 }
283 
285  build();
286  OniaParameters& par = oniaPar[type];
287  vector<BPHPlusMinusConstCandPtr>& list = oniaList[type];
288  if (!par.outdated)
289  return;
290  int i;
291  int n = recList.size();
292  list.clear();
293  list.reserve(n);
294  for (i = 0; i < n; ++i) {
296  const reco::Candidate* mcPos = ptr->getDaug("MuPos");
297  const reco::Candidate* mcNeg = ptr->getDaug("MuNeg");
298  const reco::Candidate* muPos = ptr->originalReco(mcPos);
299  const reco::Candidate* muNeg = ptr->originalReco(mcNeg);
300  if (!par.massSel->accept(*ptr))
301  continue;
302  if (!par.ptSel->accept(*muPos))
303  continue;
304  if (!par.etaSel->accept(*muPos))
305  continue;
306  if (!par.ptSel->accept(*muNeg))
307  continue;
308  if (!par.etaSel->accept(*muNeg))
309  continue;
310  if (!par.chi2Sel->accept(*ptr))
311  continue;
313  np->add("MuPos", muPos, ptr->getTrackSearchList(mcPos), BPHParticleMasses::muonMass, BPHParticleMasses::muonMSigma);
314  np->add("MuNeg", muNeg, ptr->getTrackSearchList(mcNeg), BPHParticleMasses::muonMass, BPHParticleMasses::muonMSigma);
315  if (par.mass > 0.0)
316  np->setConstraint(par.mass, par.sigma);
317  list.push_back(BPHPlusMinusConstCandPtr(np));
318  }
319  par.outdated = false;
320  return;
321 }
double getProbMin() const
get current prob min
Definition: BPHChi2Select.h:66
static const double ups2MWidth
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
double getMassMin() const
get current mass cuts
Definition: BPHMassCuts.h:58
const BPHRecoBuilder::BPHGenericCollection * posCollection
void setMassMax(double m)
Definition: BPHMassCuts.h:52
double getPtMin() const
get current pt min
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
static const double muonMSigma
constexpr float ptMin
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
static std::vector< BPHPlusMinusConstCandPtr > build(const BPHRecoBuilder &builder, const BuilderParameters &par)
bool accept(const reco::Candidate &cand) const override
select muon
virtual std::vector< prod_ptr > build()
build candidates
static const double jPsiMass
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
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
const BPHEventSetupWrapper * evSetup
void setProbMin(oniaType type, double p)
double getConstrSigma(oniaType type) const
std::map< oniaType, std::vector< BPHPlusMinusConstCandPtr > > oniaList
void setParameters(oniaType type, double ptMin, double etaMax, double massMin, double massMax, double probMin, double mass, double sigma)
double getEtaMax(oniaType type) const
virtual const reco::Candidate * getDaug(const std::string &name) const
BPHGenericPtr< const BPHPlusMinusCandidate >::type BPHPlusMinusConstCandPtr
static const double ups1MWidth
void setProbMin(double p)
set prob min
Definition: BPHChi2Select.h:60
int np
Definition: AMPTWrapper.h:43
double getMassMin() const
get current cuts
std::vector< BPHPlusMinusConstCandPtr > getList(oniaType type, BPHRecoSelect *dSel=nullptr, BPHMomentumSelect *mSel=nullptr, BPHVertexSelect *vSel=nullptr, BPHFitSelect *kSel=nullptr)
double getPtMin(oniaType type) const
get current cuts
void extractList(oniaType type)
void filter(const std::string &name, const BPHRecoSelect &sel) const
virtual bool accept(const BPHDecayVertex &cand) const =0
accept function
static const double phiMWidth
void setEtaMax(double eta)
set eta max
double getMassMax() const
Definition: BPHMassCuts.h:59
double getConstrMass(oniaType type) const
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)
static const double psi2Mass
static const double ups1Mass
const BPHRecoBuilder::BPHGenericCollection * negCollection
BPHOniaToMuMuBuilder(const BPHEventSetupWrapper &es, const BPHRecoBuilder::BPHGenericCollection *muPosCollection, const BPHRecoBuilder::BPHGenericCollection *muNegCollection)
static const double muonMass
common object to interface with edm collections
static const double ups3MWidth
void fillRecList() override
build resonance candidates
std::map< oniaType, OniaParameters > oniaPar
void setConstr(oniaType type, double mass, double sigma)
void setEtaMax(oniaType type, double eta)
virtual bool accept(const reco::Candidate &cand) const =0
bool accept(const reco::Candidate &cand) const override
select muon
void setMassMin(oniaType type, double m)
static const double psi2MWidth
void setPtMin(oniaType type, double pt)
set cuts
double getEtaMax() const
get current eta max