ATLAS Offline Software
Loading...
Searching...
No Matches
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
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)
Identifier whichTTID (const Identifier &id) const
 return the offline id (CaloLVL1_ID) of the TT to which a cell (CaloCell_ID) belongs
const LArTTCell_PgetP () const
 return the persistified map
LArTTCell_PgetP ()
 return the persistified map (non-const)
void set (const LArTTCell_P &t)
 initialize from POOL
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

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.

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.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

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}
AthMessaging()
Default constructor:

◆ ~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}
LArTTCell_P_t __t
Definition LArTTCell_P.h:47
std::vector< ALFA_RawDataContainer_p1 > t2

◆ 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}
Scalar phi() const
phi method
LArTTCell_P m_persData

◆ 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}
#define ATH_MSG_VERBOSE(x)
std::map< Identifier, std::vector< Identifier > > m_tt2cellIdMap

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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}
std::vector< LArTTCell_t > LArTTCell
Definition LArTTCell.h:35
void set(const PDATA &t)
initialize from Nova
void convert_to_D(const LArTTCell_P &t, LArTTCell &d)

◆ 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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Identifier layer_id(int pos_neg_z, int sampling, int region, int eta, int phi, int layer) const
build a layer identifier
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
std::map< Identifier, Identifier > m_cell2ttIdMap
void convert_to_P(const LArTTCell &t)
::StatusCode StatusCode
StatusCode definition for legacy code.
status
Definition merge.py:16

◆ 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.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ 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: