ATLAS Offline Software
TileHitsTestTool.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 #include "TileHitsTestTool.h"
6 
9 #include "TileSimEvent/TileHit.h"
11 #include "CaloDetDescr/CaloDetDescrElement.h"
13 #include <TH2D.h>
14 #include <TH1.h>
15 
16 #include <cmath>
17 
18 TileHitsTestTool::TileHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent)
20  m_tileID(0), m_tileTBID(0), m_tileMgr(0),
21  m_tile_eta(0), m_tile_phi(0), m_tile_energy(0), m_tile_log_energy(0), m_tile_time(0),
22  m_tile_rz(0), m_tile_etaphi(0), m_tile_energyphi(0), m_tile_energyeta(0),
23  m_mbts_side(0), m_mbts_eta(0), m_mbts_phi(0),
24  m_mbts_sidetaphi(0),
25  m_etot(0),
26  m_testMBTS(true)
27 {
28  declareProperty("TestMBTS",m_testMBTS,"");
29  }
30 
31 
36 
37  std::string detName("Tile"); //could configure this in the future?
38  m_path+=detName+"/";
39 
40  // TileCal histograms
41  _TH1D(m_tile_eta,"tile_eta",17,-1.65,1.65);
42  _TH1D(m_tile_phi,"tile_phi",16,-3.2,3.2);
43  _TH1D(m_tile_energy,"tile_energy",50,0,100);
44  _TH1D(m_tile_log_energy,"tile_log_energy",100,-14.,8.);
45  _SET_TITLE(m_tile_log_energy,"logarithm of energy deposits","log(energy [MeV])","dN/dlog(energy [MeV])");
46  _TH1D(m_tile_time,"tile_time",100,0,250);
47 
48  _TH2D(m_tile_rz,"tile_rz",16,-6200.,6200.,25,1500.,4000.);
49  _TH2D(m_tile_etaphi,"tile_etaphi",65,-1.625,1.625,129,-3.175,3.175);
50  _TH2D(m_tile_energyphi,"tile_energyphi",100,0.,10.,129,-3.175,3.175);
51  _TH2D(m_tile_energyeta,"tile_energyeta",100,0.,10.,129,-3.175,3.175);
52 
53  // MBTS histograms
54  _TH1D(m_mbts_side,"mbts_side",3,-1.5,1.5);
55  _TH1D(m_mbts_eta,"mbts_eta",2,-0.5,1.5);
56  _TH1D(m_mbts_phi,"mbts_phi",8,-0.5,7.5);
57  _TH2D(m_mbts_sidetaphi,"mbts_sidetaphi",5,-2.5,2.5,7,-0.5,7.5);
58 
59  _TH1D(m_etot,(detName+"_etot").c_str(),100,0.,500.);
60 
61  return StatusCode::SUCCESS;
62 }
63 
64 
66  // make sure we still have a TileMgr (SimFlags.ReleaseGeoModel=False)
68 
69  const TileHitVector* hitVec = nullptr;
70 
71  double etot=0.;
72  if (evtStore()->retrieve(hitVec,"TileHitVec") == StatusCode::SUCCESS) {
73  for (const TileHit& hit : *hitVec) {
74 
75  Identifier pmt_id = hit.identify();
76  Identifier cell_id = m_tileID->cell_id(pmt_id);
77 
78  const CaloDetDescrElement *ddElement = m_tileMgr->get_cell_element(cell_id);
79  if(ddElement) // skip E4' cells which are not yet described in TileDetDescrManager.
80  {
81  double eta = ddElement->eta();
82  double phi = ddElement->phi();
83  double radius = ddElement->r();
84  double z = ddElement->z();
85 
86  int pmt = m_tileID->pmt(pmt_id);
87  if (pmt>0) phi += ddElement->dphi()/2.; // to see clearly two PMTs in a cell
88 
89  // loop over subhits
90  double energy=0;
91  // ATH_MSG(INFO) << "TileHit size :" <<hit.size()<<endmsg;
92  for (int i=0; i<hit.size();++i) {
93  energy+=hit.energy(i);
94  m_tile_energy->Fill(hit.energy(i));
95  m_tile_log_energy->Fill( std::log(hit.energy(i)) );
96  m_tile_time->Fill(hit.time(i));
97  }
98  etot+=energy;
99 
100  m_tile_eta->Fill(eta);
101  m_tile_phi->Fill(phi);
106  }
107  }
108  }
109  //Check the Hit container with postfix _Fast which generated with FastCaloSim
110  const TileHitVector *hitVec_fast = nullptr;
111  if( evtStore()->contains<TileHitVector>("TileHitVec_Fast") &&
112  (evtStore()->retrieve(hitVec_fast,"TileHitVec_Fast")).isSuccess())
113  {
114  ATH_MSG_DEBUG ( "Retrieve FastCaloSim container TileHitVec_Fast." );
115  for (const TileHit& hit : *hitVec_fast)
116  {
117  Identifier pmt_id=hit.identify();
118  Identifier cell_id=m_tileID->cell_id(pmt_id);
119  const CaloDetDescrElement *ddElement=m_tileMgr->get_cell_element(cell_id);
120  if(ddElement) // skip E4' cells which are not yet described in TileDetDescrManager.
121  {
122  double eta=ddElement->eta();
123  double phi=ddElement->phi();
124  double radius=ddElement->r();
125  double z=ddElement->z();
126 
127  int pmt=m_tileID->pmt(pmt_id);
128  if(pmt>0) phi+=ddElement->dphi()/2.;
129  double energy=0;
130  for(int i=0;i<hit.size();++i)
131  {
132  energy+=hit.energy(i);
133  m_tile_energy->Fill(hit.energy(i));
134  m_tile_log_energy->Fill( std::log(hit.energy(i))) ;
135  m_tile_time->Fill(hit.time(i));
136  }
137  etot+=energy;
138 
139  m_tile_eta->Fill(eta);
140  m_tile_phi->Fill(phi);
145  }
146  }
147  }
148 
149  if(m_testMBTS) {
150  if (evtStore()->retrieve(hitVec,"MBTSHits") == StatusCode::SUCCESS) {
151  for (const TileHit& hit : *hitVec) {
152  Identifier mbts_id = hit.identify();
153  double side = m_tileTBID->side(mbts_id); // -1 or +1
154  double ieta = m_tileTBID->eta(mbts_id); // 0 for inner cell, 1 for outer cell
155  double iphi = m_tileTBID->phi(mbts_id); // 0-7, cell 0 at phi=0
157  m_mbts_eta->Fill(ieta);
158  m_mbts_phi->Fill(iphi);
159  m_mbts_sidetaphi->Fill((ieta+1)*side,iphi);
160  }
161  }
162  }
163  m_etot->Fill(etot);
164 
165 
166 
167  return StatusCode::SUCCESS;
168 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TH2::Fill
int Fill(double, double)
Definition: rootspy.cxx:382
TileHitsTestTool::m_tile_eta
TH1 * m_tile_eta
Definition: TileHitsTestTool.h:32
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
TileHitsTestTool::m_tile_etaphi
TH2 * m_tile_etaphi
Definition: TileHitsTestTool.h:33
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
TileHitsTestTool::m_etot
TH1 * m_etot
Definition: TileHitsTestTool.h:38
TileHitsTestTool::initialize
StatusCode initialize()
Definition: TileHitsTestTool.cxx:32
Tile_Base_ID::pmt
int pmt(const Identifier &id) const
Definition: Tile_Base_ID.cxx:180
TileHitsTestTool::m_mbts_sidetaphi
TH2 * m_mbts_sidetaphi
Definition: TileHitsTestTool.h:36
ReadBchFromCool.pmt
pmt
Definition: ReadBchFromCool.py:62
TileHitsTestTool::m_tile_energy
TH1 * m_tile_energy
Definition: TileHitsTestTool.h:32
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
AtlasHitsVector
Definition: AtlasHitsVector.h:33
TileHitsTestTool::m_tileID
const TileID * m_tileID
Definition: TileHitsTestTool.h:28
_SET_TITLE
#define _SET_TITLE(var, title, xaxis, yaxis)
Definition: SimTestHisto.h:93
TileHitsTestTool::TileHitsTestTool
TileHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TileHitsTestTool.cxx:18
TileHitsTestTool::m_mbts_eta
TH1 * m_mbts_eta
Definition: TileHitsTestTool.h:35
TileID.h
TileDetDescrManager.h
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:47
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SimTestToolBase
Definition: SimTestToolBase.h:20
TileHitsTestTool::m_tileTBID
const TileTBID * m_tileTBID
Definition: TileHitsTestTool.h:29
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
TileHitsTestTool::m_tile_rz
TH2 * m_tile_rz
Definition: TileHitsTestTool.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
TileHitsTestTool::m_tile_energyeta
TH2 * m_tile_energyeta
Definition: TileHitsTestTool.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TileHitsTestTool::processEvent
StatusCode processEvent()
Definition: TileHitsTestTool.cxx:65
test_pyathena.parent
parent
Definition: test_pyathena.py:15
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition: SimTestHisto.h:81
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TileHitsTestTool::m_testMBTS
bool m_testMBTS
Definition: TileHitsTestTool.h:40
TileHitsTestTool::m_tile_log_energy
TH1 * m_tile_log_energy
Definition: TileHitsTestTool.h:32
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
TileDetDescrManager::get_cell_element
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
Definition: TileDetDescrManager.h:156
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TileHitVector.h
TileHit.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
TileHitsTestTool::m_tile_phi
TH1 * m_tile_phi
Definition: TileHitsTestTool.h:32
TileHitsTestTool::m_tile_energyphi
TH2 * m_tile_energyphi
Definition: TileHitsTestTool.h:33
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
CaloDetDescrElement::z
float z() const
cell z
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
TileTBID::phi
int phi(const Identifier &id) const
extract phi field from MBTS identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:165
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
TileTBID.h
CaloDetDescrElement::r
float r() const
cell r
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:348
TileHitsTestTool::m_mbts_phi
TH1 * m_mbts_phi
Definition: TileHitsTestTool.h:35
TileTBID::eta
int eta(const Identifier &id) const
extract eta field from MBTS identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:169
SimTestHisto::m_path
std::string m_path
Definition: SimTestHisto.h:34
TileHitsTestTool.h
Tile_Base_ID::cell_id
Identifier cell_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:581
python.LArCondContChannels.detName
detName
Definition: LArCondContChannels.py:665
TileHitsTestTool::m_mbts_side
TH1 * m_mbts_side
Definition: TileHitsTestTool.h:35
TileTBID::side
int side(const Identifier &id) const
define synonyms for minimum bias scintillators
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:161
TileHitsTestTool::m_tile_time
TH1 * m_tile_time
Definition: TileHitsTestTool.h:32
TileHitsTestTool::m_tileMgr
const TileDetDescrManager * m_tileMgr
Definition: TileHitsTestTool.h:30