ATLAS Offline Software
CaloCalibrationHitsTestTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //================================================================//
6 // Chiara Debenedetti, 29/08/2011, CaloCalibrationHitsTestTool.cxx //
7 //================================================================//
8 
12 #include "CaloDetDescr/CaloDetDescrElement.h"
13 #include <TH1.h>
14 #include <TH2D.h>
15 #include <TProfile.h>
16 
17 CaloCalibrationHitsTestTool::CaloCalibrationHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent)
18  : SimTestToolBase(type, name, parent),m_calibHitType("LArActive"),
19  m_eta(nullptr), m_phi(nullptr), m_eEM(nullptr),
20  m_eNonEM(nullptr), m_eInv(nullptr), m_eEsc(nullptr),
21  m_eTot(nullptr), m_rz(nullptr), m_etaphi(nullptr),
22  m_eTot_partID(nullptr), m_eTot_eta(nullptr), m_eTot_phi(nullptr),
23  m_partID_large(nullptr), m_partID_small(nullptr)
24 {
25  declareProperty("CalibHitType", m_calibHitType="LArActive");
26 }
27 
29 
30  //--discriminate between different sections--//
31  if (m_calibHitType=="LArActive" || m_calibHitType=="LArInactive" || m_calibHitType=="LArDeadMaterial" ) {
32  m_path+="Calib/LAr/";
33  m_hitcollkey="LArCalibrationHit"+m_calibHitType.substr(3);
34  } else if (m_calibHitType=="TileActiveCell" || m_calibHitType=="TileInactiveCell" || m_calibHitType=="TileDeadMaterial") {
35  m_path+="Calib/Tile/";
36  m_hitcollkey="TileCalibHit"+m_calibHitType.substr(4);
37  } else if (m_calibHitType=="TileDM" || m_calibHitType=="TileCell") { //old naming convention for Tile CaloCalibrationHits
38  m_path+="Calib/Tile/";
39  m_hitcollkey="TileCalibration"+m_calibHitType.substr(4)+"HitCnt";
40  } else{
41  ATH_MSG_ERROR(" unknown key " <<m_calibHitType);
42  return StatusCode::FAILURE;
43  }
44 
45  //voglio: eta, phi, tutte le energie, rz, etaphi,
46  // particle ID vs Etot Prof, eta Etot prof, phi etot prof
47  _TH1D(m_eta,(m_calibHitType+"_eta").c_str(),25,-5.,5.);
48  _TH1D(m_phi,(m_calibHitType+"_phi").c_str(),25,-5.,5.);
49  _TH1D(m_eEM,(m_calibHitType+"_eEM").c_str(),100,0.,500.);
50  _TH1D(m_eNonEM,(m_calibHitType+"_eNonEM").c_str(),100,0.,500.);
51  _TH1D(m_eInv,(m_calibHitType+"_eInv").c_str(),100,0.,500.);
52  _TH1D(m_eEsc,(m_calibHitType+"_eEsc").c_str(),100,0.,500.);
53  _TH1D(m_eTot,(m_calibHitType+"_eTot").c_str(),100,0.,500.);
54 
55  _TH2D(m_rz,(m_calibHitType+"_rz").c_str(),100,-5200.,5200.,100,0.,3000.);
56  _TH2D(m_etaphi,(m_calibHitType+"_etaphi").c_str(),100,-5.,5.,100,-4.,4.);
57 
58  _TH1D(m_partID_large,(m_calibHitType+"_partID1").c_str(),100,0.,1500000.);
59  m_partID_large -> StatOverflows();
60  _TH1D(m_partID_small,(m_calibHitType+"_partID2").c_str(),100,10000.,10100.);
61 
62  _TH1D_WEIGHTED(m_eTot_partID,(m_calibHitType+"_eTot_partID").c_str(),600,0.,300000.);
63  _TH1D_WEIGHTED(m_eTot_eta,(m_calibHitType+"_eTot_eta").c_str(),25,-5.,5.);
64  _TH1D_WEIGHTED(m_eTot_phi,(m_calibHitType+"_eTot_phi").c_str(),25,-3.2,3.2);
65 
67 
68  return StatusCode::SUCCESS;
69 }
70 
72 
73  SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey,Gaudi::Hive::currentContext()};
74  const CaloDetDescrManager* caloMgr = *caloMgrHandle;
75 
76  const CaloCalibrationHitContainer* iter;
77  CHECK(evtStore()->retrieve(iter,m_hitcollkey));
78  for(const CaloCalibrationHit* hit : *iter) {
79 
80  GeoCaloCalibHit geoHit(*hit, m_hitcollkey, caloMgr);
81  if (!geoHit) continue;
82  const CaloDetDescrElement* ddElement = geoHit.getDetDescrElement();
83 
84  if (!ddElement) {
85  ATH_MSG_WARNING(" could not retrieve DetElement in CaloCalibrationHitsTestTool/" <<m_calibHitType);
86  continue;
87  }
88  double eta = ddElement->eta();
89  double phi = ddElement->phi();
90  double radius = ddElement->r();
91  double z = ddElement->z();
92  double emEnergy = geoHit.energyEM();
93  double nonEmEnergy = geoHit.energyNonEM();
94  double invEnergy = geoHit.energyInvisible();
95  double escEnergy = geoHit.energyEscaped();
96  double totEnergy = geoHit.energyTotal();
97  double particleID = hit->particleID();
98 
99  m_eta->Fill(eta);
100  m_phi->Fill(phi);
101  m_eEM->Fill(emEnergy);
102  m_eNonEM->Fill(nonEmEnergy);
103  m_eInv->Fill(invEnergy);
104  m_eEsc->Fill(escEnergy);
105  m_eTot->Fill(totEnergy);
106 
107  m_rz->Fill(z, radius);
108  m_etaphi->Fill(eta, phi);
109 
110  // particle id
111  m_partID_small->Fill(particleID);
112  m_partID_large->Fill(particleID);
113  // weighted histos
114  m_eTot_partID->Fill(particleID, totEnergy);
115  m_eTot_eta->Fill(eta, totEnergy);
116  m_eTot_phi->Fill(phi, totEnergy);
117  }
118 
119  return StatusCode::SUCCESS;
120 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloCalibrationHitContainer
Definition: CaloCalibrationHitContainer.h:25
GeoCaloCalibHit
Adaptor for CaloCalibHits.
Definition: GeoCaloCalibHit.h:26
GeoCaloCalibHit::energyEscaped
double energyEscaped() const
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
GeoCaloCalibHit::energyEM
double energyEM() const
CaloCalibrationHitsTestTool::initialize
virtual StatusCode initialize() override
Definition: CaloCalibrationHitsTestTool.cxx:28
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloCalibrationHitsTestTool::m_eEM
TH1 * m_eEM
Definition: CaloCalibrationHitsTestTool.h:34
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCalibrationHitsTestTool::m_phi
TH1 * m_phi
Definition: CaloCalibrationHitsTestTool.h:34
GeoCaloCalibHit::energyNonEM
double energyNonEM() const
GeoCaloCalibHit.h
CaloCalibrationHitContainer.h
CaloCalibrationHitsTestTool::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloCalibrationHitsTestTool.h:39
CaloCalibrationHitsTestTool::m_etaphi
TH2 * m_etaphi
Definition: CaloCalibrationHitsTestTool.h:35
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:47
GeoCaloCalibHit::getDetDescrElement
const CaloDetDescrElement * getDetDescrElement() const
CaloCalibrationHitsTestTool::m_partID_small
TH1 * m_partID_small
Definition: CaloCalibrationHitsTestTool.h:37
SimTestToolBase
Definition: SimTestToolBase.h:20
CaloCalibrationHitsTestTool::m_eNonEM
TH1 * m_eNonEM
Definition: CaloCalibrationHitsTestTool.h:34
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GeoCaloCalibHit::energyInvisible
double energyInvisible() const
z
#define z
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCalibrationHitsTestTool::m_rz
TH2 * m_rz
Definition: CaloCalibrationHitsTestTool.h:35
test_pyathena.parent
parent
Definition: test_pyathena.py:15
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition: SimTestHisto.h:81
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
_TH1D_WEIGHTED
#define _TH1D_WEIGHTED(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:67
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloCalibrationHitsTestTool.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCalibrationHitsTestTool::m_eta
TH1 * m_eta
Definition: CaloCalibrationHitsTestTool.h:34
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
CaloCalibrationHitsTestTool::m_eTot
TH1 * m_eTot
Definition: CaloCalibrationHitsTestTool.h:34
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCalibrationHitsTestTool::m_partID_large
TH1 * m_partID_large
Definition: CaloCalibrationHitsTestTool.h:37
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloDetDescrElement::z
float z() const
cell z
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GeoCaloCalibHit::energyTotal
double energyTotal() const
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloCalibrationHitsTestTool::m_calibHitType
std::string m_calibHitType
Definition: CaloCalibrationHitsTestTool.h:30
CaloCalibrationHitsTestTool::m_eTot_phi
TH1 * m_eTot_phi
Definition: CaloCalibrationHitsTestTool.h:36
CaloDetDescrElement::r
float r() const
cell r
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:348
SimTestHisto::m_path
std::string m_path
Definition: SimTestHisto.h:34
CaloCalibrationHitsTestTool::m_eEsc
TH1 * m_eEsc
Definition: CaloCalibrationHitsTestTool.h:34
CaloCalibrationHitsTestTool::processEvent
virtual StatusCode processEvent() override
Definition: CaloCalibrationHitsTestTool.cxx:71
CaloCalibrationHitsTestTool::m_hitcollkey
std::string m_hitcollkey
Definition: CaloCalibrationHitsTestTool.h:31
CaloCalibrationHitsTestTool::CaloCalibrationHitsTestTool
CaloCalibrationHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CaloCalibrationHitsTestTool.cxx:17
CaloCalibrationHitsTestTool::m_eTot_partID
TH1 * m_eTot_partID
Definition: CaloCalibrationHitsTestTool.h:36
CaloCalibrationHitsTestTool::m_eTot_eta
TH1 * m_eTot_eta
Definition: CaloCalibrationHitsTestTool.h:36
CaloCalibrationHitsTestTool::m_eInv
TH1 * m_eInv
Definition: CaloCalibrationHitsTestTool.h:34