ATLAS Offline Software
CaloTTOnAttrIdMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include "GaudiKernel/ISvcLocator.h"
10 #include "GaudiKernel/Bootstrap.h"
11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/IMessageSvc.h"
13 
14 #include "StoreGate/StoreGateSvc.h"
15 
16 #include <iostream>
17 
19 }
20 
21 
23 }
24 
25 //------------------------------------------//
27 
28  convert_to_P(m);
29 
30  IMessageSvc *msgSvc;
31  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
32  if(status.isFailure()){
33  std::cout << "Cannot locate MessageSvc" << std::endl;
34  }
35  MsgStream log( msgSvc, "CaloTTOnAttrIdMap");
36  bool dump=false;
37  if (log.level()<=MSG::VERBOSE) dump=true;
38  bool dump2=false;
39  if (log.level()<=MSG::DEBUG) dump2=true;
40 
41  log<<MSG::DEBUG<<" CaloTTOnAttrId size = "<<m.size() <<endmsg;
43  status = Gaudi::svcLocator()->service("DetectorStore",detStore);
44  if(status.isFailure()){
45  log << MSG::ERROR << "Cannot locate DetectorStore" << endmsg;
46  }
47 
48  const TTOnlineID* online_id = nullptr;
49 
50  status=detStore->retrieve(online_id);
51  if(status.isFailure()){
52  log << MSG::ERROR << "Cannot retrieve online_id" << endmsg;
53  }
54 
55  CaloTTOnAttrId::const_iterator it = m.begin();
56  CaloTTOnAttrId::const_iterator it_e = m.end();
57 
58  try {
59  for (; it!=it_e; ++it) {
60  const CaloTTOnAttrId_t& t = *it;
61 
62  HWIdentifier sid = online_id->channelId(t.crate, t.module, t.submodule, t.channel);
63 
64  if (dump) {
66  << " db struct= "
67  <<" crate="<<t.crate<<" module="<<t.module
68  <<" submodule="<<t.submodule
69  <<" channel="<<t.channel
70  <<" em_had="<<t.em_had
71  <<" pos_neg="<<t.pos_neg
72  <<" barrel_endcap_fcal"<<t.barrel_endcap_fcal
73  << endmsg;
74 
75  log<<MSG::VERBOSE<< " onl id = " << sid <<endmsg;
76  }
77 
78  AttrStruct attrStruct;
79  attrStruct.em_had = t.em_had;
80  attrStruct.pos_neg = t.pos_neg;
81  attrStruct.barrel_endcap_fcal = t.barrel_endcap_fcal;
82  attrStruct.module_type = t.module_type;
83 
84  m_on2attrIdMap[sid] = attrStruct;
85  }
86  if (dump2) log<<MSG::DEBUG<<" CaloTTOnAttrIdMap::set : number of Ids="<<m_on2attrIdMap.size()<<std::endl;
87  } catch (CaloID_Exception& except) {
88  log<<MSG::ERROR<<" Failed in CaloTTOnAttrIdMap::set " << endmsg;
89  log<<MSG::ERROR<< (std::string) except << endmsg ;
90  }
91  return;
92 }
93 
95  std::map<HWIdentifier,AttrStruct>::const_iterator it=m_on2attrIdMap.find(channelId);
96 
97  if(it!=m_on2attrIdMap.end()){
98  return ((*it).second).em_had;
99  }
100 
101  // ERROR, can not find the channelId.
102  IMessageSvc *msgSvc;
103  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
104  if(status.isFailure()){
105  std::cout << "Cannot locate MessageSvc" << std::endl;
106  }
107 
108  MsgStream log( msgSvc, "CaloTTOnAttrIdMap");
109  log<<MSG::ERROR<<" Online ID not found, channelId = " <<channelId.get_compact()<< endmsg;
110  return 0;
111 }
113  std::map<HWIdentifier,AttrStruct>::const_iterator it=m_on2attrIdMap.find(channelId);
114 
115  if(it!=m_on2attrIdMap.end()){
116  return ((*it).second).pos_neg;
117  }
118 
119  // ERROR, can not find the channelId.
120  IMessageSvc *msgSvc;
121  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
122  if(status.isFailure()){
123  std::cout << "Cannot locate MessageSvc" << std::endl;
124  }
125 
126  MsgStream log( msgSvc, "CaloTTOnAttrIdMap");
127  log<<MSG::ERROR<<" Online ID not found, channelId = " <<channelId.get_compact()<< endmsg;
128  return 0;
129 }
130 
132  std::map<HWIdentifier,AttrStruct>::const_iterator it=m_on2attrIdMap.find(channelId);
133 
134  if(it!=m_on2attrIdMap.end()){
135  return ((*it).second).barrel_endcap_fcal;
136  }
137 
138  // ERROR, can not find the channelId.
139  IMessageSvc *msgSvc;
140  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
141  if(status.isFailure()){
142  std::cout << "Cannot locate MessageSvc" << std::endl;
143  }
144 
145  MsgStream log( msgSvc, "CaloTTOnAttrIdMap");
146  log<<MSG::ERROR<<" Online ID not found, channelId = " <<channelId.get_compact()<< endmsg;
147  return 0;
148 }
149 
151  std::map<HWIdentifier,AttrStruct>::const_iterator it=m_on2attrIdMap.find(channelId);
152 
153  if(it!=m_on2attrIdMap.end()){
154  return ((*it).second).module_type;
155  }
156 
157  // ERROR, can not find the channelId.
158  IMessageSvc *msgSvc;
159  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
160  if(status.isFailure()){
161  std::cout << "Cannot locate MessageSvc" << std::endl;
162  }
163 
164  MsgStream log( msgSvc, "CaloTTOnAttrIdMap");
165  log<<MSG::ERROR<<" Online ID not found, channelId = " <<channelId.get_compact()<< endmsg;
166  return 0;
167 }
168 
170  return &m_persData;
171 }
172 
174 
175  CaloTTOnAttrId::const_iterator it = d.begin();
176  CaloTTOnAttrId::const_iterator it_e = d.end();
177 
178  for ( ;it!=it_e;++it){
179  const CaloTTOnAttrId_t& t = *it;
181 
182  t2.crate = t.crate ;
183  t2.module = t.module;
184  t2.submodule= t.submodule;
185  t2.channel = t.channel;
186 
187  t2.em_had = t.em_had;
188  t2.pos_neg = t.pos_neg;
189  t2.barrel_endcap_fcal = t.barrel_endcap_fcal;
190  t2.module_type = t.module_type;
191 
192  m_persData.m_v.push_back(t2);
193  }
194 }
195 
196 
198 
199  std::vector<CaloTTOnAttrId_P::__t>::const_iterator it = p.m_v.begin();
200  std::vector<CaloTTOnAttrId_P::__t>::const_iterator it_e = p.m_v.end();
201 
202  d.clear();
203  for ( ;it!=it_e;++it){
204  const CaloTTOnAttrId_P::__t& t = *it;
206 
207  t2.crate = t.crate ;
208  t2.module = t.module;
209  t2.submodule= t.submodule;
210  t2.channel = t.channel;
211 
212  t2.em_had = t.em_had;
213  t2.pos_neg = t.pos_neg;
214  t2.barrel_endcap_fcal = t.barrel_endcap_fcal;
215  t2.module_type = t.module_type;
216 
217  d.push_back(t2);
218  }
219 }
220 
222 
224  convert_to_D(p,d);
225  set(d);
226  m_persData.m_version = p.m_version;
227  return;
228 }
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CaloTTOnAttrId_t
Structure definition of the LArTTOnAttrIdMap.
Definition: CaloTTOnAttrId.h:15
CaloID_Exception
Exception class for Calo Identifiers.
Definition: CaloID_Exception.h:20
AttrStruct::module_type
unsigned int module_type
Definition: CaloTTOnAttrIdMap.h:29
CaloTTOnAttrIdMap::getP
CaloTTOnAttrId_P * getP()
return the persistified map
Definition: CaloTTOnAttrIdMap.cxx:169
CaloTTOnAttrIdMap::pos_neg
unsigned int pos_neg(HWIdentifier channelId) const
return 0 for z<0 channels and 1 for z>0 channels
Definition: CaloTTOnAttrIdMap.cxx:112
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TTOnlineID
Helper class for Calo TT online identifiers.
Definition: TTOnlineID.h:37
CaloTTOnAttrIdMap::barrel_endcap_fcal
unsigned int barrel_endcap_fcal(HWIdentifier channelId) const
To know if a channel belongs to the barrel, end cap or fcal parts.
Definition: CaloTTOnAttrIdMap.cxx:131
skel.it
it
Definition: skel.GENtoEVGEN.py:423
CaloTTOnAttrId
std::vector< CaloTTOnAttrId_t > CaloTTOnAttrId
Definition: CaloTTOnAttrId.h:27
AttrStruct::pos_neg
unsigned int pos_neg
Definition: CaloTTOnAttrIdMap.h:27
CaloTTOnAttrId_P::CaloTTOnAttrId_P_t
Structure of the map.
Definition: CaloTTOnAttrId_P.h:27
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
HWIdentifier
Definition: HWIdentifier.h:13
CaloTTOnAttrIdMap::module_type
unsigned int module_type(HWIdentifier channelId) const
To get the type of the module connected to the channel:
Definition: CaloTTOnAttrIdMap.cxx:150
CaloTTOnAttrIdMap::em_had
unsigned int em_had(HWIdentifier channelId) const
return the corresponding sampling of channelId:
Definition: CaloTTOnAttrIdMap.cxx:94
CaloTTOnAttrIdMap::convert_to_P
void convert_to_P(const CaloTTOnAttrId &t)
Definition: CaloTTOnAttrIdMap.cxx:173
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
AttrStruct
This is a StoreGate object holding the TT online-attribute map.
Definition: CaloTTOnAttrIdMap.h:25
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TTOnlineID.h
CaloTTOnAttrIdMap::CaloTTOnAttrIdMap
CaloTTOnAttrIdMap()
Definition: CaloTTOnAttrIdMap.cxx:18
CaloTTOnAttrIdMap::convert_to_D
void convert_to_D(const CaloTTOnAttrId_P &t, CaloTTOnAttrId &d)
Definition: CaloTTOnAttrIdMap.cxx:197
python.ChapPy.dump
def dump(buf, stdout=sys.stdout)
Definition: ChapPy.py:25
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CaloTTOnAttrIdMap::m_persData
CaloTTOnAttrId_P m_persData
Definition: CaloTTOnAttrIdMap.h:89
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloTTOnAttrIdMap::~CaloTTOnAttrIdMap
~CaloTTOnAttrIdMap()
Definition: CaloTTOnAttrIdMap.cxx:22
CaloTTOnAttrIdMap::m_on2attrIdMap
std::map< HWIdentifier, AttrStruct > m_on2attrIdMap
Definition: CaloTTOnAttrIdMap.h:87
CaloTTOnAttrId_P::m_version
int m_version
Definition: CaloTTOnAttrId_P.h:47
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloTTOnAttrId_P
This is a database object holding the TT online-attribute map.
Definition: CaloTTOnAttrId_P.h:22
TTOnlineID::channelId
HWIdentifier channelId(int crate, int module, int submodule, int channel) const
(1) create towerId from fields
Definition: TTOnlineID.h:398
merge.status
status
Definition: merge.py:17
AttrStruct::barrel_endcap_fcal
unsigned int barrel_endcap_fcal
Definition: CaloTTOnAttrIdMap.h:28
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
CaloTTOnAttrId_P::m_v
std::vector< __t > m_v
Definition: CaloTTOnAttrId_P.h:45
CaloID_Exception.h
StoreGateSvc.h
CaloTTOnAttrIdMap::set
void set(const PDATA &t)
initialize from Nova
Definition: CaloTTOnAttrIdMap.cxx:26
AttrStruct::em_had
unsigned int em_had
Definition: CaloTTOnAttrIdMap.h:26
CaloTTOnAttrIdMap.h