CMS 3D CMS Logo

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