ATLAS Offline Software
LBDurationCondAlg.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "LBDurationCondAlg.h"
13 #include "CoolKernel/IObject.h"
14 #include "GaudiKernel/SystemOfUnits.h"
16 
19 
20 
26 {
29  return StatusCode::SUCCESS;
30 }
31 
32 
38 LBDurationCondAlg::execute (const EventContext& ctx) const
39 {
40 
42  (m_lbDurationOutputKey, ctx);
43 
45  const EventIDRange fullRange=IOVInfiniteRange::infiniteRunLB();
46  lbDurationCondData.addDependency(fullRange);
47  auto lbdur = std::make_unique<LBDurationCondData> (m_default);
48  ATH_CHECK( lbDurationCondData.record (std::move (lbdur)) );
49  } else {
50 
52  (m_lblbFolderInputKey, ctx);
53  lbDurationCondData.addDependency(lblbFolder);
54 
55  if(lblbFolder.isValid()) {
56  if ((**lblbFolder)["StartTime"].isNull()) {
57  ATH_MSG_ERROR( "StartTime is NULL in " << m_lblbFolderInputKey.key() << "!" );
58  return StatusCode::FAILURE;
59  }
60 
61  if ((**lblbFolder)["EndTime"].isNull()) {
62  ATH_MSG_ERROR( "EndTime is NULL in " << m_lblbFolderInputKey.key() << "!" );
63  return StatusCode::FAILURE;
64  }
65 
66  // Times in nanoseconds.
67  cool::UInt63 startTime = (**lblbFolder)["StartTime"].data<cool::UInt63>();
68  cool::UInt63 endTime = (**lblbFolder)["EndTime"].data<cool::UInt63>();
69 
70  // Convert to seconds.
71  double duration = (endTime-startTime) * (nanosecond / second);
72 
73  auto lbdur = std::make_unique<LBDurationCondData> (duration);
74 
75 
76  ATH_CHECK( lbDurationCondData.record (std::move (lbdur)) );
77  } else {
78  auto lbdur = std::make_unique<LBDurationCondData> (m_default);
79  ATH_CHECK( lbDurationCondData.record (std::move (lbdur)) );
80  }
81  }
82  return StatusCode::SUCCESS;
83 }
84 
85 
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LBDurationCondAlg::m_lblbFolderInputKey
SG::ReadCondHandleKey< AthenaAttributeList > m_lblbFolderInputKey
Input COOL folder.
Definition: LBDurationCondAlg.h:46
python.SystemOfUnits.nanosecond
int nanosecond
Definition: SystemOfUnits.py:119
LBDurationCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
Definition: LBDurationCondAlg.cxx:38
lumiFormat.startTime
startTime
Definition: lumiFormat.py:95
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IOVInfiniteRange::infiniteRunLB
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Definition: IOVInfiniteRange.h:39
LBDurationCondAlg::m_default
const float m_default
Definition: LBDurationCondAlg.h:53
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LBDurationCondAlg::initialize
virtual StatusCode initialize() override
Gaudi initialize method.
Definition: LBDurationCondAlg.cxx:25
PixelAthHitMonAlgCfg.duration
duration
Definition: PixelAthHitMonAlgCfg.py:152
IOVInfiniteRange.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LBDurationCondAlg::m_lbDurationOutputKey
SG::WriteCondHandleKey< LBDurationCondData > m_lbDurationOutputKey
Output conditions object.
Definition: LBDurationCondAlg.h:51
LBDurationCondAlg.h
Produce LBDurationCondData from /TRIGGER/LUMI/LBLB.
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
lumiFormat.endTime
endTime
Definition: lumiFormat.py:100
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275