Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ASCIICondDbSvc Class Reference

#include <ASCIICondDbSvc.h>

Inheritance diagram for ASCIICondDbSvc:
Collaboration diagram for ASCIICondDbSvc:

Public Member Functions

 ASCIICondDbSvc (const std::string &name, ISvcLocator *svc)
 
 ~ASCIICondDbSvc ()=default
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode getRange (const std::string &, const EventContext &, EventIDRange &, IASCIICondDbSvc::dbData_t &) const override
 
virtual void dump () const override
 
void dump (std::ostringstream &) const
 

Private Types

typedef std::map< std::string, std::vector< IOVEntryT< IASCIICondDbSvc::dbData_t > > > registry_t
 

Private Member Functions

bool parse (EventIDRange &t, const std::string &s)
 
bool parse (IOVEntryT< IASCIICondDbSvc::dbData_t > &t, const std::string &s)
 
StatusCode readDbFile (const std::string &)
 

Private Attributes

Gaudi::Property< std::string > m_file {this, "CondFile", "", "cond db file name"}
 
Gaudi::Property< unsigned int > m_lbn {this, "LBN", 1, "explicit lumi block number"}
 
registry_t m_registry
 
std::mutex m_lock
 

Detailed Description

Definition at line 20 of file ASCIICondDbSvc.h.

Member Typedef Documentation

◆ registry_t

typedef std::map<std::string, std::vector<IOVEntryT<IASCIICondDbSvc::dbData_t> > > ASCIICondDbSvc::registry_t
private

Definition at line 50 of file ASCIICondDbSvc.h.

Constructor & Destructor Documentation

◆ ASCIICondDbSvc()

ASCIICondDbSvc::ASCIICondDbSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 25 of file ASCIICondDbSvc.cxx.

25  :
26  base_class(name,svcLoc)
27 {}

◆ ~ASCIICondDbSvc()

ASCIICondDbSvc::~ASCIICondDbSvc ( )
default

Member Function Documentation

◆ dump() [1/2]

void ASCIICondDbSvc::dump ( ) const
overridevirtual

Definition at line 122 of file ASCIICondDbSvc.cxx.

122  {
123 
124  std::ostringstream ost;
125  dump(ost);
126 
127  info() << ost.str() << endmsg;
128 
129 }

◆ dump() [2/2]

void ASCIICondDbSvc::dump ( std::ostringstream &  ost) const

Definition at line 135 of file ASCIICondDbSvc.cxx.

135  {
136 
137  std::lock_guard<std::mutex> lock(m_lock);
138 
139  ost << "ASCIICondDbSvc::dump()";
140 
141  ost << "\n";
142 
143 }

◆ finalize()

StatusCode ASCIICondDbSvc::finalize ( )
overridevirtual

Definition at line 148 of file ASCIICondDbSvc.cxx.

148  {
149 
150  ATH_MSG_DEBUG( "ASCIICondDbSvc::finalize()" );
151 
152  if (msgLvl(MSG::DEBUG)) {
153  std::ostringstream ost;
154  dump(ost);
155 
156  ATH_MSG_DEBUG( ost.str() );
157  }
158 
159  for ( auto e : m_registry ) {
160  for ( auto ie : e.second ) {
161  delete ie.objPtr();
162  ie.setPtr(0);
163  }
164  }
165 
166 
167  return StatusCode::SUCCESS;
168 
169 }

◆ getRange()

StatusCode ASCIICondDbSvc::getRange ( const std::string &  dbKey,
const EventContext &  ctx,
EventIDRange &  rng,
IASCIICondDbSvc::dbData_t val 
) const
overridevirtual

Definition at line 240 of file ASCIICondDbSvc.cxx.

241  {
242 
243  std::lock_guard<std::mutex> lock(m_lock);
244 
245  registry_t::const_iterator itr = m_registry.find(dbKey);
246 
247  if (itr == m_registry.end()) {
248  error() << "getRange: no dbKey " << dbKey << " found in registry"
249  << endmsg;
250  return StatusCode::FAILURE;
251  }
252 
253  for (auto e : itr->second) {
254  debug() << "compare " << e.range() << " with " << ctx.eventID()
255  << endmsg;
256  if (e.range().isInRange(EventIDBase(ctx.eventID()))) {
257  rng = e.range();
258  val = *(e.objPtr());
259  return StatusCode::SUCCESS;
260  }
261  }
262 
263  error() << "getRange: no range for Time " << ctx.eventID()
264  << " found for dbKey " << dbKey << endmsg;
265 
266  return StatusCode::FAILURE;
267 }

◆ initialize()

StatusCode ASCIICondDbSvc::initialize ( )
overridevirtual

Definition at line 32 of file ASCIICondDbSvc.cxx.

32  {
33 
34  // Initialise mother class in order to print DEBUG messages during initialize()
36  msg().setLevel( m_outputLevel.value() );
37 
38  if (!sc.isSuccess()) {
39  warning () << "Base class could not be initialized" << endmsg;
40  return StatusCode::FAILURE;
41  }
42 
43  if (m_file == "") {
44  ATH_MSG_DEBUG("db file not set");
45  return StatusCode::SUCCESS;
46  }
47 
48  if (readDbFile(m_file).isFailure()) {
49  return StatusCode::FAILURE;
50  }
51 
52  std::ostringstream ost;
53  ost << " Printing CondDB registry";
54  for (auto e : m_registry) {
55  ost << std::endl << " - id: " << e.first << " r:";
56  for (auto r : e.second) {
57  ost << " " << r.range() << " :: " << *r.objPtr();
58  }
59  }
60 
61  ATH_MSG_DEBUG( ost.str() );
62 
63  return StatusCode::SUCCESS;
64 
65 }

◆ parse() [1/2]

bool ASCIICondDbSvc::parse ( EventIDRange &  t,
const std::string &  s 
)
private

Definition at line 174 of file ASCIICondDbSvc.cxx.

174  {
175 
176  boost::smatch m;
177  boost::regex_match(s,m,rr);
178 
179  // for (auto res : m) {
180  // cout << " - " << res << endl;
181  // }
182 
183  if (m.size() != 5) { return false; }
184 
185  // set run# and timestamp
186  EventIDBase start(std::stoi(m[1]), EventIDBase::UNDEFEVT, std::stoi(m[2]));
187  EventIDBase end(std::stoi(m[3]), EventIDBase::UNDEFEVT, std::stoi(m[4]));
188 
189  start.set_lumi_block(m_lbn);
190  end.set_lumi_block(m_lbn);
191 
192  t = EventIDRange(start, end);
193 
194  return true;
195 
196 }

◆ parse() [2/2]

bool ASCIICondDbSvc::parse ( IOVEntryT< IASCIICondDbSvc::dbData_t > &  t,
const std::string &  s 
)
private

Definition at line 201 of file ASCIICondDbSvc.cxx.

201  {
202 
203  boost::smatch m;
204  boost::regex_match(s,m,ref);
205 
206  if (m.size() != 6) { return false; }
207 
208  // set run#, lumi and timestamp
209  // EventIDBase start(std::stoi(m[1]), EventIDBase::UNDEFEVT, std::stoi(m[2]));
210  // EventIDBase end(std::stoi(m[3]), EventIDBase::UNDEFEVT, std::stoi(m[4]));
211  // start.set_lumi_block(m_lbn);
212  // end.set_lumi_block(m_lbn);
213 
214  // set lumi and Timestamp
215  EventIDBase start(0, EventIDBase::UNDEFEVT,
216  std::stoi(m[2]));
217  EventIDBase end(EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT,
218  std::stoi(m[4]));
219  start.set_lumi_block(std::stoi(m[1]));
220  end.set_lumi_block(std::stoi(m[3]));
221 
222  // Set Run/Lumi
223  // EventIDBase start(std::stoi(m[1]), EventIDBase::UNDEFEVT);
224  // EventIDBase end(std::stoi(m[3]), EventIDBase::UNDEFEVT);
225  // start.set_lumi_block(std::stoi(m[2]));
226  // end.set_lumi_block(std::stoi(m[4]));
227 
228  ie.setRange(EventIDRange(start,end));
229 
230  IASCIICondDbSvc::dbData_t *v = new IASCIICondDbSvc::dbData_t( std::stof(m[5]) );
231  ie.setPtr(v);
232 
233  return true;
234 
235 }

◆ readDbFile()

StatusCode ASCIICondDbSvc::readDbFile ( const std::string &  fname)
private

Definition at line 69 of file ASCIICondDbSvc.cxx.

69  {
70 
71  StatusCode sc(StatusCode::SUCCESS);
72 
73  ATH_MSG_DEBUG("reading cond db from \"" << fname << "\"");
74 
75  std::ifstream ifs (fname);
76  std::string line;
77  if(ifs.is_open()) {
78 
79  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
80  boost::char_separator<char> sep(" ");
81 
83 
84  while( getline (ifs, line) ) {
85 
86  // ignore anything after a "#" and blank lines
87  size_t fh = line.find("#");
88  if(fh != std::string::npos)
89  line.erase(fh,line.length()-fh);
90  if (line.length() == 0) continue;
91 
92  tokenizer tokens(line, sep);
93  auto it = tokens.begin();
94 
95  std::string dbKey = *it;
96 
97  ++it;
98 
99  while (it != tokens.end()) {
100  if (parse(ie,*it)) {
101  m_registry[dbKey].push_back( ie );
102  } else {
103  error() << "while reading " << fname << " problem parsing " << *it
104  << " in line\n" << line << endmsg;
105  sc = StatusCode::FAILURE;
106  }
107  ++it;
108  }
109  }
110  ifs.close();
111  } else {
112  error() << "unable to open file " << (std::string) m_file << endmsg;
113  sc = StatusCode::FAILURE;
114  }
115 
116  return sc;
117 
118 }

Member Data Documentation

◆ m_file

Gaudi::Property<std::string> ASCIICondDbSvc::m_file {this, "CondFile", "", "cond db file name"}
private

Definition at line 47 of file ASCIICondDbSvc.h.

◆ m_lbn

Gaudi::Property<unsigned int> ASCIICondDbSvc::m_lbn {this, "LBN", 1, "explicit lumi block number"}
private

Definition at line 48 of file ASCIICondDbSvc.h.

◆ m_lock

std::mutex ASCIICondDbSvc::m_lock
mutableprivate

Definition at line 53 of file ASCIICondDbSvc.h.

◆ m_registry

registry_t ASCIICondDbSvc::m_registry
private

Definition at line 51 of file ASCIICondDbSvc.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ASCIICondDbSvc::m_file
Gaudi::Property< std::string > m_file
Definition: ASCIICondDbSvc.h:47
collListGuids.line
string line
Definition: collListGuids.py:77
IOVEntryT< IASCIICondDbSvc::dbData_t >
initialize
void initialize()
Definition: run_EoverP.cxx:894
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
skel.it
it
Definition: skel.GENtoEVGEN.py:407
ASCIICondDbSvc::m_lbn
Gaudi::Property< unsigned int > m_lbn
Definition: ASCIICondDbSvc.h:48
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
D3PDTest::rng
uint32_t rng()
Definition: FillerAlg.cxx:40
ASCIICondDbSvc::m_registry
registry_t m_registry
Definition: ASCIICondDbSvc.h:51
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
grepfile.sep
sep
Definition: grepfile.py:38
IASCIICondDbSvc::dbData_t
float dbData_t
Definition: IASCIICondDbSvc.h:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
ASCIICondDbSvc::m_lock
std::mutex m_lock
Definition: ASCIICondDbSvc.h:53
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
python.PyAthena.v
v
Definition: PyAthena.py:154
ASCIICondDbSvc::readDbFile
StatusCode readDbFile(const std::string &)
Definition: ASCIICondDbSvc.cxx:69
ref
const boost::regex ref(r_ef)
ASCIICondDbSvc::parse
bool parse(EventIDRange &t, const std::string &s)
Definition: ASCIICondDbSvc.cxx:174
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
DEBUG
#define DEBUG
Definition: page_access.h:11
RatesAnalysisFullMenu.fh
fh
Definition: RatesAnalysisFullMenu.py:126
ASCIICondDbSvc::dump
virtual void dump() const override
Definition: ASCIICondDbSvc.cxx:122
rr
const boost::regex rr(r_r)
get_generator_info.error
error
Definition: get_generator_info.py:40
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7