ATLAS Offline Software
Loading...
Searching...
No Matches
TBBeamQualityEMFractionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 // retrieve detector description manager for LAr subsystem
56 const CaloCell_ID* idHelper = nullptr;
57 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
58
59 //obtainine Identifier helpers
60 m_hecID_help = idHelper->hec_idHelper();
61 if (!m_hecID_help) {
62 log << MSG::ERROR << "unable to obtain hec id " << endmsg;
63 return StatusCode::FAILURE;
64 }
65 m_emecID_help = idHelper->em_idHelper();
66 if (!m_emecID_help) {
67 log << MSG::ERROR << "unable to obtain emec id " << endmsg;
68 return StatusCode::FAILURE;
69 }
70
71 m_fcalID_help = idHelper->fcal_idHelper();
72 if (!m_fcalID_help) {
73 log << MSG::ERROR << "unable to obtain fcal id " << endmsg;
74 return StatusCode::FAILURE;
75 }
76
77
78
79 log<<MSG::DEBUG<<"Got to before p_toolSvc"<<endmsg;
80
81 if (m_em_fracnumdet=="HEC") {
82 m_em_fracnumsamp.push_back(8);
83 m_em_fracnumsamp.push_back(9);
84 m_em_fracnumsamp.push_back(10);
85 }
86 if (m_em_fracdendet=="HEC") {
87 m_em_fracdensamp.push_back(8);
88 m_em_fracdensamp.push_back(9);
89 m_em_fracdensamp.push_back(10);
90 }
91 if (m_em_fracnumdet=="EMEC") {
92 m_em_fracnumsamp.push_back(6);
93 m_em_fracnumsamp.push_back(7);
94 }
95 if (m_em_fracdendet=="EMEC") {
96 m_em_fracdensamp.push_back(6);
97 m_em_fracdensamp.push_back(7);
98 }
99 if (m_em_fracnumdet=="FCAL") {
100 m_em_fracnumsamp.push_back(21);
101 m_em_fracnumsamp.push_back(22);
102 m_em_fracnumsamp.push_back(23);
103 }
104 if (m_em_fracdendet=="FCAL") {
105 m_em_fracdensamp.push_back(21);
106 m_em_fracdensamp.push_back(22);
107 m_em_fracdensamp.push_back(23);
108 }
109
110 return StatusCode::SUCCESS;
111}//init
112
113StatusCode TBBeamQualityEMFractionTool::accept(const std::vector<std::string>& particles)
114{//accept
115
116 MsgStream log(msgSvc(),name());
117
118 log << MSG::DEBUG
119 << "TBBeamQualityEMFractionTool: Started Accept"
120 << endmsg;
121
122 StatusCode sc;
123
124 log << MSG::DEBUG << "m_em_fracnumdet: "<<m_em_fracnumdet<<endmsg;
125 log << MSG::DEBUG << "m_em_fracdendet: "<<m_em_fracdendet<<endmsg;
126 log << MSG::DEBUG << " called for: "<<particles.size()<<" particles"<<endmsg;
127
128 // setting up layers (h6)
129
130 // setting tmp variables
131 // resetting the numerator and denominator to 0
132
133 //long chan =0;
134 float numenergy=0;
135 float denenergy=0;
136 m_Mlayer.assign (500, 0);
137
138 //Accesing the CaloCellContainer
139 const CaloCellContainer* cellContainer = nullptr;
140
141 sc = evtStore()->retrieve(cellContainer);
142 if (sc.isFailure()) {
143 log << MSG::ERROR << "couldn't get the calo cells from storegate" << endmsg;
144 log << MSG::ERROR << "here is what is in storegate: " << evtStore()->dump() << endmsg;
145 return StatusCode::FAILURE;
146 }
147
148 for (const CaloCell* cell_ptr : *cellContainer) {
149
150 //obtaining dde pointer
151 const CaloDetDescrElement* caloDDE_ptr = cell_ptr->caloDDE();
152
153 //obtaining SubCalo
154 //const CaloCell_ID::SUBCALO subcalo = caloDDE_ptr->getSubCalo();
155
156 //obtaining sampling (layer)
157 const CaloCell_ID::CaloSample sampling = caloDDE_ptr->getSampling();
158
159 // This map will have the layers as an index and increment the energy
160 // Does this for ALL layers ( all detectors )
161
162 if (sampling >= 0 && sampling < m_Mlayer.size())
163 m_Mlayer[sampling]+=cell_ptr->energy();
164
165 } //iterating
166
167 // picking out layers of interest and filling numerator and denominator energies.
168
169 for (unsigned int i=0;i<m_em_fracnumsamp.size();++i) {
170 if (m_em_fracnumsamp[i] < m_Mlayer.size())
171 numenergy+=m_Mlayer[m_em_fracnumsamp[i]];
172 }
173
174 for (unsigned int i=0;i<m_em_fracdensamp.size();++i) {
175 if (m_em_fracdensamp[i] < m_Mlayer.size())
176 denenergy+=m_Mlayer[m_em_fracdensamp[i]];
177 }
178
179 if (denenergy!=0) {
180 m_em_frac=numenergy/denenergy;
181
183 return StatusCode::SUCCESS;
184 }
185 else {
186 return StatusCode::FAILURE;
187 }
188 }
189 else {
190 return StatusCode::FAILURE;
191 }
192}//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)