CMS 3D CMS Logo

BPHDecayToTkpTknSymChargeBuilder.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 //-------------------------------
27 
28 //---------------
29 // C++ Headers --
30 //---------------
31 using namespace std;
32 
33 //-------------------
34 // Initializations --
35 //-------------------
36 
37 //----------------
38 // Constructors --
39 //----------------
41  const edm::EventSetup& es,
42  const std::string& daug1Name,
43  double daug1Mass,
44  double daug1Sigma,
45  const std::string& daug2Name,
46  double daug2Mass,
47  double daug2Sigma,
48  const BPHRecoBuilder::BPHGenericCollection* posCollection,
49  const BPHRecoBuilder::BPHGenericCollection* negCollection,
50  double expectedMass)
52  d1Name(daug1Name),
53  d1Mass(daug1Mass),
54  d1Sigma(daug1Sigma),
55  d2Name(daug2Name),
56  d2Mass(daug2Mass),
57  d2Sigma(daug2Sigma),
58  eMass(expectedMass),
59  pCollection(posCollection),
60  nCollection(negCollection),
61  pt1Min(-1.0),
62  pt2Min(-1.0),
63  eta1Max(10.0),
64  eta2Max(10.0),
65  dzMax(1.0) {}
66 
67 //--------------
68 // Destructor --
69 //--------------
71 
72 //--------------
73 // Operations --
74 //--------------
75 vector<BPHPlusMinusConstCandPtr> BPHDecayToTkpTknSymChargeBuilder::build() {
76  if (updated)
77  return recList;
78 
79  recList.clear();
80 
81  // extract basic informations from input collections
82 
83  vector<Particle*> pList;
84  vector<Particle*> nList;
85 
86  addParticle(pCollection, +1, pList);
87  addParticle(nCollection, -1, nList);
88  int iPos;
89  int iNeg;
90  int nPos = pList.size();
91  int nNeg = nList.size();
92  double massMin = getMassMin();
93  double massMax = getMassMax();
94  double mSqMin = massMin * massMin * 0.9;
95  double mSqMax = massMax * massMax * 1.1;
96  if (mSqMin < 0.0)
97  mSqMin = 0.0;
98 
99  for (iPos = 0; iPos < nPos; ++iPos) {
100  Particle* pc = pList[iPos];
101  const reco::Track* pt = pc->track;
102  double px = pc->px;
103  double py = pc->py;
104  double pz = pc->pz;
105  double p1 = pc->e1;
106  double p2 = pc->e2;
107  for (iNeg = 0; iNeg < nNeg; ++iNeg) {
108  Particle* nc = nList[iNeg];
109  const reco::Track* nt = nc->track;
110  if (fabs(nt->dz() - pt->dz()) > dzMax)
111  continue;
112  double nx = nc->px;
113  double ny = nc->py;
114  double nz = nc->pz;
115  double n1 = nc->e1;
116  double n2 = nc->e2;
117  const float tx = px + nx;
118  const float ty = py + ny;
119  const float tz = pz + nz;
120  const float ta = ((p1 > 0.0) && (n2 > 0.0) ? p1 + n2 : -1.0);
121  const float tb = ((p2 > 0.0) && (n1 > 0.0) ? p2 + n1 : -1.0);
122  float ma = (ta > 0 ? (ta * ta) - ((tx * tx) + (ty * ty) + (tz * tz)) : -1.0);
123  float mb = (tb > 0 ? (tb * tb) - ((tx * tx) + (ty * ty) + (tz * tz)) : -1.0);
124  // if ( ma > 0.0 ) ma = sqrt( ma );
125  // else ma = -1.0;
126  // if ( mb > 0.0 ) mb = sqrt( mb );
127  // else mb = -1.0;
128  if (((ma < mSqMin) || (ma > mSqMax)) && ((mb < mSqMin) || (mb > mSqMax)))
129  continue;
130  BPHPlusMinusCandidatePtr rc(nullptr);
131  float rcMass = -1.0;
132  if (ma > 0.0) {
134  rc->add(d1Name, pc->cand, d1Mass, d1Sigma);
135  rc->add(d2Name, nc->cand, d2Mass, d2Sigma);
136  rcMass = rc->composite().mass();
137  }
138  BPHPlusMinusCandidatePtr rb(nullptr);
139  float rbMass = -1.0;
140  if (mb > 0.0) {
142  rb->add(d1Name, nc->cand, d1Mass, d1Sigma);
143  rb->add(d2Name, pc->cand, d2Mass, d2Sigma);
144  rbMass = rb->composite().mass();
145  }
146  BPHPlusMinusCandidatePtr* rp(nullptr);
147  double mass = -1.0;
148  if ((rc.get() != nullptr) && ((rb.get() == nullptr) || (fabs(rcMass - eMass) < fabs(rbMass - eMass)))) {
149  mass = rcMass;
150  rp = &rc;
151  } else {
152  mass = rbMass;
153  rp = &rb;
154  }
155  BPHPlusMinusCandidate* rr = rp->get();
156  if (mass < massMin)
157  continue;
158  if (mass > massMax)
159  continue;
160  if (!chi2Sel->accept(*rr))
161  continue;
162  recList.push_back(*rp);
163  }
164  }
165 
166  for (iPos = 0; iPos < nPos; ++iPos)
167  delete pList[iPos];
168  for (iNeg = 0; iNeg < nNeg; ++iNeg)
169  delete nList[iNeg];
170 
171  updated = true;
172  return recList;
173 }
174 
177  updated = false;
178  pt1Min = pt;
179  return;
180 }
181 
183  updated = false;
184  pt2Min = pt;
185  return;
186 }
187 
189  updated = false;
190  eta1Max = eta;
191  return;
192 }
193 
195  updated = false;
196  eta2Max = eta;
197  return;
198 }
199 
201  updated = false;
202  dzMax = dz;
203  return;
204 }
205 
207  int charge,
208  vector<Particle*>& list) {
209  int i;
210  int n = collection->size();
211  list.reserve(n);
212  for (i = 0; i < n; ++i) {
213  const reco::Candidate& cand = collection->get(i);
214  int q = cand.charge();
215  if ((charge > 0) && (q <= 0))
216  continue;
217  if ((charge < 0) && (q >= 0))
218  continue;
220  const reco::Track* tk = BPHTrackReference::getTrack(cand, "cfhp");
221  if (tk == nullptr)
222  continue;
223  double px = p4.px();
224  double py = p4.py();
225  double pz = p4.pz();
226  double p2 = (px * px) + (py * py) + (pz * pz);
227  double e1 = ((p4.pt() >= pt1Min) && (p4.eta() <= eta1Max) ? sqrt(p2 + (d1Mass * d1Mass)) : -1.0);
228  double e2 = ((p4.pt() >= pt2Min) && (p4.eta() <= eta2Max) ? sqrt(p2 + (d2Mass * d2Mass)) : -1.0);
229  if ((e1 > 0.0) || (e2 > 0.0))
230  list.push_back(new Particle(&cand, tk, px, py, pz, e1, e2));
231  }
232  return;
233 }
BPHChi2Select.h
BPHTrackReference.h
mps_fire.i
i
Definition: mps_fire.py:428
BPHDecayToTkpTknSymChargeBuilder::Particle::py
double py
Definition: BPHDecayToTkpTknSymChargeBuilder.h:112
BPHDecayToTkpTknSymChargeBuilder::addParticle
void addParticle(const BPHRecoBuilder::BPHGenericCollection *collection, int charge, std::vector< Particle * > &list)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:206
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
BPHDecayGenericBuilder::getMassMax
double getMassMax() const
Definition: BPHDecayGenericBuilder.h:63
nt
int nt
Definition: AMPTWrapper.h:42
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
BPHDecayToTkpTknSymChargeBuilder::Particle::track
const reco::Track * track
Definition: BPHDecayToTkpTknSymChargeBuilder.h:110
BPHPlusMinusCandidatePtr
BPHGenericPtr< BPHPlusMinusCandidate >::type BPHPlusMinusCandidatePtr
Definition: BPHPlusMinusCandidatePtr.h:7
BPHDecayToTkpTknSymChargeBuilder::d1Name
std::string d1Name
Definition: BPHDecayToTkpTknSymChargeBuilder.h:86
BPHDecayToTkpTknSymChargeBuilder::dzMax
double dzMax
Definition: BPHDecayToTkpTknSymChargeBuilder.h:101
BPHDecayToTkpTknSymChargeBuilder::Particle::cand
const reco::Candidate * cand
Definition: BPHDecayToTkpTknSymChargeBuilder.h:109
BPHDecayToTkpTknSymChargeBuilder::Particle::e1
double e1
Definition: BPHDecayToTkpTknSymChargeBuilder.h:114
BPHDecayToTkpTknSymChargeBuilder::nCollection
const BPHRecoBuilder::BPHGenericCollection * nCollection
Definition: BPHDecayToTkpTknSymChargeBuilder.h:95
BPHPlusMinusCandidate
Definition: BPHPlusMinusCandidate.h:32
BPHDecayToTkpTknSymChargeBuilder::pt1Min
double pt1Min
Definition: BPHDecayToTkpTknSymChargeBuilder.h:97
BPHDecayToTkpTknSymChargeBuilder.h
ZMuMuCategoriesSequences_cff.massMin
massMin
Definition: ZMuMuCategoriesSequences_cff.py:136
BPHDecayToTkpTknSymChargeBuilder::Particle::pz
double pz
Definition: BPHDecayToTkpTknSymChargeBuilder.h:113
BPHDecayToTkpTknSymChargeBuilder::d2Name
std::string d2Name
Definition: BPHDecayToTkpTknSymChargeBuilder.h:89
dzMax
constexpr float dzMax
Definition: PhotonIDValueMapProducer.cc:152
BPHParticlePtSelect.h
BPHDecayToTkpTknSymChargeBuilder::setTrk1EtaMax
void setTrk1EtaMax(double eta)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:188
BPHTrackReference::getTrack
static const reco::Track * getTrack(const reco::Candidate &rc, const char *modeList="cfhbpmnigset", char *modeFlag=nullptr)
Definition: BPHTrackReference.h:60
BPHParticleMasses.h
BPHMassSymSelect.h
BPHDecayToTkpTknSymChargeBuilder::eta2Max
double eta2Max
Definition: BPHDecayToTkpTknSymChargeBuilder.h:100
BPHDecayGenericBuilder::updated
bool updated
Definition: BPHDecayGenericBuilder.h:80
PVValHelper::eta
Definition: PVValidationHelpers.h:69
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
BPHDecayToTkpTknSymChargeBuilder::pt2Min
double pt2Min
Definition: BPHDecayToTkpTknSymChargeBuilder.h:98
reco::Track
Definition: Track.h:27
p2
double p2[4]
Definition: TauolaWrapper.h:90
BPHDecayToTkpTknSymChargeBuilder::recList
std::vector< BPHPlusMinusConstCandPtr > recList
Definition: BPHDecayToTkpTknSymChargeBuilder.h:103
HLT_FULL_cff.pt1Min
pt1Min
Definition: HLT_FULL_cff.py:68690
BPHDecayToTkpTknSymChargeBuilder::d1Mass
double d1Mass
Definition: BPHDecayToTkpTknSymChargeBuilder.h:87
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BPHDecayToTkpTknSymChargeBuilder::~BPHDecayToTkpTknSymChargeBuilder
~BPHDecayToTkpTknSymChargeBuilder() override
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:70
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
BPHDecayGenericBuilder::evSetup
const edm::EventSetup * evSetup
Definition: BPHDecayGenericBuilder.h:73
BPHDecayToTkpTknSymChargeBuilder::Particle::e2
double e2
Definition: BPHDecayToTkpTknSymChargeBuilder.h:115
fastsim::Constants::eMass
static constexpr double eMass
Electron mass[GeV].
Definition: Constants.h:13
BPHDecayGenericBuilder::chi2Sel
BPHChi2Select * chi2Sel
Definition: BPHDecayGenericBuilder.h:76
BPHDecayToTkpTknSymChargeBuilder::pCollection
const BPHRecoBuilder::BPHGenericCollection * pCollection
Definition: BPHDecayToTkpTknSymChargeBuilder.h:94
BPHDecayToTkpTknSymChargeBuilder::setTrk2EtaMax
void setTrk2EtaMax(double eta)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:194
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
BPHMassSelect.h
cand
Definition: decayParser.h:32
LorentzVector.h
BPHDecayToTkpTknSymChargeBuilder::eMass
double eMass
Definition: BPHDecayToTkpTknSymChargeBuilder.h:92
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
p4
double p4[4]
Definition: TauolaWrapper.h:92
p1
double p1[4]
Definition: TauolaWrapper.h:89
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
edm::EventSetup
Definition: EventSetup.h:57
ZMuMuCategoriesSequences_cff.massMax
massMax
Definition: ZMuMuCategoriesSequences_cff.py:137
BPHParticleEtaSelect.h
BPHRecoBuilder.h
BPHDecayToTkpTknSymChargeBuilder::d1Sigma
double d1Sigma
Definition: BPHDecayToTkpTknSymChargeBuilder.h:88
BPHDecayToTkpTknSymChargeBuilder::BPHDecayToTkpTknSymChargeBuilder
BPHDecayToTkpTknSymChargeBuilder(const edm::EventSetup &es, const std::string &daug1Name, double daug1Mass, double daug1Sigma, const std::string &daug2Name, double daug2Mass, double daug2Sigma, const BPHRecoBuilder::BPHGenericCollection *posCollection, const BPHRecoBuilder::BPHGenericCollection *negCollection, double expectedMass)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:40
HLT_FULL_cff.pt2Min
pt2Min
Definition: HLT_FULL_cff.py:68687
reco::Candidate
Definition: Candidate.h:27
BPHRecoBuilder::BPHGenericCollection
Definition: BPHRecoBuilder.h:70
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
BPHDecayToTkpTknSymChargeBuilder::d2Mass
double d2Mass
Definition: BPHDecayToTkpTknSymChargeBuilder.h:90
std
Definition: JetResolutionObject.h:76
BPHDecayToTkpTknSymChargeBuilder::setDzMax
void setDzMax(double dz)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:200
BPHPlusMinusCandidate.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
BPHDecayToTkpTknSymChargeBuilder::setTrk2PtMin
void setTrk2PtMin(double pt)
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:182
BPHDecayGenericBuilder
Definition: BPHDecayGenericBuilder.h:36
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
Particle
Definition: Particle.py:1
Candidate.h
BPHChi2Select::accept
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
BPHDecayToTkpTknSymChargeBuilder::Particle::px
double px
Definition: BPHDecayToTkpTknSymChargeBuilder.h:111
BPHDecayToTkpTknSymChargeBuilder::eta1Max
double eta1Max
Definition: BPHDecayToTkpTknSymChargeBuilder.h:99
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
BPHDecayToTkpTknSymChargeBuilder::build
std::vector< BPHPlusMinusConstCandPtr > build()
build candidates
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:75
BPHGenericPtr::create
static type create(Args &&... args)
Definition: BPHGenericPtr.h:10
BPHDecayToTkpTknSymChargeBuilder::setTrk1PtMin
void setTrk1PtMin(double pt)
set cuts
Definition: BPHDecayToTkpTknSymChargeBuilder.cc:176
BPHDecayGenericBuilder::getMassMin
double getMassMin() const
get current cuts
Definition: BPHDecayGenericBuilder.h:62
BPHDecayToTkpTknSymChargeBuilder::d2Sigma
double d2Sigma
Definition: BPHDecayToTkpTknSymChargeBuilder.h:91