ATLAS Offline Software
PFRadialEnergyCalculatorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
14 
16 
17  ATH_MSG_DEBUG("Accessed radial energy profile function");
18 
19  for (auto thisEflowCaloObject : theEflowCaloObjectContainer){
20 
21  //If there are no clusters available then we cannot calculate any calorimeter shower profiles
22  if (thisEflowCaloObject->nClusters() < 1 ) continue;
23 
24  const std::vector<std::pair<eflowTrackClusterLink*,std::pair<float,float> > > matchedTrackList = thisEflowCaloObject->efRecLink();
25 
26  for( auto track: matchedTrackList){
27 
28  eflowRecTrack* efRecTrack = (track.first)->getTrack();
29 
30  std::vector<eflowRecCluster*> matchedClusters;
31  matchedClusters.clear();
32  std::vector<eflowTrackClusterLink*> links = efRecTrack->getClusterMatches();
33  for (auto *thisEFlowTrackClusterLink : links) matchedClusters.push_back(thisEFlowTrackClusterLink->getCluster());
34 
35  std::vector<std::pair<xAOD::CaloCluster*, bool> > clusterSubtractionList;
36  clusterSubtractionList.reserve(matchedClusters.size());
37  for (auto *thisEFlowRecCluster : matchedClusters) clusterSubtractionList.emplace_back(thisEFlowRecCluster->getCluster(),false);
38 
39  eflowCellList calorimeterCellList;
40  eflowSubtract::Subtractor::makeOrderedCellList(efRecTrack->getTrackCaloPoints(),clusterSubtractionList,calorimeterCellList);
41 
42  std::vector<int> layerToStoreVector;
43  std::vector<float> radiusToStoreVector;
44  std::vector<float> avgEdensityToStoreVector;
45 
46  //Loop over calorimeter layers and in each layer we will calculate radial energy profiles.
47  for (int i=0; i < eflowCalo::nRegions ;i++){
48 
50  ATH_MSG_DEBUG("layer is "<<layer);
51  double ringThickness = eflowRingThicknesses::ringThickness((eflowCaloENUM)i);
52  ATH_MSG_DEBUG("ring thickness is "<<ringThickness);
53 
54  double eta_extr = calorimeterCellList.etaFF(layer);
55  ATH_MSG_DEBUG("extrapolated eta ["<<layer<<"] is "<<eta_extr);
56  double phi_extr = calorimeterCellList.phiFF(layer);
57  ATH_MSG_DEBUG("extrapolated phi ["<<layer<<"] is "<<phi_extr);
58 
59  if (eta_extr == -999.0){
60  continue;
61  }
62 
63  //Loop over rings of calorimeter cells going out in increasing radius from the track impact point in this calorimeter layer
64  for (unsigned int indexOfRing = 0; indexOfRing < 100; indexOfRing++){
65 
66  CellIt beginRing = calorimeterCellList.getLowerBound((eflowCaloENUM)i, ringThickness*(indexOfRing));
67  if(beginRing == calorimeterCellList.end()) break;
68 
69  int totalCellsinRing = 0;
70  double totalEnergyPerRing = 0;
71  double energyDensityPerRing = 0;
72  double averageEnergyDensityPerRing = 0;
73 
74  //Get the list of calorimeter cells in this cell ring
75  std::vector<std::pair<const CaloCell*,int> > tempVector = (*beginRing).second;
76 
77  //Loop over the calorimeter cells in this cell ring and calculate total and average energy densities in this cell ring.
78  for (auto thisPair : tempVector){
79  const CaloDetDescrElement* DDE = (thisPair.first)->caloDDE();
80  CaloCell_ID::CaloSample sampling = DDE->getSampling();
81 
82  if(eflowCalo::translateSampl(sampling)!=(eflowCaloENUM)i) break;
83 
84  ATH_MSG_DEBUG(" cell eta and phi are " << (thisPair.first)->eta() << " and " << (thisPair.first)->phi() << " with index " << thisPair.second << " and sampling of " << sampling);
85  ATH_MSG_DEBUG(" cell energy is " << (thisPair.first)->energy());
86 
87  totalCellsinRing += 1;
88 
89  totalEnergyPerRing += (thisPair.first)->energy();
90  double totalEnergyCell = (thisPair.first)->energy();
91  ATH_MSG_DEBUG(" Total E per Cell is " << totalEnergyCell);
92  ATH_MSG_DEBUG(" Total E per Ring is " << totalEnergyPerRing);
93 
94  double cellVolume = DDE->volume();
95  ATH_MSG_DEBUG(" cell volume is " << cellVolume/1000.);
96 
97  double energyDensityCell = totalEnergyCell/(cellVolume/1000.);
98  ATH_MSG_DEBUG(" E density per Cell is " << energyDensityCell);
99  ATH_MSG_DEBUG(" Initial added E density per Cell is " << energyDensityPerRing);
100  energyDensityPerRing += energyDensityCell;
101  ATH_MSG_DEBUG(" Final added E density per Cell is " << energyDensityPerRing);
102  averageEnergyDensityPerRing = energyDensityPerRing/((totalCellsinRing)*(efRecTrack->getTrack()->e()/1000.));
103 
104  }
105 
106  ATH_MSG_DEBUG(" track eta is " << efRecTrack->getTrack()->eta());
107  ATH_MSG_DEBUG(" track E is " << efRecTrack->getTrack()->e()/1000.);
108  ATH_MSG_DEBUG(" Average E density per Ring is " << averageEnergyDensityPerRing);
109 
110  //Fill up the vectors with energy density, layer and ring radii
111  if (averageEnergyDensityPerRing != 0){
112  avgEdensityToStoreVector.push_back(averageEnergyDensityPerRing);
113  int layerToStore = (eflowCaloENUM)i;
114  ATH_MSG_DEBUG("layerToStore is "<< layerToStore);
115  layerToStoreVector.push_back(layerToStore);
116  double radiusToStore = (indexOfRing)*ringThickness;
117  ATH_MSG_DEBUG("radiusToStore is "<< radiusToStore);
118  radiusToStoreVector.push_back(radiusToStore);
119  }
120  else {ATH_MSG_DEBUG("averageEnergyDensityPerRing = 0");}
121 
122  }//loop over rings of calorimeter cells
123 
124  }//loop over the calorimeter layers
125 
126  //Add the vectors with energy density, layer and ring radii to this eflowRecTrack
127  efRecTrack->setLayerCellOrderVector(layerToStoreVector);
128  efRecTrack->setRadiusCellOrderVector(radiusToStoreVector);
129  efRecTrack->setAvgEDensityCellOrderVector(avgEdensityToStoreVector);
130 
131  }//loop over tracks matched to clusters
132 
133  }//loop on eflowCaloObjectContainer
134 
135  return StatusCode::SUCCESS;
136 }
eflowRecTrack::setRadiusCellOrderVector
void setRadiusCellOrderVector(const std::vector< float > &radiusToStoreVector)
Definition: eflowRecTrack.h:97
eflowCellList::phiFF
double phiFF(eflowCaloENUM layer) const
Definition: eflowCellList.h:79
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:79
eflowRecTrack::setAvgEDensityCellOrderVector
void setAvgEDensityCellOrderVector(const std::vector< float > &avgEdensityToStoreVector)
Definition: eflowRecTrack.h:100
eflowSubtractor.h
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
eflowCellList::end
CellIt end()
Definition: eflowCellList.h:57
eflowRecTrack::setLayerCellOrderVector
void setLayerCellOrderVector(const std::vector< int > &layerToStoreVector)
Definition: eflowRecTrack.h:94
eflowCellList
Concrete class derived class from pure virtual eflowAbstractCellList.
Definition: eflowCellList.h:42
PFRadialEnergyCalculatorTool::execute
virtual StatusCode execute(eflowCaloObjectContainer &theEflowCaloObjectContainer) override
Definition: PFRadialEnergyCalculatorTool.cxx:15
eflowCellList::etaFF
double etaFF(eflowCaloENUM layer) const
Definition: eflowCellList.h:78
eflowRecTrack
This class extends the information about a xAOD::Track.
Definition: eflowRecTrack.h:46
eflowRingThicknesses.h
eflowRecTrack::getClusterMatches
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
Definition: eflowRecTrack.h:67
eflowRecTrack.h
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
eflowRingThicknesses::ringThickness
static double ringThickness(const eflowCaloENUM &layer)
Definition: eflowRingThicknesses.cxx:5
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::links
links
Definition: CLinks_v1.cxx:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
eflowRecCluster.h
PFRadialEnergyCalculatorTool.h
eflowCellList.h
eflowRecTrack::getTrack
const xAOD::TrackParticle * getTrack() const
Definition: eflowRecTrack.h:54
CaloDetDescrElement::volume
float volume() const
cell volume
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:381
eflowCalo::nRegions
static const int nRegions
Definition: eflowCaloRegions.h:45
xAOD::TrackParticle_v1::e
virtual double e() const override final
The total energy of the particle.
Definition: TrackParticle_v1.cxx:111
CellIt
std::map< eflowCellPosition, std::vector< std::pair< const CaloCell *, int > > >::iterator CellIt
Definition: eflowAbstractCellList.h:25
eflowRecTrack::getTrackCaloPoints
const eflowTrackCaloPoints & getTrackCaloPoints() const
Definition: eflowRecTrack.h:56
eflowCalo::LAYER
LAYER
Definition: eflowCaloRegions.h:36
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
eflowSubtract::Subtractor::makeOrderedCellList
static void makeOrderedCellList(const eflowTrackCaloPoints &trackCalo, const std::vector< std::pair< xAOD::CaloCluster *, bool >> &clusters, eflowCellList &orderedCells)
Definition: eflowSubtractor.cxx:51
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
eflowCellList::getLowerBound
CellIt getLowerBound(eflowCaloENUM layer, double r)
Definition: eflowCellList.h:59
eflowCalo::translateSampl
static LAYER translateSampl(CaloCell_ID::CaloSample sampl)
Definition: eflowCaloRegions.cxx:45
eflowCaloObjectContainer
Definition: eflowCaloObject.h:101
eflowCaloENUM
eflowCalo::LAYER eflowCaloENUM
Definition: eflowCaloRegions.h:49