CMS 3D CMS Logo

Conversion.cc
Go to the documentation of this file.
4 #include "CLHEP/Units/GlobalPhysicalConstants.h"
5 
6 using namespace reco;
7 
8 
10  const std::vector<reco::TrackRef>& tr,
11  const std::vector<math::XYZPointF>& trackPositionAtEcal,
12  const reco::Vertex & convVtx,
13  const std::vector<reco::CaloClusterPtr> & matchingBC,
14  const float DCA,
15  const std::vector<math::XYZPointF> & innPoint,
16  const std::vector<math::XYZVectorF> & trackPin,
17  const std::vector<math::XYZVectorF> & trackPout,
18  const float mva,
20 
21 
22  caloCluster_(sc),
23  trackToBaseRefs_(),
24  thePositionAtEcal_(trackPositionAtEcal),
25  theConversionVertex_(convVtx),
26  theMatchingBCs_(matchingBC),
27  theTrackInnerPosition_(innPoint),
28  theTrackPin_(trackPin),
29  theTrackPout_(trackPout),
30  theMinDistOfApproach_(DCA),
31  theMVAout_(mva),
32  qualityMask_(0),
33  nSharedHits_(0),
34  algorithm_(algo)
35  {
36  trackToBaseRefs_.reserve(tr.size());
37  for( auto const& track: tr) {
38  trackToBaseRefs_.emplace_back(track);
39  }
40  }
41 
42 
43 
44 
46  const std::vector<edm::RefToBase<reco::Track> >& tr,
47  const std::vector<math::XYZPointF>& trackPositionAtEcal,
48  const reco::Vertex & convVtx,
49  const std::vector<reco::CaloClusterPtr> & matchingBC,
50  const float DCA,
51  const std::vector<math::XYZPointF> & innPoint,
52  const std::vector<math::XYZVectorF> & trackPin,
53  const std::vector<math::XYZVectorF> & trackPout,
54  const std::vector<uint8_t>& nHitsBeforeVtx,
55  const std::vector<Measurement1DFloat> & dlClosestHitToVtx,
56  uint8_t nSharedHits,
57  const float mva,
59 
60 
62  thePositionAtEcal_(trackPositionAtEcal),
63  theConversionVertex_(convVtx),
64  theMatchingBCs_(matchingBC),
65  theTrackInnerPosition_(innPoint),
66  theTrackPin_(trackPin),
67  theTrackPout_(trackPout),
68  nHitsBeforeVtx_(nHitsBeforeVtx),
69  dlClosestHitToVtx_(dlClosestHitToVtx),
71  theMVAout_(mva),
72  qualityMask_(0),
73  nSharedHits_(nSharedHits),
74  algorithm_(algo)
75  {
76 
77  }
78 
79 
80 
81 
83  const std::vector<reco::TrackRef>& tr,
84  const reco::Vertex & convVtx,
86  caloCluster_(sc),
88  theConversionVertex_(convVtx),
89  qualityMask_(0),
90  nSharedHits_(0),
91  algorithm_(algo)
92  {
93  trackToBaseRefs_.reserve(tr.size());
94  for( auto const& track: tr) {
95  trackToBaseRefs_.emplace_back(track);
96  }
97 
98 
99  theMinDistOfApproach_ = 9999.;
100  theMVAout_ = 9999.;
101  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
102  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
103  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
104  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
105  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
106  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
107  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
108  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
109 
110 
111  }
112 
113 
115  const std::vector<edm::RefToBase<reco::Track> >& tr,
116  const reco::Vertex & convVtx,
118  caloCluster_(sc), trackToBaseRefs_(tr),
119  theConversionVertex_(convVtx),
120  qualityMask_(0),
121  nSharedHits_(0),
122  algorithm_(algo)
123  {
124 
125 
126  theMinDistOfApproach_ = 9999.;
127  theMVAout_ = 9999.;
128  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
129  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
130  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
131  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
132  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
133  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
134  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
135  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
136 
137 
138  }
139 
140 
141 
143 
144  algorithm_=0;
145  qualityMask_=0;
146  theMinDistOfApproach_ = 9999.;
147  nSharedHits_ = 0;
148  theMVAout_ = 9999.;
149  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
150  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
151  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
152  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
153  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
154  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
155  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
156  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
157 
158 }
159 
160 
161 std::string const Conversion::algoNames[] = { "undefined","ecalSeeded","trackerOnly","mixed","pflow"};
162 
165  int index = std::find(algoNames, algoNames+size, name)-algoNames;
166  if(index == size) return undefined;
167 
168  return ConversionAlgorithm(index);
169 }
170 
172  return new Conversion( * this );
173 }
174 
175 
176 std::vector<edm::RefToBase<reco::Track> > const& Conversion::tracks() const {
177  return trackToBaseRefs_;
178 }
179 
180 
181 
183 
184  if ( this->nTracks() == 2 )
185  return true;
186  else
187  return false;
188 }
189 
191  double invMass=-99.;
192  const float mElec= 0.000511;
193  if ( nTracks()==2 ) {
194  double px= tracksPin()[0].x() + tracksPin()[1].x();
195  double py= tracksPin()[0].y() + tracksPin()[1].y();
196  double pz= tracksPin()[0].z() + tracksPin()[1].z();
197  double mom1= tracksPin()[0].Mag2();
198  double mom2= tracksPin()[1].Mag2();
199  double e = sqrt( mom1+ mElec*mElec ) + sqrt( mom2 + mElec*mElec );
200  invMass= ( e*e - px*px -py*py - pz*pz);
201  if ( invMass>0) invMass = sqrt(invMass);
202  else
203  invMass = -1;
204  }
205 
206  return invMass;
207 }
208 
210  double dCotTheta=-99.;
211 
212  if ( nTracks()==2 ) {
213  double theta1=this->tracksPin()[0].Theta();
214  double theta2=this->tracksPin()[1].Theta();
215  dCotTheta = 1./tan(theta1) - 1./tan(theta2) ;
216  }
217 
218  return dCotTheta;
219 
220 }
221 
222 
224 
225  if ( nTracks()==2 ) {
226  return this->tracksPin()[0] + this->tracksPin()[1];
227  }
228  return math::XYZVectorF(0.,0.,0.);
229 
230 
231 
232 }
233 
234 
236 
238  if ( this->conversionVertex().isValid() )
239  p4 = this->conversionVertex().p4( 0.000511, 0.5);
240 
241  return p4;
242 
243 
244 }
245 
246 
247 
249 
250  if ( this->conversionVertex().isValid() ) {
251  return this->refittedPair4Momentum().Vect();
252  }
253  return math::XYZVectorF(0.,0.,0.);
254 
255 }
256 
257 
258 
259 double Conversion::EoverP() const {
260 
261 
262  double ep=-99.;
263 
264  if ( nTracks() > 0 ) {
265  unsigned int size= this->caloCluster().size();
266  float etot=0.;
267  for ( unsigned int i=0; i<size; i++) {
268  etot+= caloCluster()[i]->energy();
269  }
270  if (this->pairMomentum().Mag2() !=0) ep= etot/sqrt(this->pairMomentum().Mag2());
271  }
272 
273 
274 
275  return ep;
276 
277 }
278 
279 
280 
282 
283 
284  double ep=-99.;
285 
286  if ( nTracks() > 0 ) {
287  unsigned int size= this->caloCluster().size();
288  float etot=0.;
289  for ( unsigned int i=0; i<size; i++) {
290  etot+= caloCluster()[i]->energy();
291  }
292  if (this->refittedPairMomentum().Mag2() !=0) ep= etot/sqrt(this->refittedPairMomentum().Mag2());
293  }
294 
295 
296 
297  return ep;
298 
299 }
300 
301 
302 
303 std::vector<double> Conversion::tracksSigned_d0() const {
304  std::vector<double> result;
305  result.reserve(tracks().size());
306 
307  for (auto const& track: tracks()) {
308  result.emplace_back(track->d0()* track->charge()) ;
309  }
310  return result;
311 }
312 
314  double result=-99;
315  if ( nTracks()==2 ) {
316  result = tracksPin()[0].phi() - tracksPin()[1].phi();
317  if( result > pi) { result = result - twopi;}
318  if( result < -pi) { result = result + twopi;}
319  }
320 
321  return result;
322 
323 
324 }
325 
327  double result =-99.;
328 
329  if ( nTracks()==2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull() ) {
330 
331  float recoPhi1 = ecalImpactPosition()[0].phi();
332  if( recoPhi1 > pi) { recoPhi1 = recoPhi1 - twopi;}
333  if( recoPhi1 < -pi) { recoPhi1 = recoPhi1 + twopi;}
334 
335  float recoPhi2 = ecalImpactPosition()[1].phi();
336  if( recoPhi2 > pi) { recoPhi2 = recoPhi2 - twopi;}
337  if( recoPhi2 < -pi) { recoPhi2 = recoPhi2 + twopi;}
338 
339  result = recoPhi1 -recoPhi2;
340 
341  if( result > pi) { result = result - twopi;}
342  if( result < -pi) { result = result + twopi;}
343 
344  }
345 
346  return result;
347 
348 
349 }
350 
352  double result=-99.;
353 
354 
355  if ( nTracks()==2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull() ) {
356 
357  result =ecalImpactPosition()[0].eta() - ecalImpactPosition()[1].eta();
358 
359  }
360 
361 
362 
363  return result;
364 
365 
366 }
367 
368 double Conversion::dxy(const math::XYZPoint& myBeamSpot) const {
369 
370  const reco::Vertex &vtx = conversionVertex();
371  if (!vtx.isValid()) return -9999.;
372 
374 
375  double dxy = (-(vtx.x() - myBeamSpot.x())*mom.y() + (vtx.y() - myBeamSpot.y())*mom.x())/mom.rho();
376  return dxy;
377 
378 }
379 
380 double Conversion::dz(const math::XYZPoint& myBeamSpot) const {
381 
382  const reco::Vertex &vtx = conversionVertex();
383  if (!vtx.isValid()) return -9999.;
384 
386 
387  double dz = (vtx.z()-myBeamSpot.z()) - ((vtx.x()-myBeamSpot.x())*mom.x()+(vtx.y()-myBeamSpot.y())*mom.y())/mom.rho() * mom.z()/mom.rho();
388  return dz;
389 
390 }
391 
392 double Conversion::lxy(const math::XYZPoint& myBeamSpot) const {
393 
394  const reco::Vertex &vtx = conversionVertex();
395  if (!vtx.isValid()) return -9999.;
396 
398 
399  double dbsx = vtx.x() - myBeamSpot.x();
400  double dbsy = vtx.y() - myBeamSpot.y();
401  double lxy = (mom.x()*dbsx + mom.y()*dbsy)/mom.rho();
402  return lxy;
403 
404 }
405 
406 double Conversion::lz(const math::XYZPoint& myBeamSpot) const {
407 
408  const reco::Vertex &vtx = conversionVertex();
409  if (!vtx.isValid()) return -9999.;
410 
412 
413  double lz = (vtx.z() - myBeamSpot.z())*mom.z()/std::abs(mom.z());
414  return lz;
415 
416 }
417 
size
Write out results.
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Definition: Conversion.h:98
static const std::string algoNames[]
Definition: Conversion.h:44
std::vector< math::XYZVectorF > theTrackPout_
P_out of tracks.
Definition: Conversion.h:204
ConversionAlgorithm algo() const
Definition: Conversion.h:224
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:74
double y() const
y coordinate
Definition: Vertex.h:113
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
double EoverP() const
Definition: Conversion.cc:259
const std::vector< Measurement1DFloat > & dlClosestHitToVtx() const
Vector of signed decay length with uncertainty from nearest hit on track to the conversion vtx positi...
Definition: Conversion.h:164
reco::CaloClusterPtrVector caloCluster_
vector pointer to a/multiple seed CaloCluster(s)
Definition: Conversion.h:190
std::vector< double > tracksSigned_d0() const
signed transverse impact parameter for each track
Definition: Conversion.cc:303
double lxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:392
static ConversionAlgorithm algoByName(const std::string &name)
Definition: Conversion.cc:163
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:209
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:20
double pairInvariantMass() const
if nTracks=2 returns the pair invariant mass. Original tracks are used here
Definition: Conversion.cc:190
math::XYZVectorF refittedPairMomentum() const
Conversion tracks momentum from the tracks refitted with vertex constraint.
Definition: Conversion.cc:248
uint8_t nSharedHits_
number of shared hits between tracks
Definition: Conversion.h:217
double EoverPrefittedTracks() const
Definition: Conversion.cc:281
const Double_t pi
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
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:115
uint16_t qualityMask_
Definition: Conversion.h:215
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
const std::vector< reco::CaloClusterPtr > & bcMatchingWithTracks() const
Definition: Conversion.h:152
std::vector< math::XYZPointF > theTrackInnerPosition_
P_in of tracks.
Definition: Conversion.h:200
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:102
Conversion * clone() const
returns a clone of the candidate
Definition: Conversion.cc:171
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:235
const std::vector< math::XYZVectorF > & tracksPin() const
Vector of track momentum measured at the innermost hit.
Definition: Conversion.h:160
uint8_t algorithm_
conversion algorithm/provenance
Definition: Conversion.h:219
double x() const
x coordinate
Definition: Vertex.h:111
math::XYZVectorF pairMomentum() const
Conversion tracks momentum from the tracks inner momentum.
Definition: Conversion.cc:223
const std::vector< math::XYZPointF > & ecalImpactPosition() const
Definition: Conversion.h:150
uint8_t nSharedHits() const
number of shared hits btw the two track
Definition: Conversion.h:166
double dEtaTracksAtEcal() const
Definition: Conversion.cc:351
double dz(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:380
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:135
std::vector< math::XYZVectorF > theTrackPin_
P_in of tracks.
Definition: Conversion.h:202
float theMVAout_
TMVA output.
Definition: Conversion.h:214
std::vector< reco::CaloClusterPtr > theMatchingBCs_
Clusters mathing the tracks (these are not the seeds)
Definition: Conversion.h:198
double lz(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:406
float theMinDistOfApproach_
Distance of min approach of the two tracks.
Definition: Conversion.h:212
std::vector< math::XYZPointF > thePositionAtEcal_
position at the ECAl surface of the track extrapolation
Definition: Conversion.h:194
fixed size matrix
std::vector< edm::RefToBase< reco::Track > > trackToBaseRefs_
vector Track RefToBase
Definition: Conversion.h:192
const std::vector< uint8_t > & nHitsBeforeVtx() const
Vector of the number of hits before the vertex along each track trajector.
Definition: Conversion.h:162
std::vector< Measurement1DFloat > dlClosestHitToVtx_
signed decay length and uncertainty from nearest hit on track to conversion vertex ...
Definition: Conversion.h:208
double dPhiTracksAtEcal() const
Definition: Conversion.cc:326
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
reco::Vertex theConversionVertex_
Fitted Kalman conversion vertex.
Definition: Conversion.h:196
bool isConverted() const
Bool flagging objects having track size >0.
Definition: Conversion.cc:182
std::vector< uint8_t > nHitsBeforeVtx_
number of hits before the vertex on each trackerOnly
Definition: Conversion.h:206
reco::CaloClusterPtrVector caloCluster() const
Pointer to CaloCluster (foe Egamma Conversions it points to a SuperCluster)
Definition: Conversion.h:94
double dPhiTracksAtVtx() const
Definition: Conversion.cc:313
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:176
double dxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:368