CMS 3D CMS Logo

Classes | Functions
egamma Namespace Reference

Classes

struct  ElectronMomentum
 

Functions

float classBasedElectronEnergy (reco::GsfElectron const &, reco::BeamSpot const &, EcalClusterFunctionBaseClass const &crackCorrectionFunction)
 
double classBasedElectronEnergyUncertainty (reco::GsfElectron const &)
 
reco::GsfElectron::Classification classifyElectron (reco::GsfElectron const &)
 
ElectronMomentum correctElectronMomentum (reco::GsfElectron const &, TrajectoryStateOnSurface const &)
 
double electronEnergyUncertainty (reco::GsfElectron::Classification c, double eta, double brem, double energy)
 
std::pair< reco::TrackRef, float > getClosestCtfToGsf (reco::GsfTrackRef const &, edm::Handle< reco::TrackCollection > const &ctfTracksH)
 
template<typename T >
uint32_t getRandomSeedFromObj (const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
 
uint32_t getRandomSeedFromSC (const edm::Event &iEvent, const reco::SuperClusterRef scRef)
 
bool isBetterElectron (reco::GsfElectron const &, reco::GsfElectron const &)
 
bool isInnermostElectron (reco::GsfElectron const &, reco::GsfElectron const &)
 
int sharedDets (reco::GsfTrackRef const &, reco::GsfTrackRef const &)
 
int sharedDets (const GsfTrackRef &gsfTrackRef1, const GsfTrackRef &gsfTrackRef2)
 
float sharedEnergy (reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
 
float sharedEnergy (reco::SuperClusterRef const &sc1, reco::SuperClusterRef const &sc2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
 
int sharedHits (reco::GsfTrackRef const &, reco::GsfTrackRef const &)
 
int sharedHits (const GsfTrackRef &gsfTrackRef1, const GsfTrackRef &gsfTrackRef2)
 
double simpleElectronEnergyUncertainty (reco::GsfElectron const &)
 

Function Documentation

float egamma::classBasedElectronEnergy ( reco::GsfElectron const &  electron,
reco::BeamSpot const &  bs,
EcalClusterFunctionBaseClass const &  crackCorrectionFunction 
)

Definition at line 296 of file ElectronEnergyCorrector.cc.

References reco::GsfElectron::classification(), corr, EgHLTOffHistBins_cfi::et, hcaldqm::quantity::fEnergy, EcalClusterFunctionBaseClass::getValue(), reco::GsfElectron::isEB(), reco::GsfElectron::isEE(), and reco::GsfElectron::superCluster().

Referenced by GsfElectronAlgo::createElectron().

298  {
299  auto elClass = electron.classification();
300 
301  // new corrections from N. Chanon et al., taken from EcalClusterCorrectionObjectSpecific.cc
302  float corr = 1.;
303  float corr2 = 1.;
304  float energy = electron.superCluster()->energy();
305 
306  //int subdet = electron.superCluster()->seed()->hitsAndFractions()[0].first.subdetId();
307 
308  if (electron.isEB()) {
309  float cetacorr = fEta(electron.superCluster()->rawEnergy(), electron.superCluster()->eta(), 0) /
310  electron.superCluster()->rawEnergy();
311  energy = electron.superCluster()->rawEnergy() * cetacorr; //previously in CMSSW
312  //energy = superCluster.rawEnergy()*fEta(e5x5, superCluster.seed()->eta(), 0)/e5x5;
313  } else if (electron.isEE()) {
314  energy = electron.superCluster()->rawEnergy() + electron.superCluster()->preshowerEnergy();
315  } else {
316  edm::LogWarning("ElectronEnergyCorrector::classBasedParameterizationEnergy")
317  << "nor barrel neither endcap electron !";
318  }
319 
320  corr = fBremEta(electron.superCluster()->phiWidth() / electron.superCluster()->etaWidth(),
321  electron.superCluster()->eta(),
322  0,
323  elClass);
324 
325  float et = energy * TMath::Sin(2 * TMath::ATan(TMath::Exp(-electron.superCluster()->eta()))) / corr;
326 
327  if (electron.isEB()) {
328  corr2 = corr * fEt(et, 0, elClass);
329  } else if (electron.isEE()) {
330  corr2 = corr * fEnergy(energy / corr, 1, elClass);
331  } else {
332  edm::LogWarning("ElectronEnergyCorrector::classBasedParameterizationEnergy")
333  << "nor barrel neither endcap electron !";
334  }
335 
336  float newEnergy = energy / corr2;
337 
338  // cracks
339  double crackcor = 1.;
340  for (reco::CaloCluster_iterator cIt = electron.superCluster()->clustersBegin();
341  cIt != electron.superCluster()->clustersEnd();
342  ++cIt) {
343  const reco::CaloClusterPtr cc = *cIt;
344  crackcor *= (electron.superCluster()->rawEnergy() + cc->energy() * (crackCorrectionFunction.getValue(*cc) - 1.)) /
345  electron.superCluster()->rawEnergy();
346  }
347  newEnergy *= crackcor;
348 
349  return newEnergy;
350 }
JetCorrectorParameters corr
Definition: classes.h:5
double egamma::classBasedElectronEnergyUncertainty ( reco::GsfElectron const &  electron)

Definition at line 271 of file ElectronEnergyCorrector.cc.

References reco::GsfElectron::classification(), reco::GsfElectron::correctedEcalEnergy(), electronEnergyUncertainty(), and reco::GsfElectron::superCluster().

Referenced by GsfElectronAlgo::createElectron().

271  {
272  double ecalEnergy = electron.correctedEcalEnergy();
273  double eleEta = electron.superCluster()->eta();
274  double brem = electron.superCluster()->etaWidth() / electron.superCluster()->phiWidth();
275  return egamma::electronEnergyUncertainty(electron.classification(), eleEta, brem, ecalEnergy);
276 }
double electronEnergyUncertainty(reco::GsfElectron::Classification c, double eta, double brem, double energy)
reco::GsfElectron::Classification egamma::classifyElectron ( reco::GsfElectron const &  )
egamma::ElectronMomentum egamma::correctElectronMomentum ( reco::GsfElectron const &  electron,
TrajectoryStateOnSurface const &  vtxTsos 
)

Definition at line 23 of file ElectronMomentumCorrector.cc.

References reco::GsfElectron::BADTRACK, reco::GsfElectron::BIGBREM, reco::GsfElectron::classification(), reco::GsfElectron::correctedEcalEnergy(), reco::GsfElectron::correctedEcalEnergyError(), EgHLTOffHistBins_cfi::eOverP, reco::GsfElectron::GAP, reco::GsfElectron::GOLDEN, reco::GsfElectron::isEB(), reco::GsfElectron::isEE(), GaussianSumUtilities1D::mode(), MultiGaussianStateTransform::multiState1D(), reco::GsfElectron::p4(), Scenarios_cff::scale, reco::GsfElectron::SHOWERING, mathSSE::sqrt(), reco::btau::trackMomentum, reco::GsfElectron::trackMomentumAtVtx(), and SingleGaussianState1D::variance().

Referenced by GsfElectronAlgo::createElectron().

24  {
25  int elClass = electron.classification();
26 
27  //=======================================================================================
28  // cluster energy
29  //=======================================================================================
30 
31  float scEnergy = electron.correctedEcalEnergy();
32  float errorEnergy = electron.correctedEcalEnergyError();
33 
34  //=======================================================================================
35  // track momentum
36  //=======================================================================================
37 
38  // basic values
39  float trackMomentum = electron.trackMomentumAtVtx().R();
40  //float errorTrackMomentum = 999. ;
41 
42  // tracker momentum scale corrections (Mykhailo Dalchenko)
43  double scale = 1.;
44  if (electron.isEB()) {
45  if (elClass == 0) {
46  scale = 1. / (0.00104 * sqrt(trackMomentum) + 1);
47  }
48  if (elClass == 1) {
49  scale = 1. / (0.0017 * sqrt(trackMomentum) + 0.9986);
50  }
51  if (elClass == 3) {
52  scale = 1. / (1.004 - 0.00021 * trackMomentum);
53  }
54  if (elClass == 4) {
55  scale = 0.995;
56  }
57  } else if (electron.isEE()) {
58  if (elClass == 3) {
59  scale = 1. / (1.01432 - 0.00201872 * trackMomentum + 0.0000142621 * trackMomentum * trackMomentum);
60  }
61  if (elClass == 4) {
62  scale = 1. / (0.996859 - 0.000345347 * trackMomentum);
63  }
64  }
65  if (scale < 0.)
66  scale = 1.; // CC added protection
67  trackMomentum = trackMomentum * scale;
68 
69  // error (must be done after trackMomentum rescaling)
71  GaussianSumUtilities1D qpUtils(qpState);
72  float errorTrackMomentum = trackMomentum * trackMomentum * sqrt(qpUtils.mode().variance());
73 
74  //=======================================================================================
75  // combination
76  //=======================================================================================
77 
78  float finalMomentum = electron.p4().t(); // initial
79  float finalMomentumError = 999.;
80 
81  // first check for large errors
82 
83  if (errorTrackMomentum / trackMomentum > 0.5 && errorEnergy / scEnergy <= 0.5) {
84  finalMomentum = scEnergy;
85  finalMomentumError = errorEnergy;
86  } else if (errorTrackMomentum / trackMomentum <= 0.5 && errorEnergy / scEnergy > 0.5) {
87  finalMomentum = trackMomentum;
88  finalMomentumError = errorTrackMomentum;
89  } else if (errorTrackMomentum / trackMomentum > 0.5 && errorEnergy / scEnergy > 0.5) {
90  if (errorTrackMomentum / trackMomentum < errorEnergy / scEnergy) {
91  finalMomentum = trackMomentum;
92  finalMomentumError = errorTrackMomentum;
93  } else {
94  finalMomentum = scEnergy;
95  finalMomentumError = errorEnergy;
96  }
97  }
98 
99  // then apply the combination algorithm
100  else {
101  // calculate E/p and corresponding error
102  float eOverP = scEnergy / trackMomentum;
103  float errorEOverP = sqrt((errorEnergy / trackMomentum) * (errorEnergy / trackMomentum) +
104  (scEnergy * errorTrackMomentum / trackMomentum / trackMomentum) *
105  (scEnergy * errorTrackMomentum / trackMomentum / trackMomentum));
106 
107  bool eleIsNotInCombination = false;
108  if ((eOverP > 1 + 2.5 * errorEOverP) || (eOverP < 1 - 2.5 * errorEOverP) || (eOverP < 0.8) || (eOverP > 1.3)) {
109  eleIsNotInCombination = true;
110  }
111  if (eleIsNotInCombination) {
112  if (eOverP > 1) {
113  finalMomentum = scEnergy;
114  finalMomentumError = errorEnergy;
115  } else {
116  if (elClass == reco::GsfElectron::GOLDEN) {
117  finalMomentum = scEnergy;
118  finalMomentumError = errorEnergy;
119  }
120  if (elClass == reco::GsfElectron::BIGBREM) {
121  if (scEnergy < 36) {
122  finalMomentum = trackMomentum;
123  finalMomentumError = errorTrackMomentum;
124  } else {
125  finalMomentum = scEnergy;
126  finalMomentumError = errorEnergy;
127  }
128  }
129  if (elClass == reco::GsfElectron::BADTRACK) {
130  finalMomentum = scEnergy;
131  finalMomentumError = errorEnergy;
132  }
133  if (elClass == reco::GsfElectron::SHOWERING) {
134  if (scEnergy < 30) {
135  finalMomentum = trackMomentum;
136  finalMomentumError = errorTrackMomentum;
137  } else {
138  finalMomentum = scEnergy;
139  finalMomentumError = errorEnergy;
140  }
141  }
142  if (elClass == reco::GsfElectron::GAP) {
143  if (scEnergy < 60) {
144  finalMomentum = trackMomentum;
145  finalMomentumError = errorTrackMomentum;
146  } else {
147  finalMomentum = scEnergy;
148  finalMomentumError = errorEnergy;
149  }
150  }
151  }
152  }
153 
154  else {
155  // combination
156  finalMomentum = (scEnergy / errorEnergy / errorEnergy + trackMomentum / errorTrackMomentum / errorTrackMomentum) /
157  (1 / errorEnergy / errorEnergy + 1 / errorTrackMomentum / errorTrackMomentum);
158  float finalMomentumVariance = 1 / (1 / errorEnergy / errorEnergy + 1 / errorTrackMomentum / errorTrackMomentum);
159  finalMomentumError = sqrt(finalMomentumVariance);
160  }
161  }
162 
163  //=======================================================================================
164  // final set
165  //=======================================================================================
166 
167  auto const& oldMomentum = electron.p4();
168 
169  return {{oldMomentum.x() * finalMomentum / oldMomentum.t(),
170  oldMomentum.y() * finalMomentum / oldMomentum.t(),
171  oldMomentum.z() * finalMomentum / oldMomentum.t(),
172  finalMomentum},
173  errorTrackMomentum,
174  finalMomentumError};
175 }
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
T sqrt(T t)
Definition: SSEVec.h:19
double egamma::electronEnergyUncertainty ( reco::GsfElectron::Classification  c,
double  eta,
double  brem,
double  energy 
)

Definition at line 402 of file EnergyUncertaintyElectronSpecific.cc.

References Exception.

Referenced by classBasedElectronEnergyUncertainty().

402  {
403  if (c == GsfElectron::GOLDEN)
404  return computeEnergyUncertaintyGolden(eta, brem, energy);
405  if (c == GsfElectron::BIGBREM)
406  return computeEnergyUncertaintyBigbrem(eta, brem, energy);
407  if (c == GsfElectron::SHOWERING)
408  return computeEnergyUncertaintyShowering(eta, brem, energy);
409  if (c == GsfElectron::BADTRACK)
410  return computeEnergyUncertaintyBadTrack(eta, brem, energy);
411  if (c == GsfElectron::GAP)
412  return computeEnergyUncertaintyCracks(eta, brem, energy);
413  throw cms::Exception("GsfElectronAlgo|InternalError") << "unknown classification";
414 }
std::pair< TrackRef, float > egamma::getClosestCtfToGsf ( reco::GsfTrackRef const &  gsfTrackRef,
edm::Handle< reco::TrackCollection > const &  ctfTracksH 
)

Definition at line 17 of file GsfElectronTools.cc.

References funct::abs(), TrackingRecHit::all, HLT_2018_cff::dEta, HLT_2018_cff::dPhi, reco::HitPattern::getHitPattern(), reco::HitPattern::hitPattern, min(), pi, reco::HitPattern::pixelHitFilter(), edm::Handle< T >::product(), mathSSE::sqrt(), reco::HitPattern::stripTIBHitFilter(), reco::HitPattern::stripTIDHitFilter(), and reco::HitPattern::TRACK_HITS.

Referenced by GsfElectronAlgo::createElectron(), and GsfElectronCoreBaseProducer::fillElectronCore().

18  {
19  float maxFracShared = 0;
20  TrackRef ctfTrackRef = TrackRef();
21  const TrackCollection* ctfTrackCollection = ctfTracksH.product();
22 
23  // get the Hit Pattern for the gsfTrack
24  const HitPattern& gsfHitPattern = gsfTrackRef->hitPattern();
25 
26  unsigned int counter = 0;
27  for (auto ctfTkIter = ctfTrackCollection->begin(); ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++) {
28  double dEta = gsfTrackRef->eta() - ctfTkIter->eta();
29  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi();
30  double pi = acos(-1.);
31  if (std::abs(dPhi) > pi)
32  dPhi = 2 * pi - std::abs(dPhi);
33 
34  // dont want to look at every single track in the event!
35  if (sqrt(dEta * dEta + dPhi * dPhi) > 0.3)
36  continue;
37 
38  unsigned int shared = 0;
39  int gsfHitCounter = 0;
40  int numGsfInnerHits = 0;
41  int numCtfInnerHits = 0;
42  // get the CTF Track Hit Pattern
43  const HitPattern& ctfHitPattern = ctfTkIter->hitPattern();
44 
45  for (auto elHitsIt = gsfTrackRef->recHitsBegin(); elHitsIt != gsfTrackRef->recHitsEnd();
46  elHitsIt++, gsfHitCounter++) {
47  if (!((**elHitsIt).isValid())) //count only valid Hits
48  {
49  continue;
50  }
51 
52  // look only in the pixels/TIB/TID
53  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter);
54  if (!(HitPattern::pixelHitFilter(gsfHit) || HitPattern::stripTIBHitFilter(gsfHit) ||
55  HitPattern::stripTIDHitFilter(gsfHit))) {
56  continue;
57  }
58 
59  numGsfInnerHits++;
60 
61  int ctfHitsCounter = 0;
62  numCtfInnerHits = 0;
63  for (auto ctfHitsIt = ctfTkIter->recHitsBegin(); ctfHitsIt != ctfTkIter->recHitsEnd();
64  ctfHitsIt++, ctfHitsCounter++) {
65  if (!((**ctfHitsIt).isValid())) //count only valid Hits!
66  {
67  continue;
68  }
69 
70  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
71  if (!(HitPattern::pixelHitFilter(ctfHit) || HitPattern::stripTIBHitFilter(ctfHit) ||
72  HitPattern::stripTIDHitFilter(ctfHit))) {
73  continue;
74  }
75 
76  numCtfInnerHits++;
77 
78  if ((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all)) {
79  shared++;
80  break;
81  }
82 
83  } //ctfHits iterator
84 
85  } //gsfHits iterator
86 
87  if ((numGsfInnerHits == 0) || (numCtfInnerHits == 0)) {
88  continue;
89  }
90 
91  if (static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits) > maxFracShared) {
92  maxFracShared = static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits);
93  ctfTrackRef = TrackRef(ctfTracksH, counter);
94  }
95 
96  } //ctfTrack iterator
97 
98  return make_pair(ctfTrackRef, maxFracShared);
99  }
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
const Double_t pi
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:491
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
T const * product() const
Definition: Handle.h:69
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
template<typename T >
uint32_t egamma::getRandomSeedFromObj ( const edm::Event iEvent,
const T obj,
size_t  nrObjs,
size_t  objNr 
)

Definition at line 21 of file EgammaRandomSeeds.h.

References edm::EventID::event(), edm::EventBase::id(), createfilelist::int, edm::EventID::luminosityBlock(), M_PI, SiStripPI::max, edm::EventID::run(), and SurveyInfoScenario_cff::seed.

Referenced by CalibratedPhotonProducerT< T >::setSemiDetRandomSeed(), and CalibratedElectronProducerT< T >::setSemiDetRandomSeed().

21  {
22  std::seed_seq seeder = {int(iEvent.id().event()),
23  int(iEvent.id().luminosityBlock()),
24  int(iEvent.id().run()),
25  int(nrObjs),
26  int(std::numeric_limits<int>::max() * obj.phi() / M_PI) & 0xFFF,
27  int(objNr)};
28  uint32_t seed = 0, tries = 10;
29  do {
30  seeder.generate(&seed, &seed + 1);
31  tries++;
32  } while (seed == 0 && tries < 10);
33  return seed ? seed : iEvent.id().event() + 10000 * objNr;
34  }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
#define M_PI
edm::EventID id() const
Definition: EventBase.h:59
uint32_t egamma::getRandomSeedFromSC ( const edm::Event iEvent,
const reco::SuperClusterRef  scRef 
)

Definition at line 5 of file EgammaRandomSeeds.cc.

References edm::EventID::event(), edm::EventBase::id(), createfilelist::int, edm::Ref< C, T, F >::key(), edm::EventID::luminosityBlock(), hltrates_dqm_sourceclient-live_cfg::offset, edm::EventID::run(), and SurveyInfoScenario_cff::seed.

Referenced by CalibratedPhotonProducerT< T >::setSemiDetRandomSeed(), and CalibratedElectronProducerT< T >::setSemiDetRandomSeed().

5  {
6  const int offset = 0; //for future expansion
7  std::seed_seq seeder = {int(iEvent.id().event()),
8  int(iEvent.id().luminosityBlock()),
9  int(iEvent.id().run()),
10  int(scRef->seed()->seed().rawId()),
11  int(scRef->seed()->hitsAndFractions().size()),
12  offset};
13  uint32_t seed = 0, tries = 10;
14  do {
15  seeder.generate(&seed, &seed + 1);
16  tries++;
17  } while (seed == 0 && tries < 10);
18  return seed ? seed : iEvent.id().event() + 10000 * scRef.key();
19 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
key_type key() const
Accessor for product key.
Definition: Ref.h:250
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
edm::EventID id() const
Definition: EventBase.h:59
bool egamma::isBetterElectron ( reco::GsfElectron const &  e1,
reco::GsfElectron const &  e2 
)

Definition at line 16 of file EgAmbiguityTools.cc.

References funct::abs(), and reco::GsfElectron::eSuperClusterOverP().

Referenced by isInnermostElectron(), and GsfElectronBaseProducer::setAmbiguityData().

16  {
17  return (std::abs(e1.eSuperClusterOverP() - 1) < std::abs(e2.eSuperClusterOverP() - 1));
18  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool egamma::isInnermostElectron ( reco::GsfElectron const &  e1,
reco::GsfElectron const &  e2 
)

Definition at line 20 of file EgAmbiguityTools.cc.

References reco::GsfElectron::gsfTrack(), and isBetterElectron().

Referenced by GsfElectronBaseProducer::setAmbiguityData().

20  {
21  // retreive first valid hit
22  int gsfHitCounter1 = 0;
23  for (auto const& elHit : e1.gsfTrack()->recHits()) {
24  if (elHit->isValid())
25  break;
26  gsfHitCounter1++;
27  }
28 
29  int gsfHitCounter2 = 0;
30  for (auto const& elHit : e2.gsfTrack()->recHits()) {
31  if (elHit->isValid())
32  break;
33  gsfHitCounter2++;
34  }
35 
36  uint32_t gsfHit1 = e1.gsfTrack()->hitPattern().getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
37  uint32_t gsfHit2 = e2.gsfTrack()->hitPattern().getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2);
38 
39  if (HitPattern::getSubStructure(gsfHit1) != HitPattern::getSubStructure(gsfHit2)) {
40  return (HitPattern::getSubStructure(gsfHit1) < HitPattern::getSubStructure(gsfHit2));
41  } else if (HitPattern::getLayer(gsfHit1) != HitPattern::getLayer(gsfHit2)) {
42  return (HitPattern::getLayer(gsfHit1) < HitPattern::getLayer(gsfHit2));
43  } else {
44  return isBetterElectron(e1, e2);
45  }
46  }
bool isBetterElectron(reco::GsfElectron const &, reco::GsfElectron const &)
int egamma::sharedDets ( reco::GsfTrackRef const &  ,
reco::GsfTrackRef const &   
)
int egamma::sharedDets ( const GsfTrackRef gsfTrackRef1,
const GsfTrackRef gsfTrackRef2 
)

Definition at line 95 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern().

95  {
96  //get the Hit Pattern for the gsfTracks
97  const HitPattern& gsfHitPattern1 = gsfTrackRef1->hitPattern();
98  const HitPattern& gsfHitPattern2 = gsfTrackRef2->hitPattern();
99 
100  unsigned int shared = 0;
101 
102  int gsfHitCounter1 = 0;
103  for (trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin(); elHitsIt1 != gsfTrackRef1->recHitsEnd();
104  elHitsIt1++, gsfHitCounter1++) {
105  if (!((**elHitsIt1).isValid())) {
106  //count only valid Hits
107  continue;
108  }
109  //if (gsfHitCounter1>1) continue; // to test only the first hit of the track 1
110  uint32_t gsfHit = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
111  if (!(HitPattern::pixelHitFilter(gsfHit) || HitPattern::stripTIBHitFilter(gsfHit) ||
112  HitPattern::stripTOBHitFilter(gsfHit) || HitPattern::stripTECHitFilter(gsfHit) ||
113  HitPattern::stripTIDHitFilter(gsfHit))) {
114  continue;
115  }
116 
117  int gsfHitsCounter2 = 0;
118  for (trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin(); gsfHitsIt2 != gsfTrackRef2->recHitsEnd();
119  gsfHitsIt2++, gsfHitsCounter2++) {
120  if (!((**gsfHitsIt2).isValid())) {
121  //count only valid Hits!
122  continue;
123  }
124 
125  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitsCounter2);
126  if (!(HitPattern::pixelHitFilter(gsfHit2) || HitPattern::stripTIBHitFilter(gsfHit2) ||
127  HitPattern::stripTOBHitFilter(gsfHit2) || HitPattern::stripTECHitFilter(gsfHit2) ||
128  HitPattern::stripTIDHitFilter(gsfHit2)))
129  continue;
130  if ((**elHitsIt1).geographicalId() == (**gsfHitsIt2).geographicalId())
131  shared++;
132  } //gsfHits2 iterator
133  } //gsfHits1 iterator
134 
135  //std::cout << "[sharedHits] number of shared dets " << shared << std::endl;
136  //return shared/min(gsfTrackRef1->numberOfValidHits(),gsfTrackRef2->numberOfValidHits());
137  return shared;
138  }
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
float egamma::sharedEnergy ( reco::CaloCluster const &  clu1,
reco::CaloCluster const &  clu2,
EcalRecHitCollection const &  barrelRecHits,
EcalRecHitCollection const &  endcapRecHits 
)

Definition at line 140 of file EgAmbiguityTools.cc.

References EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), HLT_2018_cff::fractionShared, and reco::CaloCluster::hitsAndFractions().

Referenced by RealisticHitToClusterAssociator::findAndMergeInvisibleClusters(), GsfElectronBaseProducer::setAmbiguityData(), and sharedEnergy().

143  {
144  double fractionShared = 0;
145 
146  for (auto const& h1 : clu1.hitsAndFractions()) {
147  for (auto const& h2 : clu2.hitsAndFractions()) {
148  if (h1.first != h2.first)
149  continue;
150 
151  // here we have common Xtal id
153  if (h1.first.subdetId() == EcalBarrel) {
154  if ((itt = barrelRecHits.find(h1.first)) != barrelRecHits.end())
155  fractionShared += itt->energy();
156  } else if (h1.first.subdetId() == EcalEndcap) {
157  if ((itt = endcapRecHits.find(h1.first)) != endcapRecHits.end())
158  fractionShared += itt->energy();
159  }
160  }
161  }
162 
163  //std::cout << "[sharedEnergy] shared energy /min(energy1,energy2) " << fractionShared << std::endl;
164  return fractionShared;
165  }
std::vector< EcalRecHit >::const_iterator const_iterator
float egamma::sharedEnergy ( reco::SuperClusterRef const &  sc1,
reco::SuperClusterRef const &  sc2,
EcalRecHitCollection const &  barrelRecHits,
EcalRecHitCollection const &  endcapRecHits 
)

Definition at line 167 of file EgAmbiguityTools.cc.

References sharedEnergy().

170  {
171  double energyShared = 0;
172  for (CaloCluster_iterator icl1 = sc1->clustersBegin(); icl1 != sc1->clustersEnd(); icl1++) {
173  for (CaloCluster_iterator icl2 = sc2->clustersBegin(); icl2 != sc2->clustersEnd(); icl2++) {
174  energyShared += sharedEnergy(**icl1, **icl2, barrelRecHits, endcapRecHits);
175  }
176  }
177  return energyShared;
178  }
float sharedEnergy(reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
int egamma::sharedHits ( reco::GsfTrackRef const &  ,
reco::GsfTrackRef const &   
)
int egamma::sharedHits ( const GsfTrackRef gsfTrackRef1,
const GsfTrackRef gsfTrackRef2 
)

Definition at line 48 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern(), and TrackingRecHit::some.

48  {
49  //get the Hit Pattern for the gsfTracks
50  HitPattern const& gsfHitPattern1 = gsfTrackRef1->hitPattern();
51  HitPattern const& gsfHitPattern2 = gsfTrackRef2->hitPattern();
52 
53  unsigned int shared = 0;
54 
55  int gsfHitCounter1 = 0;
56  for (trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin(); elHitsIt1 != gsfTrackRef1->recHitsEnd();
57  elHitsIt1++, gsfHitCounter1++) {
58  if (!(*elHitsIt1)->isValid()) {
59  //count only valid Hits
60  continue;
61  }
62  //if (gsfHitCounter1>1) continue; // test only the first hit of the track 1
63  uint32_t gsfHit = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
64  if (!(HitPattern::pixelHitFilter(gsfHit) || HitPattern::stripTIBHitFilter(gsfHit) ||
65  HitPattern::stripTOBHitFilter(gsfHit) || HitPattern::stripTECHitFilter(gsfHit) ||
66  HitPattern::stripTIDHitFilter(gsfHit))) {
67  continue;
68  }
69 
70  int gsfHitsCounter2 = 0;
71  for (trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin(); gsfHitsIt2 != gsfTrackRef2->recHitsEnd();
72  gsfHitsIt2++, gsfHitsCounter2++) {
73  if (!(**gsfHitsIt2).isValid()) {
74  //count only valid Hits
75  continue;
76  }
77  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitsCounter2);
78  if (!(HitPattern::pixelHitFilter(gsfHit2) || HitPattern::stripTIBHitFilter(gsfHit2) ||
79  HitPattern::stripTOBHitFilter(gsfHit2) || HitPattern::stripTECHitFilter(gsfHit2) ||
80  HitPattern::stripTIDHitFilter(gsfHit2))) {
81  continue;
82  }
83  if ((*elHitsIt1)->sharesInput(&(**gsfHitsIt2), TrackingRecHit::some)) {
84  //if (comp.equals(&(**elHitsIt1),&(**gsfHitsIt2))) {
86  shared++;
87  }
88  } //gsfHits2 iterator
89  } //gsfHits1 iterator
90 
91  //std::cout << "[sharedHits] number of shared hits " << shared << std::endl;
92  return shared;
93  }
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
double egamma::simpleElectronEnergyUncertainty ( reco::GsfElectron const &  electron)

Definition at line 278 of file ElectronEnergyCorrector.cc.

References reco::GsfElectron::correctedEcalEnergy(), relativeConstraints::error, reco::GsfElectron::isEB(), and reco::GsfElectron::isEE().

Referenced by GsfElectronAlgo::createElectron().

278  {
279  double error = 999.;
280  double ecalEnergy = electron.correctedEcalEnergy();
281 
282  if (electron.isEB()) {
283  float parEB[3] = {5.24e-02, 2.01e-01, 1.00e-02};
284  error = ecalEnergy * energyError(ecalEnergy, parEB);
285  } else if (electron.isEE()) {
286  float parEE[3] = {1.46e-01, 9.21e-01, 1.94e-03};
287  error = ecalEnergy * energyError(ecalEnergy, parEE);
288  } else {
289  edm::LogWarning("ElectronEnergyCorrector::simpleParameterizationUncertainty")
290  << "nor barrel neither endcap electron !";
291  }
292 
293  return error;
294 }