ATLAS Offline Software
TrackDepositInCaloTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOTRKMUIDTOOLS_TRACKDEPOSITINCALOTOOL_H
6 #define CALOTRKMUIDTOOLS_TRACKDEPOSITINCALOTOOL_H
7 
8 // --- Tools ---
11 
12 // --- Athena common ---
14 #include "GaudiKernel/ITHistSvc.h"
15 #include "GaudiKernel/ToolHandle.h"
18 
19 // --- Athena ---
23 #include "CxxUtils/CachedValue.h"
24 
25 // --- STL ---
26 #include <map>
27 #include <vector>
28 
29 // --- Forward declarations ---
30 class CaloCellContainer;
31 class CaloPhiRange;
33 
34 class TH1F;
35 class TH2F;
36 
37 
39 // TrackDepositInCaloTool
41 class TrackDepositInCaloTool : public AthAlgTool, virtual public ITrackDepositInCaloTool {
52 public:
53  TrackDepositInCaloTool(const std::string& type, const std::string& name, const IInterface* pInterface);
54  virtual ~TrackDepositInCaloTool() = default;
55 
56  StatusCode initialize() override;
57 
64  std::vector<DepositInCalo> getDeposits(const Trk::TrackParameters* par, const CaloCellContainer* caloCellCont) const override;
65 
66  std::vector<DepositInCalo> getDeposits(const xAOD::TrackParticle* tp, const CaloCellContainer* caloCellCont,
67  const CaloExtensionCollection* extensionCache) const override;
68 
69  std::vector<DepositInCalo> deposits(const Trk::TrackParameters* par, const CaloCellContainer* cellContainer) const override;
81  Trk::Surface* createSurface(const CaloDetDescriptor* descr, CaloSurfaceType type) const override;
82 
88  double calcEnergy(const Trk::TrackParameters* par, const Trk::ParticleHypothesis& particleHypo) const override;
89 
90 private:
91  std::unique_ptr<const Trk::TrackParameters> extrapolateToSolenoid(const EventContext& ctx, const Trk::TrackParameters* par,
92  bool oppositeMomentum = false) const;
93 
99  static std::unique_ptr<Amg::Vector3D> extrapolateR(const Amg::Vector3D& initialPosition, double phi0, double theta0, double r) ;
104  static std::unique_ptr<Amg::Vector3D> extrapolateZ(const Amg::Vector3D& initialPosition, double phi0, double theta0, double z) ;
109 
115  const CaloCell* getClosestCell(const CaloDetDescrManager* caloDDM,
116  const Trk::TrackParameters* par,
117  const CaloDetDescriptor* descr,
118  const CaloCellContainer* cellContainer) const;
119 
120 
121  static const CaloCell* getClosestCellLAr(const CaloDetDescrManager* caloDDM,
122  const Trk::TrackParameters* par,
123  const CaloDetDescriptor* descr,
124  const CaloCellContainer* caloCellCont);
125 
126  const CaloCell* getClosestCellTile(const CaloDetDescrManager* caloDDM,
127  const Trk::TrackParameters* par,
128  const CaloDetDescriptor* descr,
129  const CaloCellContainer* caloCellCont) const;
130 
131  std::vector<const CaloCell*> getCaloCellsForLayer(const CaloDetDescrManager* caloDDM,
132  const CaloDetDescriptor* descr,
133  const Trk::TrackParameters* parEntrance,
134  const Trk::TrackParameters* parExit,
135  const CaloCellContainer* caloCellCont) const;
136 
137  std::vector<const CaloCell*> getCaloCellsForTile(const CaloDetDescrManager* caloDDM,
138  const CaloDetDescriptor* descr,
139  const Trk::TrackParameters* parEntrance,
140  const Trk::TrackParameters* parExit,
141  const CaloCellContainer* caloCellCont) const;
142 
155  const Trk::TrackParameters* par,
156  std::map<double, const CaloDetDescriptor*>& caloInfo,
157  std::vector<Amg::Vector3D>& extrapolations) const;
158 
159  std::unique_ptr<const Trk::TrackParameters> extrapolateToEntranceOfLayer(const EventContext& ctx,
160  const Trk::TrackParameters* par,
161  const CaloDetDescriptor* descr) const;
162 
163  std::unique_ptr<const Trk::TrackParameters> extrapolateToExitOfLayer(const EventContext& ctx,
164  const Trk::TrackParameters* par,
165  const CaloDetDescriptor* descr) const;
166 
167  static double distance(const Amg::Vector3D& p1, const Amg::Vector3D& p2) ;
168 
169  static bool isInsideDomain(double position, double domainCenter, double domainWidth, bool phiVariable = false) ;
170  static bool isInsideCell(const Amg::Vector3D& position, const CaloCell* cell) ;
171  static bool inCell(const CaloCell* cell, const Amg::Vector3D& pos) ;
172 
173 private:
174  // Services & Tools
176  ToolHandle<Trk::IExtrapolator> m_extrapolator{this, "ExtrapolatorHandle", ""};
177 
179 
180  ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtensionTool{this, "ParticleCaloExtensionTool", "",
181  "Tool to make the step-wise extrapolation"};
182  ToolHandle<Rec::IParticleCaloCellAssociationTool> m_caloCellAssociationTool{this, "ParticleCaloCellAssociationTool", ""};
183 
185  this,
186  "CaloDetDescrManager",
187  "CaloDetDescrManager",
188  "SG Key for CaloDetDescrManager in the Condition Store"
189  };
190 
191  // Members
192  bool m_doExtr;
193  bool m_doHist;
194 
195  struct LayerMaps {
197  CaloLayerMap m_barrelLayerMap;
199  CaloLayerMap m_endCapLayerMap;
200  };
202 
204 
205  // Histograms
206  struct Hists {
207  StatusCode book (ITHistSvc& histSvc);
208 
212 
215 
223 
230  };
231  std::unique_ptr<Hists> m_h;
232  Hists& getHists() const;
233 
234 };
235 
236 #endif
TrackDepositInCaloTool::extrapolateR
static std::unique_ptr< Amg::Vector3D > extrapolateR(const Amg::Vector3D &initialPosition, double phi0, double theta0, double r)
Extrapolate track to cylinder surface along straight line.
Definition: TrackDepositInCaloTool.cxx:701
TrackDepositInCaloTool::getClosestCell
const CaloCell * getClosestCell(const CaloDetDescrManager *caloDDM, const Trk::TrackParameters *par, const CaloDetDescriptor *descr, const CaloCellContainer *cellContainer) const
Retrieve the CaloCell for which its center is closest to the position of the particle.
Definition: TrackDepositInCaloTool.cxx:895
TrackDepositInCaloTool::Hists::m_hEMB3vsdEta
TH2F * m_hEMB3vsdEta
Definition: TrackDepositInCaloTool.h:229
beamspotman.r
def r
Definition: beamspotman.py:676
TrackDepositInCaloTool::initializeDetectorInfo
LayerMaps initializeDetectorInfo(const CaloDetDescrManager *caloDDM) const
Definition: TrackDepositInCaloTool.cxx:642
TrackDepositInCaloTool::bookHistos
StatusCode bookHistos()
Create histograms and register them to HistSvc.
Definition: TrackDepositInCaloTool.cxx:1007
CaloPhiRange
This class defines the phi convention for Calorimeters.
Definition: CaloPhiRange.h:28
TrackDepositInCaloTool::Hists::m_hParELossEta
TH2F * m_hParELossEta
Definition: TrackDepositInCaloTool.h:213
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
TrackDepositInCaloTool::createSurface
Trk::Surface * createSurface(const CaloDetDescriptor *descr, CaloSurfaceType type) const override
Creates a Trk::Surface for a calorimeter region that is described by CaloDetDescr.
Definition: TrackDepositInCaloTool.cxx:831
TrackDepositInCaloTool::deposits
std::vector< DepositInCalo > deposits(const Trk::TrackParameters *par, const CaloCellContainer *cellContainer) const override
Definition: TrackDepositInCaloTool.cxx:478
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
TrackDepositInCaloTool::calcEnergy
double calcEnergy(const Trk::TrackParameters *par, const Trk::ParticleHypothesis &particleHypo) const override
Calculate the energy using .
Definition: TrackDepositInCaloTool.cxx:629
TrackDepositInCaloTool::initialize
StatusCode initialize() override
Definition: TrackDepositInCaloTool.cxx:54
TrackDepositInCaloTool::Hists
Definition: TrackDepositInCaloTool.h:206
TrackDepositInCaloTool::Hists::m_hEMB1vsdPhi
TH2F * m_hEMB1vsdPhi
Definition: TrackDepositInCaloTool.h:224
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
TrackDepositInCaloTool::m_doExtr
bool m_doExtr
Flag to perform extrapolations using m_extrapolator.
Definition: TrackDepositInCaloTool.h:192
TrackDepositInCaloTool::Hists::m_hDepositLayer13
TH1F * m_hDepositLayer13
Definition: TrackDepositInCaloTool.h:210
TrackDepositInCaloTool::isInsideDomain
static bool isInsideDomain(double position, double domainCenter, double domainWidth, bool phiVariable=false)
Definition: TrackDepositInCaloTool.cxx:1081
ParticleTest.tp
tp
Definition: ParticleTest.py:25
TrackDepositInCaloTool::m_doHist
bool m_doHist
Flag to write histograms to track performance.
Definition: TrackDepositInCaloTool.h:193
IExtrapolator.h
TrackDepositInCaloTool::extrapolateToSolenoid
std::unique_ptr< const Trk::TrackParameters > extrapolateToSolenoid(const EventContext &ctx, const Trk::TrackParameters *par, bool oppositeMomentum=false) const
Definition: TrackDepositInCaloTool.cxx:438
TrackDepositInCaloTool::Hists::m_hDistDepositsTile
TH2F * m_hDistDepositsTile
Definition: TrackDepositInCaloTool.h:221
TrackDepositInCaloTool::getHists
Hists & getHists() const
Definition: TrackDepositInCaloTool.cxx:1070
TrackDepositInCaloTool::m_h
std::unique_ptr< Hists > m_h
Definition: TrackDepositInCaloTool.h:231
TrackDepositInCaloTool::Hists::m_hDepositLayer12
TH1F * m_hDepositLayer12
Definition: TrackDepositInCaloTool.h:209
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
TrackDepositInCaloTool::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: TrackDepositInCaloTool.h:175
TrackDepositInCaloTool::LayerMaps::m_endCapLayerMap
CaloLayerMap m_endCapLayerMap
Definition: TrackDepositInCaloTool.h:199
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
TrackDepositInCaloTool::getCaloCellsForLayer
std::vector< const CaloCell * > getCaloCellsForLayer(const CaloDetDescrManager *caloDDM, const CaloDetDescriptor *descr, const Trk::TrackParameters *parEntrance, const Trk::TrackParameters *parExit, const CaloCellContainer *caloCellCont) const
Definition: TrackDepositInCaloTool.cxx:234
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
TrackDepositInCaloTool::Hists::book
StatusCode book(ITHistSvc &histSvc)
Definition: TrackDepositInCaloTool.cxx:1020
TrackDepositInCaloTool
Definition: TrackDepositInCaloTool.h:41
TrackDepositInCaloTool::m_caloDetDescrMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Definition: TrackDepositInCaloTool.h:184
TrackDepositInCaloTool::Hists::m_hEMB2vsdPhi
TH2F * m_hEMB2vsdPhi
Definition: TrackDepositInCaloTool.h:225
TrackDepositInCaloTool::m_tileDDM
const TileDetDescrManager * m_tileDDM
Definition: TrackDepositInCaloTool.h:178
ITrackDepositInCaloTool.h
TrackDepositInCaloTool::Hists::m_hDepositsInCore
TH1F * m_hDepositsInCore
Definition: TrackDepositInCaloTool.h:219
z
#define z
TileDetDescrManager
Definition: TileDetDescrManager.h:33
TrackDepositInCaloTool::extrapolateToExitOfLayer
std::unique_ptr< const Trk::TrackParameters > extrapolateToExitOfLayer(const EventContext &ctx, const Trk::TrackParameters *par, const CaloDetDescriptor *descr) const
Definition: TrackDepositInCaloTool.cxx:404
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TrackDepositInCaloTool::getTraversedLayers
StatusCode getTraversedLayers(const CaloDetDescrManager *caloDDM, const Trk::TrackParameters *par, std::map< double, const CaloDetDescriptor * > &caloInfo, std::vector< Amg::Vector3D > &extrapolations) const
This function determines which calorimeter regions the tracks traverses.
Definition: TrackDepositInCaloTool.cxx:758
TrackDepositInCaloTool::getDeposits
std::vector< DepositInCalo > getDeposits(const Trk::TrackParameters *par, const CaloCellContainer *caloCellCont) const override
Fills the vector of DepositInCalo using TrackParameters as input.
Definition: TrackDepositInCaloTool.cxx:70
AthAlgTool.h
CxxUtils::CachedValue
Cached value with atomic update.
Definition: CachedValue.h:55
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
TrackDepositInCaloTool::extrapolateToEntranceOfLayer
std::unique_ptr< const Trk::TrackParameters > extrapolateToEntranceOfLayer(const EventContext &ctx, const Trk::TrackParameters *par, const CaloDetDescriptor *descr) const
Definition: TrackDepositInCaloTool.cxx:361
TrackDepositInCaloTool::TrackDepositInCaloTool
TrackDepositInCaloTool(const std::string &type, const std::string &name, const IInterface *pInterface)
Definition: TrackDepositInCaloTool.cxx:43
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
TrackDepositInCaloTool::Hists::m_hDepositsInCone
TH1F * m_hDepositsInCone
Definition: TrackDepositInCaloTool.h:220
Trk::ParametersBase
Definition: ParametersBase.h:55
IParticleCaloCellAssociationTool.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TrackDepositInCaloTool::Hists::m_hEMB1vsdEta
TH2F * m_hEMB1vsdEta
Definition: TrackDepositInCaloTool.h:227
TrackDepositInCaloTool::m_caloCellAssociationTool
ToolHandle< Rec::IParticleCaloCellAssociationTool > m_caloCellAssociationTool
Definition: TrackDepositInCaloTool.h:182
ReadCondHandleKey.h
TrackDepositInCaloTool::getClosestCellTile
const CaloCell * getClosestCellTile(const CaloDetDescrManager *caloDDM, const Trk::TrackParameters *par, const CaloDetDescriptor *descr, const CaloCellContainer *caloCellCont) const
Definition: TrackDepositInCaloTool.cxx:940
TrackDepositInCaloTool::Hists::m_hDistDepositsHEC
TH2F * m_hDistDepositsHEC
Definition: TrackDepositInCaloTool.h:222
TrackDepositInCaloTool::m_layerMaps
CxxUtils::CachedValue< LayerMaps > m_layerMaps
Definition: TrackDepositInCaloTool.h:201
TrackDepositInCaloTool::distance
static double distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
Definition: TrackDepositInCaloTool.cxx:1124
CachedValue.h
Cached value with atomic update.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TrackDepositInCaloTool::extrapolateZ
static std::unique_ptr< Amg::Vector3D > extrapolateZ(const Amg::Vector3D &initialPosition, double phi0, double theta0, double z)
Extrapolate track to disc surface along straight line.
Definition: TrackDepositInCaloTool.cxx:731
TrackDepositInCaloTool::Hists::m_hEMB3vsdPhi
TH2F * m_hEMB3vsdPhi
Definition: TrackDepositInCaloTool.h:226
TrackDepositInCaloTool::inCell
static bool inCell(const CaloCell *cell, const Amg::Vector3D &pos)
Definition: TrackDepositInCaloTool.cxx:1115
TrackDepositInCaloTool::Hists::m_hDepositLayer14
TH1F * m_hDepositLayer14
Definition: TrackDepositInCaloTool.h:211
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
TrackDepositInCaloTool::getClosestCellLAr
static const CaloCell * getClosestCellLAr(const CaloDetDescrManager *caloDDM, const Trk::TrackParameters *par, const CaloDetDescriptor *descr, const CaloCellContainer *caloCellCont)
Definition: TrackDepositInCaloTool.cxx:920
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TrackDepositInCaloTool::Hists::m_hParELossSample
TH2F * m_hParELossSample
Definition: TrackDepositInCaloTool.h:214
SG::ReadCondHandleKey< CaloDetDescrManager >
TrackParticle.h
IParticleCaloExtensionTool.h
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescriptor
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
Definition: CaloDetDescriptor.h:58
TrackDepositInCaloTool::Hists::m_hEMB2vsdEta
TH2F * m_hEMB2vsdEta
Definition: TrackDepositInCaloTool.h:228
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrackDepositInCaloTool::~TrackDepositInCaloTool
virtual ~TrackDepositInCaloTool()=default
TrackDepositInCaloTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: TrackDepositInCaloTool.h:176
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrackDepositInCaloTool::m_caloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
Definition: TrackDepositInCaloTool.h:180
AthAlgTool
Definition: AthAlgTool.h:26
TrackDepositInCaloTool::Hists::m_hDeltaRadiusLastPar
TH1F * m_hDeltaRadiusLastPar
Definition: TrackDepositInCaloTool.h:218
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
TrackDepositInCaloTool::Hists::m_hDeltaEtaLastPar
TH1F * m_hDeltaEtaLastPar
Definition: TrackDepositInCaloTool.h:217
TrackDepositInCaloTool::isInsideCell
static bool isInsideCell(const Amg::Vector3D &position, const CaloCell *cell)
Definition: TrackDepositInCaloTool.cxx:1098
TrackDepositInCaloTool::LayerMaps
Definition: TrackDepositInCaloTool.h:195
TrackDepositInCaloTool::getCaloCellsForTile
std::vector< const CaloCell * > getCaloCellsForTile(const CaloDetDescrManager *caloDDM, const CaloDetDescriptor *descr, const Trk::TrackParameters *parEntrance, const Trk::TrackParameters *parExit, const CaloCellContainer *caloCellCont) const
Definition: TrackDepositInCaloTool.cxx:261
TrackDepositInCaloTool::LayerMaps::m_barrelLayerMap
CaloLayerMap m_barrelLayerMap
< std::map of distance versus descriptor for cylindrical calo regions
Definition: TrackDepositInCaloTool.h:197
ServiceHandle< ITHistSvc >