ATLAS Offline Software
Loading...
Searching...
No Matches
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
9LumiBlockMuWriter::LumiBlockMuWriter(const std::string& name, ISvcLocator* pSvcLocator)
10 : AthReentrantAlgorithm(name,pSvcLocator)
11{
12}
13
15{
16 ATH_MSG_INFO("LumiBlockMuWriter::initialize()");
17
19 ATH_CHECK(m_actMuKey.initialize());
20 ATH_CHECK(m_aveMuKey.initialize());
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteDecorHandleKey< xAOD::EventInfo > m_actMuKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_aveMuKey
virtual StatusCode execute(const EventContext &ctx) const override
LumiBlockMuWriter(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Handle class for adding a decoration to an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
bool isPresent() const
Is the referenced container present in SG?