CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
TrackDetMatchInfo Class Reference

#include <TrackDetMatchInfo.h>

Public Types

enum  EnergyType {
  EcalRecHits, HcalRecHits, HORecHits, TowerTotal,
  TowerEcal, TowerHcal, TowerHO
}
 

Public Member Functions

double coneEnergy (double dR, EnergyType)
 
double crossedEnergy (EnergyType)
 energy in detector elements crossed by the track by types More...
 
std::string dumpGeometry (const DetId &)
 
double ecalConeEnergy ()
 
double ecalCrossedEnergy ()
 
double ecalEnergy ()
 
double ecalTowerConeEnergy ()
 
double ecalTowerEnergy ()
 
DetId findMaxDeposition (EnergyType)
 Find detector elements with highest energy deposition. More...
 
DetId findMaxDeposition (EnergyType, int gridSize)
 
DetId findMaxDeposition (const DetId &, EnergyType, int gridSize)
 
GlobalPoint getPosition (const DetId &)
 
double hcalConeEnergy ()
 
double hcalCrossedEnergy ()
 
double hcalEnergy ()
 
double hcalTowerConeEnergy ()
 
double hcalTowerEnergy ()
 
double hoConeEnergy ()
 
double hoCrossedEnergy ()
 
double hoEnergy ()
 
double hoTowerConeEnergy ()
 
double hoTowerEnergy ()
 
int numberOfSegments () const
 
int numberOfSegmentsInDetector (int detector) const
 
int numberOfSegmentsInStation (int station) const
 
int numberOfSegmentsInStation (int station, int detector) const
 
double nXnEnergy (const DetId &, EnergyType, int gridSize=1)
 get energy of the NxN shape (N = 2*gridSize + 1) around given detector element More...
 
double nXnEnergy (EnergyType, int gridSize=1)
 get energy of the NxN shape (N = 2*gridSize + 1) around track projection More...
 
void setCaloGeometry (const CaloGeometry *geometry)
 
 TrackDetMatchInfo ()
 

Public Attributes

std::vector< TAMuonChamberMatchchambers
 
std::vector< DetIdcrossedEcalIds
 
std::vector< const EcalRecHit * > crossedEcalRecHits
 hits in detector elements crossed by a track More...
 
std::vector< DetIdcrossedHcalIds
 
std::vector< const HBHERecHit * > crossedHcalRecHits
 
std::vector< DetIdcrossedHOIds
 
std::vector< const HORecHit * > crossedHORecHits
 
std::vector< DetIdcrossedPreshowerIds
 
std::vector< DetIdcrossedTowerIds
 
std::vector< const CaloTower * > crossedTowers
 
std::vector< const EcalRecHit * > ecalRecHits
 hits in the cone More...
 
double ecalTrueEnergy
 
std::vector< const HBHERecHit * > hcalRecHits
 
double hcalTrueEnergy
 
double hcalTrueEnergyCorrected
 
std::vector< const HORecHit * > hoRecHits
 
bool isGoodCalo
 
bool isGoodEcal
 
bool isGoodHcal
 
bool isGoodHO
 
bool isGoodMuon
 
const SimTracksimTrack
 MC truth info. More...
 
SimTrackRef simTrackRef_
 
FreeTrajectoryState stateAtIP
 track info More...
 
std::vector< const CaloTower * > towers
 
reco::TrackRef trackRef_
 
math::XYZPoint trkGlobPosAtEcal
 Track position at different parts of the calorimeter. More...
 
math::XYZPoint trkGlobPosAtHcal
 
math::XYZPoint trkGlobPosAtHO
 
GlobalVector trkMomAtEcal
 
GlobalVector trkMomAtHcal
 
GlobalVector trkMomAtHO
 

Private Member Functions

bool insideCone (const DetId &, const double)
 

Private Attributes

const CaloGeometrycaloGeometry
 

Detailed Description

Definition at line 13 of file TrackDetMatchInfo.h.

Member Enumeration Documentation

◆ EnergyType

Constructor & Destructor Documentation

◆ TrackDetMatchInfo()

TrackDetMatchInfo::TrackDetMatchInfo ( )

Definition at line 289 of file TrackDetMatchInfo.cc.

290  : trkGlobPosAtEcal(0, 0, 0),
291  trkGlobPosAtHcal(0, 0, 0),
292  trkGlobPosAtHO(0, 0, 0),
293  trkMomAtEcal(0, 0, 0),
294  trkMomAtHcal(0, 0, 0),
295  trkMomAtHO(0, 0, 0),
296  isGoodEcal(false),
297  isGoodHcal(false),
298  isGoodCalo(false),
299  isGoodHO(false),
300  isGoodMuon(false),
301  simTrack(nullptr),
302  ecalTrueEnergy(-999),
303  hcalTrueEnergy(-999) {}
math::XYZPoint trkGlobPosAtHO
math::XYZPoint trkGlobPosAtHcal
GlobalVector trkMomAtHO
GlobalVector trkMomAtEcal
GlobalVector trkMomAtHcal
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
const SimTrack * simTrack
MC truth info.

Member Function Documentation

◆ coneEnergy()

double TrackDetMatchInfo::coneEnergy ( double  dR,
EnergyType  type 
)

cone energy around the track direction at the origin (0,0,0) ( not well defined for tracks originating away from IP)

Definition at line 91 of file TrackDetMatchInfo.cc.

References crossedTowers, HGC3DClusterGenMatchSelector_cfi::dR, EcalRecHits, ecalRecHits, HCALHighEnergyHPDFilter_cfi::energy, Exception, HcalRecHits, hcalRecHits, HORecHits, hoRecHits, insideCone(), TowerEcal, TowerHcal, TowerHO, and TowerTotal.

Referenced by ecalConeEnergy(), ecalTowerConeEnergy(), hcalConeEnergy(), hcalTowerConeEnergy(), hoConeEnergy(), and hoTowerConeEnergy().

91  {
92  double energy(0);
93  switch (type) {
94  case EcalRecHits: {
95  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end(); hit++)
96  if (insideCone((*hit)->detid(), dR))
97  energy += (*hit)->energy();
98  } break;
99  case HcalRecHits: {
100  for (std::vector<const HBHERecHit*>::const_iterator hit = hcalRecHits.begin(); hit != hcalRecHits.end(); hit++)
101  if (insideCone((*hit)->detid(), dR))
102  energy += (*hit)->energy();
103  } break;
104  case HORecHits: {
105  for (std::vector<const HORecHit*>::const_iterator hit = hoRecHits.begin(); hit != hoRecHits.end(); hit++)
106  if (insideCone((*hit)->detid(), dR))
107  energy += (*hit)->energy();
108  } break;
109  case TowerTotal: {
110  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
111  if (insideCone((*hit)->id(), dR))
112  energy += (*hit)->energy();
113  } break;
114  case TowerEcal: {
115  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
116  if (insideCone((*hit)->id(), dR))
117  energy += (*hit)->emEnergy();
118  } break;
119  case TowerHcal: {
120  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
121  if (insideCone((*hit)->id(), dR))
122  energy += (*hit)->hadEnergy();
123  } break;
124  case TowerHO: {
125  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
126  if (insideCone((*hit)->id(), dR))
127  energy += (*hit)->outerEnergy();
128  } break;
129  default:
130  throw cms::Exception("FatalError") << "Unknown calo energy type: " << type;
131  }
132  return energy;
133 }
std::vector< const CaloTower * > crossedTowers
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
bool insideCone(const DetId &, const double)
std::vector< const HORecHit * > hoRecHits

◆ crossedEnergy()

double TrackDetMatchInfo::crossedEnergy ( EnergyType  type)

energy in detector elements crossed by the track by types

Definition at line 39 of file TrackDetMatchInfo.cc.

References crossedEcalRecHits, crossedHcalRecHits, crossedHORecHits, crossedTowers, EcalRecHits, HCALHighEnergyHPDFilter_cfi::energy, Exception, HcalRecHits, HORecHits, TowerEcal, TowerHcal, TowerHO, and TowerTotal.

Referenced by ecalCrossedEnergy(), ecalTowerEnergy(), hcalCrossedEnergy(), hcalTowerEnergy(), hoCrossedEnergy(), and hoTowerEnergy().

39  {
40  double energy(0);
41  switch (type) {
42  case EcalRecHits: {
43  for (std::vector<const EcalRecHit*>::const_iterator hit = crossedEcalRecHits.begin();
44  hit != crossedEcalRecHits.end();
45  hit++)
46  energy += (*hit)->energy();
47  } break;
48  case HcalRecHits: {
49  for (std::vector<const HBHERecHit*>::const_iterator hit = crossedHcalRecHits.begin();
50  hit != crossedHcalRecHits.end();
51  hit++)
52  energy += (*hit)->energy();
53  } break;
54  case HORecHits: {
55  for (std::vector<const HORecHit*>::const_iterator hit = crossedHORecHits.begin(); hit != crossedHORecHits.end();
56  hit++)
57  energy += (*hit)->energy();
58  } break;
59  case TowerTotal: {
60  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
61  energy += (*hit)->energy();
62  } break;
63  case TowerEcal: {
64  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
65  energy += (*hit)->emEnergy();
66  } break;
67  case TowerHcal: {
68  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
69  energy += (*hit)->hadEnergy();
70  } break;
71  case TowerHO: {
72  for (std::vector<const CaloTower*>::const_iterator hit = crossedTowers.begin(); hit != crossedTowers.end(); hit++)
73  energy += (*hit)->outerEnergy();
74  } break;
75  default:
76  throw cms::Exception("FatalError") << "Unknown calo energy type: " << type;
77  }
78  return energy;
79 }
std::vector< const CaloTower * > crossedTowers
std::vector< const HBHERecHit * > crossedHcalRecHits
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
std::vector< const HORecHit * > crossedHORecHits

◆ dumpGeometry()

std::string TrackDetMatchInfo::dumpGeometry ( const DetId id)

Definition at line 16 of file TrackDetMatchInfo.cc.

References caloGeometry, Exception, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), point, and hiPixelPairStep_cff::points.

16  {
19  throw cms::Exception("FatalError") << "Failed to access geometry for DetId: " << id.rawId();
20  }
21  std::ostringstream oss;
22 
25  oss << "(" << point->z() << ", " << point->perp() << ", " << point->eta() << ", " << point->phi() << "), \t";
26  return oss.str();
27 }
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const CaloGeometry * caloGeometry
MgrType::const_iterator const_iterator
Definition: EZArrayFL.h:24
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ ecalConeEnergy()

double TrackDetMatchInfo::ecalConeEnergy ( )

Definition at line 547 of file TrackDetMatchInfo.cc.

References coneEnergy(), and EcalRecHits.

547 { return coneEnergy(999, EcalRecHits); }
double coneEnergy(double dR, EnergyType)

◆ ecalCrossedEnergy()

double TrackDetMatchInfo::ecalCrossedEnergy ( )

Definition at line 553 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and EcalRecHits.

Referenced by ecalEnergy().

553 { return crossedEnergy(EcalRecHits); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ ecalEnergy()

double TrackDetMatchInfo::ecalEnergy ( )
inline

Definition at line 102 of file TrackDetMatchInfo.h.

References ecalCrossedEnergy().

102 { return ecalCrossedEnergy(); }

◆ ecalTowerConeEnergy()

double TrackDetMatchInfo::ecalTowerConeEnergy ( )
inline

Definition at line 96 of file TrackDetMatchInfo.h.

References coneEnergy(), and TowerEcal.

96 { return coneEnergy(999, TowerEcal); }
double coneEnergy(double dR, EnergyType)

◆ ecalTowerEnergy()

double TrackDetMatchInfo::ecalTowerEnergy ( )
inline

Definition at line 95 of file TrackDetMatchInfo.h.

References crossedEnergy(), and TowerEcal.

95 { return crossedEnergy(TowerEcal); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ findMaxDeposition() [1/3]

DetId TrackDetMatchInfo::findMaxDeposition ( EnergyType  type)

Find detector elements with highest energy deposition.

Definition at line 305 of file TrackDetMatchInfo.cc.

References EcalRecHits, ecalRecHits, HCALHighEnergyHPDFilter_cfi::energy, Exception, HcalRecHits, hcalRecHits, HORecHits, hoRecHits, l1ctLayer2EG_cff::id, particleFlowClusterECALTimeSelected_cfi::maxEnergy, TowerEcal, TowerHcal, TowerHO, towers, and TowerTotal.

Referenced by findMaxDeposition().

305  {
306  DetId id;
307  float maxEnergy = -9999;
308  switch (type) {
309  case EcalRecHits: {
310  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end(); hit++)
311  if ((*hit)->energy() > maxEnergy) {
312  maxEnergy = (*hit)->energy();
313  id = (*hit)->detid();
314  }
315  } break;
316  case HcalRecHits: {
317  for (std::vector<const HBHERecHit*>::const_iterator hit = hcalRecHits.begin(); hit != hcalRecHits.end(); hit++)
318  if ((*hit)->energy() > maxEnergy) {
319  maxEnergy = (*hit)->energy();
320  id = (*hit)->detid();
321  }
322  } break;
323  case HORecHits: {
324  for (std::vector<const HORecHit*>::const_iterator hit = hoRecHits.begin(); hit != hoRecHits.end(); hit++)
325  if ((*hit)->energy() > maxEnergy) {
326  maxEnergy = (*hit)->energy();
327  id = (*hit)->detid();
328  }
329  } break;
330  case TowerTotal:
331  case TowerEcal:
332  case TowerHcal:
333  case TowerHO: {
334  for (std::vector<const CaloTower*>::const_iterator hit = towers.begin(); hit != towers.end(); hit++) {
335  double energy = 0;
336  switch (type) {
337  case TowerTotal:
338  energy = (*hit)->energy();
339  break;
340  case TowerEcal:
341  energy = (*hit)->emEnergy();
342  break;
343  case TowerHcal:
344  energy = (*hit)->hadEnergy();
345  break;
346  case TowerHO:
347  energy = (*hit)->energy();
348  break;
349  default:
350  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
351  }
352  if (energy > maxEnergy) {
353  maxEnergy = energy;
354  id = (*hit)->id();
355  }
356  }
357  } break;
358  default:
359  throw cms::Exception("FatalError")
360  << "Maximal energy deposition: unkown or not implemented energy type requested, type:" << type;
361  }
362  return id;
363 }
std::vector< const CaloTower * > towers
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
Definition: DetId.h:17
std::vector< const HORecHit * > hoRecHits

◆ findMaxDeposition() [2/3]

DetId TrackDetMatchInfo::findMaxDeposition ( EnergyType  type,
int  gridSize 
)

Definition at line 511 of file TrackDetMatchInfo.cc.

References crossedEcalIds, crossedHcalIds, crossedHOIds, crossedTowerIds, EcalRecHits, Exception, findMaxDeposition(), HcalRecHits, HORecHits, TowerEcal, TowerHcal, TowerHO, and TowerTotal.

511  {
512  DetId id_max;
513  switch (type) {
514  case TowerTotal:
515  case TowerHcal:
516  case TowerEcal:
517  case TowerHO:
518  if (crossedTowerIds.empty())
519  return id_max;
520  return findMaxDeposition(crossedTowerIds.front(), type, gridSize);
521  break;
522  case EcalRecHits:
523  if (crossedEcalIds.empty())
524  return id_max;
525  return findMaxDeposition(crossedEcalIds.front(), type, gridSize);
526  break;
527  case HcalRecHits:
528  if (crossedHcalIds.empty())
529  return id_max;
530  return findMaxDeposition(crossedHcalIds.front(), type, gridSize);
531  break;
532  case HORecHits:
533  if (crossedHOIds.empty())
534  return id_max;
535  return findMaxDeposition(crossedHOIds.front(), type, gridSize);
536  break;
537  default:
538  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
539  }
540  return id_max;
541 }
std::vector< DetId > crossedTowerIds
std::vector< DetId > crossedEcalIds
DetId findMaxDeposition(EnergyType)
Find detector elements with highest energy deposition.
std::vector< DetId > crossedHcalIds
std::vector< DetId > crossedHOIds
Definition: DetId.h:17

◆ findMaxDeposition() [3/3]

DetId TrackDetMatchInfo::findMaxDeposition ( const DetId id,
EnergyType  type,
int  gridSize 
)

Definition at line 365 of file TrackDetMatchInfo.cc.

References funct::abs(), DetId::Calo, HLT_2023v12_cff::dEta, HLT_2023v12_cff::dPhi, DetId::Ecal, EcalBarrel, EcalEndcap, EcalRecHits, ecalRecHits, Exception, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, HcalRecHits, hcalRecHits, HORecHits, hoRecHits, CaloTowerDetId::ieta(), EBDetId::ieta(), HcalDetId::ieta(), DetIdInfo::info(), CaloTowerDetId::iphi(), EBDetId::iphi(), HcalDetId::iphi(), EEDetId::ix(), EEDetId::iy(), TowerEcal, TowerHcal, TowerHO, towers, TowerTotal, and EEDetId::zside().

365  {
366  double energy_max(0);
367  DetId id_max;
368  if (id.rawId() == 0)
369  return id_max;
370  switch (type) {
371  case TowerTotal:
372  case TowerHcal:
373  case TowerEcal:
374  case TowerHO: {
375  if (id.det() != DetId::Calo) {
376  throw cms::Exception("FatalError") << "Wrong DetId. Expected CaloTower, but found:\n"
377  << DetIdInfo::info(id, nullptr) << "\n";
378  }
379  CaloTowerDetId centerId(id);
380  for (std::vector<const CaloTower*>::const_iterator hit = towers.begin(); hit != towers.end(); hit++) {
381  CaloTowerDetId neighborId((*hit)->id());
382  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
383  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
384  int dPhi = abs(centerId.iphi() - neighborId.iphi());
385  if (abs(72 - dPhi) < dPhi)
386  dPhi = 72 - dPhi;
387  if (dEta <= gridSize && dPhi <= gridSize) {
388  switch (type) {
389  case TowerTotal:
390  if (energy_max < (*hit)->energy()) {
391  energy_max = (*hit)->energy();
392  id_max = (*hit)->id();
393  }
394  break;
395  case TowerEcal:
396  if (energy_max < (*hit)->emEnergy()) {
397  energy_max = (*hit)->emEnergy();
398  id_max = (*hit)->id();
399  }
400  break;
401  case TowerHcal:
402  if (energy_max < (*hit)->hadEnergy()) {
403  energy_max = (*hit)->hadEnergy();
404  id_max = (*hit)->id();
405  }
406  break;
407  case TowerHO:
408  if (energy_max < (*hit)->outerEnergy()) {
409  energy_max = (*hit)->outerEnergy();
410  id_max = (*hit)->id();
411  }
412  break;
413  default:
414  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
415  }
416  }
417  }
418  } break;
419  case EcalRecHits: {
420  if (id.det() != DetId::Ecal || (id.subdetId() != EcalBarrel && id.subdetId() != EcalEndcap)) {
421  throw cms::Exception("FatalError") << "Wrong DetId. Expected EcalBarrel or EcalEndcap, but found:\n"
422  << DetIdInfo::info(id, nullptr) << "\n";
423  }
424  // Since the ECAL granularity is small and the gap between EE and EB is significant,
425  // energy is computed only within the system that contains the central element
426  if (id.subdetId() == EcalBarrel) {
427  EBDetId centerId(id);
428  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end();
429  hit++) {
430  if ((*hit)->id().subdetId() != EcalBarrel)
431  continue;
432  EBDetId neighborId((*hit)->id());
433  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
434  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
435  int dPhi = abs(centerId.iphi() - neighborId.iphi());
436  if (abs(360 - dPhi) < dPhi)
437  dPhi = 360 - dPhi;
438  if (dEta <= gridSize && dPhi <= gridSize) {
439  if (energy_max < (*hit)->energy()) {
440  energy_max = (*hit)->energy();
441  id_max = (*hit)->id();
442  }
443  }
444  }
445  } else {
446  // Endcap
447  EEDetId centerId(id);
448  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end();
449  hit++) {
450  if ((*hit)->id().subdetId() != EcalEndcap)
451  continue;
452  EEDetId neighborId((*hit)->id());
453  if (centerId.zside() == neighborId.zside() && abs(centerId.ix() - neighborId.ix()) <= gridSize &&
454  abs(centerId.iy() - neighborId.iy()) <= gridSize) {
455  if (energy_max < (*hit)->energy()) {
456  energy_max = (*hit)->energy();
457  id_max = (*hit)->id();
458  }
459  }
460  }
461  }
462  } break;
463  case HcalRecHits: {
464  if (id.det() != DetId::Hcal || (id.subdetId() != HcalBarrel && id.subdetId() != HcalEndcap)) {
465  throw cms::Exception("FatalError") << "Wrong DetId. Expected HE or HB, but found:\n"
466  << DetIdInfo::info(id, nullptr) << "\n";
467  }
468  HcalDetId centerId(id);
469  for (std::vector<const HBHERecHit*>::const_iterator hit = hcalRecHits.begin(); hit != hcalRecHits.end(); hit++) {
470  HcalDetId neighborId((*hit)->id());
471  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
472  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
473  int dPhi = abs(centerId.iphi() - neighborId.iphi());
474  if (abs(72 - dPhi) < dPhi)
475  dPhi = 72 - dPhi;
476  if (dEta <= gridSize && dPhi <= gridSize) {
477  if (energy_max < (*hit)->energy()) {
478  energy_max = (*hit)->energy();
479  id_max = (*hit)->id();
480  }
481  }
482  }
483  } break;
484  case HORecHits: {
485  if (id.det() != DetId::Hcal || (id.subdetId() != HcalOuter)) {
486  throw cms::Exception("FatalError") << "Wrong DetId. Expected HO, but found:\n"
487  << DetIdInfo::info(id, nullptr) << "\n";
488  }
489  HcalDetId centerId(id);
490  for (std::vector<const HORecHit*>::const_iterator hit = hoRecHits.begin(); hit != hoRecHits.end(); hit++) {
491  HcalDetId neighborId((*hit)->id());
492  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
493  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
494  int dPhi = abs(centerId.iphi() - neighborId.iphi());
495  if (abs(72 - dPhi) < dPhi)
496  dPhi = 72 - dPhi;
497  if (dEta <= gridSize && dPhi <= gridSize) {
498  if (energy_max < (*hit)->energy()) {
499  energy_max = (*hit)->energy();
500  id_max = (*hit)->id();
501  }
502  }
503  }
504  } break;
505  default:
506  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
507  }
508  return id_max;
509 }
std::vector< const CaloTower * > towers
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: DetId.h:17
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
std::vector< const HORecHit * > hoRecHits

◆ getPosition()

GlobalPoint TrackDetMatchInfo::getPosition ( const DetId id)

Definition at line 29 of file TrackDetMatchInfo.cc.

References caloGeometry, Exception, CaloSubdetectorGeometry::getGeometry(), and CaloGeometry::getSubdetectorGeometry().

Referenced by insideCone().

29  {
30  // this part might be slow
33  throw cms::Exception("FatalError") << "Failed to access geometry for DetId: " << id.rawId();
34  return GlobalPoint(0, 0, 0);
35  }
36  return caloGeometry->getSubdetectorGeometry(id)->getGeometry(id)->getPosition();
37 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const CaloGeometry * caloGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34

◆ hcalConeEnergy()

double TrackDetMatchInfo::hcalConeEnergy ( )

Definition at line 549 of file TrackDetMatchInfo.cc.

References coneEnergy(), and HcalRecHits.

549 { return coneEnergy(999, HcalRecHits); }
double coneEnergy(double dR, EnergyType)

◆ hcalCrossedEnergy()

double TrackDetMatchInfo::hcalCrossedEnergy ( )

Definition at line 555 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and HcalRecHits.

Referenced by hcalEnergy().

555 { return crossedEnergy(HcalRecHits); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ hcalEnergy()

double TrackDetMatchInfo::hcalEnergy ( )
inline

Definition at line 103 of file TrackDetMatchInfo.h.

References hcalCrossedEnergy().

103 { return hcalCrossedEnergy(); }

◆ hcalTowerConeEnergy()

double TrackDetMatchInfo::hcalTowerConeEnergy ( )
inline

Definition at line 98 of file TrackDetMatchInfo.h.

References coneEnergy(), and TowerHcal.

98 { return coneEnergy(999, TowerHcal); }
double coneEnergy(double dR, EnergyType)

◆ hcalTowerEnergy()

double TrackDetMatchInfo::hcalTowerEnergy ( )
inline

Definition at line 97 of file TrackDetMatchInfo.h.

References crossedEnergy(), and TowerHcal.

97 { return crossedEnergy(TowerHcal); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ hoConeEnergy()

double TrackDetMatchInfo::hoConeEnergy ( )

Definition at line 551 of file TrackDetMatchInfo.cc.

References coneEnergy(), and HcalRecHits.

551 { return coneEnergy(999, HcalRecHits); }
double coneEnergy(double dR, EnergyType)

◆ hoCrossedEnergy()

double TrackDetMatchInfo::hoCrossedEnergy ( )

Definition at line 557 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and HORecHits.

Referenced by hoEnergy().

557 { return crossedEnergy(HORecHits); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ hoEnergy()

double TrackDetMatchInfo::hoEnergy ( )
inline

Definition at line 104 of file TrackDetMatchInfo.h.

References hoCrossedEnergy().

Referenced by Jet.Jet::hoEnergyFraction().

104 { return hoCrossedEnergy(); }

◆ hoTowerConeEnergy()

double TrackDetMatchInfo::hoTowerConeEnergy ( )
inline

Definition at line 100 of file TrackDetMatchInfo.h.

References coneEnergy(), and TowerHO.

100 { return coneEnergy(999, TowerHO); }
double coneEnergy(double dR, EnergyType)

◆ hoTowerEnergy()

double TrackDetMatchInfo::hoTowerEnergy ( )
inline

Definition at line 99 of file TrackDetMatchInfo.h.

References crossedEnergy(), and TowerHO.

99 { return crossedEnergy(TowerHO); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types

◆ insideCone()

bool TrackDetMatchInfo::insideCone ( const DetId id,
const double  dR 
)
private

Definition at line 81 of file TrackDetMatchInfo.cc.

References electronAnalyzer_cfi::DeltaR, HGC3DClusterGenMatchSelector_cfi::dR, getPosition(), PV3DBase< T, PVType, FrameType >::mag(), FreeTrajectoryState::momentum(), stateAtIP, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by coneEnergy().

81  {
82  GlobalPoint idPosition = getPosition(id);
83  if (idPosition.mag() < 0.01)
84  return false;
85 
86  math::XYZVector idPositionRoot(idPosition.x(), idPosition.y(), idPosition.z());
88  return ROOT::Math::VectorUtil::DeltaR(trackP3, idPositionRoot) < dR;
89 }
GlobalPoint getPosition(const DetId &)
T z() const
Definition: PV3DBase.h:61
FreeTrajectoryState stateAtIP
track info
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31

◆ numberOfSegments()

int TrackDetMatchInfo::numberOfSegments ( ) const

Definition at line 559 of file TrackDetMatchInfo.cc.

References relativeConstraints::chamber, and chambers.

559  {
560  int numSegments = 0;
561  for (std::vector<TAMuonChamberMatch>::const_iterator chamber = chambers.begin(); chamber != chambers.end(); chamber++)
562  numSegments += chamber->segments.size();
563  return numSegments;
564 }
std::vector< TAMuonChamberMatch > chambers

◆ numberOfSegmentsInDetector()

int TrackDetMatchInfo::numberOfSegmentsInDetector ( int  detector) const

Definition at line 582 of file TrackDetMatchInfo.cc.

References relativeConstraints::chamber, chambers, and hgcalTestNeighbor_cfi::detector.

582  {
583  int numSegments = 0;
584  for (std::vector<TAMuonChamberMatch>::const_iterator chamber = chambers.begin(); chamber != chambers.end(); chamber++)
585  if (chamber->detector() == detector)
586  numSegments += chamber->segments.size();
587  return numSegments;
588 }
std::vector< TAMuonChamberMatch > chambers

◆ numberOfSegmentsInStation() [1/2]

int TrackDetMatchInfo::numberOfSegmentsInStation ( int  station) const

Definition at line 566 of file TrackDetMatchInfo.cc.

References relativeConstraints::chamber, chambers, and relativeConstraints::station.

566  {
567  int numSegments = 0;
568  for (std::vector<TAMuonChamberMatch>::const_iterator chamber = chambers.begin(); chamber != chambers.end(); chamber++)
569  if (chamber->station() == station)
570  numSegments += chamber->segments.size();
571  return numSegments;
572 }
std::vector< TAMuonChamberMatch > chambers

◆ numberOfSegmentsInStation() [2/2]

int TrackDetMatchInfo::numberOfSegmentsInStation ( int  station,
int  detector 
) const

Definition at line 574 of file TrackDetMatchInfo.cc.

References relativeConstraints::chamber, chambers, hgcalTestNeighbor_cfi::detector, and relativeConstraints::station.

574  {
575  int numSegments = 0;
576  for (std::vector<TAMuonChamberMatch>::const_iterator chamber = chambers.begin(); chamber != chambers.end(); chamber++)
577  if (chamber->station() == station && chamber->detector() == detector)
578  numSegments += chamber->segments.size();
579  return numSegments;
580 }
std::vector< TAMuonChamberMatch > chambers

◆ nXnEnergy() [1/2]

double TrackDetMatchInfo::nXnEnergy ( const DetId id,
EnergyType  type,
int  gridSize = 1 
)

get energy of the NxN shape (N = 2*gridSize + 1) around given detector element

Definition at line 137 of file TrackDetMatchInfo.cc.

References funct::abs(), DetId::Calo, HLT_2023v12_cff::dEta, HLT_2023v12_cff::dPhi, DetId::Ecal, EcalBarrel, EcalEndcap, EcalRecHits, ecalRecHits, HCALHighEnergyHPDFilter_cfi::energy, Exception, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, HcalRecHits, hcalRecHits, HORecHits, hoRecHits, CaloTowerDetId::ieta(), EBDetId::ieta(), HcalDetId::ieta(), DetIdInfo::info(), CaloTowerDetId::iphi(), EBDetId::iphi(), HcalDetId::iphi(), EEDetId::ix(), EEDetId::iy(), TowerEcal, TowerHcal, TowerHO, towers, TowerTotal, and EEDetId::zside().

Referenced by nXnEnergy().

137  {
138  double energy(0);
139  if (id.rawId() == 0)
140  return 0.;
141  switch (type) {
142  case TowerTotal:
143  case TowerHcal:
144  case TowerEcal:
145  case TowerHO: {
146  if (id.det() != DetId::Calo) {
147  throw cms::Exception("FatalError") << "Wrong DetId. Expected CaloTower, but found:\n"
148  << DetIdInfo::info(id, nullptr) << "\n";
149  }
150  CaloTowerDetId centerId(id);
151  for (std::vector<const CaloTower*>::const_iterator hit = towers.begin(); hit != towers.end(); hit++) {
152  CaloTowerDetId neighborId((*hit)->id());
153  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
154  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
155  int dPhi = abs(centerId.iphi() - neighborId.iphi());
156  if (abs(72 - dPhi) < dPhi)
157  dPhi = 72 - dPhi;
158  if (dEta <= gridSize && dPhi <= gridSize) {
159  switch (type) {
160  case TowerTotal:
161  energy += (*hit)->energy();
162  break;
163  case TowerEcal:
164  energy += (*hit)->emEnergy();
165  break;
166  case TowerHcal:
167  energy += (*hit)->hadEnergy();
168  break;
169  case TowerHO:
170  energy += (*hit)->outerEnergy();
171  break;
172  default:
173  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
174  }
175  }
176  }
177  } break;
178  case EcalRecHits: {
179  if (id.det() != DetId::Ecal || (id.subdetId() != EcalBarrel && id.subdetId() != EcalEndcap)) {
180  throw cms::Exception("FatalError") << "Wrong DetId. Expected EcalBarrel or EcalEndcap, but found:\n"
181  << DetIdInfo::info(id, nullptr) << "\n";
182  }
183  // Since the ECAL granularity is small and the gap between EE and EB is significant,
184  // energy is computed only within the system that contains the central element
185  if (id.subdetId() == EcalBarrel) {
186  EBDetId centerId(id);
187  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end();
188  hit++) {
189  if ((*hit)->id().subdetId() != EcalBarrel)
190  continue;
191  EBDetId neighborId((*hit)->id());
192  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
193  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
194  int dPhi = abs(centerId.iphi() - neighborId.iphi());
195  if (abs(360 - dPhi) < dPhi)
196  dPhi = 360 - dPhi;
197  if (dEta <= gridSize && dPhi <= gridSize) {
198  energy += (*hit)->energy();
199  }
200  }
201  } else {
202  // Endcap
203  EEDetId centerId(id);
204  for (std::vector<const EcalRecHit*>::const_iterator hit = ecalRecHits.begin(); hit != ecalRecHits.end();
205  hit++) {
206  if ((*hit)->id().subdetId() != EcalEndcap)
207  continue;
208  EEDetId neighborId((*hit)->id());
209  if (centerId.zside() == neighborId.zside() && abs(centerId.ix() - neighborId.ix()) <= gridSize &&
210  abs(centerId.iy() - neighborId.iy()) <= gridSize) {
211  energy += (*hit)->energy();
212  }
213  }
214  }
215  } break;
216  case HcalRecHits: {
217  if (id.det() != DetId::Hcal || (id.subdetId() != HcalBarrel && id.subdetId() != HcalEndcap)) {
218  throw cms::Exception("FatalError") << "Wrong DetId. Expected HE or HB, but found:\n"
219  << DetIdInfo::info(id, nullptr) << "\n";
220  }
221  HcalDetId centerId(id);
222  for (std::vector<const HBHERecHit*>::const_iterator hit = hcalRecHits.begin(); hit != hcalRecHits.end(); hit++) {
223  HcalDetId neighborId((*hit)->id());
224  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
225  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
226  int dPhi = abs(centerId.iphi() - neighborId.iphi());
227  if (abs(72 - dPhi) < dPhi)
228  dPhi = 72 - dPhi;
229  if (dEta <= gridSize && dPhi <= gridSize) {
230  energy += (*hit)->energy();
231  }
232  }
233  } break;
234  case HORecHits: {
235  if (id.det() != DetId::Hcal || (id.subdetId() != HcalOuter)) {
236  throw cms::Exception("FatalError") << "Wrong DetId. Expected HO, but found:\n"
237  << DetIdInfo::info(id, nullptr) << "\n";
238  }
239  HcalDetId centerId(id);
240  for (std::vector<const HORecHit*>::const_iterator hit = hoRecHits.begin(); hit != hoRecHits.end(); hit++) {
241  HcalDetId neighborId((*hit)->id());
242  int dEta = abs((centerId.ieta() < 0 ? centerId.ieta() + 1 : centerId.ieta()) -
243  (neighborId.ieta() < 0 ? neighborId.ieta() + 1 : neighborId.ieta()));
244  int dPhi = abs(centerId.iphi() - neighborId.iphi());
245  if (abs(72 - dPhi) < dPhi)
246  dPhi = 72 - dPhi;
247  if (dEta <= gridSize && dPhi <= gridSize) {
248  energy += (*hit)->energy();
249  }
250  }
251  } break;
252  default:
253  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
254  }
255  return energy;
256 }
std::vector< const CaloTower * > towers
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
std::vector< const HORecHit * > hoRecHits

◆ nXnEnergy() [2/2]

double TrackDetMatchInfo::nXnEnergy ( EnergyType  type,
int  gridSize = 1 
)

get energy of the NxN shape (N = 2*gridSize + 1) around track projection

Definition at line 258 of file TrackDetMatchInfo.cc.

References crossedEcalIds, crossedHcalIds, crossedHOIds, crossedTowerIds, EcalRecHits, Exception, HcalRecHits, HORecHits, nXnEnergy(), TowerEcal, TowerHcal, TowerHO, and TowerTotal.

258  {
259  switch (type) {
260  case TowerTotal:
261  case TowerHcal:
262  case TowerEcal:
263  case TowerHO:
264  if (crossedTowerIds.empty())
265  return 0;
266  return nXnEnergy(crossedTowerIds.front(), type, gridSize);
267  break;
268  case EcalRecHits:
269  if (crossedEcalIds.empty())
270  return 0;
271  return nXnEnergy(crossedEcalIds.front(), type, gridSize);
272  break;
273  case HcalRecHits:
274  if (crossedHcalIds.empty())
275  return 0;
276  return nXnEnergy(crossedHcalIds.front(), type, gridSize);
277  break;
278  case HORecHits:
279  if (crossedHOIds.empty())
280  return 0;
281  return nXnEnergy(crossedHOIds.front(), type, gridSize);
282  break;
283  default:
284  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
285  }
286  return -999;
287 }
std::vector< DetId > crossedTowerIds
std::vector< DetId > crossedEcalIds
std::vector< DetId > crossedHcalIds
double nXnEnergy(const DetId &, EnergyType, int gridSize=1)
get energy of the NxN shape (N = 2*gridSize + 1) around given detector element
std::vector< DetId > crossedHOIds

◆ setCaloGeometry()

void TrackDetMatchInfo::setCaloGeometry ( const CaloGeometry geometry)
inline

Definition at line 111 of file TrackDetMatchInfo.h.

References caloGeometry, and relativeConstraints::geometry.

Member Data Documentation

◆ caloGeometry

const CaloGeometry* TrackDetMatchInfo::caloGeometry
private

Definition at line 117 of file TrackDetMatchInfo.h.

Referenced by dumpGeometry(), getPosition(), and setCaloGeometry().

◆ chambers

std::vector<TAMuonChamberMatch> TrackDetMatchInfo::chambers

◆ crossedEcalIds

std::vector<DetId> TrackDetMatchInfo::crossedEcalIds

detector elements crossed by a track (regardless of whether energy was deposited or not)

Definition at line 66 of file TrackDetMatchInfo.h.

Referenced by muonisolation::CaloExtractorByAssociator::deposits(), findMaxDeposition(), nXnEnergy(), and pat::PATIsolatedTrackProducer::produce().

◆ crossedEcalRecHits

std::vector<const EcalRecHit*> TrackDetMatchInfo::crossedEcalRecHits

hits in detector elements crossed by a track

Definition at line 59 of file TrackDetMatchInfo.h.

Referenced by crossedEnergy().

◆ crossedHcalIds

std::vector<DetId> TrackDetMatchInfo::crossedHcalIds

◆ crossedHcalRecHits

std::vector<const HBHERecHit*> TrackDetMatchInfo::crossedHcalRecHits

Definition at line 60 of file TrackDetMatchInfo.h.

Referenced by crossedEnergy().

◆ crossedHOIds

std::vector<DetId> TrackDetMatchInfo::crossedHOIds

◆ crossedHORecHits

std::vector<const HORecHit*> TrackDetMatchInfo::crossedHORecHits

Definition at line 61 of file TrackDetMatchInfo.h.

Referenced by crossedEnergy().

◆ crossedPreshowerIds

std::vector<DetId> TrackDetMatchInfo::crossedPreshowerIds

Definition at line 70 of file TrackDetMatchInfo.h.

◆ crossedTowerIds

std::vector<DetId> TrackDetMatchInfo::crossedTowerIds

◆ crossedTowers

std::vector<const CaloTower*> TrackDetMatchInfo::crossedTowers

◆ ecalRecHits

std::vector<const EcalRecHit*> TrackDetMatchInfo::ecalRecHits

◆ ecalTrueEnergy

double TrackDetMatchInfo::ecalTrueEnergy

Definition at line 79 of file TrackDetMatchInfo.h.

◆ hcalRecHits

std::vector<const HBHERecHit*> TrackDetMatchInfo::hcalRecHits

◆ hcalTrueEnergy

double TrackDetMatchInfo::hcalTrueEnergy

Definition at line 80 of file TrackDetMatchInfo.h.

◆ hcalTrueEnergyCorrected

double TrackDetMatchInfo::hcalTrueEnergyCorrected

Definition at line 81 of file TrackDetMatchInfo.h.

◆ hoRecHits

std::vector<const HORecHit*> TrackDetMatchInfo::hoRecHits

◆ isGoodCalo

bool TrackDetMatchInfo::isGoodCalo

Definition at line 48 of file TrackDetMatchInfo.h.

◆ isGoodEcal

bool TrackDetMatchInfo::isGoodEcal

Definition at line 46 of file TrackDetMatchInfo.h.

Referenced by spr::chargeIsolation(), and spr::chargeIsolationEcal().

◆ isGoodHcal

bool TrackDetMatchInfo::isGoodHcal

Definition at line 47 of file TrackDetMatchInfo.h.

Referenced by spr::chargeIsolationHcal(), and spr::coneChargeIsolation().

◆ isGoodHO

bool TrackDetMatchInfo::isGoodHO

Definition at line 49 of file TrackDetMatchInfo.h.

◆ isGoodMuon

bool TrackDetMatchInfo::isGoodMuon

Definition at line 50 of file TrackDetMatchInfo.h.

◆ simTrack

const SimTrack* TrackDetMatchInfo::simTrack

MC truth info.

Definition at line 78 of file TrackDetMatchInfo.h.

◆ simTrackRef_

SimTrackRef TrackDetMatchInfo::simTrackRef_

Definition at line 86 of file TrackDetMatchInfo.h.

◆ stateAtIP

FreeTrajectoryState TrackDetMatchInfo::stateAtIP

track info

Definition at line 75 of file TrackDetMatchInfo.h.

Referenced by insideCone().

◆ towers

std::vector<const CaloTower*> TrackDetMatchInfo::towers

◆ trackRef_

reco::TrackRef TrackDetMatchInfo::trackRef_

Obsolete methods and data members for backward compatibility. Will be removed in future releases.

Definition at line 85 of file TrackDetMatchInfo.h.

◆ trkGlobPosAtEcal

math::XYZPoint TrackDetMatchInfo::trkGlobPosAtEcal

◆ trkGlobPosAtHcal

math::XYZPoint TrackDetMatchInfo::trkGlobPosAtHcal

◆ trkGlobPosAtHO

math::XYZPoint TrackDetMatchInfo::trkGlobPosAtHO

◆ trkMomAtEcal

GlobalVector TrackDetMatchInfo::trkMomAtEcal

Definition at line 42 of file TrackDetMatchInfo.h.

Referenced by IsolatedTracksCone::analyze().

◆ trkMomAtHcal

GlobalVector TrackDetMatchInfo::trkMomAtHcal

Definition at line 43 of file TrackDetMatchInfo.h.

Referenced by IsolatedTracksCone::analyze().

◆ trkMomAtHO

GlobalVector TrackDetMatchInfo::trkMomAtHO

Definition at line 44 of file TrackDetMatchInfo.h.