CMS 3D CMS Logo

Typedefs | Functions
egammaTools Namespace Reference

Typedefs

typedef math::XYZTLorentzVector LorentzVector
 

Functions

ConversionInfo arbitrateConversionPartnersbyR (const std::vector< ConversionInfo > &v_convCandidates)
 
double ecalEta (const math::XYZVector &momentum, const math::XYZPoint &vertex)
 
double ecalPhi (const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
 
ConversionInfo findBestConversionMatch (const std::vector< ConversionInfo > &v_convCandidates)
 
ConversionInfo getConversionInfo (const reco::Track *el_track, const reco::Track *candPartnerTk, const double bFieldAtOrigin)
 
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::GsfElectron &gsfElectron, const edm::Handle< reco::TrackCollection > &track_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
 
std::pair< double, double > getConversionInfo (LorentzVector trk1_p4, int trk1_q, float trk1_d0, LorentzVector trk2_p4, int trk2_q, float trk2_d0, float bFieldAtOrigin)
 
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)
 
void localEcalClusterCoordsEB (const reco::CaloCluster &bclus, const CaloGeometry &geom, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt)
 
void localEcalClusterCoordsEE (const reco::CaloCluster &bclus, const CaloGeometry &geom, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt)
 
template<class Candidate >
void validateEgammaCandidate (Candidate const &candidate)
 
void validateGsfElectron (reco::GsfElectron const &electron)
 

Typedef Documentation

Definition at line 10 of file ConversionFinder.cc.

Function Documentation

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

Definition at line 304 of file ConversionFinder.cc.

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

Referenced by findBestConversionMatch().

304  {
305 
306  if(v_convCandidates.size() == 1)
307  return v_convCandidates.at(0);
308 
309  double R = sqrt(pow(v_convCandidates.at(0).dist,2) + pow(v_convCandidates.at(0).dcot,2));
310 
311  int iArbitrated = 0;
312  int i = 0;
313 
314  for(auto const& temp : v_convCandidates) {
315  double temp_R = sqrt(pow(temp.dist,2) + pow(temp.dcot,2));
316  if(temp_R < R) {
317  R = temp_R;
318  iArbitrated = i;
319  }
320  ++i;
321  }
322 
323  return v_convCandidates.at(iArbitrated);
324 
325  }
T sqrt(T t)
Definition: SSEVec.h:18
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double egammaTools::ecalEta ( const math::XYZVector momentum,
const math::XYZPoint vertex 
)

Definition at line 71 of file ECALPositionCalculator.cc.

References ETA, etaBarrelEndcap, cmsBatch::log, Geom::pi(), R_ECAL, funct::tan(), theta(), and Z_Endcap.

Referenced by ContainmentCorrectionAnalyzer::analyze(), and PreshowerAndECALLinker::testLink().

72 {
73 
74  // Get kinematic variables
75 
76  float etaParticle = momentum.eta();
77  float vZ = vertex.z();
78  float vRho = vertex.Rho();
79 
80  if (etaParticle != 0.0)
81  {
82  float theta = 0.0;
83  float zEcal = (R_ECAL-vRho)*sinh(etaParticle)+vZ;
84 
85  if(zEcal != 0.0) theta = atan(R_ECAL/zEcal);
86  if(theta < 0.0) theta = theta + Geom::pi() ;
87 
88  float ETA = - log(tan(0.5*theta));
89 
90  if( fabs(ETA) > etaBarrelEndcap )
91  {
92  float Zend = Z_Endcap ;
93  if(etaParticle < 0.0 ) Zend = - Zend;
94  float Zlen = Zend - vZ ;
95  float RR = Zlen/sinh(etaParticle);
96  theta = atan((RR+vRho)/Zend);
97  if(theta < 0.0) theta = theta+Geom::pi();
98  ETA = -log(tan(0.5*theta));
99  }
100  return ETA;
101 
102  } else {
103  edm::LogWarning("") << "[EcalPositionFromTrack::etaTransformation] Warning: "
104  << "Eta equals to zero, not correcting";
105  return etaParticle;
106  }
107 
108 }
Geom::Theta< T > theta() const
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static float etaBarrelEndcap
static float Z_Endcap
constexpr double pi()
Definition: Pi.h:31
static float R_ECAL
double egammaTools::ecalPhi ( const MagneticField magField,
const math::XYZVector momentum,
const math::XYZPoint vertex,
const int  charge 
)

Definition at line 16 of file ECALPositionCalculator.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, etaBarrelEndcap, MagneticField::inTesla(), Geom::pi(), Geom::twoPi(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk(), MuonMETAlgo::correctMETforMuon(), and PreshowerAndECALLinker::testLink().

17 {
18 
19  // Get kinematic variables
20 
21  float ptParticle = momentum.Rho();
22  float etaParticle = momentum.eta();
23  float phiParticle = momentum.phi();
24  float vRho = vertex.Rho();
25 
26  // Magnetic field
27 
28  const float RBARM = 1.357 ; // was 1.31 , updated on 16122003
29  const float ZENDM = 3.186 ; // was 3.15 , updated on 16122003
30 
31  float rbend = RBARM-(vRho/100.0); //Assumed vRho in cm
32  float bend = 0.3 * magField.inTesla(GlobalPoint(0.,0.,0.)).z() * rbend / 2.0;
33  float phi = 0.0;
34 
35  if( fabs(etaParticle) <= etaBarrelEndcap)
36  {
37  if (fabs(bend/ptParticle) <= 1.)
38  {
39  phi = phiParticle - asin(bend/ptParticle)*charge;
40  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
41  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
42  } else {
43  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
44  << "Too low Pt, giving up";
45  return phiParticle;
46  }
47 
48  } // end if in the barrel
49 
50  if(fabs(etaParticle) > etaBarrelEndcap)
51  {
52  float rHit = 0.0;
53  rHit = ZENDM / sinh(fabs(etaParticle));
54  if (fabs(((rHit-(vRho/100.0))/rbend)*bend/ptParticle) <= 1.0)
55  {
56  phi = phiParticle - asin(((rHit-(vRho/100.0)) / rbend)*bend/ptParticle)*charge;
57  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
58  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
59  } else {
60  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
61  << "Too low Pt, giving up";
62  return phiParticle;
63  }
64 
65  } // end if in the endcap
66 
67  return phi;
68 
69 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T z() const
Definition: PV3DBase.h:64
static float etaBarrelEndcap
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32
ConversionInfo egammaTools::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, mps_fire::i, funct::pow(), ConversionInfo::radiusOfConversion, mathSSE::sqrt(), and groupFilesInBlocks::temp.

Referenced by getConversionInfo().

329  {
330  using namespace std;
331 
332  if(v_convCandidates.empty())
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.empty())
397  return arbitrateConversionPartnersbyR(v_0);
398 
399  if(!v_1.empty())
400  return arbitrateConversionPartnersbyR(v_1);
401 
402  if(!v_2.empty())
403  return arbitrateConversionPartnersbyR(v_2);
404 
405  if(!v_3.empty())
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
const double dist
const int flag
T sqrt(T t)
Definition: SSEVec.h:18
const double radiusOfConversion
const double dcot
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:21
ConversionInfo arbitrateConversionPartnersbyR(const std::vector< ConversionInfo > &v_convCandidates)
const int deltaMissingHits
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ConversionInfo egammaTools::getConversionInfo ( const reco::Track el_track,
const reco::Track candPartnerTk,
const double  bFieldAtOrigin 
)

Definition at line 242 of file ConversionFinder.cc.

References reco::TrackBase::charge(), funct::cos(), edmIntegrityCheck::d, reco::TrackBase::d0(), reco::TrackBase::dz(), reco::TrackBase::p(), funct::pow(), reco::TrackBase::pt(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), funct::sin(), mathSSE::sqrt(), and funct::tan().

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

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

Referenced by GsfElectronAlgo::createElectron(), AdHocNTupler::fill(), ZeeCandidateFilter::filter(), getConversionInfos(), and ElectronConversionRejectionVars::produce().

42  {
43 
44  std::vector<ConversionInfo> temp = getConversionInfos(gsfElectron,ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
45  return findBestConversionMatch(temp);
46 
47 }
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 egammaTools::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 27 of file ConversionFinder.cc.

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

31  {
32 
33  std::vector<ConversionInfo> temp = getConversionInfos(*gsfElectron.core(),ctftracks_h,gsftracks_h,bFieldAtOrigin,minFracSharedHits) ;
34  return findBestConversionMatch(temp);
35 
36 }
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
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 egammaTools::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::TrackBase::charge(), reco::GsfElectron::closestCtfTrackRef(), funct::cos(), edmIntegrityCheck::d, reco::TrackBase::d0(), boostedElectronIsolation_cff::deltaR, reco::TrackBase::dz(), RemoveAddSevLevel::flag, getElectronTrack(), reco::TrackBase::hitPattern(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::numberOfLostHits(), reco::TrackBase::p(), funct::pow(), edm::Handle< T >::product(), reco::TrackBase::pt(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::GsfElectron::shFracInnerHits(), funct::sin(), mathSSE::sqrt(), and funct::tan().

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().numberOfLostHits(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
double p() const
momentum vector magnitude
Definition: TrackBase.h:654
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:205
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:636
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
key_type key() const
Accessor for product key.
Definition: Ref.h:263
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:666
math::XYZTLorentzVector LorentzVector
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:660
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
math::XYZTLorentzVector LorentzVector
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:678
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
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:648
float shFracInnerHits() const
Definition: GsfElectron.h:204
T const * product() const
Definition: Handle.h:74
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:485
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:21
int numberOfLostHits(HitCategory category) const
Definition: HitPattern.h:990
fixed size matrix
HLT enums.
int charge() const
track electric charge
Definition: TrackBase.h:606
const reco::Track * getElectronTrack(const reco::GsfElectronCore &, const float minFracSharedHits=0.45)
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:672
std::pair<double, double> egammaTools::getConversionInfo ( LorentzVector  trk1_p4,
int  trk1_q,
float  trk1_d0,
LorentzVector  trk2_p4,
int  trk2_q,
float  trk2_d0,
float  bFieldAtOrigin 
)

Definition at line 423 of file ConversionFinder.cc.

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

427  {
428 
429 
430  double tk1Curvature = -0.3*bFieldAtOrigin*(trk1_q/trk1_p4.pt())/100.;
431  double rTk1 = fabs(1./tk1Curvature);
432  double xTk1 = -1.*(1./tk1Curvature - trk1_d0)*sin(trk1_p4.phi());
433  double yTk1 = (1./tk1Curvature - trk1_d0)*cos(trk1_p4.phi());
434 
435 
436  double tk2Curvature = -0.3*bFieldAtOrigin*(trk2_q/trk2_p4.pt())/100.;
437  double rTk2 = fabs(1./tk2Curvature);
438  double xTk2 = -1.*(1./tk2Curvature - trk2_d0)*sin(trk2_p4.phi());
439  double yTk2 = (1./tk2Curvature - trk2_d0)*cos(trk2_p4.phi());
440 
441 
442  double dist = sqrt(pow(xTk1-xTk2, 2) + pow(yTk1-yTk2 , 2));
443  dist = dist - (rTk1 + rTk2);
444 
445  double dcot = 1./tan(trk1_p4.theta()) - 1./tan(trk2_p4.theta());
446 
447  return std::make_pair(dist, dcot);
448 
449  }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
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
std::vector< ConversionInfo > egammaTools::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 51 of file ConversionFinder.cc.

References reco::GsfElectronCore::ctfGsfOverlap(), reco::GsfElectronCore::ctfTrack(), ConversionInfo::dcot, boostedElectronIsolation_cff::deltaR, ConversionInfo::dist, edm::Ref< C, T, F >::get(), getConversionInfo(), reco::GsfElectronCore::gsfTrack(), edm::HandleBase::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), reco::HitPattern::MISSING_INNER_HITS, ConversionInfo::pointOfConversion, edm::Handle< T >::product(), and ConversionInfo::radiusOfConversion.

Referenced by getConversionInfo().

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

Definition at line 290 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().

290  {
291 
292  if(electron.closestCtfTrackRef().isNonnull() &&
293  electron.shFracInnerHits() > minFracSharedHits)
294  return (const reco::Track*)electron.closestCtfTrackRef().get();
295 
296  return (const reco::Track*)(electron.gsfTrack().get());
297 }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:205
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
float shFracInnerHits() const
Definition: GsfElectron.h:204
const reco::Track* egammaTools::getElectronTrack ( const reco::GsfElectronCore ,
const float  minFracSharedHits = 0.45 
)
bool egammaTools::isFromConversion ( const ConversionInfo convInfo,
double  maxAbsDist = 0.02,
double  maxAbsDcot = 0.02 
)

Definition at line 20 of file ConversionFinder.cc.

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

22 {
23  return (std::abs(convInfo.dist) < maxAbsDist) && (std::abs(convInfo.dcot) < maxAbsDcot);
24 }
const double dist
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const double dcot
void egammaTools::localEcalClusterCoordsEB ( const reco::CaloCluster bclus,
const CaloGeometry geom,
float &  etacry,
float &  phicry,
int &  ieta,
int &  iphi,
float &  thetatilt,
float &  phitilt 
)

Definition at line 14 of file EcalClusterLocal.cc.

References reco::deltaR(), egammaForCoreTracking_cff::depth, runTauDisplay::dr, DetId::Ecal, EcalBarrel, reco::CaloCluster::energy(), reco::tau::disc::Eta(), PV3DBase< T, PVType, FrameType >::eta(), plotBeamSpotDB::first, relativeConstraints::geom, TruncatedPyramid::getPhiAxis(), TruncatedPyramid::getPosition(), CaloGeometry::getSubdetectorGeometry(), TruncatedPyramid::getThetaAxis(), reco::CaloCluster::hitsAndFractions(), EBDetId::ieta(), EBDetId::iphi(), cmsBatch::log, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), Pi, reco::CaloCluster::position(), PV3DBase< T, PVType, FrameType >::theta(), and X0.

Referenced by EGEnergyCorrector::CorrectedEnergyWithError(), EGEnergyCorrector::CorrectedEnergyWithErrorV3(), EcalRegressionData::fill(), EGRegressionModifierV3::getSeedCrysCoord(), SuperClusterHelper::localCoordinates(), EGRegressionModifierV2::modifyObject(), and EGRegressionModifierV1::modifyObject().

16 {
17 
18  assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalBarrel);
19 
20  const CaloSubdetectorGeometry* geom=caloGeometry.getSubdetectorGeometry(DetId::Ecal,EcalBarrel);//EcalBarrel = 1
21 
22  const math::XYZPoint& position_ = bclus.position();
23  double Theta = -position_.theta()+0.5*TMath::Pi();
24  double Eta = position_.eta();
25  double Phi = TVector2::Phi_mpi_pi(position_.phi());
26 
27  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
28  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
29  const float X0 = 0.89; const float T0 = 7.4;
30  double depth = X0 * (T0 + log(bclus.energy()));
31 
32  //find max energy crystal
33  std::vector< std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
34  float drmin = 999.;
35  EBDetId crystalseed;
36  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
37  for (unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
38 
39  EBDetId crystal(crystals_vector[icry].first);
40 
41  auto cell=geom->getGeometry(crystal);
42  const TruncatedPyramid* cpyr = dynamic_cast<const TruncatedPyramid*>(cell.get());
43  GlobalPoint center_pos = cpyr->getPosition(depth);
44  double EtaCentr = center_pos.eta();
45  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
46 
47  float dr = reco::deltaR(Eta,Phi,EtaCentr,PhiCentr);
48  if (dr<drmin) {
49  drmin = dr;
50  crystalseed = crystal;
51  }
52 
53  }
54 
55  ieta = crystalseed.ieta();
56  iphi = crystalseed.iphi();
57 
58  // Get center cell position from shower depth
59  auto cell=geom->getGeometry(crystalseed);
60  const TruncatedPyramid* cpyr = dynamic_cast<const TruncatedPyramid*>(cell.get());
61 
62  thetatilt = cpyr->getThetaAxis();
63  phitilt = cpyr->getPhiAxis();
64 
65  GlobalPoint center_pos = cpyr->getPosition(depth);
66 
67  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
68  double PhiWidth = (TMath::Pi()/180.);
69  phicry = (TVector2::Phi_mpi_pi(Phi-PhiCentr))/PhiWidth;
70  //Some flips to take into account ECAL barrel symmetries:
71  if (ieta<0) phicry *= -1.;
72 
73  double ThetaCentr = -center_pos.theta()+0.5*TMath::Pi();
74  double ThetaWidth = (TMath::Pi()/180.)*TMath::Cos(ThetaCentr);
75  etacry = (Theta-ThetaCentr)/ThetaWidth;
76  //flip to take into account ECAL barrel symmetries:
77  if (ieta<0) etacry *= -1.;
78 
79  return;
80 
81 }
const double Pi
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
GlobalPoint getPosition(CCGFloat depth) const override
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
CCGFloat getPhiAxis() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
double energy() const
cluster energy
Definition: CaloCluster.h:126
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
CCGFloat getThetaAxis() const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
T eta() const
Definition: PV3DBase.h:76
static const double X0
void egammaTools::localEcalClusterCoordsEE ( const reco::CaloCluster bclus,
const CaloGeometry geom,
float &  xcry,
float &  ycry,
int &  ix,
int &  iy,
float &  thetatilt,
float &  phitilt 
)

Definition at line 83 of file EcalClusterLocal.cc.

References Abs(), reco::deltaR(), egammaForCoreTracking_cff::depth, runTauDisplay::dr, DetId::Ecal, EcalEndcap, reco::CaloCluster::energy(), reco::tau::disc::Eta(), PV3DBase< T, PVType, FrameType >::eta(), reco::CaloCluster::eta(), plotBeamSpotDB::first, relativeConstraints::geom, TruncatedPyramid::getPhiAxis(), TruncatedPyramid::getPosition(), CaloGeometry::getSubdetectorGeometry(), TruncatedPyramid::getThetaAxis(), reco::CaloCluster::hitsAndFractions(), EEDetId::ix(), EEDetId::iy(), cmsBatch::log, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), reco::CaloCluster::position(), X, PV3DBase< T, PVType, FrameType >::x(), X0, DOFs::Y, and PV3DBase< T, PVType, FrameType >::y().

Referenced by EcalRegressionData::fill(), EGRegressionModifierV3::getSeedCrysCoord(), SuperClusterHelper::localCoordinates(), EGRegressionModifierV2::modifyObject(), and EGRegressionModifierV1::modifyObject().

85 {
86 
87  assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalEndcap);
88 
89  const CaloSubdetectorGeometry* geom=caloGeometry.getSubdetectorGeometry(DetId::Ecal,EcalEndcap);//EcalBarrel = 1
90 
91  const math::XYZPoint& position_ = bclus.position();
92  //double Theta = -position_.theta()+0.5*TMath::Pi();
93  double Eta = position_.eta();
94  double Phi = TVector2::Phi_mpi_pi(position_.phi());
95  double X = position_.x();
96  double Y = position_.y();
97 
98  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
99  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
100  const float X0 = 0.89; float T0 = 1.2;
101  //different T0 value if outside of preshower coverage
102  if (TMath::Abs(bclus.eta())<1.653) T0 = 3.1;
103 
104  double depth = X0 * (T0 + log(bclus.energy()));
105 
106  //find max energy crystal
107  std::vector< std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
108  float drmin = 999.;
109  EEDetId crystalseed;
110  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
111  for (unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
112 
113  EEDetId crystal(crystals_vector[icry].first);
114 
115  auto cell=geom->getGeometry(crystal);
116  const TruncatedPyramid* cpyr = dynamic_cast<const TruncatedPyramid*>(cell.get());
117  GlobalPoint center_pos = cpyr->getPosition(depth);
118  double EtaCentr = center_pos.eta();
119  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
120 
121  float dr = reco::deltaR(Eta,Phi,EtaCentr,PhiCentr);
122  if (dr<drmin) {
123  drmin = dr;
124  crystalseed = crystal;
125  }
126 
127  }
128 
129  ix = crystalseed.ix();
130  iy = crystalseed.iy();
131 
132  // Get center cell position from shower depth
133  auto cell=geom->getGeometry(crystalseed);
134  const TruncatedPyramid* cpyr = dynamic_cast<const TruncatedPyramid*>(cell.get());
135 
136  thetatilt = cpyr->getThetaAxis();
137  phitilt = cpyr->getPhiAxis();
138 
139  GlobalPoint center_pos = cpyr->getPosition(depth);
140 
141  double XCentr = center_pos.x();
142  double XWidth = 2.59;
143  xcry = (X-XCentr)/XWidth;
144 
145 
146  double YCentr = center_pos.y();
147  double YWidth = 2.59;
148  ycry = (Y-YCentr)/YWidth;
149 
150  return;
151 
152 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
GlobalPoint getPosition(CCGFloat depth) const override
int ix() const
Definition: EEDetId.h:77
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
#define X(str)
Definition: MuonsGrabber.cc:48
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
CCGFloat getPhiAxis() const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:168
T Abs(T a)
Definition: MathUtil.h:49
double energy() const
cluster energy
Definition: CaloCluster.h:126
int iy() const
Definition: EEDetId.h:83
CCGFloat getThetaAxis() const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
T eta() const
Definition: PV3DBase.h:76
static const double X0
T x() const
Definition: PV3DBase.h:62
template<class Candidate >
void egammaTools::validateEgammaCandidate ( Candidate const &  candidate)

Definition at line 11 of file validateEgammaCandidate.h.

References constexpr, and validateGsfElectron().

Referenced by MVAValueMapProducer< ParticleType >::produce().

11  {
12  if constexpr (std::is_same<Candidate, reco::GsfElectron>()) {
13  validateGsfElectron(candidate);
14  }
15  }
void validateGsfElectron(reco::GsfElectron const &electron)
#define constexpr
void egammaTools::validateGsfElectron ( reco::GsfElectron const &  electron)

Definition at line 5 of file validateEgammaCandidate.cc.

References reco::GsfElectron::convVtxFitProb(), and Exception.

Referenced by validateEgammaCandidate().

5  {
6  if (electron.convVtxFitProb() > 1.0f) {
7  throw cms::Exception("EgammaError")
8  << "invalid value " << electron.convVtxFitProb() << " for reco::GsfElectron.conversionRejection_.vtxFitProb\n"
9  << "It should be either beween 0.0f and 1.0f or negative in case no matching conversion was found.\n"
10  << "Probably you need to update the electron collection with the EG9X105XObjectUpdateModifier plugin:\n"
11  << "see PhysicsTools/NanoAOD/python/electrons_cff.py for an example.\n";
12  }
13 }