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