CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions
ConversionFinder Class Reference

#include <ConversionFinder.h>

Public Member Functions

ConversionInfo arbitrateConversionPartnersbyR (const std::vector< ConversionInfo > &v_convCandidates)
 
 ConversionFinder ()
 
ConversionInfo findBestConversionMatch (const std::vector< ConversionInfo > &v_convCandidates)
 
ConversionInfo getConversionInfo (const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
 
ConversionInfo getConversionInfo (const reco::GsfElectron &gsfElectron, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
 
ConversionInfo getConversionInfo (const reco::Track *el_track, const reco::Track *candPartnerTk, const double bFieldAtOrigin)
 
ConversionInfo getConversionInfo (const reco::GsfElectron &gsfElectron, const edm::Handle< reco::TrackCollection > &track_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
 
std::vector< ConversionInfogetConversionInfos (const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
 
const reco::TrackgetElectronTrack (const reco::GsfElectron &, const float minFracSharedHits=0.45)
 
const reco::TrackgetElectronTrack (const reco::GsfElectronCore &, const float minFracSharedHits=0.45)
 
bool isFromConversion (const ConversionInfo &, double maxAbsDist=0.02, double maxAbsDcot=0.02)
 
 ~ConversionFinder ()
 

Static Public Member Functions

static std::pair< double, double > getConversionInfo (math::XYZTLorentzVector trk1_p4, int trk1_q, float trk1_d0, math::XYZTLorentzVector trk2_p4, int trk2_q, float trk2_d0, float bFieldAtOrigin)
 

Detailed Description

Definition at line 36 of file ConversionFinder.h.

Constructor & Destructor Documentation

ConversionFinder::ConversionFinder ( )

Definition at line 19 of file ConversionFinder.cc.

19 {}
ConversionFinder::~ConversionFinder ( )

Definition at line 22 of file ConversionFinder.cc.

22 {}

Member Function Documentation

ConversionInfo ConversionFinder::arbitrateConversionPartnersbyR ( const std::vector< ConversionInfo > &  v_convCandidates)

Definition at line 299 of file ConversionFinder.cc.

References ConversionInfo::dcot(), ConversionInfo::dist(), i, funct::pow(), dttmaxenums::R, mathSSE::sqrt(), and groupFilesInBlocks::temp.

Referenced by findBestConversionMatch().

299  {
300 
301  if(v_convCandidates.size() == 1)
302  return v_convCandidates.at(0);
303 
304  ConversionInfo arbitratedConvInfo = v_convCandidates.at(0);
305  double R = sqrt(pow(arbitratedConvInfo.dist(),2) + pow(arbitratedConvInfo.dcot(),2));
306 
307  for(unsigned int i = 1; i < v_convCandidates.size(); i++) {
308  ConversionInfo temp = v_convCandidates.at(i);
309  double temp_R = sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2));
310  if(temp_R < R) {
311  R = temp_R;
312  arbitratedConvInfo = temp;
313  }
314 
315  }
316 
317  return arbitratedConvInfo;
318 
319  }
int i
Definition: DBlmapReader.cc:9
double dist() const
T sqrt(T t)
Definition: SSEVec.h:48
double dcot() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ConversionInfo ConversionFinder::findBestConversionMatch ( const std::vector< ConversionInfo > &  v_convCandidates)

Definition at line 322 of file ConversionFinder.cc.

References arbitrateConversionPartnersbyR(), ConversionInfo::dcot(), ConversionInfo::deltaMissingHits(), ConversionInfo::dist(), ConversionInfo::flag(), i, funct::pow(), ConversionInfo::radiusOfConversion(), mathSSE::sqrt(), and groupFilesInBlocks::temp.

Referenced by getConversionInfo().

323  {
324  using namespace std;
325 
326  if(v_convCandidates.size() == 0)
327  return ConversionInfo(-9999.,-9999.,-9999.,
328  math::XYZPoint(-9999.,-9999.,-9999),
330  -9999, -9999);
331 
332 
333  if(v_convCandidates.size() == 1)
334  return v_convCandidates.at(0);
335 
336  vector<ConversionInfo> v_0;
337  vector<ConversionInfo> v_1;
338  vector<ConversionInfo> v_2;
339  vector<ConversionInfo> v_3;
340  //loop over the candidates
341  for(unsigned int i = 1; i < v_convCandidates.size(); i++) {
342  ConversionInfo temp = v_convCandidates.at(i);
343 
344  if(temp.flag() == 0) {
345  bool isConv = false;
346  if(fabs(temp.dist()) < 0.02 &&
347  fabs(temp.dcot()) < 0.02 &&
348  temp.deltaMissingHits() < 3 &&
349  temp.radiusOfConversion() > -2)
350  isConv = true;
351  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 &&
352  temp.deltaMissingHits() < 2 &&
353  temp.radiusOfConversion() > -2)
354  isConv = true;
355 
356  if(isConv)
357  v_0.push_back(temp);
358  }
359 
360  if(temp.flag() == 1) {
361 
362  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 &&
363  temp.deltaMissingHits() < 2 &&
364  temp.radiusOfConversion() > -2)
365  v_1.push_back(temp);
366  }
367  if(temp.flag() == 2) {
368 
369  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot()*temp.dcot(),2)) < 0.05 &&
370  temp.deltaMissingHits() < 2 &&
371  temp.radiusOfConversion() > -2)
372  v_2.push_back(temp);
373 
374  }
375  if(temp.flag() == 3) {
376 
377  if(sqrt(temp.dist()*temp.dist() + temp.dcot()*temp.dcot()) < 0.05
378  && temp.deltaMissingHits() < 2
379  && temp.radiusOfConversion() > -2)
380  v_3.push_back(temp);
381 
382  }
383 
384  }//candidate conversion loop
385 
386  //now do some arbitration
387 
388  //give preference to conversion partners found in the CTF collection
389  //using the electron's CTF track
390  if(v_0.size() > 0)
391  return arbitrateConversionPartnersbyR(v_0);
392 
393  if(v_1.size() > 0)
394  return arbitrateConversionPartnersbyR(v_1);
395 
396  if(v_2.size() > 0)
397  return arbitrateConversionPartnersbyR(v_2);
398 
399  if(v_3.size() > 0)
400  return arbitrateConversionPartnersbyR(v_3);
401 
402 
403  //if we get here, we didn't find a candidate conversion partner that
404  //satisfied even the loose selections
405  //return the the closest partner by R
406  return arbitrateConversionPartnersbyR(v_convCandidates);
407 
408  }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
int i
Definition: DBlmapReader.cc:9
double radiusOfConversion() const
double dist() const
T sqrt(T t)
Definition: SSEVec.h:48
ConversionInfo arbitrateConversionPartnersbyR(const std::vector< ConversionInfo > &v_convCandidates)
int deltaMissingHits() const
int flag() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
double dcot() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ConversionInfo ConversionFinder::getConversionInfo ( const reco::GsfElectronCore gsfElectron,
const edm::Handle< reco::TrackCollection > &  ctftracks_h,
const edm::Handle< reco::GsfTrackCollection > &  gsftracks_h,
const double  bFieldAtOrigin,
const double  minFracSharedHits = 0.45 
)

Definition at line 36 of file ConversionFinder.cc.

References findBestConversionMatch(), getConversionInfos(), and groupFilesInBlocks::temp.

Referenced by ZeeCandidateFilter::filter(), and getConversionInfos().

40  {
41 
42  std::vector<ConversionInfo> temp = getConversionInfos(gsfElectron,ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
43  return findBestConversionMatch(temp);
44 
45 }
ConversionInfo findBestConversionMatch(const std::vector< ConversionInfo > &v_convCandidates)
std::vector< ConversionInfo > getConversionInfos(const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
ConversionInfo ConversionFinder::getConversionInfo ( const reco::GsfElectron gsfElectron,
const edm::Handle< reco::TrackCollection > &  ctftracks_h,
const edm::Handle< reco::GsfTrackCollection > &  gsftracks_h,
const double  bFieldAtOrigin,
const double  minFracSharedHits = 0.45 
)

Definition at line 25 of file ConversionFinder.cc.

References reco::GsfElectron::core(), findBestConversionMatch(), getConversionInfos(), and groupFilesInBlocks::temp.

29  {
30 
31  std::vector<ConversionInfo> temp = getConversionInfos(*gsfElectron.core(),ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
32  return findBestConversionMatch(temp);
33 
34 }
ConversionInfo findBestConversionMatch(const std::vector< ConversionInfo > &v_convCandidates)
std::vector< ConversionInfo > getConversionInfos(const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
ConversionInfo ConversionFinder::getConversionInfo ( const reco::Track el_track,
const reco::Track candPartnerTk,
const double  bFieldAtOrigin 
)

Definition at line 237 of file ConversionFinder.cc.

References reco::TrackBase::charge(), funct::cos(), reco::TrackBase::d0(), reco::TrackBase::dz(), reco::TrackBase::p(), funct::pow(), reco::TrackBase::pt(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), dt_dqm_sourceclient_common_cff::reco, funct::sin(), mathSSE::sqrt(), funct::tan(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

239  {
240 
241  using namespace reco;
242 
243  //now calculate the conversion related information
244  LorentzVector el_tk_p4(el_track->px(), el_track->py(), el_track->pz(), el_track->p());
245  double elCurvature = -0.3*bFieldAtOrigin*(el_track->charge()/el_tk_p4.pt())/100.;
246  double rEl = fabs(1./elCurvature);
247  double xEl = -1*(1./elCurvature - el_track->d0())*sin(el_tk_p4.phi());
248  double yEl = (1./elCurvature - el_track->d0())*cos(el_tk_p4.phi());
249 
250 
251  LorentzVector cand_p4 = LorentzVector(candPartnerTk->px(), candPartnerTk->py(),candPartnerTk->pz(), candPartnerTk->p());
252  double candCurvature = -0.3*bFieldAtOrigin*(candPartnerTk->charge()/cand_p4.pt())/100.;
253  double rCand = fabs(1./candCurvature);
254  double xCand = -1*(1./candCurvature - candPartnerTk->d0())*sin(cand_p4.phi());
255  double yCand = (1./candCurvature - candPartnerTk->d0())*cos(cand_p4.phi());
256 
257  double d = sqrt(pow(xEl-xCand, 2) + pow(yEl-yCand , 2));
258  double dist = d - (rEl + rCand);
259  double dcot = 1./tan(el_tk_p4.theta()) - 1./tan(cand_p4.theta());
260 
261  //get the point of conversion
262  double xa1 = xEl + (xCand-xEl) * rEl/d;
263  double xa2 = xCand + (xEl-xCand) * rCand/d;
264  double ya1 = yEl + (yCand-yEl) * rEl/d;
265  double ya2 = yCand + (yEl-yCand) * rCand/d;
266 
267  double x=.5*(xa1+xa2);
268  double y=.5*(ya1+ya2);
269  double rconv = sqrt(pow(x,2) + pow(y,2));
270  double z = el_track->dz() + rEl*el_track->pz()*TMath::ACos(1-pow(rconv,2)/(2.*pow(rEl,2)))/el_track->pt();
271 
272  math::XYZPoint convPoint(x, y, z);
273 
274  //now assign a sign to the radius of conversion
275  float tempsign = el_track->px()*x + el_track->py()*y;
276  tempsign = tempsign/fabs(tempsign);
277  rconv = tempsign*rconv;
278 
279  //return an instance of ConversionInfo, but with a NULL track refs
280  return ConversionInfo(dist, dcot, rconv, convPoint, TrackRef(), GsfTrackRef(), -9999, -9999);
281 
282 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
double d0() const
dxy parameter in perigee convention (d0 = - dxy)
Definition: TrackBase.h:121
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
math::XYZTLorentzVector LorentzVector
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:131
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:129
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:125
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
int charge() const
track electric charge
Definition: TrackBase.h:111
Definition: DDAxes.h:10
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:133
math::PtEtaPhiELorentzVectorF LorentzVector
std::pair< double, double > ConversionFinder::getConversionInfo ( math::XYZTLorentzVector  trk1_p4,
int  trk1_q,
float  trk1_d0,
math::XYZTLorentzVector  trk2_p4,
int  trk2_q,
float  trk2_d0,
float  bFieldAtOrigin 
)
static

Definition at line 417 of file ConversionFinder.cc.

References funct::cos(), funct::pow(), funct::sin(), mathSSE::sqrt(), and funct::tan().

421  {
422 
423 
424  double tk1Curvature = -0.3*bFieldAtOrigin*(trk1_q/trk1_p4.pt())/100.;
425  double rTk1 = fabs(1./tk1Curvature);
426  double xTk1 = -1.*(1./tk1Curvature - trk1_d0)*sin(trk1_p4.phi());
427  double yTk1 = (1./tk1Curvature - trk1_d0)*cos(trk1_p4.phi());
428 
429 
430  double tk2Curvature = -0.3*bFieldAtOrigin*(trk2_q/trk2_p4.pt())/100.;
431  double rTk2 = fabs(1./tk2Curvature);
432  double xTk2 = -1.*(1./tk2Curvature - trk2_d0)*sin(trk2_p4.phi());
433  double yTk2 = (1./tk2Curvature - trk2_d0)*cos(trk2_p4.phi());
434 
435 
436  double dist = sqrt(pow(xTk1-xTk2, 2) + pow(yTk1-yTk2 , 2));
437  dist = dist - (rTk1 + rTk2);
438 
439  double dcot = 1./tan(trk1_p4.theta()) - 1./tan(trk2_p4.theta());
440 
441  return std::make_pair(dist, dcot);
442 
443  }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ConversionInfo ConversionFinder::getConversionInfo ( const reco::GsfElectron gsfElectron,
const edm::Handle< reco::TrackCollection > &  track_h,
const double  bFieldAtOrigin,
const double  minFracSharedHits = 0.45 
)

Definition at line 447 of file ConversionFinder.cc.

References reco::GsfElectron::closestCtfTrackRef(), funct::cos(), deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, getElectronTrack(), funct::pow(), edm::Handle< T >::product(), dt_dqm_sourceclient_common_cff::reco, reco::GsfElectron::shFracInnerHits(), funct::sin(), mathSSE::sqrt(), funct::tan(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

450  {
451 
452 
453  using namespace reco;
454  using namespace std;
455  using namespace edm;
456 
457 
458  const TrackCollection *ctftracks = track_h.product();
459  const reco::TrackRef el_ctftrack = gsfElectron.closestCtfTrackRef();
460  int ctfidx = -999.;
461  int flag = -9999.;
462  if(el_ctftrack.isNonnull() && gsfElectron.shFracInnerHits() > minFracSharedHits) {
463  ctfidx = static_cast<int>(el_ctftrack.key());
464  flag = 0;
465  } else
466  flag = 1;
467 
468 
469  /*
470  determine whether we're going to use the CTF track or the GSF track
471  using the electron's CTF track to find the dist, dcot has been shown
472  to reduce the inefficiency
473  */
474  const reco::Track* el_track = getElectronTrack(gsfElectron, minFracSharedHits);
475  LorentzVector el_tk_p4(el_track->px(), el_track->py(), el_track->pz(), el_track->p());
476 
477 
478  int tk_i = 0;
479  double mindcot = 9999.;
480  //make a null Track Ref
481  TrackRef candCtfTrackRef = TrackRef() ;
482 
483 
484  for(TrackCollection::const_iterator tk = ctftracks->begin();
485  tk != ctftracks->end(); tk++, tk_i++) {
486  //if the general Track is the same one as made by the electron, skip it
487  if((tk_i == ctfidx))
488  continue;
489 
490  LorentzVector tk_p4 = LorentzVector(tk->px(), tk->py(),tk->pz(), tk->p());
491 
492  //look only in a cone of 0.5
493  double dR = deltaR(el_tk_p4, tk_p4);
494  if(dR>0.5)
495  continue;
496 
497 
498  //require opp. sign -> Should we use the majority logic??
499  if(tk->charge() + el_track->charge() != 0)
500  continue;
501 
502  double dcot = fabs(1./tan(tk_p4.theta()) - 1./tan(el_tk_p4.theta()));
503  if(dcot < mindcot) {
504  mindcot = dcot;
505  candCtfTrackRef = reco::TrackRef(track_h, tk_i);
506  }
507  }//track loop
508 
509 
510  if(!candCtfTrackRef.isNonnull())
511  return ConversionInfo(-9999.,-9999.,-9999.,
512  math::XYZPoint(-9999.,-9999.,-9999),
514  -9999, -9999);
515 
516 
517 
518  //now calculate the conversion related information
519  double elCurvature = -0.3*bFieldAtOrigin*(el_track->charge()/el_tk_p4.pt())/100.;
520  double rEl = fabs(1./elCurvature);
521  double xEl = -1*(1./elCurvature - el_track->d0())*sin(el_tk_p4.phi());
522  double yEl = (1./elCurvature - el_track->d0())*cos(el_tk_p4.phi());
523 
524 
525  LorentzVector cand_p4 = LorentzVector(candCtfTrackRef->px(), candCtfTrackRef->py(),candCtfTrackRef->pz(), candCtfTrackRef->p());
526  double candCurvature = -0.3*bFieldAtOrigin*(candCtfTrackRef->charge()/cand_p4.pt())/100.;
527  double rCand = fabs(1./candCurvature);
528  double xCand = -1*(1./candCurvature - candCtfTrackRef->d0())*sin(cand_p4.phi());
529  double yCand = (1./candCurvature - candCtfTrackRef->d0())*cos(cand_p4.phi());
530 
531  double d = sqrt(pow(xEl-xCand, 2) + pow(yEl-yCand , 2));
532  double dist = d - (rEl + rCand);
533  double dcot = 1./tan(el_tk_p4.theta()) - 1./tan(cand_p4.theta());
534 
535  //get the point of conversion
536  double xa1 = xEl + (xCand-xEl) * rEl/d;
537  double xa2 = xCand + (xEl-xCand) * rCand/d;
538  double ya1 = yEl + (yCand-yEl) * rEl/d;
539  double ya2 = yCand + (yEl-yCand) * rCand/d;
540 
541  double x=.5*(xa1+xa2);
542  double y=.5*(ya1+ya2);
543  double rconv = sqrt(pow(x,2) + pow(y,2));
544  double z = el_track->dz() + rEl*el_track->pz()*TMath::ACos(1-pow(rconv,2)/(2.*pow(rEl,2)))/el_track->pt();
545 
546  math::XYZPoint convPoint(x, y, z);
547 
548  //now assign a sign to the radius of conversion
549  float tempsign = el_track->px()*x + el_track->py()*y;
550  tempsign = tempsign/fabs(tempsign);
551  rconv = tempsign*rconv;
552 
553  int deltaMissingHits = -9999;
554  deltaMissingHits = candCtfTrackRef->trackerExpectedHitsInner().numberOfHits() - el_track->trackerExpectedHitsInner().numberOfHits();
555  return ConversionInfo(dist, dcot, rconv, convPoint, candCtfTrackRef, GsfTrackRef(), deltaMissingHits, flag);
556 
557  }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
const reco::Track * getElectronTrack(const reco::GsfElectron &, const float minFracSharedHits=0.45)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
math::XYZTLorentzVector LorentzVector
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
float float float z
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:185
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
float shFracInnerHits() const
Definition: GsfElectron.h:184
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T const * product() const
Definition: Handle.h:81
Definition: DDAxes.h:10
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
math::PtEtaPhiELorentzVectorF LorentzVector
std::vector< ConversionInfo > ConversionFinder::getConversionInfos ( const reco::GsfElectronCore gsfElectron,
const edm::Handle< reco::TrackCollection > &  ctftracks_h,
const edm::Handle< reco::GsfTrackCollection > &  gsftracks_h,
const double  bFieldAtOrigin,
const double  minFracSharedHits = 0.45 
)

Definition at line 49 of file ConversionFinder.cc.

References reco::GsfElectronCore::ctfGsfOverlap(), reco::GsfElectronCore::ctfTrack(), ConversionInfo::dcot(), deltaR(), ConversionInfo::dist(), getConversionInfo(), reco::GsfElectronCore::gsfTrack(), edm::HandleBase::id(), ConversionInfo::pointOfConversion(), edm::Handle< T >::product(), ConversionInfo::radiusOfConversion(), and dt_dqm_sourceclient_common_cff::reco.

Referenced by getConversionInfo().

53  {
54 
55 
56 
57  using namespace reco;
58  using namespace std;
59  using namespace edm;
60 
61 
62  //get the track collections
63  const TrackCollection *ctftracks = ctftracks_h.product();
64  const GsfTrackCollection *gsftracks = gsftracks_h.product();
65 
66  //get the references to the gsf and ctf tracks that are made
67  //by the electron
68  const reco::TrackRef el_ctftrack = gsfElectron.ctfTrack();
69  const reco::GsfTrackRef el_gsftrack = gsfElectron.gsfTrack();
70 
71  //protect against the wrong collection being passed to the function
72  if(el_ctftrack.isNonnull() && el_ctftrack.id() != ctftracks_h.id())
73  throw cms::Exception("ConversionFinderError") << "ProductID of ctf track collection does not match ProductID of electron's CTF track! \n";
74  if(el_gsftrack.isNonnull() && el_gsftrack.id() != gsftracks_h.id())
75  throw cms::Exception("ConversionFinderError") << "ProductID of gsf track collection does not match ProductID of electron's GSF track! \n";
76 
77  //make p4s for the electron's tracks for use later
78  LorentzVector el_ctftrack_p4;
79  if(el_ctftrack.isNonnull() && gsfElectron.ctfGsfOverlap() > minFracSharedHits)
80  el_ctftrack_p4 = LorentzVector(el_ctftrack->px(), el_ctftrack->py(), el_ctftrack->pz(), el_ctftrack->p());
81  LorentzVector el_gsftrack_p4(el_gsftrack->px(), el_gsftrack->py(), el_gsftrack->pz(), el_gsftrack->p());
82 
83  //the electron's CTF track must share at least 45% of the inner hits
84  //with the electron's GSF track
85  int ctfidx = -999.;
86  int gsfidx = -999.;
87  if(el_ctftrack.isNonnull() && gsfElectron.ctfGsfOverlap() > minFracSharedHits)
88  ctfidx = static_cast<int>(el_ctftrack.key());
89 
90  gsfidx = static_cast<int>(el_gsftrack.key());
91 
92 
93  //these vectors are for those candidate partner tracks that pass our cuts
94  vector<ConversionInfo> v_candidatePartners;
95  //track indices required to make references
96  int ctftk_i = 0;
97  int gsftk_i = 0;
98 
99 
100  //loop over the CTF tracks and try to find the partner track
101  for(TrackCollection::const_iterator ctftk = ctftracks->begin();
102  ctftk != ctftracks->end(); ctftk++, ctftk_i++) {
103 
104  if((ctftk_i == ctfidx))
105  continue;
106 
107  //candidate track's p4
108  LorentzVector ctftk_p4 = LorentzVector(ctftk->px(), ctftk->py(), ctftk->pz(), ctftk->p());
109 
110  //apply quality cuts to remove bad tracks
111  if(ctftk->ptError()/ctftk->pt() > 0.05)
112  continue;
113  if(ctftk->numberOfValidHits() < 5)
114  continue;
115 
116  if(el_ctftrack.isNonnull() &&
117  gsfElectron.ctfGsfOverlap() > minFracSharedHits &&
118  fabs(ctftk_p4.Pt() - el_ctftrack->pt())/el_ctftrack->pt() < 0.2)
119  continue;
120 
121  //use the electron's CTF track, if not null, to search for the partner track
122  //look only in a cone of 0.5 to save time, and require that the track is opp. sign
123  if(el_ctftrack.isNonnull() && gsfElectron.ctfGsfOverlap() > minFracSharedHits &&
124  deltaR(el_ctftrack_p4, ctftk_p4) < 0.5 &&
125  (el_ctftrack->charge() + ctftk->charge() == 0) ) {
126 
127  ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_ctftrack.get()), &(*ctftk), bFieldAtOrigin);
128 
129  //need to add the track reference information for completeness
130  //because the overloaded fnc above does not make a trackRef
131  int deltaMissingHits = ctftk->trackerExpectedHitsInner().numberOfHits() - el_ctftrack->trackerExpectedHitsInner().numberOfHits();
132  convInfo = ConversionInfo(convInfo.dist(),
133  convInfo.dcot(),
134  convInfo.radiusOfConversion(),
135  convInfo.pointOfConversion(),
136  TrackRef(ctftracks_h, ctftk_i),
137  GsfTrackRef() ,
138  deltaMissingHits,
139  0);
140 
141  v_candidatePartners.push_back(convInfo);
142 
143  }//using the electron's CTF track
144 
145 
146  //now we check using the electron's gsf track
147  if(deltaR(el_gsftrack_p4, ctftk_p4) < 0.5 &&
148  (el_gsftrack->charge() + ctftk->charge() == 0) &&
149  el_gsftrack->ptError()/el_gsftrack->pt() < 0.25) {
150 
151  int deltaMissingHits = ctftk->trackerExpectedHitsInner().numberOfHits() - el_gsftrack->trackerExpectedHitsInner().numberOfHits();
152  ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_gsftrack.get()), &(*ctftk), bFieldAtOrigin);
153  convInfo = ConversionInfo(convInfo.dist(),
154  convInfo.dcot(),
155  convInfo.radiusOfConversion(),
156  convInfo.pointOfConversion(),
157  TrackRef(ctftracks_h, ctftk_i),
158  GsfTrackRef(),
159  deltaMissingHits,
160  1);
161 
162  v_candidatePartners.push_back(convInfo);
163  }//using the electron's GSF track
164 
165  }//loop over the CTF track collection
166 
167 
168  //------------------------------------------------------ Loop over GSF collection ----------------------------------//
169  for(GsfTrackCollection::const_iterator gsftk = gsftracks->begin();
170  gsftk != gsftracks->end(); gsftk++, gsftk_i++) {
171 
172  //reject the electron's own gsfTrack
173  if(gsfidx == gsftk_i)
174  continue;
175 
176  LorentzVector gsftk_p4 = LorentzVector(gsftk->px(), gsftk->py(), gsftk->pz(), gsftk->p());
177 
178  //apply quality cuts to remove bad tracks
179  if(gsftk->ptError()/gsftk->pt() > 0.5)
180  continue;
181  if(gsftk->numberOfValidHits() < 5)
182  continue;
183 
184  if(fabs(gsftk->pt() - el_gsftrack->pt())/el_gsftrack->pt() < 0.25)
185  continue;
186 
187  //try using the electron's CTF track first if it exists
188  //look only in a cone of 0.5 around the electron's track
189  //require opposite sign
190  if(el_ctftrack.isNonnull() && gsfElectron.ctfGsfOverlap() > minFracSharedHits &&
191  deltaR(el_ctftrack_p4, gsftk_p4) < 0.5 &&
192  (el_ctftrack->charge() + gsftk->charge() == 0)) {
193 
194  int deltaMissingHits = gsftk->trackerExpectedHitsInner().numberOfHits() - el_ctftrack->trackerExpectedHitsInner().numberOfHits();
195  ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_ctftrack.get()), (const reco::Track*)(&(*gsftk)), bFieldAtOrigin);
196  //fill the Ref info
197  convInfo = ConversionInfo(convInfo.dist(),
198  convInfo.dcot(),
199  convInfo.radiusOfConversion(),
200  convInfo.pointOfConversion(),
201  TrackRef(),
202  GsfTrackRef(gsftracks_h, gsftk_i),
203  deltaMissingHits,
204  2);
205  v_candidatePartners.push_back(convInfo);
206 
207  }
208 
209  //use the electron's gsf track
210  if(deltaR(el_gsftrack_p4, gsftk_p4) < 0.5 &&
211  (el_gsftrack->charge() + gsftk->charge() == 0) &&
212  (el_gsftrack->ptError()/el_gsftrack_p4.pt() < 0.5)) {
213  ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_gsftrack.get()), (const reco::Track*)(&(*gsftk)), bFieldAtOrigin);
214  //fill the Ref info
215 
216  int deltaMissingHits = gsftk->trackerExpectedHitsInner().numberOfHits() - el_gsftrack->trackerExpectedHitsInner().numberOfHits();
217  convInfo = ConversionInfo(convInfo.dist(),
218  convInfo.dcot(),
219  convInfo.radiusOfConversion(),
220  convInfo.pointOfConversion(),
221  TrackRef(),
222  GsfTrackRef(gsftracks_h, gsftk_i),
223  deltaMissingHits,
224  3);
225 
226  v_candidatePartners.push_back(convInfo);
227  }
228  }//loop over the gsf track collection
229 
230 
231  return v_candidatePartners;
232 
233 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
double radiusOfConversion() const
float ctfGsfOverlap() const
ProductID id() const
Definition: HandleBase.cc:15
ConversionInfo getConversionInfo(const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
math::XYZTLorentzVector LorentzVector
const GsfTrackRef & gsfTrack() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
double dist() const
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
math::XYZPoint pointOfConversion() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T const * product() const
Definition: Handle.h:81
TrackRef ctfTrack() const
double dcot() const
math::PtEtaPhiELorentzVectorF LorentzVector
const reco::Track * ConversionFinder::getElectronTrack ( const reco::GsfElectron electron,
const float  minFracSharedHits = 0.45 
)

Definition at line 285 of file ConversionFinder.cc.

References reco::GsfElectron::closestCtfTrackRef(), edm::Ref< C, T, F >::get(), reco::GsfElectron::gsfTrack(), edm::Ref< C, T, F >::isNonnull(), and reco::GsfElectron::shFracInnerHits().

Referenced by getConversionInfo().

285  {
286 
287  if(electron.closestCtfTrackRef().isNonnull() &&
288  electron.shFracInnerHits() > minFracSharedHits)
289  return (const reco::Track*)electron.closestCtfTrackRef().get();
290 
291  return (const reco::Track*)(electron.gsfTrack().get());
292 }
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:185
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float shFracInnerHits() const
Definition: GsfElectron.h:184
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
const reco::Track* ConversionFinder::getElectronTrack ( const reco::GsfElectronCore ,
const float  minFracSharedHits = 0.45 
)
bool ConversionFinder::isFromConversion ( const ConversionInfo convInfo,
double  maxAbsDist = 0.02,
double  maxAbsDcot = 0.02 
)

Definition at line 11 of file ConversionFinder.cc.

References funct::abs(), ConversionInfo::dcot(), ConversionInfo::dist(), and edm::false.

12  {
13  if ( (std::abs(convInfo.dist())<maxAbsDist) && (std::abs(convInfo.dcot())<maxAbsDcot) )
14  return true ;
15  return false ;
16  }
double dist() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double dcot() const
volatile std::atomic< bool > shutdown_flag false