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 (edm::ESHandle< 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

edm::ESHandle< CaloGeometrycaloGeometry
 

Detailed Description

Definition at line 14 of file TrackDetMatchInfo.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

TrackDetMatchInfo::TrackDetMatchInfo ( )

Definition at line 314 of file TrackDetMatchInfo.cc.

314  :
315  trkGlobPosAtEcal(0,0,0)
316  , trkGlobPosAtHcal(0,0,0)
317  , trkGlobPosAtHO(0,0,0)
318  , trkMomAtEcal(0,0,0)
319  , trkMomAtHcal(0,0,0)
320  , trkMomAtHO(0,0,0)
321  , isGoodEcal(false)
322  , isGoodHcal(false)
323  , isGoodCalo(false)
324  , isGoodHO(false)
325  , isGoodMuon(false)
326  , simTrack(nullptr)
327  , ecalTrueEnergy(-999)
328  , hcalTrueEnergy(-999)
329 {
330 }
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

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 108 of file TrackDetMatchInfo.cc.

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

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

109 {
110  double energy(0);
111  switch (type) {
112  case EcalRecHits:
113  {
114  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++)
115  if (insideCone((*hit)->detid(),dR)) energy += (*hit)->energy();
116  }
117  break;
118  case HcalRecHits:
119  {
120  for(std::vector<const HBHERecHit*>::const_iterator hit = hcalRecHits.begin(); hit != hcalRecHits.end(); hit++)
121  if (insideCone((*hit)->detid(),dR)) energy += (*hit)->energy();
122  }
123  break;
124  case HORecHits:
125  {
126  for(std::vector<const HORecHit*>::const_iterator hit = hoRecHits.begin(); hit != hoRecHits.end(); hit++)
127  if (insideCone((*hit)->detid(),dR)) energy += (*hit)->energy();
128  }
129  break;
130  case TowerTotal:
131  {
132  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
133  if (insideCone((*hit)->id(),dR)) energy += (*hit)->energy();
134  }
135  break;
136  case TowerEcal:
137  {
138  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
139  if (insideCone((*hit)->id(),dR)) energy += (*hit)->emEnergy();
140  }
141  break;
142  case TowerHcal:
143  {
144  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
145  if (insideCone((*hit)->id(),dR)) energy += (*hit)->hadEnergy();
146  }
147  break;
148  case TowerHO:
149  {
150  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
151  if (insideCone((*hit)->id(),dR)) energy += (*hit)->outerEnergy();
152  }
153  break;
154  default:
155  throw cms::Exception("FatalError") << "Unknown calo energy type: " << type;
156  }
157  return energy;
158 }
type
Definition: HCALResponse.h:21
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
double TrackDetMatchInfo::crossedEnergy ( EnergyType  type)

energy in detector elements crossed by the track by types

Definition at line 47 of file TrackDetMatchInfo.cc.

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

Referenced by BetaCalculatorECAL::addInfoToCandidate(), ecalCrossedEnergy(), ecalTowerEnergy(), MuonIdProducer::fillMuonId(), hcalCrossedEnergy(), hcalTowerEnergy(), hoCrossedEnergy(), and hoTowerEnergy().

48 {
49  double energy(0);
50  switch (type) {
51  case EcalRecHits:
52  {
53  for(std::vector<const EcalRecHit*>::const_iterator hit=crossedEcalRecHits.begin(); hit!=crossedEcalRecHits.end(); hit++)
54  energy += (*hit)->energy();
55  }
56  break;
57  case HcalRecHits:
58  {
59  for(std::vector<const HBHERecHit*>::const_iterator hit = crossedHcalRecHits.begin(); hit != crossedHcalRecHits.end(); hit++)
60  energy += (*hit)->energy();
61  }
62  break;
63  case HORecHits:
64  {
65  for(std::vector<const HORecHit*>::const_iterator hit = crossedHORecHits.begin(); hit != crossedHORecHits.end(); hit++)
66  energy += (*hit)->energy();
67  }
68  break;
69  case TowerTotal:
70  {
71  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
72  energy += (*hit)->energy();
73  }
74  break;
75  case TowerEcal:
76  {
77  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
78  energy += (*hit)->emEnergy();
79  }
80  break;
81  case TowerHcal:
82  {
83  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
84  energy += (*hit)->hadEnergy();
85  }
86  break;
87  case TowerHO:
88  {
89  for(std::vector<const CaloTower*>::const_iterator hit=crossedTowers.begin(); hit!=crossedTowers.end(); hit++)
90  energy += (*hit)->outerEnergy();
91  }
92  break;
93  default:
94  throw cms::Exception("FatalError") << "Unknown calo energy type: " << type;
95  }
96  return energy;
97 }
type
Definition: HCALResponse.h:21
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
std::string TrackDetMatchInfo::dumpGeometry ( const DetId id)

Definition at line 17 of file TrackDetMatchInfo.cc.

References EZArrayFL< T >::begin(), caloGeometry, EZArrayFL< T >::end(), Exception, CaloCellGeometry::getCorners(), CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), edm::ESHandleBase::isValid(), point, and hiPixelPairStep_cff::points.

Referenced by setCaloGeometry().

18 {
19  if ( ! caloGeometry.isValid() ||
22  throw cms::Exception("FatalError") << "Failed to access geometry for DetId: " << id.rawId();
23  }
24  std::ostringstream oss;
25 
28  point != points.end(); ++point)
29  oss << "(" << point->z() << ", " << point->perp() << ", " << point->eta() << ", " << point->phi() << "), \t";
30  return oss.str();
31 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
const_iterator begin() const
Definition: EZArrayFL.h:63
edm::ESHandle< CaloGeometry > caloGeometry
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
CornersVec const & getCorners() const
Returns the corner points of this cell&#39;s volume.
MgrType::const_iterator const_iterator
Definition: EZArrayFL.h:27
const_iterator end() const
Definition: EZArrayFL.h:64
bool isValid() const
Definition: ESHandle.h:47
*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
double TrackDetMatchInfo::ecalConeEnergy ( )

Definition at line 581 of file TrackDetMatchInfo.cc.

References coneEnergy(), and EcalRecHits.

582 {
583  return coneEnergy (999, EcalRecHits );
584 }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::ecalCrossedEnergy ( )

Definition at line 596 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and EcalRecHits.

Referenced by ecalEnergy().

597 {
598  return crossedEnergy( EcalRecHits );
599 }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
double TrackDetMatchInfo::ecalEnergy ( )
inline

Definition at line 103 of file TrackDetMatchInfo.h.

References ecalCrossedEnergy().

103 { return ecalCrossedEnergy(); }
double TrackDetMatchInfo::ecalTowerConeEnergy ( )
inline

Definition at line 97 of file TrackDetMatchInfo.h.

References coneEnergy(), and TowerEcal.

97 { return coneEnergy(999,TowerEcal); }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::ecalTowerEnergy ( )
inline

Definition at line 96 of file TrackDetMatchInfo.h.

References crossedEnergy(), and TowerEcal.

96 { return crossedEnergy(TowerEcal); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
DetId TrackDetMatchInfo::findMaxDeposition ( EnergyType  type)

Find detector elements with highest energy deposition.

Definition at line 332 of file TrackDetMatchInfo.cc.

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

Referenced by MuonIdProducer::fillMuonId(), findMaxDeposition(), and InterestingTrackEcalDetIdProducer::produce().

333 {
334  DetId id;
335  float maxEnergy = -9999;
336  switch (type) {
337  case EcalRecHits:
338  {
339  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++)
340  if ( (*hit)->energy() > maxEnergy ) {
341  maxEnergy = (*hit)->energy();
342  id = (*hit)->detid();
343  }
344  }
345  break;
346  case HcalRecHits:
347  {
348  for(std::vector<const HBHERecHit*>::const_iterator hit=hcalRecHits.begin(); hit!=hcalRecHits.end(); hit++)
349  if ( (*hit)->energy() > maxEnergy ) {
350  maxEnergy = (*hit)->energy();
351  id = (*hit)->detid();
352  }
353  }
354  break;
355  case HORecHits:
356  {
357  for(std::vector<const HORecHit*>::const_iterator hit=hoRecHits.begin(); hit!=hoRecHits.end(); hit++)
358  if ( (*hit)->energy() > maxEnergy ) {
359  maxEnergy = (*hit)->energy();
360  id = (*hit)->detid();
361  }
362  }
363  break;
364  case TowerTotal:
365  case TowerEcal:
366  case TowerHcal:
367  {
368  for(std::vector<const CaloTower*>::const_iterator hit=towers.begin(); hit!=towers.end(); hit++)
369  {
370  double energy = 0;
371  switch (type) {
372  case TowerTotal:
373  energy = (*hit)->energy();
374  break;
375  case TowerEcal:
376  energy = (*hit)->emEnergy();
377  break;
378  case TowerHcal:
379  energy = (*hit)->hadEnergy();
380  break;
381  case TowerHO:
382  energy = (*hit)->energy();
383  break;
384  default:
385  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
386  }
387  if ( energy > maxEnergy ) {
388  maxEnergy = energy;
389  id = (*hit)->id();
390  }
391  }
392  }
393  default:
394  throw cms::Exception("FatalError") << "Maximal energy deposition: unkown or not implemented energy type requested, type:" << type;
395  }
396  return id;
397 }
type
Definition: HCALResponse.h:21
std::vector< const CaloTower * > towers
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
Definition: DetId.h:18
std::vector< const HORecHit * > hoRecHits
DetId TrackDetMatchInfo::findMaxDeposition ( EnergyType  type,
int  gridSize 
)

Definition at line 546 of file TrackDetMatchInfo.cc.

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

547 {
548  DetId id_max;
549  switch (type) {
550  case TowerTotal:
551  case TowerHcal:
552  case TowerEcal:
553  case TowerHO:
554  if( crossedTowerIds.empty() ) return id_max;
555  return findMaxDeposition(crossedTowerIds.front(), type, gridSize);
556  break;
557  case EcalRecHits:
558  if( crossedEcalIds.empty() ) return id_max;
559  return findMaxDeposition(crossedEcalIds.front(), type, gridSize);
560  break;
561  case HcalRecHits:
562  if( crossedHcalIds.empty() ) return id_max;
563  return findMaxDeposition(crossedHcalIds.front(), type, gridSize);
564  break;
565  case HORecHits:
566  if( crossedHOIds.empty() ) return id_max;
567  return findMaxDeposition(crossedHOIds.front(), type, gridSize);
568  break;
569  default:
570  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
571  }
572  return id_max;
573 }
type
Definition: HCALResponse.h:21
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:18
DetId TrackDetMatchInfo::findMaxDeposition ( const DetId id,
EnergyType  type,
int  gridSize 
)

Definition at line 399 of file TrackDetMatchInfo.cc.

References funct::abs(), DetId::Calo, 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().

400 {
401  double energy_max(0);
402  DetId id_max;
403  if ( id.rawId() == 0 ) return id_max;
404  switch (type) {
405  case TowerTotal:
406  case TowerHcal:
407  case TowerEcal:
408  case TowerHO:
409  {
410  if ( id.det() != DetId::Calo ) {
411  throw cms::Exception("FatalError") << "Wrong DetId. Expected CaloTower, but found:\n" <<
412  DetIdInfo::info(id,nullptr)<<"\n";
413  }
414  CaloTowerDetId centerId(id);
415  for(std::vector<const CaloTower*>::const_iterator hit=towers.begin(); hit!=towers.end(); hit++) {
416  CaloTowerDetId neighborId((*hit)->id());
417  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
418  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
419  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
420  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
421  if( dEta <= gridSize && dPhi <= gridSize ) {
422  switch (type) {
423  case TowerTotal:
424  if ( energy_max < (*hit)->energy() ){
425  energy_max = (*hit)->energy();
426  id_max = (*hit)->id();
427  }
428  break;
429  case TowerEcal:
430  if ( energy_max < (*hit)->emEnergy() ){
431  energy_max = (*hit)->emEnergy();
432  id_max = (*hit)->id();
433  }
434  break;
435  case TowerHcal:
436  if ( energy_max < (*hit)->hadEnergy() ){
437  energy_max = (*hit)->hadEnergy();
438  id_max = (*hit)->id();
439  }
440  break;
441  case TowerHO:
442  if ( energy_max < (*hit)->outerEnergy() ){
443  energy_max = (*hit)->outerEnergy();
444  id_max = (*hit)->id();
445  }
446  break;
447  default:
448  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
449  }
450  }
451  }
452  }
453  break;
454  case EcalRecHits:
455  {
456  if( id.det() != DetId::Ecal || (id.subdetId() != EcalBarrel && id.subdetId() != EcalEndcap) ) {
457  throw cms::Exception("FatalError") << "Wrong DetId. Expected EcalBarrel or EcalEndcap, but found:\n" <<
458  DetIdInfo::info(id,nullptr)<<"\n";
459  }
460  // Since the ECAL granularity is small and the gap between EE and EB is significant,
461  // energy is computed only within the system that contains the central element
462  if( id.subdetId() == EcalBarrel ) {
463  EBDetId centerId(id);
464  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++) {
465  if ((*hit)->id().subdetId() != EcalBarrel) continue;
466  EBDetId neighborId((*hit)->id());
467  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
468  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
469  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
470  if ( abs(360-dPhi) < dPhi ) dPhi = 360-dPhi;
471  if( dEta <= gridSize && dPhi <= gridSize ) {
472  if ( energy_max < (*hit)->energy() ){
473  energy_max = (*hit)->energy();
474  id_max = (*hit)->id();
475  }
476  }
477  }
478  } else {
479  // Endcap
480  EEDetId centerId(id);
481  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++) {
482  if ((*hit)->id().subdetId() != EcalEndcap) continue;
483  EEDetId neighborId((*hit)->id());
484  if( centerId.zside() == neighborId.zside() &&
485  abs(centerId.ix()-neighborId.ix()) <= gridSize &&
486  abs(centerId.iy()-neighborId.iy()) <= gridSize ) {
487  if ( energy_max < (*hit)->energy() ){
488  energy_max = (*hit)->energy();
489  id_max = (*hit)->id();
490  }
491  }
492  }
493  }
494  }
495  break;
496  case HcalRecHits:
497  {
498  if( id.det() != DetId::Hcal || (id.subdetId() != HcalBarrel && id.subdetId() != HcalEndcap) ) {
499  throw cms::Exception("FatalError") << "Wrong DetId. Expected HE or HB, but found:\n" <<
500  DetIdInfo::info(id,nullptr)<<"\n";
501  }
502  HcalDetId centerId(id);
503  for(std::vector<const HBHERecHit*>::const_iterator hit=hcalRecHits.begin(); hit!=hcalRecHits.end(); hit++) {
504  HcalDetId neighborId((*hit)->id());
505  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
506  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
507  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
508  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
509  if( dEta <= gridSize && dPhi <= gridSize ){
510  if ( energy_max < (*hit)->energy() ){
511  energy_max = (*hit)->energy();
512  id_max = (*hit)->id();
513  }
514  }
515  }
516  }
517  break;
518  case HORecHits:
519  {
520  if( id.det() != DetId::Hcal || (id.subdetId() != HcalOuter) ) {
521  throw cms::Exception("FatalError") << "Wrong DetId. Expected HO, but found:\n" <<
522  DetIdInfo::info(id,nullptr)<<"\n";
523  }
524  HcalDetId centerId(id);
525  for(std::vector<const HORecHit*>::const_iterator hit=hoRecHits.begin(); hit!=hoRecHits.end(); hit++) {
526  HcalDetId neighborId((*hit)->id());
527  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
528  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
529  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
530  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
531  if( dEta <= gridSize && dPhi <= gridSize ) {
532  if ( energy_max < (*hit)->energy() ){
533  energy_max = (*hit)->energy();
534  id_max = (*hit)->id();
535  }
536  }
537  }
538  }
539  break;
540  default:
541  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
542  }
543  return id_max;
544 }
type
Definition: HCALResponse.h:21
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:18
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
std::vector< const HORecHit * > hoRecHits
GlobalPoint TrackDetMatchInfo::getPosition ( const DetId id)

Definition at line 34 of file TrackDetMatchInfo.cc.

References caloGeometry, Exception, CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), and edm::ESHandleBase::isValid().

Referenced by BetaCalculatorECAL::addInfoToCandidate(), insideCone(), and setCaloGeometry().

35 {
36  // this part might be slow
37  if ( ! caloGeometry.isValid() ||
40  throw cms::Exception("FatalError") << "Failed to access geometry for DetId: " << id.rawId();
41  return GlobalPoint(0,0,0);
42  }
44 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::ESHandle< CaloGeometry > caloGeometry
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
bool isValid() const
Definition: ESHandle.h:47
double TrackDetMatchInfo::hcalConeEnergy ( )

Definition at line 586 of file TrackDetMatchInfo.cc.

References coneEnergy(), and HcalRecHits.

587 {
588  return coneEnergy (999, HcalRecHits );
589 }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::hcalCrossedEnergy ( )

Definition at line 601 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and HcalRecHits.

Referenced by hcalEnergy().

602 {
603  return crossedEnergy( HcalRecHits );
604 }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
double TrackDetMatchInfo::hcalEnergy ( )
inline

Definition at line 104 of file TrackDetMatchInfo.h.

References hcalCrossedEnergy().

104 { return hcalCrossedEnergy(); }
double TrackDetMatchInfo::hcalTowerConeEnergy ( )
inline

Definition at line 99 of file TrackDetMatchInfo.h.

References coneEnergy(), and TowerHcal.

99 { return coneEnergy(999, TowerHcal); }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::hcalTowerEnergy ( )
inline

Definition at line 98 of file TrackDetMatchInfo.h.

References crossedEnergy(), and TowerHcal.

98 { return crossedEnergy(TowerHcal); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
double TrackDetMatchInfo::hoConeEnergy ( )

Definition at line 591 of file TrackDetMatchInfo.cc.

References coneEnergy(), and HcalRecHits.

592 {
593  return coneEnergy (999, HcalRecHits );
594 }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::hoCrossedEnergy ( )

Definition at line 606 of file TrackDetMatchInfo.cc.

References crossedEnergy(), and HORecHits.

Referenced by hoEnergy().

607 {
608  return crossedEnergy( HORecHits );
609 }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
double TrackDetMatchInfo::hoEnergy ( )
inline
double TrackDetMatchInfo::hoTowerConeEnergy ( )
inline

Definition at line 101 of file TrackDetMatchInfo.h.

References coneEnergy().

101 { return coneEnergy(999, TowerHO); }
double coneEnergy(double dR, EnergyType)
double TrackDetMatchInfo::hoTowerEnergy ( )
inline

Definition at line 100 of file TrackDetMatchInfo.h.

References crossedEnergy().

100 { return crossedEnergy(TowerHO); }
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
bool TrackDetMatchInfo::insideCone ( const DetId id,
const double  dR 
)
private

Definition at line 99 of file TrackDetMatchInfo.cc.

References HiRegitMuonDetachedTripletStep_cff::DeltaR, PFRecoTauDiscriminationAgainstElectronDeadECAL_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(), and setCaloGeometry().

99  {
100  GlobalPoint idPosition = getPosition(id);
101  if (idPosition.mag()<0.01) return false;
102 
103  math::XYZVector idPositionRoot( idPosition.x(), idPosition.y(), idPosition.z() );
105  return ROOT::Math::VectorUtil::DeltaR(trackP3, idPositionRoot) < dR;
106 }
GlobalPoint getPosition(const DetId &)
T y() const
Definition: PV3DBase.h:63
FreeTrajectoryState stateAtIP
track info
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T x() const
Definition: PV3DBase.h:62
int TrackDetMatchInfo::numberOfSegments ( ) const

Definition at line 612 of file TrackDetMatchInfo.cc.

References relativeConstraints::chamber, and chambers.

Referenced by hoEnergy().

612  {
613  int numSegments = 0;
614  for(std::vector<TAMuonChamberMatch>::const_iterator chamber=chambers.begin(); chamber!=chambers.end(); chamber++)
615  numSegments += chamber->segments.size();
616  return numSegments;
617 }
std::vector< TAMuonChamberMatch > chambers
int TrackDetMatchInfo::numberOfSegmentsInDetector ( int  detector) const

Definition at line 633 of file TrackDetMatchInfo.cc.

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

Referenced by hoEnergy().

633  {
634  int numSegments = 0;
635  for(std::vector<TAMuonChamberMatch>::const_iterator chamber=chambers.begin(); chamber!=chambers.end(); chamber++)
636  if(chamber->detector()==detector) numSegments += chamber->segments.size();
637  return numSegments;
638 }
std::vector< TAMuonChamberMatch > chambers
int TrackDetMatchInfo::numberOfSegmentsInStation ( int  station) const

Definition at line 619 of file TrackDetMatchInfo.cc.

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

Referenced by hoEnergy().

619  {
620  int numSegments = 0;
621  for(std::vector<TAMuonChamberMatch>::const_iterator chamber=chambers.begin(); chamber!=chambers.end(); chamber++)
622  if(chamber->station()==station) numSegments += chamber->segments.size();
623  return numSegments;
624 }
std::vector< TAMuonChamberMatch > chambers
int TrackDetMatchInfo::numberOfSegmentsInStation ( int  station,
int  detector 
) const

Definition at line 626 of file TrackDetMatchInfo.cc.

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

626  {
627  int numSegments = 0;
628  for(std::vector<TAMuonChamberMatch>::const_iterator chamber=chambers.begin(); chamber!=chambers.end(); chamber++)
629  if(chamber->station()==station&&chamber->detector()==detector) numSegments += chamber->segments.size();
630  return numSegments;
631 }
std::vector< TAMuonChamberMatch > chambers
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 163 of file TrackDetMatchInfo.cc.

References funct::abs(), DetId::Calo, 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().

Referenced by BetaCalculatorECAL::addInfoToCandidate(), EopTreeWriter::analyze(), MuonIdProducer::fillMuonId(), and nXnEnergy().

164 {
165  double energy(0);
166  if ( id.rawId() == 0 ) return 0.;
167  switch (type) {
168  case TowerTotal:
169  case TowerHcal:
170  case TowerEcal:
171  case TowerHO:
172  {
173  if ( id.det() != DetId::Calo ) {
174  throw cms::Exception("FatalError") << "Wrong DetId. Expected CaloTower, but found:\n" <<
175  DetIdInfo::info(id,nullptr)<<"\n";
176  }
177  CaloTowerDetId centerId(id);
178  for(std::vector<const CaloTower*>::const_iterator hit=towers.begin(); hit!=towers.end(); hit++) {
179  CaloTowerDetId neighborId((*hit)->id());
180  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
181  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
182  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
183  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
184  if( dEta <= gridSize && dPhi <= gridSize ) {
185  switch (type) {
186  case TowerTotal:
187  energy += (*hit)->energy();
188  break;
189  case TowerEcal:
190  energy += (*hit)->emEnergy();
191  break;
192  case TowerHcal:
193  energy += (*hit)->hadEnergy();
194  break;
195  case TowerHO:
196  energy += (*hit)->outerEnergy();
197  break;
198  default:
199  throw cms::Exception("FatalError") << "Unknown calo tower energy type: " << type;
200  }
201  }
202  }
203  }
204  break;
205  case EcalRecHits:
206  {
207  if( id.det() != DetId::Ecal || (id.subdetId() != EcalBarrel && id.subdetId() != EcalEndcap) ) {
208  throw cms::Exception("FatalError") << "Wrong DetId. Expected EcalBarrel or EcalEndcap, but found:\n" <<
209  DetIdInfo::info(id,nullptr)<<"\n";
210  }
211  // Since the ECAL granularity is small and the gap between EE and EB is significant,
212  // energy is computed only within the system that contains the central element
213  if( id.subdetId() == EcalBarrel ) {
214  EBDetId centerId(id);
215  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++) {
216  if ((*hit)->id().subdetId() != EcalBarrel) continue;
217  EBDetId neighborId((*hit)->id());
218  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
219  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
220  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
221  if ( abs(360-dPhi) < dPhi ) dPhi = 360-dPhi;
222  if( dEta <= gridSize && dPhi <= gridSize ) {
223  energy += (*hit)->energy();
224  }
225  }
226  } else {
227  // Endcap
228  EEDetId centerId(id);
229  for(std::vector<const EcalRecHit*>::const_iterator hit=ecalRecHits.begin(); hit!=ecalRecHits.end(); hit++) {
230  if ((*hit)->id().subdetId() != EcalEndcap) continue;
231  EEDetId neighborId((*hit)->id());
232  if( centerId.zside() == neighborId.zside() &&
233  abs(centerId.ix()-neighborId.ix()) <= gridSize &&
234  abs(centerId.iy()-neighborId.iy()) <= gridSize ) {
235  energy += (*hit)->energy();
236  }
237  }
238  }
239  }
240  break;
241  case HcalRecHits:
242  {
243  if( id.det() != DetId::Hcal || (id.subdetId() != HcalBarrel && id.subdetId() != HcalEndcap) ) {
244  throw cms::Exception("FatalError") << "Wrong DetId. Expected HE or HB, but found:\n" <<
245  DetIdInfo::info(id,nullptr)<<"\n";
246  }
247  HcalDetId centerId(id);
248  for(std::vector<const HBHERecHit*>::const_iterator hit=hcalRecHits.begin(); hit!=hcalRecHits.end(); hit++) {
249  HcalDetId neighborId((*hit)->id());
250  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
251  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
252  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
253  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
254  if( dEta <= gridSize && dPhi <= gridSize ){
255  energy += (*hit)->energy();
256  }
257  }
258  }
259  break;
260  case HORecHits:
261  {
262  if( id.det() != DetId::Hcal || (id.subdetId() != HcalOuter) ) {
263  throw cms::Exception("FatalError") << "Wrong DetId. Expected HO, but found:\n" <<
264  DetIdInfo::info(id,nullptr)<<"\n";
265  }
266  HcalDetId centerId(id);
267  for(std::vector<const HORecHit*>::const_iterator hit=hoRecHits.begin(); hit!=hoRecHits.end(); hit++) {
268  HcalDetId neighborId((*hit)->id());
269  int dEta = abs( (centerId.ieta()<0?centerId.ieta()+1:centerId.ieta() )
270  -(neighborId.ieta()<0?neighborId.ieta()+1:neighborId.ieta() ) ) ;
271  int dPhi = abs( centerId.iphi()-neighborId.iphi() );
272  if ( abs(72-dPhi) < dPhi ) dPhi = 72-dPhi;
273  if( dEta <= gridSize && dPhi <= gridSize ) {
274  energy += (*hit)->energy();
275  }
276  }
277  }
278  break;
279  default:
280  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
281  }
282  return energy;
283 }
type
Definition: HCALResponse.h:21
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
double TrackDetMatchInfo::nXnEnergy ( EnergyType  type,
int  gridSize = 1 
)

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

Definition at line 285 of file TrackDetMatchInfo.cc.

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

286 {
287  switch (type) {
288  case TowerTotal:
289  case TowerHcal:
290  case TowerEcal:
291  case TowerHO:
292  if( crossedTowerIds.empty() ) return 0;
293  return nXnEnergy(crossedTowerIds.front(), type, gridSize);
294  break;
295  case EcalRecHits:
296  if( crossedEcalIds.empty() ) return 0;
297  return nXnEnergy(crossedEcalIds.front(), type, gridSize);
298  break;
299  case HcalRecHits:
300  if( crossedHcalIds.empty() ) return 0;
301  return nXnEnergy(crossedHcalIds.front(), type, gridSize);
302  break;
303  case HORecHits:
304  if( crossedHOIds.empty() ) return 0;
305  return nXnEnergy(crossedHOIds.front(), type, gridSize);
306  break;
307  default:
308  throw cms::Exception("FatalError") << "Unkown or not implemented energy type requested, type:" << type;
309  }
310  return -999;
311 }
type
Definition: HCALResponse.h:21
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
void TrackDetMatchInfo::setCaloGeometry ( edm::ESHandle< CaloGeometry geometry)
inline

Definition at line 112 of file TrackDetMatchInfo.h.

References caloGeometry, dumpGeometry(), geometry, getPosition(), insideCone(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TrackDetectorAssociator::associate().

112 { caloGeometry = geometry; }
edm::ESHandle< CaloGeometry > caloGeometry
ESHandle< TrackerGeometry > geometry

Member Data Documentation

edm::ESHandle<CaloGeometry> TrackDetMatchInfo::caloGeometry
private

Definition at line 117 of file TrackDetMatchInfo.h.

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

std::vector<TAMuonChamberMatch> TrackDetMatchInfo::chambers
std::vector<DetId> TrackDetMatchInfo::crossedEcalIds
std::vector<const EcalRecHit*> TrackDetMatchInfo::crossedEcalRecHits

hits in detector elements crossed by a track

Definition at line 60 of file TrackDetMatchInfo.h.

Referenced by crossedEnergy(), CaloCleaner< T >::fill_correction_map(), and TrackDetectorAssociator::fillEcal().

std::vector<DetId> TrackDetMatchInfo::crossedHcalIds
std::vector<const HBHERecHit*> TrackDetMatchInfo::crossedHcalRecHits
std::vector<DetId> TrackDetMatchInfo::crossedHOIds
std::vector<const HORecHit*> TrackDetMatchInfo::crossedHORecHits
std::vector<DetId> TrackDetMatchInfo::crossedPreshowerIds
std::vector<DetId> TrackDetMatchInfo::crossedTowerIds
std::vector<const CaloTower*> TrackDetMatchInfo::crossedTowers
std::vector<const EcalRecHit*> TrackDetMatchInfo::ecalRecHits
double TrackDetMatchInfo::ecalTrueEnergy

Definition at line 80 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillCaloTruth().

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

Definition at line 81 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillCaloTruth().

double TrackDetMatchInfo::hcalTrueEnergyCorrected

Definition at line 82 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillCaloTruth().

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

Definition at line 49 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillCaloTowers().

bool TrackDetMatchInfo::isGoodEcal
bool TrackDetMatchInfo::isGoodHcal
bool TrackDetMatchInfo::isGoodHO

Definition at line 50 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillHO().

bool TrackDetMatchInfo::isGoodMuon

Definition at line 51 of file TrackDetMatchInfo.h.

const SimTrack* TrackDetMatchInfo::simTrack

MC truth info.

Definition at line 79 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::fillCaloTruth().

SimTrackRef TrackDetMatchInfo::simTrackRef_

Definition at line 87 of file TrackDetMatchInfo.h.

FreeTrajectoryState TrackDetMatchInfo::stateAtIP
std::vector<const CaloTower*> TrackDetMatchInfo::towers
reco::TrackRef TrackDetMatchInfo::trackRef_

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

Definition at line 86 of file TrackDetMatchInfo.h.

math::XYZPoint TrackDetMatchInfo::trkGlobPosAtEcal
math::XYZPoint TrackDetMatchInfo::trkGlobPosAtHcal
math::XYZPoint TrackDetMatchInfo::trkGlobPosAtHO
GlobalVector TrackDetMatchInfo::trkMomAtEcal
GlobalVector TrackDetMatchInfo::trkMomAtHcal
GlobalVector TrackDetMatchInfo::trkMomAtHO

Definition at line 45 of file TrackDetMatchInfo.h.

Referenced by TrackDetectorAssociator::associate().