ATLAS Offline Software
Loading...
Searching...
No Matches
LArSCHitFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <sstream>
8
10#include "CaloEvent/CaloCell.h"
12#include "CaloDetDescr/CaloDetDescrElement.h"
14
17
18#include <vector>
19#include <list>
20#include <map>
21#include <iostream>
22#include <cmath>
23
24#include "LArSCHitFillerTool.h"
25
26namespace D3PD {
27
28
36 (const std::string& type,
37 const std::string& name,
38 const IInterface* parent)
39 : BlockFillerTool<LArHitContainer> (type, name, parent),
40 m_dd_fSampl (nullptr),
41 m_caloEtaSelection( false ),
42 m_caloPhiSelection( false ),
43 m_caloLayerSelection( false ),
44 m_caloSelection( false ),
45 m_scidtool ("CaloSuperCellIDTool")
46 {
47
48 declareProperty( "CaloEtaCut", m_etaCut );
49 declareProperty( "CaloPhiCut", m_phiCut );
50 declareProperty( "CaloLayers", m_caloLayers );
51 declareProperty( "CaloDetectors", m_caloNums );
52 // 1=EMB; 2=EMEC Outer Wheel; 3=EMEC Inner Wheel; 4=HEC; 5=FCAL
53
54 declareProperty ("SCIDTool", m_scidtool,
55 "Offline / supercell mapping tool.");
56
57 LArSCHitFillerTool::book().ignore(); // Avoid coverity warnings.
58}
59
60
62{
63 ServiceHandle<StoreGateSvc> detStore("DetectorStore", name());
64 CHECK( detStore.retrieve() ) ;
65 CHECK( m_scidtool.retrieve() );
66 CHECK( m_caloSuperCellMgrKey.initialize() );
67 CHECK( detStore->retrieve (m_sc_idHelper) );
68
69 CHECK ( detStore->retrieve(m_emid) );
70 CHECK ( detStore->retrieve(m_fcalid) );
71 CHECK ( detStore->retrieve(m_hecid) );
72 CHECK ( detStore->retrieve(m_tileid) );
73 CHECK ( detStore->retrieve(m_onlineHelper));
74
75 CHECK ( detStore->retrieve(m_dd_fSampl));
76
77 const unsigned int nSubCalo = static_cast< int >( CaloCell_ID::NSUBCALO );
78
79 //check calo number specified
80 m_caloSelection = false;
81 if( m_caloNums.size() == 0 ) {
82 ATH_MSG_INFO( " *** LArSCHitFillerTool: No calorimeter selection" );
83 // return StatusCode::SUCCESS;
84 } else if( m_caloNums.size() > nSubCalo ) {
85 REPORT_MESSAGE( MSG::FATAL )
86 << " More than " << nSubCalo << " calo specified. "
87 << "Must be wrong. Stop.";
88 return StatusCode::FAILURE;
89 } else {
90 m_caloSelection = true;
91 for( unsigned int index = 0; index < m_caloNums.size(); ++index ) {
92 if( m_caloNums[ index ]>= nSubCalo ) {
93 REPORT_MESSAGE( MSG::FATAL )
94 << "Invalid calo specification:"
95 << m_caloNums[index] << "Stop.";
96 return StatusCode::FAILURE;
97 } else {
98 ATH_MSG_INFO( "*** LArSCHitFillerTool: Select calorimeter " << m_caloNums[ index ] );
99 }
100 }
101 }
102
103 m_caloEtaSelection = false;
104 if ( m_etaCut.size() >0 ) {
105 if ( m_etaCut.size()== 2 && m_etaCut[0]<m_etaCut[1] ) {
106 REPORT_MESSAGE( MSG::INFO ) << "*** LArSCHitFillerTool: Eta Selection specified: " << m_etaCut[0] << ", " << m_etaCut[1];
108 } else {
109 REPORT_MESSAGE( MSG::FATAL ) << " *** LArSCHitFillerTool: Invalid Eta Cut Range specified: Abort!";
110 return StatusCode::FAILURE;
111 }
112 }
113
114 m_caloPhiSelection = false;
115 if ( m_phiCut.size() >0 ) {
116 if ( m_phiCut.size() == 2 && m_phiCut[0]<m_phiCut[1] ) {
117 REPORT_MESSAGE( MSG::INFO ) << "*** LArSCHitFillerTool: Phi Selection specified: " << m_phiCut[0] << ", " << m_phiCut[1];
118 m_caloPhiSelection = true;
119 } else {
120 REPORT_MESSAGE( MSG::FATAL ) << " *** LArSCHitFillerTool: Invalid Phi Cut Range specified: Abort!";
121 return StatusCode::FAILURE;
122 }
123 }
124
125 m_caloLayerSelection = false;
126 if ( m_caloLayers.size()>0 ) {
127 if ( m_caloLayers.size()>28 ) {
128 REPORT_MESSAGE( MSG::FATAL ) << " *** LArSCHitFillerTool: Invalid No. of Calo Layer selection: " << m_caloLayers.size() << " Abort!";
129 return StatusCode::FAILURE;
130 }
131 for( unsigned int j=0; j<m_caloLayers.size(); j++) {
132 if (m_caloLayers[j]>27 ) {
133 REPORT_MESSAGE( MSG::FATAL ) << " *** LArSCHitFillerTool: Invalid Calo Layer selection: " << m_caloLayers[j] << " Abort!";
134 return StatusCode::FAILURE;
135 }
136 }
138 }
139
140
141 ATH_MSG_INFO( " *** LArSCHitFillerTool: caloEtaSelection " << m_caloEtaSelection );
142 ATH_MSG_INFO( " *** LArSCHitFillerTool: caloPhiSelection " << m_caloPhiSelection );
143 ATH_MSG_INFO( " *** LArSCHitFillerTool: caloLayerSelection " << m_caloLayerSelection );
144
145 ATH_MSG_INFO( " *** LArSCHitFillerTool: completed" );
146 return StatusCode::SUCCESS;
147}
148
153{
154 CHECK( addVariable ("nSC", m_nSC ));
155 CHECK( addVariable ("E", m_E));
156 CHECK( addVariable ("eta", m_eta));
157 CHECK( addVariable ("phi", m_phi));
158 CHECK( addVariable ("Eoff", m_Eoff));
159 CHECK( addVariable ("Et", m_Et));
160 CHECK( addVariable ("fsampl", m_fsampl));
161 CHECK( addVariable ("calo", m_calo));
162 CHECK( addVariable ("region", m_region));
163 CHECK( addVariable ("sampling", m_sampling));
164 CHECK( addVariable ("ieta", m_ieta));
165 CHECK( addVariable ("jphi", m_jphi));
166 //CHECK( addVariable ("hid", m_hashid));
167 CHECK( addVariable ("IdCells", m_offlId));
168
169 return StatusCode::SUCCESS;
170}
171
172
182
183 std::map<int, double> sc_E;
184
185 typedef LArHitContainer CONTAINER;
186 CONTAINER::const_iterator f_hit = p.begin();
187 CONTAINER::const_iterator l_hit = p.end();
188 for( ; f_hit != l_hit; ++f_hit ) {
189 const LArHit* hit = ( *f_hit );
190 const Identifier cell_id = hit->cellID();
191 Identifier sc_offl_id = m_scidtool->offlineToSuperCellID (cell_id);
192 int hashId = m_sc_idHelper->calo_cell_hash( sc_offl_id) ;
193 if (hashId < 999999)
194 sc_E[hashId] += hit->energy();
195 }
196
197
198 int nSC = 0;
199
200 std::map<int, double>::const_iterator it = sc_E.begin();
201 std::map<int, double>::const_iterator it_e = sc_E.end();
202
203 SG::ReadCondHandle<CaloSuperCellDetDescrManager> caloSuperCellMgrHandle{m_caloSuperCellMgrKey,Gaudi::Hive::currentContext()};
204 const CaloSuperCellDetDescrManager* sc_dd_mgr = *caloSuperCellMgrHandle;
205
206 for ( ; it!=it_e ; ++it ) {
207 int hashId = (*it).first;
208 Identifier offlId = m_sc_idHelper->cell_id(hashId) ;
209 float fsampl = m_dd_fSampl->FSAMPL(offlId);
210 double E = (*it).second;
211
212 // int pn = m_sc_idHelper->pos_neg(offlId);
213 int calo = m_sc_idHelper->sub_calo(hashId);
214 int region = m_sc_idHelper->region(offlId);
215 unsigned int lay = m_sc_idHelper->sampling(offlId);
216 int ieta = m_sc_idHelper->eta(offlId);
217 int jphi = m_sc_idHelper->phi(offlId);
218 float feta = sc_dd_mgr->get_element(offlId)->eta();
219 float fphi = sc_dd_mgr->get_element(offlId)->phi();
220 int lardet = calo;
221
222 if (m_caloSelection) {
223 std::vector< unsigned int >::const_iterator theFound =
224 std::find( m_caloNums.begin(), m_caloNums.end(), lardet );
225 if( theFound == m_caloNums.end() ) continue;
226 }
227 if ( m_caloEtaSelection ) {
228 if (feta<m_etaCut[0] || feta>m_etaCut[1]) continue;
229 }
230 if ( m_caloPhiSelection ) {
231 if (fphi<m_phiCut[0] || fphi>m_phiCut[1]) continue;
232 }
233 if ( m_caloLayerSelection ) {
234 bool tmp=false;
235 for( unsigned int j=0; j<m_caloLayers.size(); j++) {
236 if (m_caloLayers[j]==lay) tmp=true;
237 }
238 if (!tmp) continue;
239 }
240 nSC++;
241 m_E->push_back( E );
242 m_calo->push_back( calo );
243 m_region->push_back( region );
244 m_sampling->push_back( lay );
245 m_ieta->push_back( ieta );
246 m_jphi->push_back( jphi );
247 m_offlId->push_back( offlId.get_identifier32().get_compact() );
248 m_eta->push_back( feta );
249 m_phi->push_back( fphi );
250 double offEnergy = E;
251 if ( fsampl>0. ) {
252 offEnergy /= fsampl;
253 } else {
254 offEnergy = 0;
255 }
256 m_Eoff->push_back( offEnergy );
257 m_Et->push_back( offEnergy/cosh( feta ) );
258 m_fsampl->push_back( fsampl );
259 }
260 *m_nSC = nSC;
261
262 return StatusCode::SUCCESS;
263
264}
265
266
267} // namespace D3PD
268
#define ATH_MSG_INFO(x)
Helper class for offline supercell identifiers.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Type-safe wrapper for block filler tools.
std::vector< unsigned int > * m_offlId
std::vector< int > * m_jphi
virtual StatusCode book()
Book variables for this block.
std::vector< int > * m_calo
virtual StatusCode fill(const LArHitContainer &p)
Fill one block — type-safe version.
std::vector< double > * m_E
std::vector< double > * m_Eoff
std::vector< double > * m_Et
const CaloCell_SuperCell_ID * m_sc_idHelper
idHlper
LArSCHitFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
std::vector< double > * m_eta
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Property: Offline / supercell mapping tool.
std::vector< float > m_phiCut
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
std::vector< unsigned int > m_caloLayers
virtual StatusCode initialize()
Book variables for this block.
std::vector< int > * m_region
const ILArfSampl * m_dd_fSampl
std::vector< unsigned int > m_caloNums
const LArFCAL_ID * m_fcalid
std::vector< double > * m_phi
std::vector< int > * m_ieta
std::vector< double > * m_fsampl
std::vector< float > m_etaCut
std::vector< int > * m_sampling
const LArOnlineID * m_onlineHelper
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Hit collection.
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
double energy() const
Definition LArHit.h:113
Identifier cellID() const
Definition LArHit.h:108
Block filler tool for noisy FEB information.
Definition index.py:1