ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LArTTCellMap Class Reference

This is a StoreGate object holding the offline TT-cell map. More...

#include <LArTTCellMap.h>

Inheritance diagram for LArTTCellMap:
Collaboration diagram for LArTTCellMap:

Public Types

typedef LArTTCell PDATA
 

Public Member Functions

 LArTTCellMap ()
 
 ~LArTTCellMap ()
 
void set (const PDATA &t)
 initialize from Nova More...
 
const std::vector< Identifier > & createCellIDvec (const Identifier &id) const
 Return a vector of offline Identifiers (corresponding helpers = LArEM_ID, LArHEC_ID, LArFCAL_ID) for a TT-layer offline id (helper=CaloLVL1_ID) More...
 
Identifier whichTTID (const Identifier &id) const
 return the offline id (CaloLVL1_ID) of the TT to which a cell (CaloCell_ID) belongs More...
 
const LArTTCell_PgetP () const
 return the persistified map More...
 
LArTTCell_PgetP ()
 return the persistified map (non-const) More...
 
void set (const LArTTCell_P &t)
 initialize from POOL More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

void convert_to_P (const LArTTCell &t)
 
void convert_to_D (const LArTTCell_P &t, LArTTCell &d)
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::map< Identifier, Identifierm_cell2ttIdMap
 
std::map< Identifier, std::vector< Identifier > > m_tt2cellIdMap
 
LArTTCell_P m_persData
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

This is a StoreGate object holding the offline TT-cell map.

Its persistifiable version is the LArTTCellMap_P class

Author
Hong Ma
maintained by F. Ledroit

Definition at line 27 of file LArTTCellMap.h.

Member Typedef Documentation

◆ PDATA

Definition at line 32 of file LArTTCellMap.h.

Constructor & Destructor Documentation

◆ LArTTCellMap()

LArTTCellMap::LArTTCellMap ( )

Definition at line 17 of file LArTTCellMap.cxx.

18  : AthMessaging ("LArTTCellMap")
19 {
20 }

◆ ~LArTTCellMap()

LArTTCellMap::~LArTTCellMap ( )

Definition at line 23 of file LArTTCellMap.cxx.

24 {
25 
26 }

Member Function Documentation

◆ convert_to_D()

void LArTTCellMap::convert_to_D ( const LArTTCell_P t,
LArTTCell d 
)
private

Definition at line 239 of file LArTTCellMap.cxx.

240 {
241 
242  std::vector<LArTTCell_P::__t>::const_iterator it = p.m_v.begin();
243  std::vector<LArTTCell_P::__t>::const_iterator it_e = p.m_v.end();
244 
245  d.clear();
246  for ( ;it!=it_e;++it){
247  const LArTTCell_P::__t& t = *it;
248  LArTTCell_t t2 ;
249 
250  t2.det = t.det ;
251  t2.pn = t.pn ;
252  t2.region = t.region;
253  t2.sample = t.sample;
254  t2.eta = t.eta ;
255  t2.phi = t.phi ;
256 
257  t2.tpn = t.tpn ;
258  t2.tregion = t.tregion;
259  t2.tsample = t.tsample;
260  t2.teta = t.teta ;
261  t2.tphi = t.tphi ;
262  t2.layer = t.layer ;
263 
264  d.push_back(t2);
265  }
266 
267 }

◆ convert_to_P()

void LArTTCellMap::convert_to_P ( const LArTTCell t)
private

Definition at line 209 of file LArTTCellMap.cxx.

210 {
211 
212  LArTTCell::const_iterator it = d.begin();
213  LArTTCell::const_iterator it_e = d.end();
214 
215  for ( ;it!=it_e;++it){
216  const LArTTCell_t& t = *it;
218 
219  t2.det = t.det;
220  t2.pn = t.pn;
221  t2.sample = t.sample;
222  t2.region = t.region;
223  t2.eta = t.eta;
224  t2.phi = t. phi;
225 
226  t2.tpn = t.tpn ;
227  t2.tsample = t.tsample;
228  t2.tregion = t.tregion;
229  t2.teta = t.teta;
230  t2.tphi = t.tphi;
231  t2.layer = t.layer;
232 
233  m_persData.m_v.push_back(t2);
234  }
235 
236 }

◆ createCellIDvec()

const std::vector< Identifier > & LArTTCellMap::createCellIDvec ( const Identifier id) const

Return a vector of offline Identifiers (corresponding helpers = LArEM_ID, LArHEC_ID, LArFCAL_ID) for a TT-layer offline id (helper=CaloLVL1_ID)

Definition at line 182 of file LArTTCellMap.cxx.

183 {
184 
185  std::map<Identifier,std::vector<Identifier> >::const_iterator
186  it=m_tt2cellIdMap.find(sid);
187 
188  if(it!=m_tt2cellIdMap.end()){
189  return (*it).second;
190  }
191 
192  ATH_MSG_VERBOSE( " vector of offline cell ID not found, TT id = " <<sid.get_compact() );
193 
194  static const std::vector<Identifier> v;
195  return v ;
196 
197 }

◆ getP() [1/2]

LArTTCell_P * LArTTCellMap::getP ( )

return the persistified map (non-const)

Definition at line 204 of file LArTTCellMap.cxx.

205 {
206  return &m_persData;
207 }

◆ getP() [2/2]

const LArTTCell_P * LArTTCellMap::getP ( ) const

return the persistified map

Definition at line 199 of file LArTTCellMap.cxx.

200 {
201  return &m_persData;
202 }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ set() [1/2]

void LArTTCellMap::set ( const LArTTCell_P t)

initialize from POOL

Definition at line 269 of file LArTTCellMap.cxx.

270 {
271  LArTTCell d ;
272  convert_to_D(p,d);
273  set(d);
274  m_persData.m_version = p.m_version;
275  return ;
276 }

◆ set() [2/2]

void LArTTCellMap::set ( const PDATA t)

initialize from Nova

Definition at line 29 of file LArTTCellMap.cxx.

30 {
31 
32  convert_to_P(m);
33 
34  ATH_MSG_DEBUG( " LArTTCell size = "<<m.size() );
35 
36  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "LArTTCellMap");
37 
38  const LArEM_ID* em_id = nullptr;
39  const LArHEC_ID* hec_id = nullptr;
40  const LArFCAL_ID* fcal_id = nullptr;
41  const CaloLVL1_ID* lvl1_id = nullptr;
42 
43  StatusCode status=detStore->retrieve(em_id);
44  if(status.isFailure()){
45  ATH_MSG_ERROR( "Cannot retrieve em_id" );
46  }
47  status=detStore->retrieve(hec_id);
48  if(status.isFailure()){
49  ATH_MSG_ERROR( "Cannot retrieve hec_id" );
50  }
51  status=detStore->retrieve(fcal_id);
52  if(status.isFailure()){
53  ATH_MSG_ERROR( "Cannot retrieve fcal_id" );
54  }
55  status=detStore->retrieve(lvl1_id);
56  if(status.isFailure()){
57  ATH_MSG_ERROR( "Cannot retrieve lvl1_id" );
58  }
59  LArTTCell::const_iterator it = m.begin();
60  LArTTCell::const_iterator it_e = m.end();
61 
62  // useful in debug phase; can be removed afterwards
63  std::set<Identifier> cellIdSet;
64 
65  try {
66  for (; it!=it_e; ++it) {
67  const LArTTCell_t& t = *it;
68 
69  Identifier id ;
70 
71  if(t.det==0){
72  // EM
73  id = em_id->channel_id(t.pn,t.sample,t.region,t.eta,t.phi);
74  } else if(t.det==1){
75  // HEC
76  id = hec_id->channel_id(t.pn,t.sample,t.region,t.eta,t.phi);
77  } else if(t.det==2){
78  // FCAL sample==region
79  id = fcal_id->channel_id(t.pn,t.region,t.eta,t.phi);
80 
81  } else {
82  ATH_MSG_ERROR( " Wrong input Detector Number " << t.det );
83  }
84 
85  Identifier sid = lvl1_id->layer_id(t.tpn,t.tsample,t.tregion,t.teta,t.tphi,t.layer);
86 
87  ATH_MSG_VERBOSE( " db struct= "
88  <<" det="<<t.det
89  <<" pn="<<t.pn
90  <<" region="<<t.region
91  <<" sample="<<t.sample
92  <<" eta="<<t.eta<<" phi="<<t.phi
93  <<" trig pn="<<t.tpn
94  <<" trig region="<<t.tregion
95  <<" trig sample="<<t.tsample
96  <<" trig eta="<<t.teta<<" trig phi="<<t.tphi
97  <<" layer="<<t.layer );
98  ATH_MSG_VERBOSE( " lvl1 id = " << sid<<" offline id ="<<id );
99 
100  if(!(cellIdSet.insert(id)).second) {
101  ATH_MSG_ERROR( " Duplicate cell id "
102  << lvl1_id->show_to_string(id)
103  << " in TT= "
104  << lvl1_id->show_to_string(sid) );
105  }
106  m_cell2ttIdMap[id] = sid;
107 
108  std::map<Identifier,std::vector<Identifier> >::const_iterator it_find = m_tt2cellIdMap.find(sid);
109  if(it_find==m_tt2cellIdMap.end()) {
110  // a vector of Ids does not already exist for this sid, we reserve the number of elements
111  int nElements = 1;
112 
113  if(t.tsample==0) {
114  if(t.tregion==0) {
115  if(t.layer==0) {
116  nElements = 4;
117  } else if(t.layer==1) {
118  nElements = 32;
119  } else if(t.layer==2) {
120  nElements = 16;
121  } else if(t.layer==3) {
122  nElements = 8;
123  }
124 
125  } else if(t.tregion==1) {
126  nElements = 4;
127  } else if(t.tregion==2) {
128  nElements = 2;
129  } else if(t.tregion==3) {
130  nElements = 16;
131  }
132 
133  } else if(t.tsample==1) {
134  if(t.tregion==3) {
135  if(t.layer==0) {
136  nElements = 8;
137  } else if(t.layer==1) {
138  nElements = 4;
139  }
140  }
141  }
142  m_tt2cellIdMap[sid].reserve(nElements);
143  }
144  m_tt2cellIdMap[sid].push_back(id);
145  }
146  }
147 
148 
149  catch (LArID_Exception& except) {
150  ATH_MSG_ERROR( " Failed in LArTTCellMap::set " );
151  ATH_MSG_ERROR( (std::string) except );
152  }
153 
154  ATH_MSG_DEBUG( " LArTTCellMap::set : number of cell Ids="<<m_cell2ttIdMap.size() );
155 
156  detStore->release() ;
157 
158  return;
159 
160 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ whichTTID()

Identifier LArTTCellMap::whichTTID ( const Identifier id) const

return the offline id (CaloLVL1_ID) of the TT to which a cell (CaloCell_ID) belongs

Definition at line 162 of file LArTTCellMap.cxx.

163 {
164 
165  std::map<Identifier,Identifier>::const_iterator it =m_cell2ttIdMap.find(id);
166 
167  if(it!=m_cell2ttIdMap.end()){
168  return (*it).second;
169  }
170 
171  ATH_MSG_ERROR( " Offline TT ID not found for cell "<< id );
172 
173  return Identifier();
174 
175 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_cell2ttIdMap

std::map<Identifier,Identifier> LArTTCellMap::m_cell2ttIdMap
private

Definition at line 71 of file LArTTCellMap.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_persData

LArTTCell_P LArTTCellMap::m_persData
private

Definition at line 76 of file LArTTCellMap.h.

◆ m_tt2cellIdMap

std::map<Identifier,std::vector<Identifier> > LArTTCellMap::m_tt2cellIdMap
private

Definition at line 72 of file LArTTCellMap.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
LArTTCellMap::m_tt2cellIdMap
std::map< Identifier, std::vector< Identifier > > m_tt2cellIdMap
Definition: LArTTCellMap.h:72
LArTTCellMap::set
void set(const PDATA &t)
initialize from Nova
Definition: LArTTCellMap.cxx:29
LArTTCellMap::convert_to_D
void convert_to_D(const LArTTCell_P &t, LArTTCell &d)
Definition: LArTTCellMap.cxx:239
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
hist_file_dump.d
d
Definition: hist_file_dump.py:137
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArHEC_ID
Helper class for LArHEC offline identifiers.
Definition: LArHEC_ID.h:85
LArTTCell
std::vector< LArTTCell_t > LArTTCell
Definition: LArTTCell.h:35
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
LArEM_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
CaloLVL1_ID::layer_id
Identifier layer_id(int pos_neg_z, int sampling, int region, int eta, int phi, int layer) const
build a layer identifier
Definition: CaloLVL1_ID.h:530
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArTTCellMap::convert_to_P
void convert_to_P(const LArTTCell &t)
Definition: LArTTCellMap.cxx:209
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArFCAL_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloLVL1_ID
Helper class for offline TT identifiers.
Definition: CaloLVL1_ID.h:66
LArTTCell_P::LArTTCell_P_t
Structure of the map.
Definition: LArTTCell_P.h:28
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
LArTTCell_P::m_version
int m_version
Definition: LArTTCell_P.h:56
LArHEC_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
LArTTCell_t
Structure definition of the LArTTCellMap.
Definition: LArTTCell.h:18
LArTTCellMap::m_cell2ttIdMap
std::map< Identifier, Identifier > m_cell2ttIdMap
Definition: LArTTCellMap.h:71
python.PyAthena.v
v
Definition: PyAthena.py:154
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
LArTTCell_P::m_v
std::vector< __t > m_v
Definition: LArTTCell_P.h:54
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
merge.status
status
Definition: merge.py:17
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
LArID_Exception
Exception class for LAr Identifiers.
Definition: LArID_Exception.h:20
ServiceHandle< StoreGateSvc >
LArTTCellMap::m_persData
LArTTCell_P m_persData
Definition: LArTTCellMap.h:76
Identifier
Definition: IdentifierFieldParser.cxx:14