13 #include <eformat/DetectorMask.h>
15 using namespace boost::property_tree;
19 const std::string CLNAME{
"TrigSORFromPtreeHelper"};
25 const std::string& sorpath,
26 const ptree& rparams) :
33 m_runNumber = rparams.get<
unsigned int>(
"run_number");
35 std::istringstream
ss(rparams.get_child(
"timeSOR").data());
38 unsigned int microseconds = 0;
45 m_sorTime_ns = std::mktime(&
t)*std::nano::den + microseconds*1000;
55 if ((
iovdbsvc.retrieve()).isFailure()) {
56 ATH_MSG_ERROR(
"Could not find IOVDbSvc. Time dependent conditions data may be not properly handled.");
58 IOVTime currentIOVTime(ctx.eventID());
60 if (
iovdbsvc->signalBeginRun(currentIOVTime, ctx).isFailure() ) {
61 ATH_MSG_ERROR(
"Unable to signal begin run IOVTime to IOVDbSvc. IOVTime = " << currentIOVTime);
63 ATH_MSG_DEBUG(
"Set start of run time to IOVTime = " << currentIOVTime);
72 return StatusCode::SUCCESS;
83 eid.set_time_stamp_ns_offset(
m_sorTime_ns % (1000*1000*1000) );
85 eid.set_lumi_block(0);
94 auto attrList = getAttrList();
97 IOVTime iovTimeStart(attrList[
"RunNumber"].data<unsigned int>(),0);
98 IOVTime iovTimeStop(attrList[
"RunNumber"].data<unsigned int>()+1,0);
99 IOVRange iovRange(iovTimeStart, iovTimeStop);
101 auto sor =
new SOR(
true);
102 sor->add(SOR::ChanNum{0}, attrList);
103 sor->add(SOR::ChanNum{0}, iovRange);
104 sor->resetMinRange();
105 sor->addNewStart(iovTimeStart);
106 sor->addNewStop(iovTimeStop);
109 if ( m_detStore->transientContains<SOR>(m_sorpath) ) {
110 const SOR * oldsor = m_detStore->retrieve<
const SOR>(m_sorpath);
111 ATH_MSG_INFO(
"Overwriting SOR contents (a dump of the old one follows):");
113 ATH_CHECK( m_detStore->overwrite(sor, m_sorpath,
true) );
117 ATH_CHECK( m_detStore->record(sor, m_sorpath,
true) );
126 return StatusCode::SUCCESS;
136 auto attrSpec =
new coral::AttributeListSpecification{};
137 attrSpec->extend(
"RunNumber",
"unsigned int");
138 attrSpec->extend(
"SORTime",
"unsigned long long");
139 attrSpec->extend(
"RunType",
"string");
140 attrSpec->extend(
"DetectorMaskFst",
"unsigned long long");
141 attrSpec->extend(
"DetectorMaskSnd",
"unsigned long long");
142 attrSpec->extend(
"RecordingEnabled",
"bool");
147 attrList[
"RunNumber"].data<
unsigned int>() = m_runNumber;
148 attrList[
"RunType"].data<std::string>() = m_rparams.get<std::string>(
"run_type");
149 attrList[
"RecordingEnabled"].data<
bool>() = m_rparams.get<
bool>(
"recording_enabled");
151 attrList[
"SORTime"].data<
unsigned long long>() = m_sorTime_ns;
153 std::pair<uint64_t, uint64_t>
dm = eformat::helper::DetectorMask(m_rparams.get_child(
"det_mask").data()).serialize();
154 attrList[
"DetectorMaskFst"].data<
unsigned long long>() =
dm.first;
155 attrList[
"DetectorMaskSnd"].data<
unsigned long long>() =
dm.second;
174 return StatusCode::SUCCESS;
183 ATH_MSG_ERROR(
"Could not find proxy for SOR_Params folder.");
184 return StatusCode::FAILURE;
188 if (!
proxy->provider()) {
195 ATH_MSG_ERROR(
"Could not cast to IAddressProvider interface and set the provider for SOR_Params.");
196 return StatusCode::FAILURE;
198 proxy->setProvider(provider,
proxy->storeID());
201 return StatusCode::SUCCESS;