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 17 of file ConversionFinder.cc.

17 {}
ConversionFinder::~ConversionFinder ( )

Definition at line 20 of file ConversionFinder.cc.

20 {}

Member Function Documentation

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

Definition at line 305 of file ConversionFinder.cc.

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

Referenced by findBestConversionMatch().

305  {
306 
307  if(v_convCandidates.size() == 1)
308  return v_convCandidates.at(0);
309 
310  ConversionInfo arbitratedConvInfo = v_convCandidates.at(0);
311  double R = sqrt(pow(arbitratedConvInfo.dist(),2) + pow(arbitratedConvInfo.dcot(),2));
312 
313  for(unsigned int i = 1; i < v_convCandidates.size(); i++) {
314  ConversionInfo temp = v_convCandidates.at(i);
315  double temp_R = sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2));
316  if(temp_R < R) {
317  R = temp_R;
318  arbitratedConvInfo = temp;
319  }
320 
321  }
322 
323  return arbitratedConvInfo;
324 
325  }
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 328 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().

329  {
330  using namespace std;
331 
332  if(v_convCandidates.size() == 0)
333  return ConversionInfo(-9999.,-9999.,-9999.,
334  math::XYZPoint(-9999.,-9999.,-9999),
336  -9999, -9999);
337 
338 
339  if(v_convCandidates.size() == 1)
340  return v_convCandidates.at(0);
341 
342  vector<ConversionInfo> v_0;
343  vector<ConversionInfo> v_1;
344  vector<ConversionInfo> v_2;
345  vector<ConversionInfo> v_3;
346  //loop over the candidates
347  for(unsigned int i = 1; i < v_convCandidates.size(); i++) {
348  ConversionInfo temp = v_convCandidates.at(i);
349 
350  if(temp.flag() == 0) {
351  bool isConv = false;
352  if(fabs(temp.dist()) < 0.02 &&
353  fabs(temp.dcot()) < 0.02 &&
354  temp.deltaMissingHits() < 3 &&
355  temp.radiusOfConversion() > -2)
356  isConv = true;
357  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 &&
358  temp.deltaMissingHits() < 2 &&
359  temp.radiusOfConversion() > -2)
360  isConv = true;
361 
362  if(isConv)
363  v_0.push_back(temp);
364  }
365 
366  if(temp.flag() == 1) {
367 
368  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 &&
369  temp.deltaMissingHits() < 2 &&
370  temp.radiusOfConversion() > -2)
371  v_1.push_back(temp);
372  }
373  if(temp.flag() == 2) {
374 
375  if(sqrt(pow(temp.dist(),2) + pow(temp.dcot()*temp.dcot(),2)) < 0.05 &&
376  temp.deltaMissingHits() < 2 &&
377  temp.radiusOfConversion() > -2)
378  v_2.push_back(temp);
379 
380  }
381  if(temp.flag() == 3) {
382 
383  if(sqrt(temp.dist()*temp.dist() + temp.dcot()*temp.dcot()) < 0.05
384  && temp.deltaMissingHits() < 2
385  && temp.radiusOfConversion() > -2)
386  v_3.push_back(temp);
387 
388  }
389 
390  }//candidate conversion loop
391 
392  //now do some arbitration
393 
394  //give preference to conversion partners found in the CTF collection
395  //using the electron's CTF track
396  if(v_0.size() > 0)
397  return arbitrateConversionPartnersbyR(v_0);
398 
399  if(v_1.size() > 0)
400  return arbitrateConversionPartnersbyR(v_1);
401 
402  if(v_2.size() > 0)
403  return arbitrateConversionPartnersbyR(v_2);
404 
405  if(v_3.size() > 0)
406  return arbitrateConversionPartnersbyR(v_3);
407 
408 
409  //if we get here, we didn't find a candidate conversion partner that
410  //satisfied even the loose selections
411  //return the the closest partner by R
412  return arbitrateConversionPartnersbyR(v_convCandidates);
413 
414  }
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:19
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 34 of file ConversionFinder.cc.

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

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

38  {
39 
40  std::vector<ConversionInfo> temp = getConversionInfos(gsfElectron,ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
41  return findBestConversionMatch(temp);
42 
43 }
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 23 of file ConversionFinder.cc.

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

27  {
28 
29  std::vector<ConversionInfo> temp = getConversionInfos(*gsfElectron.core(),ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
30  return findBestConversionMatch(temp);
31 
32 }
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 243 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.

245  {
246 
247  using namespace reco;
248 
249  //now calculate the conversion related information
250  LorentzVector el_tk_p4(el_track->px(), el_track->py(), el_track->pz(), el_track->p());
251  double elCurvature = -0.3*bFieldAtOrigin*(el_track->charge()/el_tk_p4.pt())/100.;
252  double rEl = fabs(1./elCurvature);
253  double xEl = -1*(1./elCurvature - el_track->d0())*sin(el_tk_p4.phi());
254  double yEl = (1./elCurvature - el_track->d0())*cos(el_tk_p4.phi());
255 
256 
257  LorentzVector cand_p4 = LorentzVector(candPartnerTk->px(), candPartnerTk->py(),candPartnerTk->pz(), candPartnerTk->p());
258  double candCurvature = -0.3*bFieldAtOrigin*(candPartnerTk->charge()/cand_p4.pt())/100.;
259  double rCand = fabs(1./candCurvature);
260  double xCand = -1*(1./candCurvature - candPartnerTk->d0())*sin(cand_p4.phi());
261  double yCand = (1./candCurvature - candPartnerTk->d0())*cos(cand_p4.phi());
262 
263  double d = sqrt(pow(xEl-xCand, 2) + pow(yEl-yCand , 2));
264  double dist = d - (rEl + rCand);
265  double dcot = 1./tan(el_tk_p4.theta()) - 1./tan(cand_p4.theta());
266 
267  //get the point of conversion
268  double xa1 = xEl + (xCand-xEl) * rEl/d;
269  double xa2 = xCand + (xEl-xCand) * rCand/d;
270  double ya1 = yEl + (yCand-yEl) * rEl/d;
271  double ya2 = yCand + (yEl-yCand) * rCand/d;
272 
273  double x=.5*(xa1+xa2);
274  double y=.5*(ya1+ya2);
275  double rconv = sqrt(pow(x,2) + pow(y,2));
276  double z = el_track->dz() + rEl*el_track->pz()*TMath::ACos(1-pow(rconv,2)/(2.*pow(rEl,2)))/el_track->pt();
277 
278  math::XYZPoint convPoint(x, y, z);
279 
280  //now assign a sign to the radius of conversion
281  float tempsign = el_track->px()*x + el_track->py()*y;
282  tempsign = tempsign/fabs(tempsign);
283  rconv = tempsign*rconv;
284 
285  //return an instance of ConversionInfo, but with a NULL track refs
286  return ConversionInfo(dist, dcot, rconv, convPoint, TrackRef(), GsfTrackRef(), -9999, -9999);
287 
288 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
double p() const
momentum vector magnitude
Definition: TrackBase.h:663
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:645
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:675
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:669
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:687
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:657
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:19
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
int charge() const
track electric charge
Definition: TrackBase.h:615
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:681
math::PtEtaPhiELorentzVectorF LorentzVector
static 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
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 453 of file ConversionFinder.cc.

References reco::GsfElectron::closestCtfTrackRef(), funct::cos(), deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, archive::flag, getElectronTrack(), reco::HitPattern::MISSING_INNER_HITS, 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.

456  {
457 
458 
459  using namespace reco;
460  using namespace std;
461  using namespace edm;
462 
463 
464  const TrackCollection *ctftracks = track_h.product();
465  const reco::TrackRef el_ctftrack = gsfElectron.closestCtfTrackRef();
466  int ctfidx = -999.;
467  int flag = -9999.;
468  if(el_ctftrack.isNonnull() && gsfElectron.shFracInnerHits() > minFracSharedHits) {
469  ctfidx = static_cast<int>(el_ctftrack.key());
470  flag = 0;
471  } else
472  flag = 1;
473 
474 
475  /*
476  determine whether we're going to use the CTF track or the GSF track
477  using the electron's CTF track to find the dist, dcot has been shown
478  to reduce the inefficiency
479  */
480  const reco::Track* el_track = getElectronTrack(gsfElectron, minFracSharedHits);
481  LorentzVector el_tk_p4(el_track->px(), el_track->py(), el_track->pz(), el_track->p());
482 
483 
484  int tk_i = 0;
485  double mindcot = 9999.;
486  //make a null Track Ref
487  TrackRef candCtfTrackRef = TrackRef() ;
488 
489 
490  for(TrackCollection::const_iterator tk = ctftracks->begin();
491  tk != ctftracks->end(); tk++, tk_i++) {
492  //if the general Track is the same one as made by the electron, skip it
493  if((tk_i == ctfidx))
494  continue;
495 
496  LorentzVector tk_p4 = LorentzVector(tk->px(), tk->py(),tk->pz(), tk->p());
497 
498  //look only in a cone of 0.5
499  double dR = deltaR(el_tk_p4, tk_p4);
500  if(dR>0.5)
501  continue;
502 
503 
504  //require opp. sign -> Should we use the majority logic??
505  if(tk->charge() + el_track->charge() != 0)
506  continue;
507 
508  double dcot = fabs(1./tan(tk_p4.theta()) - 1./tan(el_tk_p4.theta()));
509  if(dcot < mindcot) {
510  mindcot = dcot;
511  candCtfTrackRef = reco::TrackRef(track_h, tk_i);
512  }
513  }//track loop
514 
515 
516  if(!candCtfTrackRef.isNonnull())
517  return ConversionInfo(-9999.,-9999.,-9999.,
518  math::XYZPoint(-9999.,-9999.,-9999),
520  -9999, -9999);
521 
522 
523 
524  //now calculate the conversion related information
525  double elCurvature = -0.3*bFieldAtOrigin*(el_track->charge()/el_tk_p4.pt())/100.;
526  double rEl = fabs(1./elCurvature);
527  double xEl = -1*(1./elCurvature - el_track->d0())*sin(el_tk_p4.phi());
528  double yEl = (1./elCurvature - el_track->d0())*cos(el_tk_p4.phi());
529 
530 
531  LorentzVector cand_p4 = LorentzVector(candCtfTrackRef->px(), candCtfTrackRef->py(),candCtfTrackRef->pz(), candCtfTrackRef->p());
532  double candCurvature = -0.3*bFieldAtOrigin*(candCtfTrackRef->charge()/cand_p4.pt())/100.;
533  double rCand = fabs(1./candCurvature);
534  double xCand = -1*(1./candCurvature - candCtfTrackRef->d0())*sin(cand_p4.phi());
535  double yCand = (1./candCurvature - candCtfTrackRef->d0())*cos(cand_p4.phi());
536 
537  double d = sqrt(pow(xEl-xCand, 2) + pow(yEl-yCand , 2));
538  double dist = d - (rEl + rCand);
539  double dcot = 1./tan(el_tk_p4.theta()) - 1./tan(cand_p4.theta());
540 
541  //get the point of conversion
542  double xa1 = xEl + (xCand-xEl) * rEl/d;
543  double xa2 = xCand + (xEl-xCand) * rCand/d;
544  double ya1 = yEl + (yCand-yEl) * rEl/d;
545  double ya2 = yCand + (yEl-yCand) * rCand/d;
546 
547  double x=.5*(xa1+xa2);
548  double y=.5*(ya1+ya2);
549  double rconv = sqrt(pow(x,2) + pow(y,2));
550  double z = el_track->dz() + rEl*el_track->pz()*TMath::ACos(1-pow(rconv,2)/(2.*pow(rEl,2)))/el_track->pt();
551 
552  math::XYZPoint convPoint(x, y, z);
553 
554  //now assign a sign to the radius of conversion
555  float tempsign = el_track->px()*x + el_track->py()*y;
556  tempsign = tempsign/fabs(tempsign);
557  rconv = tempsign*rconv;
558 
559  int deltaMissingHits = -9999;
560 
561  deltaMissingHits = candCtfTrackRef->hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS)
562  - el_track->hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS);
563 
564  return ConversionInfo(dist, dcot, rconv, convPoint, candCtfTrackRef, GsfTrackRef(), deltaMissingHits, flag);
565 
566  }
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
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
float float float z
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
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:198
T const * product() const
Definition: Handle.h:81
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:19
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
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 47 of file ConversionFinder.cc.

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

Referenced by getConversionInfo().

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

291  {
292 
293  if(electron.closestCtfTrackRef().isNonnull() &&
294  electron.shFracInnerHits() > minFracSharedHits)
295  return (const reco::Track*)electron.closestCtfTrackRef().get();
296 
297  return (const reco::Track*)(electron.gsfTrack().get());
298 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
float shFracInnerHits() const
Definition: GsfElectron.h:198
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
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 10 of file ConversionFinder.cc.

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

12 {
13  return (std::abs(convInfo.dist()) < maxAbsDist) && (std::abs(convInfo.dcot()) < maxAbsDcot);
14 }
double dist() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double dcot() const