ATLAS Offline Software
LumiBlockMuWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LumiBlockMuWriter.h"
8 
9 LumiBlockMuWriter::LumiBlockMuWriter(const std::string& name, ISvcLocator* pSvcLocator)
10  : AthReentrantAlgorithm(name,pSvcLocator)
11 {
12 }
13 
15 {
16  ATH_MSG_INFO("LumiBlockMuWriter::initialize()");
17 
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode LumiBlockMuWriter::execute(const EventContext& ctx) const
26 {
27  ATH_MSG_DEBUG("LumiBlockMuWriter::execute()");
28 
29  float actualMu = 0.0;
30  float muToLumi = 0.0;
31  float averageMu = 0.0;
32  if (!m_lumiDataKey.empty()) {
34  if (lumiData->lbAverageLuminosity() != 0 ||
35  lumiData->lbAverageInteractionsPerCrossing() != 0) {
36  muToLumi = lumiData->muToLumi();
37  if( std::abs( muToLumi ) > 0.00001 ) {
38  unsigned int bcid = ctx.eventID().bunch_crossing_id();
39  actualMu = lumiData->lbLuminosityPerBCIDVector().at(bcid) / muToLumi;
40  }
41  }
42  averageMu = lumiData->lbAverageInteractionsPerCrossing();
43  }
44 
46  if (!actMu.isPresent()) {
47  ATH_MSG_ERROR( "actualInteractionsPerCrossing.isPresent check fails" );
48  return StatusCode::FAILURE;
49  }
50  if (!actMu.isAvailable()) {
51  actMu(0) = actualMu;
52  }
53 
55  if (!aveMu.isPresent()) {
56  ATH_MSG_ERROR( "averageInteractionsPerCrossing.isPresent check fails" );
57  return StatusCode::FAILURE;
58  }
59  if (!aveMu.isAvailable()) {
60  aveMu(0) = averageMu;
61  }
62 
63  return StatusCode::SUCCESS;
64 }
LuminosityCondData::lbLuminosityPerBCIDVector
const std::vector< float > & lbLuminosityPerBCIDVector() const
Definition: LuminosityCondData.cxx:46
LumiBlockMuWriter::LumiBlockMuWriter
LumiBlockMuWriter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LumiBlockMuWriter.cxx:9
LumiBlockMuWriter.h
LuminosityCondData::muToLumi
float muToLumi() const
Definition: LuminosityCondData.cxx:56
SG::WriteDecorHandle::isAvailable
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
LuminosityCondData::lbAverageLuminosity
float lbAverageLuminosity() const
Definition: LuminosityCondData.cxx:16
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
LumiBlockMuWriter::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: LumiBlockMuWriter.cxx:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LumiBlockMuWriter::initialize
virtual StatusCode initialize() override
Definition: LumiBlockMuWriter.cxx:14
LumiBlockMuWriter::m_actMuKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_actMuKey
Definition: LumiBlockMuWriter.h:36
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
LumiBlockMuWriter::m_aveMuKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_aveMuKey
Definition: LumiBlockMuWriter.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LumiBlockMuWriter::m_lumiDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Definition: LumiBlockMuWriter.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LuminosityCondData::lbAverageInteractionsPerCrossing
float lbAverageInteractionsPerCrossing() const
Definition: LuminosityCondData.cxx:26
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SG::WriteDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30