ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
void setRunNumber (unsigned int run)
 Overwrite run number from RunParams @params run New run number. More...
 
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. More...
 
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. More...
 
EventIDBase eventID () const
 Create an EventIDBase filled with the value from rparams. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

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

Private Attributes

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

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

Definition at line 27 of file TrigSORFromPtreeHelper.h.

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),
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 }

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 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

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

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

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

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

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

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

43 { m_runNumber = run; }

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

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

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

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


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MMMonUtils.get_time
def get_time(histo)
Definition: MMMonUtils.py:50
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthMessaging::ATLAS_THREAD_SAFE
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)
Definition: AthMessaging.h:141
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
TrigSORFromPtreeHelper::m_sorTime_ns
unsigned long long m_sorTime_ns
Definition: TrigSORFromPtreeHelper.h:72
TrigSORFromPtreeHelper::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: TrigSORFromPtreeHelper.h:68
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
IAddressProvider
interface for IOA providers
Definition: IAddressProvider.h:28
StateLessPT_NewConfig.iovdbsvc
iovdbsvc
Definition: StateLessPT_NewConfig.py:430
python.BackTrackingConfig.iovsvc
iovsvc
BackTracking Configuration ##############################################.
Definition: BackTrackingConfig.py:98
TrigSORFromPtreeHelper::m_sorpath
std::string m_sorpath
Definition: TrigSORFromPtreeHelper.h:69
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
TrigSORFromPtreeHelper::m_runNumber
unsigned int m_runNumber
Definition: TrigSORFromPtreeHelper.h:71
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TrigSORFromPtreeHelper::m_rparams
const boost::property_tree::ptree & m_rparams
Definition: TrigSORFromPtreeHelper.h:70
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
ServiceHandle< IIOVDbSvc >