ATLAS Offline Software
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 ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode getRange (const std::string &, const EventContext &, EventIDRange &, IASCIICondDbSvc::dbData_t &) const
 
virtual void dump () const
 
virtual 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 48 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 ( )

Definition at line 31 of file ASCIICondDbSvc.cxx.

31  {
32 
33 }

Member Function Documentation

◆ dump() [1/2]

void ASCIICondDbSvc::dump ( ) const
virtual

Definition at line 128 of file ASCIICondDbSvc.cxx.

128  {
129 
130  std::ostringstream ost;
131  dump(ost);
132 
133  info() << ost.str() << endmsg;
134 
135 }

◆ dump() [2/2]

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

Definition at line 141 of file ASCIICondDbSvc.cxx.

141  {
142 
143  std::lock_guard<std::mutex> lock(m_lock);
144 
145  ost << "ASCIICondDbSvc::dump()";
146 
147  ost << "\n";
148 
149 }

◆ finalize()

StatusCode ASCIICondDbSvc::finalize ( )
virtual

Definition at line 154 of file ASCIICondDbSvc.cxx.

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

◆ getRange()

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

Definition at line 246 of file ASCIICondDbSvc.cxx.

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

◆ initialize()

StatusCode ASCIICondDbSvc::initialize ( )
virtual

Definition at line 38 of file ASCIICondDbSvc.cxx.

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

◆ parse() [1/2]

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

Definition at line 180 of file ASCIICondDbSvc.cxx.

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

◆ parse() [2/2]

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

Definition at line 207 of file ASCIICondDbSvc.cxx.

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

◆ readDbFile()

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

Definition at line 75 of file ASCIICondDbSvc.cxx.

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

Member Data Documentation

◆ m_file

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

Definition at line 45 of file ASCIICondDbSvc.h.

◆ m_lbn

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

Definition at line 46 of file ASCIICondDbSvc.h.

◆ m_lock

std::mutex ASCIICondDbSvc::m_lock
mutableprivate

Definition at line 51 of file ASCIICondDbSvc.h.

◆ m_registry

registry_t ASCIICondDbSvc::m_registry
private

Definition at line 49 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
checkFileSG.line
line
Definition: checkFileSG.py:75
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:45
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:396
ASCIICondDbSvc::m_lbn
Gaudi::Property< unsigned int > m_lbn
Definition: ASCIICondDbSvc.h:46
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:49
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:221
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
ASCIICondDbSvc::m_lock
std::mutex m_lock
Definition: ASCIICondDbSvc.h:51
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:75
ref
const boost::regex ref(r_ef)
ASCIICondDbSvc::parse
bool parse(EventIDRange &t, const std::string &s)
Definition: ASCIICondDbSvc.cxx:180
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
DEBUG
#define DEBUG
Definition: page_access.h:11
ASCIICondDbSvc::dump
virtual void dump() const
Definition: ASCIICondDbSvc.cxx:128
RatesAnalysisFullMenu.fh
fh
Definition: RatesAnalysisFullMenu.py:127
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