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 // Temporary hack workaround for algoByName string "above array bounds"
7 // error reported by gcc from Conversion::algoByName below. This could
8 // should probably be demangled a bit in any case, but for now just
9 // turn off the warning/error in this file.
10 // Do not copy this into other files without checking with the release
11 // coordinators! PE 20091231
12 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4
13 # pragma GCC diagnostic ignored "-Warray-bounds"
14 #endif
15 
16 using namespace reco;
17 
18 
20  const std::vector<reco::TrackRef> tr,
21  const std::vector<math::XYZPointF> trackPositionAtEcal,
22  const reco::Vertex & convVtx,
23  const std::vector<reco::CaloClusterPtr> & matchingBC,
24  const float DCA,
25  const std::vector<math::XYZPointF> & innPoint,
26  const std::vector<math::XYZVectorF> & trackPin,
27  const std::vector<math::XYZVectorF> & trackPout,
28  const float mva,
30 
31 
32  caloCluster_(sc), tracks_(tr),
33  thePositionAtEcal_(trackPositionAtEcal),
34  theConversionVertex_(convVtx),
35  theMatchingBCs_(matchingBC),
36  theMinDistOfApproach_(DCA),
37  theTrackInnerPosition_(innPoint),
38  theTrackPin_(trackPin),
39  theTrackPout_(trackPout),
40  nSharedHits_(0),
41  theMVAout_(mva),
42  algorithm_(algo),
43  qualityMask_(0)
44  {
45 
46  }
47 
48 
49 
50 
52  const std::vector<edm::RefToBase<reco::Track> > tr,
53  const std::vector<math::XYZPointF> trackPositionAtEcal,
54  const reco::Vertex & convVtx,
55  const std::vector<reco::CaloClusterPtr> & matchingBC,
56  const float DCA,
57  const std::vector<math::XYZPointF> & innPoint,
58  const std::vector<math::XYZVectorF> & trackPin,
59  const std::vector<math::XYZVectorF> & trackPout,
60  const std::vector<uint8_t> nHitsBeforeVtx,
61  const std::vector<Measurement1DFloat> & dlClosestHitToVtx,
62  uint8_t nSharedHits,
63  const float mva,
65 
66 
67  caloCluster_(sc), trackToBaseRefs_(tr),
68  thePositionAtEcal_(trackPositionAtEcal),
69  theConversionVertex_(convVtx),
70  theMatchingBCs_(matchingBC),
71  theMinDistOfApproach_(DCA),
72  theTrackInnerPosition_(innPoint),
73  theTrackPin_(trackPin),
74  theTrackPout_(trackPout),
75  nHitsBeforeVtx_(nHitsBeforeVtx),
76  dlClosestHitToVtx_(dlClosestHitToVtx),
77  nSharedHits_(nSharedHits),
78  theMVAout_(mva),
79  algorithm_(algo),
80  qualityMask_(0)
81  {
82 
83  }
84 
85 
86 
87 
89  const std::vector<reco::TrackRef> tr,
90  const reco::Vertex & convVtx,
92  caloCluster_(sc), tracks_(tr),
93  theConversionVertex_(convVtx),
94  nSharedHits_(0),
95  algorithm_(algo),
96  qualityMask_(0)
97  {
98 
99 
100  theMinDistOfApproach_ = 9999.;
101  theMVAout_ = 9999.;
102  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
103  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
104  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
105  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
106  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
107  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
108  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
109  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
110 
111 
112  }
113 
114 
116  const std::vector<edm::RefToBase<reco::Track> > tr,
117  const reco::Vertex & convVtx,
119  caloCluster_(sc), trackToBaseRefs_(tr),
120  theConversionVertex_(convVtx),
121  nSharedHits_(0),
122  algorithm_(algo),
123  qualityMask_(0)
124  {
125 
126 
127  theMinDistOfApproach_ = 9999.;
128  theMVAout_ = 9999.;
129  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
130  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
131  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
132  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
133  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
134  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
135  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
136  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
137 
138 
139  }
140 
141 
142 
144 
145  algorithm_=0;
146  qualityMask_=0;
147  theMinDistOfApproach_ = 9999.;
148  nSharedHits_ = 0;
149  theMVAout_ = 9999.;
150  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
151  thePositionAtEcal_.push_back(math::XYZPointF(0.,0.,0.));
152  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
153  theTrackInnerPosition_.push_back(math::XYZPointF(0.,0.,0.));
154  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
155  theTrackPin_.push_back(math::XYZVectorF(0.,0.,0.));
156  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
157  theTrackPout_.push_back(math::XYZVectorF(0.,0.,0.));
158 
159 }
160 
161 
163 
164 
165 std::string const Conversion::algoNames[] = { "undefined","ecalSeeded","trackerOnly","mixed"};
166 
169  int index = std::find(algoNames, algoNames+size, name)-algoNames;
170  if(index == size) return undefined;
171 
172  return ConversionAlgorithm(index);
173 }
174 
176  return new Conversion( * this );
177 }
178 
179 
180 std::vector<edm::RefToBase<reco::Track> > Conversion::tracks() const {
181  if (trackToBaseRefs_.size() ==0 ) {
182 
183  for (std::vector<reco::TrackRef>::const_iterator ref=tracks_.begin(); ref!=tracks_.end(); ref++ )
184  {
186  trackToBaseRefs_.push_back(tt);
187 
188  }
189  }
190 
191  return trackToBaseRefs_;
192 }
193 
194 
195 
197 
198  if ( this->nTracks() == 2 )
199  return true;
200  else
201  return false;
202 }
203 
205  double invMass=-99.;
206  const float mElec= 0.000511;
207  if ( nTracks()==2 ) {
208  double px= tracksPin()[0].x() + tracksPin()[1].x();
209  double py= tracksPin()[0].y() + tracksPin()[1].y();
210  double pz= tracksPin()[0].z() + tracksPin()[1].z();
211  double mom1= tracksPin()[0].Mag2();
212  double mom2= tracksPin()[1].Mag2();
213  double e = sqrt( mom1+ mElec*mElec ) + sqrt( mom2 + mElec*mElec );
214  invMass= ( e*e - px*px -py*py - pz*pz);
215  if ( invMass>0) invMass = sqrt(invMass);
216  else
217  invMass = -1;
218  }
219 
220  return invMass;
221 }
222 
224  double dCotTheta=-99.;
225 
226  if ( nTracks()==2 ) {
227  double theta1=this->tracksPin()[0].Theta();
228  double theta2=this->tracksPin()[1].Theta();
229  dCotTheta = 1./tan(theta1) - 1./tan(theta2) ;
230  }
231 
232  return dCotTheta;
233 
234 }
235 
236 
238 
239  if ( nTracks()==2 ) {
240  return this->tracksPin()[0] + this->tracksPin()[1];
241  }
242  return math::XYZVectorF(0.,0.,0.);
243 
244 
245 
246 }
247 
248 
250 
252  if ( this->conversionVertex().isValid() )
253  p4 = this->conversionVertex().p4( 0.000511, 0.5);
254 
255  return p4;
256 
257 
258 }
259 
260 
261 
263 
264  if ( this->conversionVertex().isValid() ) {
265  return this->refittedPair4Momentum().Vect();
266  }
267  return math::XYZVectorF(0.,0.,0.);
268 
269 }
270 
271 
272 
273 double Conversion::EoverP() const {
274 
275 
276  double ep=-99.;
277 
278  if ( nTracks() > 0 ) {
279  unsigned int size= this->caloCluster().size();
280  float etot=0.;
281  for ( unsigned int i=0; i<size; i++) {
282  etot+= caloCluster()[i]->energy();
283  }
284  if (this->pairMomentum().Mag2() !=0) ep= etot/sqrt(this->pairMomentum().Mag2());
285  }
286 
287 
288 
289  return ep;
290 
291 }
292 
293 
294 
296 
297 
298  double ep=-99.;
299 
300  if ( nTracks() > 0 ) {
301  unsigned int size= this->caloCluster().size();
302  float etot=0.;
303  for ( unsigned int i=0; i<size; i++) {
304  etot+= caloCluster()[i]->energy();
305  }
306  if (this->refittedPairMomentum().Mag2() !=0) ep= etot/sqrt(this->refittedPairMomentum().Mag2());
307  }
308 
309 
310 
311  return ep;
312 
313 }
314 
315 
316 
317 std::vector<double> Conversion::tracksSigned_d0() const {
318  std::vector<double> result;
319 
320  for (unsigned int i=0; i< nTracks(); i++)
321  result.push_back(tracks()[i]->d0()* tracks()[i]->charge()) ;
322 
323  return result;
324 
325 
326 }
327 
329  double result=-99;
330  if ( nTracks()==2 ) {
331  result = tracksPin()[0].phi() - tracksPin()[1].phi();
332  if( result > pi) { result = result - twopi;}
333  if( result < -pi) { result = result + twopi;}
334  }
335 
336  return result;
337 
338 
339 }
340 
342  double result =-99.;
343 
344  if ( nTracks()==2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull() ) {
345 
346  float recoPhi1 = ecalImpactPosition()[0].phi();
347  if( recoPhi1 > pi) { recoPhi1 = recoPhi1 - twopi;}
348  if( recoPhi1 < -pi) { recoPhi1 = recoPhi1 + twopi;}
349 
350  float recoPhi2 = ecalImpactPosition()[1].phi();
351  if( recoPhi2 > pi) { recoPhi2 = recoPhi2 - twopi;}
352  if( recoPhi2 < -pi) { recoPhi2 = recoPhi2 + twopi;}
353 
354  result = recoPhi1 -recoPhi2;
355 
356  if( result > pi) { result = result - twopi;}
357  if( result < -pi) { result = result + twopi;}
358 
359  }
360 
361  return result;
362 
363 
364 }
365 
367  double result=-99.;
368 
369 
370  if ( nTracks()==2 && bcMatchingWithTracks()[0].isNonnull() && bcMatchingWithTracks()[1].isNonnull() ) {
371 
372  result =ecalImpactPosition()[0].eta() - ecalImpactPosition()[1].eta();
373 
374  }
375 
376 
377 
378  return result;
379 
380 
381 }
382 
383 double Conversion::dxy(const math::XYZPoint& myBeamSpot) const {
384 
385  const reco::Vertex &vtx = conversionVertex();
386  if (!vtx.isValid()) return -9999.;
387 
389 
390  double dxy = (-(vtx.x() - myBeamSpot.x())*mom.y() + (vtx.y() - myBeamSpot.y())*mom.x())/mom.rho();
391  return dxy;
392 
393 }
394 
395 double Conversion::dz(const math::XYZPoint& myBeamSpot) const {
396 
397  const reco::Vertex &vtx = conversionVertex();
398  if (!vtx.isValid()) return -9999.;
399 
401 
402  double dz = (vtx.z()-myBeamSpot.z()) - ((vtx.x()-myBeamSpot.x())*mom.x()+(vtx.y()-myBeamSpot.y())*mom.y())/mom.rho() * mom.z()/mom.rho();
403  return dz;
404 
405 }
406 
407 double Conversion::lxy(const math::XYZPoint& myBeamSpot) const {
408 
409  const reco::Vertex &vtx = conversionVertex();
410  if (!vtx.isValid()) return -9999.;
411 
413 
414  double dbsx = vtx.x() - myBeamSpot.x();
415  double dbsy = vtx.y() - myBeamSpot.y();
416  double lxy = (mom.x()*dbsx + mom.y()*dbsy)/mom.rho();
417  return lxy;
418 
419 }
420 
421 double Conversion::lz(const math::XYZPoint& myBeamSpot) const {
422 
423  const reco::Vertex &vtx = conversionVertex();
424  if (!vtx.isValid()) return -9999.;
425 
427 
428  double lz = (vtx.z() - myBeamSpot.z())*mom.z()/std::abs(mom.z());
429  return lz;
430 
431 }
432 
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:273
std::vector< double > tracksSigned_d0() const
signed transverse impact parameter for each track
Definition: Conversion.cc:317
double lxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:407
#define abs(x)
Definition: mlp_lapack.h:159
static ConversionAlgorithm algoByName(const std::string &name)
Definition: Conversion.cc:167
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:223
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:204
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:262
uint8_t nSharedHits_
number of shared hits between tracks
Definition: Conversion.h:217
double EoverPrefittedTracks() const
Definition: Conversion.cc:295
const Double_t pi
std::vector< edm::RefToBase< reco::Track > > tracks() const
vector of track to base references
Definition: Conversion.cc:180
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
tuple result
Definition: query.py:137
virtual ~Conversion()
destructor
Definition: Conversion.cc:162
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:175
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:249
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:237
const std::vector< math::XYZPointF > & ecalImpactPosition() const
Definition: Conversion.h:153
double dEtaTracksAtEcal() const
Definition: Conversion.cc:366
double dz(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:395
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:421
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:341
LimitAlgo * algo
Definition: Combine.cc:60
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:196
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:328
double dxy(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.cc:383