ATLAS Offline Software
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 
7 NAME: eflowCaloObject.cxx
8 PACKAGE: offline/Reconstruction/eflowRec
9 
10 AUTHORS: D.R.Tovey, M.Hodgkinson and T.Velz
11 CREATED: 22nd November, 2004
12 
13 ********************************************************************/
14 
16 #include "eflowRec/eflowRecTrack.h"
23 
25 
26 void 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 
65 const 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();
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  if (pull_015 > 0.0 + (log10(40000)-log10(trackPt))*33.2 && 0.0 != expectedEnergySigma && bestClusters_015 && bestClusters_02 && useUpdated2015ChargedShowerSubtraction){
136  thisEfRecTrack->setSubtracted(); //this tricks eflowRec into thinking this track was subtracted, and hence no further subtraction will be done
137  thisEfRecTrack->setIsInDenseEnvironment();
138  //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)
139  //we use a larger cone of 0.2 for this
140  std::vector<eflowRecCluster*> theBestEfRecClusters_02;
141  for (eflowTrackClusterLink* thisLink : *bestClusters_02) if (thisLink->getCluster()->getCluster()->e() > 0.0) theBestEfRecClusters_02.push_back(thisLink->getCluster());
142  integrator->measureNewClus(theBestEfRecClusters_02, thisEfRecTrack);
143  j1st = integrator->getFirstIntLayer();
144  cellSubtractionManager.getOrdering(binnedParameters, trackE, trackEM1eta, j1st,useLegacyEnergyBinIndexing);
145  thisEfRecTrack->setEExpect(cellSubtractionManager.fudgeMean() * trackE, fabs(cellSubtractionManager.fudgeStdDev()*trackE)*fabs(cellSubtractionManager.fudgeStdDev()*trackE));
146  }
147  else {
148  thisEfRecTrack->setEExpect(expectedEnergy, expectedEnergySigma*expectedEnergySigma);
149  }//ok to do subtraction, and so we just set the usual expected E + sigma of expected E needed for subtraction
150  }
151  }
152 }
153 
154 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
eflowRecCluster
This class extends the information about a xAOD::CaloCluster.
Definition: eflowRecCluster.h:40
eflowCaloObject::nClusters
unsigned nClusters() const
Definition: eflowCaloObject.h:59
eflowCaloObject::getExpectedEnergy
double getExpectedEnergy() const
Definition: eflowCaloObject.cxx:40
eflowEEtaBinnedParameters
Inherits from eflowEEtaBinBase.
Definition: eflowEEtaBinnedParameters.h:56
eflowLayerIntegrator
This class calculates the LHED (Layer of Highest Energy Density) in a cluster or group of clusters.
Definition: eflowLayerIntegrator.h:35
eflowRecTrack::isInDenseEnvironment
bool isInDenseEnvironment() const
Definition: eflowRecTrack.h:116
PFEnergyPredictorTool
Definition: PFEnergyPredictorTool.h:17
eflowRingSubtractionManager::fudgeStdDev
double fudgeStdDev() const
Definition: eflowRingSubtractionManager.h:38
eflowCaloObject::getExpectedVariance
double getExpectedVariance() const
Definition: eflowCaloObject.cxx:48
eflowLayerIntegrator::measureNewClus
void measureNewClus(const xAOD::CaloCluster *clus, const eflowTrackCaloPoints &trackCalo)
Definition: eflowLayerIntegrator.cxx:154
eflowCaloObject::addTrackClusterLink
void addTrackClusterLink(eflowTrackClusterLink *trackClusterLink)
Definition: eflowCaloObject.h:77
eflowLayerIntegrator.h
eflowRecTrack.h
eflowCaloObject::addClusters
void addClusters(const std::vector< eflowRecCluster * > &clusters)
Definition: eflowCaloObject.cxx:36
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
eflowCaloObject::efRecTrack
const eflowRecTrack * efRecTrack(int i) const
Definition: eflowCaloObject.h:51
DMTest::links
links
Definition: CLinks_v1.cxx:22
eflowRecTrack::getEExpect
double getEExpect() const
Definition: eflowRecTrack.h:97
eflowRingSubtractionManager::fudgeMean
double fudgeMean() const
Definition: eflowRingSubtractionManager.h:37
eflowRecCluster::getCluster
xAOD::CaloCluster * getCluster()
Definition: eflowRecCluster.h:49
eflowCaloObject::nTracks
unsigned nTracks() const
Definition: eflowCaloObject.h:53
PFEnergyPredictorTool.h
eflowRecCluster.h
eflowRingSubtractionManager.h
eflowCaloObject::m_eflowRecClusters
std::vector< eflowRecCluster * > m_eflowRecClusters
Definition: eflowCaloObject.h:81
TauGNNUtils::Variables::Track::trackPt
bool trackPt(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:470
eflowRingSubtractionManager
This stores information, a rank and ring thickness, about cell rings in an ordered way.
Definition: eflowRingSubtractionManager.h:31
eflowRingSubtractionManager::getOrdering
bool getOrdering(const eflowEEtaBinnedParameters *binnedParameters, double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing)
Definition: eflowRingSubtractionManager.cxx:103
eflowCaloObject.h
PFEnergyPredictorTool::nnEnergyPrediction
float nnEnergyPrediction(const eflowRecTrack *ptr) const
Definition: PFEnergyPredictorTool.cxx:134
eflowCaloObject::~eflowCaloObject
~eflowCaloObject()
eflowCaloObject::simulateShower
void simulateShower(eflowLayerIntegrator *integrator, const eflowEEtaBinnedParameters *binnedParameters, bool useUpdated2015ChargedShowerSubtraction, const PFEnergyPredictorTool *energyP, bool useLegacyEnergyBinIndexing)
Definition: eflowCaloObject.cxx:64
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
PFHLTConfig.useUpdated2015ChargedShowerSubtraction
useUpdated2015ChargedShowerSubtraction
Definition: PFHLTConfig.py:358
eflowCaloObject::efRecCluster
const eflowRecCluster * efRecCluster(int i) const
Definition: eflowCaloObject.h:57
eflowRecTrack::getVarEExpect
double getVarEExpect() const
Definition: eflowRecTrack.h:98
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
eflowLayerIntegrator::getFirstIntLayer
eflowFirstIntENUM getFirstIntLayer() const
Definition: eflowLayerIntegrator.cxx:230
eflowEEtaBinBase::binExists
bool binExists(double e, double eta) const
Definition: eflowEEtaBinBase.h:32
eflowCaloObject::m_eflowRecTracks
std::vector< eflowRecTrack * > m_eflowRecTracks
Definition: eflowCaloObject.h:91
eflowCaloObject::getClusterEnergy
double getClusterEnergy() const
Definition: eflowCaloObject.cxx:56
eflowCaloObject::addTrackClusterLinks
void addTrackClusterLinks(const std::vector< eflowTrackClusterLink * > &trackClusterLink)
Definition: eflowCaloObject.cxx:26
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
eflowEEtaBinnedParameters.h
eflowCaloObject::addTracks
void addTracks(const std::vector< eflowRecTrack * > &tracks)
Definition: eflowCaloObject.cxx:32
eflowFirstIntRegions::J1STLAYER
J1STLAYER
Definition: eflowCaloRegions.h:58