8#include <boost/tokenizer.hpp>
9#include <boost/algorithm/string.hpp>
10#include <boost/regex.hpp>
14const std::string
r_t(
"\\[([0-9]+),([0-9]+)\\]");
15const std::string
r_r =
"\\s*\\{" +
r_t +
"-" +
r_t +
"\\}\\s*";
16const std::string
r_e =
"\\s*\\{" +
r_t +
"-" +
r_t +
"\\}=([0-9]+)\\s*";
17const std::string
r_ef =
"\\s*\\{" +
r_t +
"-" +
r_t +
"\\}=(-*[0-9]*\\.*[0-9]*)\\s*";
26 base_class(name,svcLoc)
35 StatusCode
sc(AthService::initialize());
36 msg().setLevel( m_outputLevel.value() );
38 if (!
sc.isSuccess()) {
39 warning () <<
"Base class could not be initialized" <<
endmsg;
40 return StatusCode::FAILURE;
45 return StatusCode::SUCCESS;
49 return StatusCode::FAILURE;
52 std::ostringstream ost;
53 ost <<
" Printing CondDB registry";
55 ost << std::endl <<
" - id: " << e.first <<
" r:";
57 ost <<
" " <<
r.range() <<
" :: " << *
r.objPtr();
63 return StatusCode::SUCCESS;
71 StatusCode
sc(StatusCode::SUCCESS);
75 std::ifstream ifs (fname);
79 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
80 boost::char_separator<char> sep(
" ");
84 while( getline (ifs, line) ) {
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;
92 tokenizer tokens(line, sep);
93 auto it = tokens.begin();
95 std::string dbKey = *it;
99 while (it != tokens.end()) {
103 error() <<
"while reading " << fname <<
" problem parsing " << *it
104 <<
" in line\n" << line <<
endmsg;
105 sc = StatusCode::FAILURE;
113 sc = StatusCode::FAILURE;
124 std::ostringstream ost;
127 info() << ost.str() <<
endmsg;
137 std::lock_guard<std::mutex> lock(
m_lock);
139 ost <<
"ASCIICondDbSvc::dump()";
152 if (msgLvl(MSG::DEBUG)) {
153 std::ostringstream ost;
160 for (
auto ie : e.second ) {
167 return StatusCode::SUCCESS;
177 boost::regex_match(s,m,
rr);
183 if (m.size() != 5) {
return false; }
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]));
189 start.set_lumi_block(
m_lbn);
190 end.set_lumi_block(
m_lbn);
192 t = EventIDRange(start, end);
204 boost::regex_match(s,m,
ref);
206 if (m.size() != 6) {
return false; }
215 EventIDBase start(0, EventIDBase::UNDEFEVT,
217 EventIDBase end(EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT,
219 start.set_lumi_block(std::stoi(m[1]));
220 end.set_lumi_block(std::stoi(m[3]));
228 ie.setRange(EventIDRange(start,end));
243 std::lock_guard<std::mutex> lock(
m_lock);
245 registry_t::const_iterator itr =
m_registry.find(dbKey);
248 error() <<
"getRange: no dbKey " << dbKey <<
" found in registry"
250 return StatusCode::FAILURE;
254 debug() <<
"compare " << e.range() <<
" with " << ctx.eventID()
256 if (e.range().isInRange(EventIDBase(ctx.eventID()))) {
259 return StatusCode::SUCCESS;
263 error() <<
"getRange: no range for Time " << ctx.eventID()
264 <<
" found for dbKey " << dbKey <<
endmsg;
266 return StatusCode::FAILURE;
const boost::regex ref(r_ef)
const boost::regex rr(r_r)
const std::string r_t("\\[([0-9]+),([0-9]+)\\]")
const boost::regex re(r_e)
Hold mappings of ranges to condition objects.
virtual StatusCode getRange(const std::string &, const EventContext &, EventIDRange &, IASCIICondDbSvc::dbData_t &) const override
Gaudi::Property< unsigned int > m_lbn
virtual StatusCode finalize() override
Gaudi::Property< std::string > m_file
virtual StatusCode initialize() override
ASCIICondDbSvc(const std::string &name, ISvcLocator *svc)
bool parse(EventIDRange &t, const std::string &s)
StatusCode readDbFile(const std::string &)
virtual void dump() const override