ATLAS Offline Software
Loading...
Searching...
No Matches
LArCond2NtupleBaseEB.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
13#include "CaloDetDescr/CaloDetDescrElement.h"
14
15LArCond2NtupleBaseEB::LArCond2NtupleBaseEB(const std::string& name, ISvcLocator* pSvcLocator)
16 : AthAlgorithm(name, pSvcLocator)
17 , m_initialized(false)
18 , m_nt(nullptr)
19 , m_detStore(nullptr)
20 , m_emId(nullptr)
21 , m_hecId(nullptr)
22 , m_fcalId(nullptr)
23 , m_onlineId(nullptr)
24 , m_caloId(nullptr)
25 , m_FEBTempTool("LArFEBTempTool")
26{
27}
28
30
31 ATH_MSG_DEBUG("Initializing LArCond2Ntuple base class");
32
33 if (m_ntpath.empty() || m_ntTitle.empty()) {
34 ATH_MSG_ERROR( "Need to set variable 'm_ntpath' and 'm_ntTitle' in constructor of deriving class!" );
35 return StatusCode::FAILURE;
36 }
37
38 size_t i=m_ntpath.rfind('/');
39 if (i==std::string::npos) {
40 ATH_MSG_ERROR( "Expected at least on '/' in path " << m_ntpath );
41 return StatusCode::FAILURE;
42 }
43 std::string basepath(m_ntpath.begin(),m_ntpath.begin()+i);
44
45 NTupleFilePtr file1(ntupleSvc(),basepath);
46 if (!file1){
47 ATH_MSG_ERROR( "Could not get NTupleFilePtr with path " << basepath << " failed" );
48 return StatusCode::FAILURE;
49 }
50 NTuplePtr nt(ntupleSvc(),m_ntpath);
51 if (!nt) {
52 nt=ntupleSvc()->book(m_ntpath,CLID_ColumnWiseTuple,m_ntTitle);
53 }
54 if (!nt){
55 ATH_MSG_ERROR( "Booking of NTuple at "<< m_ntpath << " and name " << m_ntTitle << " failed" );
56 return StatusCode::FAILURE;
57 }
58
59 m_nt=nt;
60
61 m_detStore= &(*detStore()); //for backward compatiblity
62
63 const CaloIdManager* calo_id_manager;
64 ATH_CHECK(detStore()->retrieve(calo_id_manager,"CaloIdManager"));
65
66 StatusCode sc;
68 ATH_CHECK(m_caloMgrKey.initialize(m_realgeom && !m_isSC));
69 if ( m_isSC ){
70 const LArOnline_SuperCellID* ll;
71 sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
72 if (sc.isFailure()) {
73 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
74 return StatusCode::FAILURE;
75 } else {
76 m_onlineId = ll;
77 ATH_MSG_DEBUG("Found the LArOnlineID helper");
78 }
79 m_caloId = calo_id_manager->getCaloCell_SuperCell_ID();
80 } else { // m_isSC
81 const LArOnlineID* ll;
82 sc = detStore()->retrieve(ll, "LArOnlineID");
83 if (sc.isFailure()) {
84 msg(MSG::ERROR) << "Could not get LArOnlineID helper !" << endmsg;
85 return StatusCode::FAILURE;
86 } else {
87 m_onlineId = ll;
88 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
89 }
90 m_caloId = calo_id_manager->getCaloCell_ID();
91 } // end of m_isSC if
92
93 m_emId=m_caloId->em_idHelper();
94 m_fcalId=m_caloId->fcal_idHelper();
95 m_hecId=m_caloId->hec_idHelper();
96
97 if (!m_emId) {
98 ATH_MSG_ERROR( "Could not access lar EM ID helper" );
99 return StatusCode::FAILURE;
100 }
101 if (!m_fcalId) {
102 ATH_MSG_ERROR( "Could not access lar FCAL ID helper" );
103 return StatusCode::FAILURE;
104 }
105 if (!m_hecId) {
106 ATH_MSG_ERROR( "Could not access lar HEC ID helper" );
107 return StatusCode::FAILURE;
108 }
109
110
111 if (m_addFEBTemp) {
112 sc = m_FEBTempTool.retrieve();
113 if (sc!=StatusCode::SUCCESS) {
114 ATH_MSG_ERROR( " Can't get FEBTempTool." );
115 return sc;
116 }
117 }
118
119 ATH_CHECK( m_BCKey.initialize() );
121 ATH_CHECK( m_cablingSCKey.initialize(m_isSC) );
122 ATH_CHECK( m_calibMapSCKey.initialize(m_addCalib && m_isSC) );
123 ATH_CHECK( m_cablingKey.initialize(!m_isSC) );
124 ATH_CHECK( m_calibMapKey.initialize(m_addCalib && !m_isSC) );
125
126 //Online-identifier variables
127 sc=nt->addItem("channelId",m_SC,m_onlChanId,0x38000000,0x3A000000);
128 if (sc!=StatusCode::SUCCESS) {
129 ATH_MSG_ERROR( "addItem 'channelId' failed" );
130 return StatusCode::FAILURE;
131 }
132
133 if(m_expandId) {
134
135 sc=nt->addItem("barrel_ec",m_SC,m_barrel_ec,0,1);
136 if (sc!=StatusCode::SUCCESS) {
137 ATH_MSG_ERROR( "addItem 'barrel_ec' failed" );
138 return StatusCode::FAILURE;
139 }
140
141 sc=nt->addItem("pos_neg",m_SC,m_pos_neg,0,1);
142 if (sc!=StatusCode::SUCCESS) {
143 ATH_MSG_ERROR( "addItem 'pos_neg' failed" );
144 return StatusCode::FAILURE;
145 }
146
147 sc=nt->addItem("FT",m_SC,m_FT,0,32);
148 if (sc!=StatusCode::SUCCESS) {
149 ATH_MSG_ERROR( "addItem 'FT' failed" );
150 return StatusCode::FAILURE;
151 }
152
153 sc=nt->addItem("slot",m_SC,m_slot,1,15);
154 if (sc!=StatusCode::SUCCESS) {
155 ATH_MSG_ERROR( "addItem 'slot' failed" );
156 return StatusCode::FAILURE;
157 }
158
159 sc=nt->addItem("channel",m_SC,m_channel,0,127);
160 if (sc!=StatusCode::SUCCESS){
161 ATH_MSG_ERROR( "addItem 'channel' failed" );
162 return StatusCode::FAILURE;
163 }
164 }//m_expandId
165
166 if(m_addCalib) {
167 sc=nt->addItem("calibLine",m_SC,m_calibLine,0,127);
168 if (sc!=StatusCode::SUCCESS) {
169 ATH_MSG_ERROR( "addItem 'calibLine' failed" );
170 return StatusCode::FAILURE;
171 }
172
173
174 sc=nt->addItem("isConnected",m_SC,m_isConnected,0,1);
175 if (sc!=StatusCode::SUCCESS) {
176 ATH_MSG_ERROR( "addItem 'isConnected' failed" );
177 return StatusCode::FAILURE;
178 }
179 }//m_addCalib
180
181
182 if (m_addHash) {
183 sc=nt->addItem("channelHash",m_SC,m_chanHash,0,200000);
184 if (sc!=StatusCode::SUCCESS) {
185 ATH_MSG_ERROR( "addItem 'channelHash' failed" );
186 return StatusCode::FAILURE;
187 }
188
189 sc=nt->addItem("febHash",m_SC,m_febHash,0,2000);
190 if (sc!=StatusCode::SUCCESS) {
191 ATH_MSG_ERROR( "addItem 'febHash' failed" );
192 return StatusCode::FAILURE;
193 }
194
195 if (m_OffId) {
196 sc=m_nt->addItem("oflHash",m_SC,m_oflHash,0,200000);
197 if (sc!=StatusCode::SUCCESS) {
198 ATH_MSG_ERROR( "addItem 'oflHash' failed" );
199 return StatusCode::FAILURE;
200 }
201 }
202 }//m_addHash
203
204
205 //Offline-identifier variables
206 if ( m_OffId ) {
207 sc=nt->addItem("offlineId",m_SC,m_oflChanId,0x20000000,0x40000000);
208 if (sc!=StatusCode::SUCCESS) {
209 ATH_MSG_ERROR( "addItem 'channelId' failed" );
210 return StatusCode::FAILURE;
211 }
212
213 sc=nt->addItem("layer",m_SC,m_layer,0,4);
214 if (sc!=StatusCode::SUCCESS) {
215 ATH_MSG_ERROR( "addItem 'layer' failed" );
216 return StatusCode::FAILURE;
217 }
218
219 if(m_realgeom) {
220 sc=nt->addItem("eta",m_SC,m_reta);
221 if (sc!=StatusCode::SUCCESS) {
222 ATH_MSG_ERROR( "addItem 'eta' failed" );
223 return StatusCode::FAILURE;
224 }
225 sc=nt->addItem("phi",m_SC,m_rphi);
226 if (sc!=StatusCode::SUCCESS) {
227 ATH_MSG_ERROR( "addItem 'phi' failed" );
228 return StatusCode::FAILURE;
229 }
230 }
231 sc=nt->addItem("ieta",m_SC,m_eta,0,510);
232 if (sc!=StatusCode::SUCCESS) {
233 ATH_MSG_ERROR( "addItem 'ieta' failed" );
234 return StatusCode::FAILURE;
235 }
236 sc=nt->addItem("iphi",m_SC,m_phi,0,1023);
237 if (sc!=StatusCode::SUCCESS) {
238 ATH_MSG_ERROR( "addItem 'iphi' failed" );
239 return StatusCode::FAILURE;
240 }
241
242 sc=nt->addItem("region",m_SC,m_region,0,5);
243 if (sc!=StatusCode::SUCCESS) {
244 ATH_MSG_ERROR( "addItem 'region' failed" );
245 return StatusCode::FAILURE;
246 }
247 sc=nt->addItem("detector",m_SC,m_detector,0,2);
248 if (sc!=StatusCode::SUCCESS) {
249 ATH_MSG_ERROR( "addItem 'detector' failed" );
250 return StatusCode::FAILURE;
251
252 }
253 }// m_OffId
254
255 if (m_addBC) {
256 sc=nt->addItem("badChan",m_SC,m_badChanWord);
257 if (sc!=StatusCode::SUCCESS) {
258 ATH_MSG_ERROR( "addItem 'badChan' failed" );
259 return StatusCode::FAILURE;
260 }
261 }
262
263 if (m_addFEBTemp) {
264 sc=nt->addItem("FEBTemp1",m_SC,m_FEBTemp1);
265 if (sc!=StatusCode::SUCCESS) {
266 ATH_MSG_ERROR( "addItem 'FEBTemp1' failed" );
267 return StatusCode::FAILURE;
268 }
269 sc=nt->addItem("FEBTemp2",m_SC,m_FEBTemp2);
270 if (sc!=StatusCode::SUCCESS) {
271 ATH_MSG_ERROR( "addItem 'FEBTemp2' failed" );
272 return StatusCode::FAILURE;
273 }
274 }
275
276 m_initialized=true;
277 return StatusCode::SUCCESS;
278}
279
281
282 ATH_MSG_DEBUG("Starting fillFromIdentifier");
283 const LArBadChannelCont *bcCont = nullptr;
284 if ( m_addBC ) {
286 bcCont =*readHandle;
287 if( !bcCont) {
288 ATH_MSG_WARNING( "Do not have Bad chan container " << m_BCKey.key() );
289 return false;
290 }
291 }
292
293 const LArCalibLineMapping *clCont=nullptr;
294 if(m_addCalib) {
295 if(m_isSC){
297 clCont={*clHdl};
298 }
299 else{
301 clCont={*clHdl};
302 }
303 if(!clCont) {
304 ATH_MSG_WARNING( "Do not have calib line mapping !!!" );
305 return false;
306 }
307 }
308
309 const LArOnOffIdMapping* cabling=nullptr;
310 if(m_isSC){
312 cabling=*cablingHdl;
313 }
314 else{
316 cabling=*cablingHdl;
317 }
318
319 if(!cabling) {
320 ATH_MSG_WARNING( "Do not have cabling !" );
321 return false;
322 }
323
325
326 if(m_expandId) {
327 m_barrel_ec[C] = m_onlineId->barrel_ec(hwid);
328 m_pos_neg[C] = m_onlineId->pos_neg(hwid);
329 m_FT[C] = m_onlineId->feedthrough(hwid);
330 m_slot[C] = m_onlineId->slot(hwid);
331 m_channel[C] = m_onlineId->channel(hwid);
332 }
333
334 if (m_addHash) {
335 m_chanHash[C]=m_onlineId->channel_Hash(hwid);
336 m_febHash[C]=m_onlineId->feb_Hash(m_onlineId->feb_Id(hwid));
337 }
338
339 if(m_addCalib) {
341 const std::vector<HWIdentifier>& calibLineV=clCont->calibSlotLine(hwid);
342 if(!calibLineV.empty()) m_calibLine[C] = m_onlineId->channel(calibLineV[0]);
343 }
344
345
346 if ( m_OffId ) {
351
352 if(m_realgeom){
355 }
359 }
360
361 if (m_addBC) m_badChanWord[C]=0;
362 bool connected=false;
363
364 const CaloDetDescrManager_Base* dd_man = nullptr;
365 if (m_realgeom) {
366 if(m_isSC) {
368 dd_man = *caloSuperCellMgrHandle;
369 }
370 else {
372 dd_man = *caloMgrHandle;
373 }
374 }
375
376 try {
377 if (cabling->isOnlineConnected(hwid)) {
378 Identifier id=cabling->cnvToIdentifier(hwid);
379 if ( m_OffId ) {
380 m_oflChanId[C] = id.get_identifier32().get_compact();
381 if (m_addHash) m_oflHash[C]=m_caloId->calo_cell_hash(id);
382
383 if (dd_man) {
384 const CaloDetDescrElement *elem = dd_man->get_element(id);
385 if(!elem) {
386 ATH_MSG_WARNING("Do not have CDDE for "<<id.getString());
387 } else {
388 m_reta[C] = elem->eta_raw();
389 m_rphi[C] = elem->phi_raw();
390 }
391 }
392
393 if (m_emId->is_lar_em(id)) {
394 m_eta[C] = m_emId->eta(id);
395 m_phi[C] = m_emId->phi(id);
396 m_layer[C] = m_emId->sampling(id);
397 m_region[C] = m_emId->region(id);
398 m_detector[C] = std::abs(m_emId->barrel_ec(id)) - 1; //0-barrel, 1-EMEC-OW, 2-EMEC-IW
399 }
400 else if (m_hecId->is_lar_hec(id)) {
401 m_eta[C] = m_hecId->eta(id);
402 m_phi[C] = m_hecId->phi(id);
403 m_layer[C] = m_hecId->sampling(id);
404 m_region[C] = m_hecId->region(id);
405 m_detector[C] = 3;
406 }
407 else if (m_fcalId->is_lar_fcal(id)) {
408 m_eta[C] = m_fcalId->eta(id);
409 m_phi[C] = m_fcalId->phi(id);
410 m_layer[C] = m_fcalId->module(id);
411 m_region[C] = 0;
412 m_detector[C] = 4;
413 }
414 } // m_OffId
415 connected=true;
416 }//end if is connected
417 }catch (LArID_Exception & except) {}
418
419 //bad-channel word
420 if (m_addBC) m_badChanWord[C]=bcCont->status(hwid).packedData();
421 // FEB temperatures
422 if (m_addFEBTemp) {
423 FEBTemp tv = m_FEBTempTool->getFebTemp(hwid);
424 if( !tv.empty() ) {
425 FEBTemp::const_iterator itb = tv.begin();
426 FEBTemp::const_iterator ite = tv.end();
427 for(;itb!=ite;++itb) {
428 m_FEBTemp1[C] = (*itb).first;
429 m_FEBTemp2[C] = (*itb).second;
430 }
431 }
432 }
433
434 if(m_addCalib) m_isConnected[C] = (long)connected;
435
436 return connected;
437}
438
439
442{
443 if(m_isSC) return m_cablingSCKey;
444 return m_cablingKey;
445}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helper class for offline supercell identifiers.
Definition of CaloDetDescrManager.
std::vector< std::pair< float, float > > FEBTemp
LArBadXCont< LArBadChannel > LArBadChannelCont
static Double_t sc
INTupleSvc * ntupleSvc()
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class initializes the Calo (LAr and Tile) offline identifiers.
const CaloCell_SuperCell_ID * getCaloCell_SuperCell_ID(void) const
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
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.
BitWord packedData() const
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
NTuple::Array< double > m_oflHash
NTuple::Array< double > m_phi
Gaudi::Property< bool > m_isSC
const LArOnlineID_Base * m_onlineId
const SG::ReadCondHandleKey< LArOnOffIdMapping > & cablingKey() const
NTuple::Array< double > m_calibLine
NTuple::Array< double > m_chanHash
NTuple::Array< double > m_oflChanId
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapSCKey
Gaudi::Property< bool > m_addHash
NTuple::Array< double > m_pos_neg
Gaudi::Property< bool > m_OffId
NTuple::Array< double > m_febHash
bool fillFromIdentifier(const HWIdentifier &id, int C)
NTuple::Array< double > m_eta
NTuple::Array< double > m_layer
Gaudi::Property< bool > m_addBC
Gaudi::Property< bool > m_addCalib
const LArFCAL_Base_ID * m_fcalId
NTuple::Array< float > m_rphi
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
const CaloCell_Base_ID * m_caloId
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
NTuple::Array< double > m_barrel_ec
LArCond2NtupleBaseEB(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_expandId
Gaudi::Property< bool > m_addFEBTemp
NTuple::Array< double > m_FT
NTuple::Array< double > m_onlChanId
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
NTuple::Array< double > m_region
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapKey
NTuple::Array< float > m_reta
NTuple::Array< double > m_isConnected
NTuple::Array< double > m_channel
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
NTuple::Array< double > m_slot
const LArHEC_Base_ID * m_hecId
NTuple::Array< double > m_badChanWord
NTuple::Array< float > m_FEBTemp2
ToolHandle< ILArFEBTempTool > m_FEBTempTool
NTuple::Array< float > m_FEBTemp1
Gaudi::Property< bool > m_realgeom
const LArEM_Base_ID * m_emId
NTuple::Array< double > m_detector
Exception class for LAr Identifiers.
struct color C