CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Conversion.cc
Go to the documentation of this file.
4 #include "CLHEP/Units/GlobalPhysicalConstants.h"
5 
6 using namespace reco;
7 
9  const std::vector<reco::TrackRef>& tr,
10  const std::vector<math::XYZPointF>& trackPositionAtEcal,
11  const reco::Vertex& convVtx,
12  const std::vector<reco::CaloClusterPtr>& matchingBC,
13  const float DCA,
14  const std::vector<math::XYZPointF>& innPoint,
15  const std::vector<math::XYZVectorF>& trackPin,
16  const std::vector<math::XYZVectorF>& trackPout,
17  const float mva,
19  :
20 
21  caloCluster_(sc),
22  trackToBaseRefs_(),
23  thePositionAtEcal_(trackPositionAtEcal),
24  theConversionVertex_(convVtx),
25  theMatchingBCs_(matchingBC),
26  theTrackInnerPosition_(innPoint),
27  theTrackPin_(trackPin),
28  theTrackPout_(trackPout),
29  theMinDistOfApproach_(DCA),
30  theMVAout_(mva),
31  qualityMask_(0),
32  nSharedHits_(0),
33  algorithm_(algo) {
34  trackToBaseRefs_.reserve(tr.size());
35  for (auto const& track : tr) {
36  trackToBaseRefs_.emplace_back(track);
37  }
38 }
39 
42  const std::vector<math::XYZPointF>& trackPositionAtEcal,
43  const reco::Vertex& convVtx,
44  const std::vector<reco::CaloClusterPtr>& matchingBC,
45  const float DCA,
46  const std::vector<math::XYZPointF>& innPoint,
47  const std::vector<math::XYZVectorF>& trackPin,
48  const std::vector<math::XYZVectorF>& trackPout,
49  const std::vector<uint8_t>& nHitsBeforeVtx,
50  const std::vector<Measurement1DFloat>& dlClosestHitToVtx,
51  uint8_t nSharedHits,
52  const float mva,
54  :
55 
56  caloCluster_(sc),
57  trackToBaseRefs_(tr),
58  thePositionAtEcal_(trackPositionAtEcal),
59  theConversionVertex_(convVtx),
60  theMatchingBCs_(matchingBC),
61  theTrackInnerPosition_(innPoint),
62  theTrackPin_(trackPin),
63  theTrackPout_(trackPout),
64  nHitsBeforeVtx_(nHitsBeforeVtx),
65  dlClosestHitToVtx_(dlClosestHitToVtx),
66  theMinDistOfApproach_(DCA),
67  theMVAout_(mva),
68  qualityMask_(0),
69  nSharedHits_(nSharedHits),
70  algorithm_(algo) {}
71 
73  const std::vector<reco::TrackRef>& tr,
74  const reco::Vertex& convVtx,
76  : caloCluster_(sc),
77  trackToBaseRefs_(),
78  theConversionVertex_(convVtx),
79  qualityMask_(0),
80  nSharedHits_(0),
81  algorithm_(algo) {
82  trackToBaseRefs_.reserve(tr.size());
83  for (auto const& track : tr) {
84  trackToBaseRefs_.emplace_back(track);
85  }
86 
87  theMinDistOfApproach_ = 9999.;
88  theMVAout_ = 9999.;
89  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
90  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
91  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
92  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
93  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
94  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
95  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
96  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
97 }
98 
101  const reco::Vertex& convVtx,
103  : caloCluster_(sc),
104  trackToBaseRefs_(tr),
105  theConversionVertex_(convVtx),
106  qualityMask_(0),
107  nSharedHits_(0),
108  algorithm_(algo) {
109  theMinDistOfApproach_ = 9999.;
110  theMVAout_ = 9999.;
111  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
112  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
113  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
114  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
115  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
116  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
117  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
118  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
119 }
120 
122  algorithm_ = 0;
123  qualityMask_ = 0;
124  theMinDistOfApproach_ = 9999.;
125  nSharedHits_ = 0;
126  theMVAout_ = 9999.;
127  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
128  thePositionAtEcal_.push_back(math::XYZPointF(0., 0., 0.));
129  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
130  theTrackInnerPosition_.push_back(math::XYZPointF(0., 0., 0.));
131  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
132  theTrackPin_.push_back(math::XYZVectorF(0., 0., 0.));
133  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
134  theTrackPout_.push_back(math::XYZVectorF(0., 0., 0.));
135 }
136 
137 std::string const Conversion::algoNames[] = {"undefined", "ecalSeeded", "trackerOnly", "mixed", "pflow"};
138 
141  int index = std::find(algoNames, algoNames + size, name) - algoNames;
142  if (index == size)
143  return undefined;
144 
145  return ConversionAlgorithm(index);
146 }
147 
148 Conversion* Conversion::clone() const { return new Conversion(*this); }
149 
150 std::vector<edm::RefToBase<reco::Track> > const& Conversion::tracks() const { return trackToBaseRefs_; }
151 
153  if (this->nTracks() == 2)
154  return true;
155  else
156  return false;
157 }
158 
160  double invMass = -99.;
161  const float mElec = 0.000511;
162  if (nTracks() == 2) {
163  double px = tracksPin()[0].x() + tracksPin()[1].x();
164  double py = tracksPin()[0].y() + tracksPin()[1].y();
165  double pz = tracksPin()[0].z() + tracksPin()[1].z();
166  double mom1 = tracksPin()[0].Mag2();
167  double mom2 = tracksPin()[1].Mag2();
168  double e = sqrt(mom1 + mElec * mElec) + sqrt(mom2 + mElec * mElec);
169  invMass = (e * e - px * px - py * py - pz * pz);
170  if (invMass > 0)
171  invMass = sqrt(invMass);
172  else
173  invMass = -1;
174  }
175 
176  return invMass;
177 }
178 
180  double dCotTheta = -99.;
181 
182  if (nTracks() == 2) {
183  double theta1 = this->tracksPin()[0].Theta();
184  double theta2 = this->tracksPin()[1].Theta();
185  dCotTheta = 1. / tan(theta1) - 1. / tan(theta2);
186  }
187 
188  return dCotTheta;
189 }
190 
192  if (nTracks() == 2) {
193  return this->tracksPin()[0] + this->tracksPin()[1];
194  }
195  return math::XYZVectorF(0., 0., 0.);
196 }
197 
200  if (this->conversionVertex().isValid())
201  p4 = this->conversionVertex().p4(0.000511, 0.5);
202 
203  return p4;
204 }
205 
207  if (this->conversionVertex().isValid()) {
208  return this->refittedPair4Momentum().Vect();
209  }
210  return math::XYZVectorF(0., 0., 0.);
211 }
212 
213 double Conversion::EoverP() const {
214  double ep = -99.;
215 
216  if (nTracks() > 0) {
217  unsigned int size = this->caloCluster().size();
218  float etot = 0.;
219  for (unsigned int i = 0; i < size; i++) {
220  etot += caloCluster()[i]->energy();
221  }
222  if (this->pairMomentum().Mag2() != 0)
223  ep = etot / sqrt(this->pairMomentum().Mag2());
224  }
225 
226  return ep;
227 }
228 
230  double ep = -99.;
231 
232  if (nTracks() > 0) {
233  unsigned int size = this->caloCluster().size();
234  float etot = 0.;
235  for (unsigned int i = 0; i < size; i++) {
236  etot += caloCluster()[i]->energy();
237  }
238  if (this->refittedPairMomentum().Mag2() != 0)
239  ep = etot / sqrt(this->refittedPairMomentum().Mag2());
240  }
241 
242  return ep;
243 }
244 
245 std::vector<double> Conversion::tracksSigned_d0() const {
246  std::vector<double> result;
247  result.reserve(tracks().size());
248 
249  for (auto const& track : tracks()) {
250  result.emplace_back(track->d0() * track->charge());
251  }
252  return result;
253 }
254 
256  double result = -99;
257  if (nTracks() == 2) {
258  result = tracksPin()[0].phi() - tracksPin()[1].phi();
259  if (result > pi) {
260  result = result - twopi;
261  }
262  if (result < -pi) {
263  result = result + twopi;
264  }
265  }
266 
267  return result;
268 }
269 
271  double result = -99.;
272 
273  if (nTracks() == 2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull()) {
274  float recoPhi1 = ecalImpactPosition()[0].phi();
275  if (recoPhi1 > pi) {
276  recoPhi1 = recoPhi1 - twopi;
277  }
278  if (recoPhi1 < -pi) {
279  recoPhi1 = recoPhi1 + twopi;
280  }
281 
282  float recoPhi2 = ecalImpactPosition()[1].phi();
283  if (recoPhi2 > pi) {
284  recoPhi2 = recoPhi2 - twopi;
285  }
286  if (recoPhi2 < -pi) {
287  recoPhi2 = recoPhi2 + twopi;
288  }
289 
290  result = recoPhi1 - recoPhi2;
291 
292  if (result > pi) {
293  result = result - twopi;
294  }
295  if (result < -pi) {
296  result = result + twopi;
297  }
298  }
299 
300  return result;
301 }
302 
304  double result = -99.;
305 
306  if (nTracks() == 2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull()) {
307  result = ecalImpactPosition()[0].eta() - ecalImpactPosition()[1].eta();
308  }
309 
310  return result;
311 }
312 
313 double Conversion::dxy(const math::XYZPoint& myBeamSpot) const {
314  const reco::Vertex& vtx = conversionVertex();
315  if (!vtx.isValid())
316  return -9999.;
317 
319 
320  double dxy = (-(vtx.x() - myBeamSpot.x()) * mom.y() + (vtx.y() - myBeamSpot.y()) * mom.x()) / mom.rho();
321  return dxy;
322 }
323 
324 double Conversion::dz(const math::XYZPoint& myBeamSpot) const {
325  const reco::Vertex& vtx = conversionVertex();
326  if (!vtx.isValid())
327  return -9999.;
328 
330 
331  double dz =
332  (vtx.z() - myBeamSpot.z()) -
333  ((vtx.x() - myBeamSpot.x()) * mom.x() + (vtx.y() - myBeamSpot.y()) * mom.y()) / mom.rho() * mom.z() / mom.rho();
334  return dz;
335 }
336 
337 double Conversion::lxy(const math::XYZPoint& myBeamSpot) const {
338  const reco::Vertex& vtx = conversionVertex();
339  if (!vtx.isValid())
340  return -9999.;
341 
343 
344  double dbsx = vtx.x() - myBeamSpot.x();
345  double dbsy = vtx.y() - myBeamSpot.y();
346  double lxy = (mom.x() * dbsx + mom.y() * dbsy) / mom.rho();
347  return lxy;
348 }
349 
350 double Conversion::lz(const math::XYZPoint& myBeamSpot) const {
351  const reco::Vertex& vtx = conversionVertex();
352  if (!vtx.isValid())
353  return -9999.;
354 
356 
357  double lz = (vtx.z() - myBeamSpot.z()) * mom.z() / std::abs(mom.z());
358  return lz;
359 }
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Definition: Conversion.h:88
static const std::string algoNames[]
Definition: Conversion.h:39
std::vector< math::XYZVectorF > theTrackPout_
P_out of tracks.
Definition: Conversion.h:197
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:75
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
double y() const
y coordinate
Definition: Vertex.h:131
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:72
double EoverP() const
Definition: Conversion.cc:213
std::vector< double > tracksSigned_d0() const
signed transverse impact parameter for each track
Definition: Conversion.cc:245
double lxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:337
static ConversionAlgorithm algoByName(const std::string &name)
Definition: Conversion.cc:139
double pairCotThetaSeparation() const
Delta cot(Theta) where Theta is the angle in the (y,z) plane between the two tracks. Original tracks are used.
Definition: Conversion.cc:179
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
double pairInvariantMass() const
if nTracks=2 returns the pair invariant mass. Original tracks are used here
Definition: Conversion.cc:159
math::XYZVectorF refittedPairMomentum() const
Conversion tracks momentum from the tracks refitted with vertex constraint.
Definition: Conversion.cc:206
uint8_t nSharedHits_
number of shared hits between tracks
Definition: Conversion.h:210
double EoverPrefittedTracks() const
Definition: Conversion.cc:229
tuple result
Definition: mps_fire.py:311
const Double_t pi
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
z coordinate
Definition: Vertex.h:133
uint16_t qualityMask_
Definition: Conversion.h:208
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
const std::vector< reco::CaloClusterPtr > & bcMatchingWithTracks() const
Definition: Conversion.h:144
std::vector< math::XYZPointF > theTrackInnerPosition_
P_in of tracks.
Definition: Conversion.h:193
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:92
Conversion * clone() const
returns a clone of the candidate
Definition: Conversion.cc:148
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:198
const std::vector< math::XYZVectorF > & tracksPin() const
Vector of track momentum measured at the innermost hit.
Definition: Conversion.h:152
uint8_t algorithm_
conversion algorithm/provenance
Definition: Conversion.h:212
double x() const
x coordinate
Definition: Vertex.h:129
math::XYZVectorF pairMomentum() const
Conversion tracks momentum from the tracks inner momentum.
Definition: Conversion.cc:191
const std::vector< math::XYZPointF > & ecalImpactPosition() const
Definition: Conversion.h:142
double dEtaTracksAtEcal() const
Definition: Conversion.cc:303
double dz(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:324
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
Definition: Vertex.cc:103
std::vector< math::XYZVectorF > theTrackPin_
P_in of tracks.
Definition: Conversion.h:195
float theMVAout_
TMVA output.
Definition: Conversion.h:207
double lz(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:350
float theMinDistOfApproach_
Distance of min approach of the two tracks.
Definition: Conversion.h:205
std::vector< math::XYZPointF > thePositionAtEcal_
position at the ECAl surface of the track extrapolation
Definition: Conversion.h:187
std::vector< edm::RefToBase< reco::Track > > trackToBaseRefs_
vector Track RefToBase
Definition: Conversion.h:185
double dPhiTracksAtEcal() const
Definition: Conversion.cc:270
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
bool isConverted() const
Bool flagging objects having track size &gt;0.
Definition: Conversion.cc:152
reco::CaloClusterPtrVector caloCluster() const
Pointer to CaloCluster (foe Egamma Conversions it points to a SuperCluster)
Definition: Conversion.h:84
tuple size
Write out results.
double dPhiTracksAtVtx() const
Definition: Conversion.cc:255
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:150
double dxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:313