ATLAS Offline Software
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 
7 LumiProfileSvc::LumiProfileSvc(const std::string& name,ISvcLocator* svc)
8  : base_class(name,svc)
9  , m_runlumilist()
10  , m_scalefactorlist()
11  , m_scaleFactorMap()
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 
20 {
21 }
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 
44 float 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 }
LumiProfileSvc::~LumiProfileSvc
virtual ~LumiProfileSvc()
Definition: LumiProfileSvc.cxx:19
LumiProfileSvc::m_scaleFactorMap
std::map< uint64_t, float > m_scaleFactorMap
map from properties
Definition: LumiProfileSvc.h:39
LumiProfileSvc::initialize
virtual StatusCode initialize() override final
Definition: LumiProfileSvc.cxx:23
python.handimod.now
now
Definition: handimod.py:675
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LumiProfileSvc::scaleFactor
virtual float scaleFactor(unsigned int run, unsigned int lumi, bool &updated) override final
Definition: LumiProfileSvc.cxx:44
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
run
Definition: run.py:1
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LumiProfileSvc::m_runlumilist
SimpleProperty< std::vector< uint64_t > > m_runlumilist
look-up table of lumi scale factor by run, lumiblock
Definition: LumiProfileSvc.h:36
LumiProfileSvc::m_scalefactorlist
SimpleProperty< std::vector< float > > m_scalefactorlist
Definition: LumiProfileSvc.h:37
LumiProfileSvc::m_now
uint64_t m_now
cached iovtime
Definition: LumiProfileSvc.h:43
LumiProfileSvc.h
A IBeamLuminosity service configured with a run/lumi list.
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LumiProfileSvc::m_currentSF
float m_currentSF
cached scale factor
Definition: LumiProfileSvc.h:41
LumiProfileSvc::LumiProfileSvc
LumiProfileSvc(const std::string &name, ISvcLocator *svc)
Definition: LumiProfileSvc.cxx:7