ATLAS Offline Software
LumiBlockTester.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LumiBlockTester.h"
8 
9 //--------------------------------------------------
10 LumiBlockTester::LumiBlockTester(const std::string& name, ISvcLocator* pSvcLocator):
11  AthReentrantAlgorithm(name,pSvcLocator),
12  m_muTool("LumiBlockMuTool")
13 {
14  declareProperty("LumiBlockMuTool", m_muTool);
15 }
16 
19 {
20  ATH_MSG_INFO("LumiBlockTester::initialize()");
21 
23 
26 
27  // Get the mu tool
28  CHECK(m_muTool.retrieve());
29 
30  ATH_MSG_INFO("LumiBlockTester::initialize() done");
31 
32  return StatusCode::SUCCESS;
33 }
34 
36 LumiBlockTester::execute (const EventContext& ctx) const
37 {
38  ATH_MSG_DEBUG("LumiBlockTester::execute()");
39 
41 
42  // only there for serial running; remove when only doing MT
43  if(!eventInfo.isValid()) {
44  ATH_MSG_FATAL("Failed to retrieve "<< m_eventInfoKey.key());
45  return StatusCode::FAILURE;
46  }
47 
48  unsigned int lumiblock = eventInfo->lumiBlock();
49  unsigned int bcid = eventInfo->bcid();
50 
51  ATH_MSG_DEBUG(" lumiblock " << lumiblock << " BCID " << bcid);
52 
54  float avgmu = lumiData->lbAverageInteractionsPerCrossing();
55  float instmu = 0.;
56 
57  if (lumiData->muToLumi() > 0.)
58  instmu = lumiData->lbLuminosityPerBCIDVector().at(bcid)/lumiData->muToLumi();
59  else
60  ATH_MSG_DEBUG(" Lumi: " << lumiData->lbLuminosityPerBCIDVector().at(bcid) << " muToLumi: " << lumiData->muToLumi() << "!");
61 
63  float live = liveData->l1LiveFractionVector().at(bcid);
64  float lumilive = liveData->lbAverageLiveFraction();
65 
66  ATH_MSG_INFO( "LB: " << lumiblock << " BCID: " << bcid << " <mu>: " << avgmu << " mu: " << instmu << " livefraction: " << live << " lumiavg livefraction: " << lumilive );
67 
68  avgmu = m_muTool->averageInteractionsPerCrossing(ctx);
69  instmu = m_muTool->actualInteractionsPerCrossing(ctx);
70  ATH_MSG_INFO( "From muTool - <mu>: " << avgmu << " mu: " << instmu);
71 
72  instmu = eventInfo->actualInteractionsPerCrossing();
73  avgmu = eventInfo->averageInteractionsPerCrossing();
74  ATH_MSG_INFO( "From EvInfo - <mu>: " << avgmu << " mu: " << instmu);
75 
76  ATH_MSG_DEBUG("LumiBlockTester::execute() done");
77  return StatusCode::SUCCESS;
78 }
LuminosityCondData::lbLuminosityPerBCIDVector
const std::vector< float > & lbLuminosityPerBCIDVector() const
Definition: LuminosityCondData.cxx:46
LumiBlockTester::m_trigLiveFractionCondDataKey
SG::ReadCondHandleKey< TrigLiveFractionCondData > m_trigLiveFractionCondDataKey
Definition: LumiBlockTester.h:41
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
LuminosityCondData::muToLumi
float muToLumi() const
Definition: LuminosityCondData.cxx:56
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.MagFieldUtils.lumiblock
lumiblock
Definition: MagFieldUtils.py:188
LumiBlockTester::initialize
virtual StatusCode initialize() override
Definition: LumiBlockTester.cxx:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LumiBlockTester::LumiBlockTester
LumiBlockTester(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LumiBlockTester.cxx:10
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ReadCondHandle.h
TrigLiveFractionCondData::lbAverageLiveFraction
float lbAverageLiveFraction(bool highPriority=true) const
Luminosity-averaged live fraction over all physics BCIDs.
Definition: TrigLiveFractionCondData.cxx:66
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
LumiBlockTester::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: LumiBlockTester.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
LumiBlockTester::m_muTool
ToolHandle< ILumiBlockMuTool > m_muTool
Definition: LumiBlockTester.h:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
TrigLiveFractionCondData::l1LiveFractionVector
const std::vector< float > & l1LiveFractionVector(bool highPriority=true) const
Return vector with all BCIDs indexed by BCID number.
Definition: TrigLiveFractionCondData.cxx:42
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::EventInfo_v1::averageInteractionsPerCrossing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Definition: EventInfo_v1.cxx:397
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LuminosityCondData::lbAverageInteractionsPerCrossing
float lbAverageInteractionsPerCrossing() const
Definition: LuminosityCondData.cxx:26
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
LumiBlockTester::m_luminosityCondDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_luminosityCondDataKey
Definition: LumiBlockTester.h:39
LumiBlockTester::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: LumiBlockTester.cxx:36
LumiBlockTester.h
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::EventInfo_v1::actualInteractionsPerCrossing
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
Definition: EventInfo_v1.cxx:380