ATLAS Offline Software
Loading...
Searching...
No Matches
LArHVIdMappingReader Class Reference

Helper to read HV ID mapping data from a file or conditions. More...

#include <LArHVIdMappingReader.h>

Inheritance diagram for LArHVIdMappingReader:
Collaboration diagram for LArHVIdMappingReader:

Public Types

using hvlineMap_t = std::map<HWIdentifier,HWIdentifier>
using electrodeMap_t = std::map<HWIdentifier,std::vector<HWIdentifier> >

Public Member Functions

 LArHVIdMappingReader ()
StatusCode read (const AthenaAttributeList *attrList, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
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

std::string fromAttrList (const AthenaAttributeList &attrList) const
std::string fromFile () const
StatusCode fillHV (const std::string &content, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

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

Helper to read HV ID mapping data from a file or conditions.

Definition at line 31 of file LArHVIdMappingReader.h.

Member Typedef Documentation

◆ electrodeMap_t

Definition at line 36 of file LArHVIdMappingReader.h.

◆ hvlineMap_t

Constructor & Destructor Documentation

◆ LArHVIdMappingReader()

LArHVIdMappingReader::LArHVIdMappingReader ( )

Definition at line 21 of file LArHVIdMappingReader.cxx.

22 : AthMessaging ("LArHVIdMappingReader")
23{
24}
AthMessaging()
Default constructor:

Member Function Documentation

◆ fillHV()

StatusCode LArHVIdMappingReader::fillHV ( const std::string & content,
const LArHVLineID & hvlineHelper,
const LArElectrodeID & electrodeHelper,
hvlineMap_t & hvlineMap,
electrodeMap_t & electrodeMap ) const
private

Definition at line 101 of file LArHVIdMappingReader.cxx.

106{
107 ATH_MSG_DEBUG("[fillHVMap] entering fillHVMap()..." );
108
109 hvlineMap.clear();
110 electrodeMap.clear();
111
112 std::istringstream infile;
113 infile.str (content);
114
115 int dummy;
116 int hvcannode;
117 int hvline;
118 int hvpartition;
119 int hvcanline;
120 int detect;
121 int side;
122 int mod;
123 int hvphi;
124 int hveta;
125 int hvgap;
126 int min;
127 int max;
128 ATH_MSG_DEBUG("start reading infile " );
129 while (infile
130 >> dummy
131 >> hvcannode
132 >> hvline
133 >> hvpartition
134 >> hvcanline
135 >> detect
136 >> side
137 >> mod
138 >> hvphi
139 >> hveta
140 >> hvgap
141 >> min
142 >> max )
143 {// Fill Maps
144 if (max > 1000) // Crude check against reading nonsense.
145 std::abort();
146 ATH_MSG_DEBUG("[fillHVMap] listing HVLineToElectrode :("
147 << dummy << ") hvline=["
148 << hvpartition << "."
149 << hvcanline << "."
150 << hvcannode << "."
151 << hvline << "] electrode=["
152 << detect << "."
153 << side << "."
154 << mod << "."
155 << hvphi << "."
156 << hveta << "."
157 << hvgap << " min="
158 << min << " max="
159 << max << "]"
160 );
161
162 std::vector<HWIdentifier> electrodeIdvec;
163 HWIdentifier hvlineId = hvlineHelper.HVLineId(hvpartition,hvcanline,hvcannode,hvline);
164
165 if( max > min ){
166 if (min < 0) min = 0;
167 if (max < 0) max = 0;
168 if (min > 1000) min = 1000; // Shouldn't happen.
169 for( int ielec=min; ielec<max+1; ielec++){
170 ATH_MSG_VERBOSE("[fillHVMap] defining electrodeId: [det="
171 << detect << " side="
172 << side << " mod="
173 << mod << " phi="
174 << hvphi << " eta="
175 << hveta << " gap="
176 << hvgap << " ielec="
177 << ielec << "]" );
178 HWIdentifier electrodeId =
179 electrodeHelper.ElectrodeId(detect,side,mod,hvphi,hveta,hvgap,ielec);
180 electrodeIdvec.push_back(electrodeId);
181
182 // Check if electrode is already in map ?
183 hvlineMap.emplace (electrodeId, hvlineId);
184 }
185 }
186 else{
187 HWIdentifier electrodeId = electrodeHelper.ElectrodeId(detect,side,mod,hvphi,hveta,hvgap,min);
188 electrodeIdvec.push_back(electrodeId);
189
190 // Check if electrode is already in map ?
191 hvlineMap.emplace (electrodeId, hvlineId);
192 }
193
194 std::vector<HWIdentifier>& l = electrodeMap[hvlineId];
195 l.insert (l.end(), electrodeIdvec.begin(), electrodeIdvec.end());
196 }
197
198 ATH_MSG_DEBUG(" end reading infile " );
199 ATH_MSG_DEBUG("[fillHV] Mapping electrode-to-hvline : number of Ids= "<<hvlineMap.size());
200 ATH_MSG_DEBUG("[fillHV] Mapping hvline-to-electrode : number of Ids= "<<electrodeMap.size());
201 ATH_MSG_DEBUG("[fillHV] exiting fillHVMap ... OK" );
202 return StatusCode::SUCCESS;
203}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
HWIdentifier ElectrodeId(int det, int side, int mod, int phi, int eta, int gap, int elec) const
Create an Electrode identifier from fields.
HWIdentifier HVLineId(int part, int canline, int cannode, int line) const
Create an HighVoltage line identifier from fields.
l
Printing final latex table to .tex output file.
str infile
Definition run.py:13

◆ fromAttrList()

std::string LArHVIdMappingReader::fromAttrList ( const AthenaAttributeList & attrList) const
private

Definition at line 57 of file LArHVIdMappingReader.cxx.

58{
59 std::ostringstream attrStr1;
60 coral::AttributeList::const_iterator itr = attrList.begin();
61 itr->toOutputStream(attrStr1);
62 std::string::size_type pos = attrStr1.str().find(':');
63 if (pos == std::string::npos)
64 pos = 0;
65 else
66 pos++;
67 std::string Line = attrStr1.str().substr(pos);
68 ATH_MSG_DEBUG(" Line " << Line );
69 return Line;
70}

◆ fromFile()

std::string LArHVIdMappingReader::fromFile ( ) const
private

Definition at line 73 of file LArHVIdMappingReader.cxx.

74{
75 ATH_MSG_WARNING( " Cannot find /LAR/IdentifierOfl/HVLineToElectrodeMap from database, Use ASCII file indeed !!!");
76 std::string tablename = PathResolver::find_file ("HVLineToElectrode.data", "DATAPATH");
77 if (tablename.empty()) {
78 ATH_MSG_FATAL( "[fillHVMap] Could not locate HVLineToElectrode.data file as well");
79 return "";
80 }
81 else{
82 ATH_MSG_DEBUG("[fillHVMap] have located HVLineToElectrode.data OK !");
83 }
84 const char * tablefile = tablename.c_str() ;
85 std::ifstream myfile(tablefile);
86 // get pointer to associated buffer object
87 std::filebuf* pbuf = myfile.rdbuf();
88 int size = pbuf->pubseekoff (0,std::ios::end,std::ios::in);
89 pbuf->pubseekpos (0,std::ios::in);
90 // allocate memory to contain file data
91 std::string buffer;
92 buffer.resize (size, ' ');
93 // get file data
94 pbuf->sgetn (buffer.data(),size);
95 myfile.close();
96 return buffer;
97}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)

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

◆ read()

StatusCode LArHVIdMappingReader::read ( const AthenaAttributeList * attrList,
const LArHVLineID & hvlineHelper,
const LArElectrodeID & electrodeHelper,
hvlineMap_t & hvlineMap,
electrodeMap_t & electrodeMap ) const

Definition at line 27 of file LArHVIdMappingReader.cxx.

32{
33 hvlineMap.clear();
34 electrodeMap.clear();
35
36 std::string content;
37 if (attrList) {
38 content = fromAttrList (*attrList);
39 }
40 else {
41 content = fromFile();
42 }
43
44 if (content.empty()) {
45 return StatusCode::FAILURE;
46 }
47
48 return fillHV (content,
49 hvlineHelper,
50 electrodeHelper,
51 hvlineMap,
52 electrodeMap);
53}
StatusCode fillHV(const std::string &content, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
std::string fromFile() const
std::string fromAttrList(const AthenaAttributeList &attrList) const
str content
Definition grepfile.py:56

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

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


The documentation for this class was generated from the following files: