ATLAS Offline Software
Loading...
Searching...
No Matches
TBBeamQualityEMFractionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//#####################################################
6//# #
7//# File : TBBeamQualityEMFractionTool.cxx #
8//# Package: TBRec #
9//# #
10//# Author : Marco Bieri <mbieri@sfu.ca> #
11//# #
12//# #
13//#####################################################
14
16
19
20#include "Identifier/Identifier.h"
21
23 const std::string& name,
24 const IInterface* parent)
25 : TBBeamQualityTool(type,name,parent),
26 m_emecID_help(nullptr),
27 m_hecID_help(nullptr),
28 m_fcalID_help(nullptr),
29 m_em_frac(0)
30{
31 declareInterface<TBBeamQualityTool>(this);
32 declareProperty("EM_fraccut",m_em_fraccut=0.2);
33 declareProperty("EM_fracnumsamp",m_em_fracnumsamp);
34 declareProperty("EM_fracdensamp",m_em_fracdensamp);
35 declareProperty("EM_fracnumdet",m_em_fracnumdet="none");
36 declareProperty("EM_fracdendet",m_em_fracdendet="none");
37}
38
41
43{ //init
44 MsgStream log(msgSvc(),name());
45 log << MSG::DEBUG
46 << "initialize"
47 << endmsg;
48
49 StatusCode sc;
50
51 m_hecID_help = NULL;
52 m_emecID_help = NULL;
53 m_fcalID_help = NULL;
54
55 /*
56 // retrieve detector description manager for LAr subsystem
57 const DataHandle<LArDetDescrManager> m_larMgr;
58 sc = detStore()->retrieve(m_larMgr);
59 if (sc.isFailure()) {
60 log << MSG::ERROR << "unable to retrieve LArDetDescrManager from detector store"<< endmsg;
61 return sc;
62 }
63
64 //obtainine Identifier helpers
65 m_hecID_help = m_larMgr->get_hec_id();
66 if (!m_hecID_help) {
67 log << MSG::ERROR << "unable to obtain hec id " << endmsg;
68 return StatusCode::FAILURE;
69 }
70 m_emecID_help = m_larMgr->get_em_id();
71 if (!m_emecID_help) {
72 log << MSG::ERROR << "unable to obtain emec id " << endmsg;
73 return StatusCode::FAILURE;
74 }
75
76 m_fcalID_help = m_larMgr->get_fcal_id();
77 if (!m_fcalID_help) {
78 log << MSG::ERROR << "unable to obtain fcal id " << endmsg;
79 return StatusCode::FAILURE;
80 }
81 */
82
83
84 // retrieve detector description manager for LAr subsystem
85 const CaloCell_ID* idHelper = nullptr;
86 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
87
88 //obtainine Identifier helpers
89 m_hecID_help = idHelper->hec_idHelper();
90 if (!m_hecID_help) {
91 log << MSG::ERROR << "unable to obtain hec id " << endmsg;
92 return StatusCode::FAILURE;
93 }
94 m_emecID_help = idHelper->em_idHelper();
95 if (!m_emecID_help) {
96 log << MSG::ERROR << "unable to obtain emec id " << endmsg;
97 return StatusCode::FAILURE;
98 }
99
100 m_fcalID_help = idHelper->fcal_idHelper();
101 if (!m_fcalID_help) {
102 log << MSG::ERROR << "unable to obtain fcal id " << endmsg;
103 return StatusCode::FAILURE;
104 }
105
106
107
108 log<<MSG::DEBUG<<"Got to before p_toolSvc"<<endmsg;
109
110 if (m_em_fracnumdet=="HEC") {
111 m_em_fracnumsamp.push_back(8);
112 m_em_fracnumsamp.push_back(9);
113 m_em_fracnumsamp.push_back(10);
114 }
115 if (m_em_fracdendet=="HEC") {
116 m_em_fracdensamp.push_back(8);
117 m_em_fracdensamp.push_back(9);
118 m_em_fracdensamp.push_back(10);
119 }
120 if (m_em_fracnumdet=="EMEC") {
121 m_em_fracnumsamp.push_back(6);
122 m_em_fracnumsamp.push_back(7);
123 }
124 if (m_em_fracdendet=="EMEC") {
125 m_em_fracdensamp.push_back(6);
126 m_em_fracdensamp.push_back(7);
127 }
128 if (m_em_fracnumdet=="FCAL") {
129 m_em_fracnumsamp.push_back(21);
130 m_em_fracnumsamp.push_back(22);
131 m_em_fracnumsamp.push_back(23);
132 }
133 if (m_em_fracdendet=="FCAL") {
134 m_em_fracdensamp.push_back(21);
135 m_em_fracdensamp.push_back(22);
136 m_em_fracdensamp.push_back(23);
137 }
138
139 return StatusCode::SUCCESS;
140}//init
141
142StatusCode TBBeamQualityEMFractionTool::accept(const std::vector<std::string>& particles)
143{//accept
144
145 MsgStream log(msgSvc(),name());
146
147 log << MSG::DEBUG
148 << "TBBeamQualityEMFractionTool: Started Accept"
149 << endmsg;
150
151 StatusCode sc;
152
153 log << MSG::DEBUG << "m_em_fracnumdet: "<<m_em_fracnumdet<<endmsg;
154 log << MSG::DEBUG << "m_em_fracdendet: "<<m_em_fracdendet<<endmsg;
155 log << MSG::DEBUG << " called for: "<<particles.size()<<" particles"<<endmsg;
156
157 // setting up layers (h6)
158
159 // setting tmp variables
160 // resetting the numerator and denominator to 0
161
162 //long chan =0;
163 float numenergy=0;
164 float denenergy=0;
165 m_Mlayer.assign (500, 0);
166
167 //Accesing the CaloCellContainer
168 const CaloCellContainer* cellContainer = nullptr;
169
170 sc = evtStore()->retrieve(cellContainer);
171 if (sc.isFailure()) {
172 log << MSG::ERROR << "couldn't get the calo cells from storegate" << endmsg;
173 log << MSG::ERROR << "here is what is in storegate: " << evtStore()->dump() << endmsg;
174 return StatusCode::FAILURE;
175 }
176
177 for (const CaloCell* cell_ptr : *cellContainer) {
178
179 //obtaining dde pointer
180 const CaloDetDescrElement* caloDDE_ptr = cell_ptr->caloDDE();
181
182 //obtaining SubCalo
183 //const CaloCell_ID::SUBCALO subcalo = caloDDE_ptr->getSubCalo();
184
185 //obtaining sampling (layer)
186 const CaloCell_ID::CaloSample sampling = caloDDE_ptr->getSampling();
187
188 // This map will have the layers as an index and increment the energy
189 // Does this for ALL layers ( all detectors )
190
191 if (sampling >= 0 && sampling < m_Mlayer.size())
192 m_Mlayer[sampling]+=cell_ptr->energy();
193
194 } //iterating
195
196 // picking out layers of interest and filling numerator and denominator energies.
197
198 for (unsigned int i=0;i<m_em_fracnumsamp.size();++i) {
199 if (m_em_fracnumsamp[i] < m_Mlayer.size())
200 numenergy+=m_Mlayer[m_em_fracnumsamp[i]];
201 }
202
203 for (unsigned int i=0;i<m_em_fracdensamp.size();++i) {
204 if (m_em_fracdensamp[i] < m_Mlayer.size())
205 denenergy+=m_Mlayer[m_em_fracdensamp[i]];
206 }
207
208 if (denenergy!=0) {
209 m_em_frac=numenergy/denenergy;
210
212 return StatusCode::SUCCESS;
213 }
214 else {
215 return StatusCode::FAILURE;
216 }
217 }
218 else {
219 return StatusCode::FAILURE;
220 }
221}//accept
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition CaloCell_ID.h:75
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition CaloCell_ID.h:69
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
virtual StatusCode accept(const std::vector< std::string > &) override
virtual StatusCode initializeTool() override
TBBeamQualityEMFractionTool(const std::string &type, const std::string &name, const IInterface *parent)
TBBeamQualityTool(const std::string &name, const std::string &type, const IInterface *parent)