ATLAS Offline Software
Loading...
Searching...
No Matches
LBDurationCondAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
12#include "LBDurationCondAlg.h"
13#include "CoolKernel/IObject.h"
14#include "GaudiKernel/SystemOfUnits.h"
16
17using Gaudi::Units::second;
18using Gaudi::Units::nanosecond;
19
20
24StatusCode
26{
28 ATH_CHECK( m_lbDurationOutputKey.initialize() );
29 return StatusCode::SUCCESS;
30}
31
32
37StatusCode
38LBDurationCondAlg::execute (const EventContext& ctx) const
39{
40
43
44 if (m_lblbFolderInputKey.empty()) {
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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Produce LBDurationCondData from /TRIGGER/LUMI/LBLB.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
SG::ReadCondHandleKey< AthenaAttributeList > m_lblbFolderInputKey
Input COOL folder.
virtual StatusCode initialize() override
Gaudi initialize method.
SG::WriteCondHandleKey< LBDurationCondData > m_lbDurationOutputKey
Output conditions object.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED