ATLAS Offline Software
Loading...
Searching...
No Matches
LumiProfileSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LumiProfileSvc.h"
6
7LumiProfileSvc::LumiProfileSvc(const std::string& name,ISvcLocator* svc)
8 : base_class(name,svc)
12 , m_currentSF(1.0)
13 , m_now(0)
14{
15 declareProperty("RunLumiList", m_runlumilist, "List of all IOVTimes ((run << 32) + (0xFFFFFFFF & lumiblock)). Same length as ScaleFactorList." );
16 declareProperty("ScaleFactorList", m_scalefactorlist, "List of scale factors for the luminosity. Same length as RunLumiList.");
17}
18
22
24{
25 m_scaleFactorMap.clear();
26 const std::vector<uint64_t>& rProp(m_runlumilist.value());
27 std::vector<uint64_t>::const_iterator iRL(rProp.begin());
28 std::vector<uint64_t>::const_iterator prEnd(rProp.end());
29 const std::vector<float>& sProp(m_scalefactorlist.value());
30 std::vector<float>::const_iterator iSF(sProp.begin());
31 std::vector<float>::const_iterator psEnd(sProp.end());
32 if (rProp.size() != sProp.size())
33 {
34 ATH_MSG_ERROR("Length of RunLumiList differs from length of ScaleFactorList!");
35 return StatusCode::FAILURE;
36 }
37 for( ; iRL != prEnd && iSF != psEnd; ++iRL, ++iSF )
38 {
39 m_scaleFactorMap.insert(std::map<uint64_t,float>::value_type(*iRL, *iSF));
40 }
41 return StatusCode::SUCCESS;
42}
43
44float LumiProfileSvc::scaleFactor(unsigned int run, unsigned int lumi, bool & updated)
45{
46 uint64_t now = (( (uint64_t) run << 32) + lumi);
47 if (m_now != now)
48 {
49 updated = true;
50 m_now = now;
51 std::map<uint64_t,float>::const_iterator iSF = m_scaleFactorMap.find(now);
52 if (iSF == m_scaleFactorMap.end())
53 {
54 ATH_MSG_WARNING("Did not find lumi scale factor for run " << run << " lb " << lumi << "; using cached value.");
55 }
56 else
57 {
58 m_currentSF = iSF->second;
59 }
60 ATH_MSG_DEBUG("Using SF=" << m_currentSF <<" for run=" << run << " lb=" << lumi << ".");
61 }
62 else
63 {
64 updated = false;
65 }
66 return m_currentSF;
67}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
A IBeamLuminosity service configured with a run/lumi list.
virtual StatusCode initialize() override final
virtual ~LumiProfileSvc()
SimpleProperty< std::vector< float > > m_scalefactorlist
float m_currentSF
cached scale factor
uint64_t m_now
cached iovtime
LumiProfileSvc(const std::string &name, ISvcLocator *svc)
SimpleProperty< std::vector< uint64_t > > m_runlumilist
look-up table of lumi scale factor by run, lumiblock
virtual float scaleFactor(unsigned int run, unsigned int lumi, bool &updated) override final
std::map< uint64_t, float > m_scaleFactorMap
map from properties
Definition run.py:1