ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. 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

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

Private Attributes

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

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

Definition at line 35 of file LArHVIdMappingReader.h.

Constructor & Destructor Documentation

◆ LArHVIdMappingReader()

LArHVIdMappingReader::LArHVIdMappingReader ( )

Definition at line 21 of file LArHVIdMappingReader.cxx.

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

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 }

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

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

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

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

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


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
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
LArHVLineID::HVLineId
HWIdentifier HVLineId(int part, int canline, int cannode, int line) const
Create an HighVoltage line identifier from fields.
Definition: LArHVLineID.h:216
run.infile
string infile
Definition: run.py:13
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
LArHVIdMappingReader::fromFile
std::string fromFile() const
Definition: LArHVIdMappingReader.cxx:73
LArElectrodeID::ElectrodeId
HWIdentifier ElectrodeId(int det, int side, int mod, int phi, int eta, int gap, int elec) const
Create an Electrode identifier from fields.
Definition: LArElectrodeID.h:306
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HWIdentifier
Definition: HWIdentifier.h:13
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TRT::Hit::side
@ side
Definition: HitInfo.h:83
grepfile.content
string content
Definition: grepfile.py:56
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
dumpHVPathFromNtuple.hvline
hvline
Definition: dumpHVPathFromNtuple.py:72
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
LArHVIdMappingReader::fromAttrList
std::string fromAttrList(const AthenaAttributeList &attrList) const
Definition: LArHVIdMappingReader.cxx:57
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.xAODType.dummy
dummy
Definition: xAODType.py:4
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
LArHVIdMappingReader::fillHV
StatusCode fillHV(const std::string &content, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
Definition: LArHVIdMappingReader.cxx:101
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
Trk::SurfaceType::Line
@ Line
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