ATLAS Offline Software
Loading...
Searching...
No Matches
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
11#include "CaloDetDescr/CaloDetDescrElement.h"
13#include <TH2D.h>
14#include <TH1.h>
15
16#include <cmath>
17
18TileHitsTestTool::TileHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent)
19 : SimTestToolBase(type, name, parent),
20 m_tileID(0), m_tileTBID(0), m_tileMgr(0),
25 m_etot(0),
26 m_testMBTS(true)
27{
28 declareProperty("TestMBTS",m_testMBTS,"");
29 }
30
31
33 CHECK(detStore()->retrieve(m_tileMgr));
34 CHECK(detStore()->retrieve(m_tileID));
35 CHECK(detStore()->retrieve(m_tileTBID));
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)
67 CHECK(detStore()->retrieve(m_tileMgr));
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);
102 m_tile_rz->Fill(z,radius);
103 m_tile_etaphi->Fill(eta,phi);
104 m_tile_energyphi->Fill(energy,phi);
105 m_tile_energyeta->Fill(energy,eta);
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);
141 m_tile_rz->Fill(z,radius);
142 m_tile_etaphi->Fill(eta,phi);
143 m_tile_energyphi->Fill(energy,phi);
144 m_tile_energyeta->Fill(energy,eta);
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
156 m_mbts_side->Fill(side);
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
#define _TH1D(var, name, nbin, xmin, xmax)
#define _SET_TITLE(var, title, xaxis, yaxis)
AtlasHitsVector< TileHit > TileHitVector
#define z
This class groups all DetDescr information related to a CaloCell.
std::string m_path
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode processEvent()
StatusCode initialize()
TileHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
const TileTBID * m_tileTBID
const TileID * m_tileID
const TileDetDescrManager * m_tileMgr
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114