ATLAS Offline Software
Loading...
Searching...
No Matches
eflowCaloObject.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: eflowCaloObject.cxx
8PACKAGE: offline/Reconstruction/eflowRec
9
10AUTHORS: D.R.Tovey, M.Hodgkinson and T.Velz
11CREATED: 22nd November, 2004
12
13********************************************************************/
14
23
25
26void eflowCaloObject::addTrackClusterLinks(const std::vector<eflowTrackClusterLink*> &trackClusterLink) {
27 for (auto *ptr : trackClusterLink) {
29 }
30}
31
32 void eflowCaloObject::addTracks(const std::vector<eflowRecTrack*> &tracks) {
33 m_eflowRecTracks.insert(m_eflowRecTracks.end(), tracks.begin(), tracks.end());
34 }
35
36 void eflowCaloObject::addClusters(const std::vector<eflowRecCluster*> &clusters) {
37 m_eflowRecClusters.insert(m_eflowRecClusters.end(), clusters.begin(), clusters.end());
38 }
39
41 double expectedEnergy(0.0);
42 for(unsigned iTrack=0; iTrack < nTracks(); ++iTrack) {
43 if (!efRecTrack(iTrack)->isInDenseEnvironment()) expectedEnergy += efRecTrack(iTrack)->getEExpect();
44 }
45 return expectedEnergy;
46}
47
49 double expectedVariance(0.0);
50 for(unsigned iTrack=0; iTrack < nTracks(); ++iTrack) {
51 if (!efRecTrack(iTrack)->isInDenseEnvironment()) expectedVariance += efRecTrack(iTrack)->getVarEExpect();
52 }
53 return expectedVariance;
54}
55
57 double clusterEnergy(0.0);
58 for(unsigned iCluster=0; iCluster < nClusters(); ++iCluster) {
59 clusterEnergy += efRecCluster(iCluster)->getCluster()->e();
60 }
61 return clusterEnergy;
62}
63
65const PFEnergyPredictorTool* energyP, bool useLegacyEnergyBinIndexing){
66
67 for (auto *thisEfRecTrack : m_eflowRecTracks) {
68
69 std::vector<eflowRecCluster*> matchedClusters;
70 matchedClusters.clear();
71 std::vector<eflowTrackClusterLink*> links = thisEfRecTrack->getClusterMatches();
72 std::vector<eflowTrackClusterLink*>::iterator itLink = links.begin();
73 std::vector<eflowTrackClusterLink*>::iterator endLink = links.end();
74 for (; itLink != endLink; ++itLink) {
75 matchedClusters.push_back((*itLink)->getCluster());
76 }
77
78 double trackEM1eta = thisEfRecTrack->getTrackCaloPoints().getEM1eta();
79 /* if a track is in the forward EM (2.5 < eta < 3.2) then there is no EM1 -> need to use EM2 */
80 if(trackEM1eta<-998.) trackEM1eta = thisEfRecTrack->getTrackCaloPoints().getEM2eta();
81 /* if a track is not in the EM region (3.2 < eta < 4.0) then should use FCAL0 */
82 if(trackEM1eta<-998.) trackEM1eta = thisEfRecTrack->getTrackCaloPoints().getFCAL0eta();
83
84 double trackE = thisEfRecTrack->getTrack()->e();
85
86 if (!binnedParameters->binExists(trackE, trackEM1eta)) {
87 thisEfRecTrack->setHasBin(false);
88 return;
89 }
90
91 /* Determine the LFI */
92 integrator->measureNewClus(matchedClusters, thisEfRecTrack);
93 eflowFirstIntENUM j1st = integrator->getFirstIntLayer();
94
95 /*Save j1st info */
96 thisEfRecTrack->setLayerHED(j1st);
97
98 /* Get parameters for j1st */
99 eflowRingSubtractionManager& cellSubtractionManager = thisEfRecTrack->getCellSubtractionManager();
100 cellSubtractionManager.getOrdering(binnedParameters, trackE, trackEM1eta, j1st,useLegacyEnergyBinIndexing);
101
102 /* Set expected energy in the eflowRecTrack object */
103 const double expectedEnergy = energyP ? energyP->nnEnergyPrediction(thisEfRecTrack) : cellSubtractionManager.fudgeMean() * thisEfRecTrack->getTrack()->e();
104 const double expectedEnergySigma = fabs(cellSubtractionManager.fudgeStdDev() * thisEfRecTrack->getTrack()->e());
105
106 const std::vector<eflowTrackClusterLink*>* bestClusters_015 = thisEfRecTrack->getAlternativeClusterMatches("cone_015");
107 const std::vector<eflowTrackClusterLink*>* bestClusters_02 = thisEfRecTrack->getAlternativeClusterMatches("cone_02");
108
109 //First we calculate how much energy is found in a cone of 0.15
110 float totalE_015 = 0.0;
111
112 //This pointer can be a nullptr if no clusters were matched to a track in dR < 0.15
113 if (bestClusters_015){
114 for (eflowTrackClusterLink* thisLink : *bestClusters_015){
115 eflowRecCluster* thisBestCluster = thisLink->getCluster();
116 if (thisBestCluster){
117 const xAOD::CaloCluster* theCluster = thisBestCluster->getCluster();
118 if (theCluster) {
119 if (theCluster->e()>0.0){
120 totalE_015 += theCluster->e();
121 }
122 }
123 }
124 }
125 }//if vector of 0.15 clusters exists
126
127 double pull_015 = NAN;
128 if (expectedEnergySigma > 1e-6 ) pull_015 = (totalE_015-expectedEnergy)/expectedEnergySigma;
129 thisEfRecTrack->setpull15(pull_015);
130
131 double trackPt = thisEfRecTrack->getTrack()->pt();
132 //If the looked up expected energy deposit was 0.0, then pull_015 is NAN. In that case we should not try to apply the 2D cut described below.
133 if (!std::isnan(pull_015)){
134 //We use a 2D cut in the pull_015 and log10 of track pt plane to define a dense environment - if too dense then we disable the charged shower subtraction
135 //The cut values are such that above a track pt of 40 GeV we are very agrressive about disabling the cell by cell charged shower subtraction.
136 //The specific cut values were found by optimising the jet resolutions in the run 2 data taking environment.
137 //Further details can be found in these slides from C. Young:
138 //https://indico.cern.ch/event/396923/contributions/949333/attachments/795878/1090871/Presentation.pdf
139 if (pull_015 > 0.0 + (log10(40000)-log10(trackPt))*33.2 && 0.0 != expectedEnergySigma && bestClusters_015 && bestClusters_02){
140 thisEfRecTrack->setSubtracted(); //this tricks eflowRec into thinking this track was subtracted, and hence no further subtraction will be done
141 thisEfRecTrack->setIsInDenseEnvironment();
142 //recalculate the LHED and the ordering and find the new expected E + sigma of expected E (the new LHED can change the latter two values we find in the look up tables)
143 //we use a larger cone of 0.2 for this
144 std::vector<eflowRecCluster*> theBestEfRecClusters_02;
145 for (eflowTrackClusterLink* thisLink : *bestClusters_02) if (thisLink->getCluster()->getCluster()->e() > 0.0) theBestEfRecClusters_02.push_back(thisLink->getCluster());
146 integrator->measureNewClus(theBestEfRecClusters_02, thisEfRecTrack);
147 j1st = integrator->getFirstIntLayer();
148 cellSubtractionManager.getOrdering(binnedParameters, trackE, trackEM1eta, j1st,useLegacyEnergyBinIndexing);
149 thisEfRecTrack->setEExpect(cellSubtractionManager.fudgeMean() * trackE, fabs(cellSubtractionManager.fudgeStdDev()*trackE)*fabs(cellSubtractionManager.fudgeStdDev()*trackE));
150 }
151 else {
152 thisEfRecTrack->setEExpect(expectedEnergy, expectedEnergySigma*expectedEnergySigma);
153 }//ok to do subtraction, and so we just set the usual expected E + sigma of expected E needed for subtraction
154 }
155 }
156}
157
158
float nnEnergyPrediction(const eflowRecTrack *ptr) const
void addTracks(const std::vector< eflowRecTrack * > &tracks)
double getExpectedVariance() const
std::vector< eflowRecTrack * > m_eflowRecTracks
double getClusterEnergy() const
void addTrackClusterLinks(const std::vector< eflowTrackClusterLink * > &trackClusterLink)
void addClusters(const std::vector< eflowRecCluster * > &clusters)
void addTrackClusterLink(eflowTrackClusterLink *trackClusterLink)
unsigned nClusters() const
const eflowRecTrack * efRecTrack(int i) const
std::vector< eflowRecCluster * > m_eflowRecClusters
unsigned nTracks() const
double getExpectedEnergy() const
void simulateShower(eflowLayerIntegrator *integrator, const eflowEEtaBinnedParameters *binnedParameters, const PFEnergyPredictorTool *energyP, bool useLegacyEnergyBinIndexing)
const eflowRecCluster * efRecCluster(int i) const
bool binExists(double e, double eta) const
Inherits from eflowEEtaBinBase.
This class calculates the LHED (Layer of Highest Energy Density) in a cluster or group of clusters.
void measureNewClus(const xAOD::CaloCluster *clus, const eflowTrackCaloPoints &trackCalo)
eflowFirstIntENUM getFirstIntLayer() const
This class extends the information about a xAOD::CaloCluster.
xAOD::CaloCluster * getCluster()
double getEExpect() const
double getVarEExpect() const
This stores information, a rank and ring thickness, about cell rings in an ordered way.
bool getOrdering(const eflowEEtaBinnedParameters *binnedParameters, double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing)
virtual double e() const
The total energy of the particle.
eflowFirstIntRegions::J1STLAYER eflowFirstIntENUM
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.