ATLAS Offline Software
Loading...
Searching...
No Matches
TrigSORFromPtreeHelper Class Reference

Helper class for Start Of Run (SOR) record. More...

#include <TrigSORFromPtreeHelper.h>

Inheritance diagram for TrigSORFromPtreeHelper:
Collaboration diagram for TrigSORFromPtreeHelper:

Public Types

typedef CondAttrListCollection SOR

Public Member Functions

 TrigSORFromPtreeHelper (IMessageSvc *msgSvc, const ServiceHandle< StoreGateSvc > &detStore, const std::string &sorpath, const boost::property_tree::ptree &rparams)
 Create the SOR helper @params msgSvc Pointer to MessageSvc @params detStore Handle to DetectorStore @params sorpath COOL folder path of SOR record (e.g.
void setRunNumber (unsigned int run)
 Overwrite run number from RunParams @params run New run number.
void setSORtime_ns (unsigned long long sorTime_ns)
 Overwrite SOR time from RunParams @params sorTime_ns New start of run time in nanoseconds since epoch.
StatusCode fillSOR (const EventContext &ctx) const
 Fill SOR record in Detector Store, reusing if present or creating new one otherwise/ @params ctx EventContext to be used for IOVDbSvc.
EventIDBase eventID () const
 Create an EventIDBase filled with the value from rparams.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

StatusCode createSOR ATLAS_NOT_THREAD_SAFE () const
coral::AttributeList getAttrList ATLAS_NOT_THREAD_SAFE () const
StatusCode setIOVRange (IOVRange &iovRange) const
StatusCode updateProxy (SOR *sor) const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

ServiceHandle< StoreGateSvcm_detStore
std::string m_sorpath
const boost::property_tree::ptree & m_rparams
unsigned int m_runNumber {0}
unsigned long long m_sorTime_ns {0}
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Helper class for Start Of Run (SOR) record.

Author
Ricardo Abreu

Helper class to retrieve the Start Of Run parameters from the prepareForRun ptree and put them into the detector store with whole-run validity.

Definition at line 25 of file TrigSORFromPtreeHelper.h.

Member Typedef Documentation

◆ SOR

Constructor & Destructor Documentation

◆ TrigSORFromPtreeHelper()

TrigSORFromPtreeHelper::TrigSORFromPtreeHelper ( IMessageSvc * msgSvc,
const ServiceHandle< StoreGateSvc > & detStore,
const std::string & sorpath,
const boost::property_tree::ptree & rparams )

Create the SOR helper @params msgSvc Pointer to MessageSvc @params detStore Handle to DetectorStore @params sorpath COOL folder path of SOR record (e.g.

/TDAQ/RunCtrl/SOR_Params) @params rparams RunParams record

Definition at line 23 of file TrigSORFromPtreeHelper.cxx.

26 :
27 AthMessaging(msgSvc, CLNAME),
28 m_detStore(detStore),
29 m_sorpath(sorpath),
30 m_rparams(rparams)
31{
32 // Set run number and timestamp from RunParams. Can be overwritten later.
33 m_runNumber = rparams.get<unsigned int>("run_number");
34
35 std::istringstream ss(rparams.get_child("timeSOR").data());
36 std::tm t = {};
37 t.tm_isdst = -1; // auto-detect daylight savings time
38 unsigned int microseconds = 0;
39
40 // Format: 08/05/24 22:14:38.000000 (see OWLTime in tdaq)
41 ss >> std::get_time(&t, "%d/%m/%y %H:%M:%S.") >> microseconds;
42 if (ss.fail()) {
43 ATH_MSG_ERROR("Cannot parse timeSOR: " << ss.str());
44 }
45 m_sorTime_ns = std::mktime(&t)*std::nano::den + microseconds*1000;
46}
#define ATH_MSG_ERROR(x)
static Double_t ss
AthMessaging()
Default constructor:
ServiceHandle< StoreGateSvc > m_detStore
unsigned long long m_sorTime_ns
const boost::property_tree::ptree & m_rparams

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

StatusCode createSOR TrigSORFromPtreeHelper::ATLAS_NOT_THREAD_SAFE ( ) const
private

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

coral::AttributeList getAttrList TrigSORFromPtreeHelper::ATLAS_NOT_THREAD_SAFE ( ) const
private

◆ eventID()

EventIDBase TrigSORFromPtreeHelper::eventID ( ) const

Create an EventIDBase filled with the value from rparams.

Definition at line 76 of file TrigSORFromPtreeHelper.cxx.

77{
78 EventIDBase eid;
79
80 // Set run and timestamp
81 eid.set_run_number( m_runNumber );
82 eid.set_time_stamp( m_sorTime_ns / (1000*1000*1000) );
83 eid.set_time_stamp_ns_offset( m_sorTime_ns % (1000*1000*1000) );
84
85 eid.set_lumi_block(0); // our best guess as this is not part of RunParams
86
87 return eid;
88}

◆ fillSOR()

StatusCode TrigSORFromPtreeHelper::fillSOR ( const EventContext & ctx) const

Fill SOR record in Detector Store, reusing if present or creating new one otherwise/ @params ctx EventContext to be used for IOVDbSvc.

Definition at line 49 of file TrigSORFromPtreeHelper.cxx.

50{
51 ATH_MSG_DEBUG("Setup SOR in DetectorStore");
52
53 // get handle to the IOVDbSvc
54 ServiceHandle<IIOVDbSvc> iovdbsvc("IOVDbSvc", CLNAME);
55 if ((iovdbsvc.retrieve()).isFailure()) {
56 ATH_MSG_ERROR("Could not find IOVDbSvc. Time dependent conditions data may be not properly handled.");
57 } else {
58 IOVTime currentIOVTime(ctx.eventID());
59 // Signal BeginRun directly to IOVDbSvc to set complete IOV start time
60 if ( iovdbsvc->signalBeginRun(currentIOVTime, ctx).isFailure() ) {
61 ATH_MSG_ERROR("Unable to signal begin run IOVTime to IOVDbSvc. IOVTime = " << currentIOVTime);
62 } else {
63 ATH_MSG_DEBUG("Set start of run time to IOVTime = " << currentIOVTime);
64 }
65 }
66
67 // createSOR marked unsafe due to copying/deletion of coral::AttributeList
68 // objects. There's no sharing of specificiations, though, so it's ok.
69 StatusCode sc ATLAS_THREAD_SAFE = createSOR();
70 ATH_CHECK( sc );
71
72 return StatusCode::SUCCESS;
73}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t sc
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ setIOVRange()

StatusCode TrigSORFromPtreeHelper::setIOVRange ( IOVRange & iovRange) const
private

Definition at line 165 of file TrigSORFromPtreeHelper.cxx.

166{
167 // set IOVRange on the IOVSvc
168 ServiceHandle<IIOVSvc> iovsvc("IOVSvc", CLNAME);
169 ATH_CHECK( iovsvc.retrieve() );
170
171 auto clid = ClassID_traits<SOR>::ID();
172 ATH_CHECK( iovsvc->setRange(clid, m_sorpath, iovRange, "StoreGateSvc") );
173
174 return StatusCode::SUCCESS;
175}
iovsvc
BackTracking Configuration ##############################################.

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

◆ setRunNumber()

void TrigSORFromPtreeHelper::setRunNumber ( unsigned int run)
inline

Overwrite run number from RunParams @params run New run number.

Definition at line 43 of file TrigSORFromPtreeHelper.h.

◆ setSORtime_ns()

void TrigSORFromPtreeHelper::setSORtime_ns ( unsigned long long sorTime_ns)
inline

Overwrite SOR time from RunParams @params sorTime_ns New start of run time in nanoseconds since epoch.

Definition at line 49 of file TrigSORFromPtreeHelper.h.

49{ m_sorTime_ns = sorTime_ns; }

◆ updateProxy()

StatusCode TrigSORFromPtreeHelper::updateProxy ( SOR * sor) const
private

Definition at line 178 of file TrigSORFromPtreeHelper.cxx.

179{
180 // check the SOR_Params proxy and add if necessary an IAddressProvider (typically for MC)
181 auto proxy = m_detStore->proxy(sor);
182 if (!proxy) {
183 ATH_MSG_ERROR("Could not find proxy for SOR_Params folder.");
184 return StatusCode::FAILURE;
185 }
186
187 // check if the transient address has an IAddressProvider, if not set IOVDbSvc as provider
188 if (!proxy->provider()) {
189 // get handle to the IOVDbSvc
190 ServiceHandle<IIOVDbSvc> iovdbsvc("IOVDbSvc", CLNAME);
191 ATH_CHECK( iovdbsvc.retrieve() );
192
193 IAddressProvider* provider = dynamic_cast<IAddressProvider*>(&*iovdbsvc);
194 if (!provider) {
195 ATH_MSG_ERROR("Could not cast to IAddressProvider interface and set the provider for SOR_Params.");
196 return StatusCode::FAILURE;
197 }
198 proxy->setProvider(provider, proxy->storeID());
199 }
200
201 return StatusCode::SUCCESS;
202}

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_detStore

ServiceHandle<StoreGateSvc> TrigSORFromPtreeHelper::m_detStore
private

Definition at line 68 of file TrigSORFromPtreeHelper.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

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

◆ m_rparams

const boost::property_tree::ptree& TrigSORFromPtreeHelper::m_rparams
private

Definition at line 70 of file TrigSORFromPtreeHelper.h.

◆ m_runNumber

unsigned int TrigSORFromPtreeHelper::m_runNumber {0}
private

Definition at line 71 of file TrigSORFromPtreeHelper.h.

71{0};

◆ m_sorpath

std::string TrigSORFromPtreeHelper::m_sorpath
private

Definition at line 69 of file TrigSORFromPtreeHelper.h.

◆ m_sorTime_ns

unsigned long long TrigSORFromPtreeHelper::m_sorTime_ns {0}
private

Definition at line 72 of file TrigSORFromPtreeHelper.h.

72{0};

The documentation for this class was generated from the following files: