ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
EvtIdModifierSvc Class Reference

#include <EvtIdModifierSvc.h>

Inheritance diagram for EvtIdModifierSvc:
Collaboration diagram for EvtIdModifierSvc:

Public Types

using number_type = EventIDBase::number_type
 

Public Member Functions

 EvtIdModifierSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters: More...
 
virtual StatusCode initialize () override
 Gaudi Service Implementation. More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface) override
 
virtual std::vector< number_typerun_number_list () const override
 return the (sorted) list of run-numbers which will be modified. More...
 
virtual void modify_evtid (EventID &evt_id, event_number_t evt_index, bool consume_stream) override
 modify an EventID's lumi block content. More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Private Member Functions

 EvtIdModifierSvc ()
 Default constructor: More...
 

Private Attributes

event_number_t m_skippedEvents
 (prop) number of events skipped in the event selector More...
 
event_number_t m_firstEvtIdx
 (prop) first event number at which we begin to modify event ids More...
 
std::vector< uint64_t > m_evtNpletsProp
 (prop) list of n-plets (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk, mod-bit) More...
 
std::string m_evtStoreName
 (prop) Name of the event store whose EventIDs will be modified. More...
 
std::vector< ItemModifierm_evtNplets
 db of list of ItemModifiers: (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk, mod-bit) More...
 
std::vector< event_number_tm_numEvtTotals
 Running total of numEvts before each modifier. More...
 

Friends

class SvcFactory< EvtIdModifierSvc >
 

Detailed Description

Definition at line 41 of file EvtIdModifierSvc.h.

Member Typedef Documentation

◆ number_type

using IEvtIdModifierSvc::number_type = EventIDBase::number_type
inherited

Definition at line 42 of file IEvtIdModifierSvc.h.

Constructor & Destructor Documentation

◆ EvtIdModifierSvc() [1/2]

EvtIdModifierSvc::EvtIdModifierSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Constructor with parameters:

Definition at line 46 of file EvtIdModifierSvc.cxx.

48  : ::AthService(name, pSvcLocator) {
49  //
50  // Property declaration
51  //
52  // declareProperty( "Property", m_nProperty );
53 
54  declareProperty("Modifiers", m_evtNpletsProp,
55  "A list of n-uplets "
56  "(RunNumber,EvtNbr,TimeStamp,LumiBlock,Nevents,ModBit).");
57 
58  declareProperty("EvtStoreName", m_evtStoreName = "StoreGateSvc",
59  "Name of the event store whose EventIDs will be modified.");
60 
61  declareProperty("SkipEvents", m_firstEvtIdx = 0,
62  "Number of events to skip before modifying EventInfos.");
63  declareProperty("SkippedEvents", m_skippedEvents = 0,
64  "Number of events skipped in the EventSelector.");
65 }

◆ EvtIdModifierSvc() [2/2]

EvtIdModifierSvc::EvtIdModifierSvc ( )
private

Default constructor:

Member Function Documentation

◆ initialize()

StatusCode EvtIdModifierSvc::initialize ( )
overridevirtual

Gaudi Service Implementation.

Definition at line 69 of file EvtIdModifierSvc.cxx.

69  {
70  ATH_MSG_INFO("Initializing " << name() << "...");
71 
72  if (const auto nplets_prop_count = m_evtNpletsProp.size();
73  nplets_prop_count > 0) {
74  // they should be Nplets...
75  if (nplets_prop_count % prop_per_nplet != 0) {
76  ATH_MSG_ERROR("invalid list of n-plets (not divisible by "
77  << prop_per_nplet << ")" << endmsg << "check your joboptions !");
78  return StatusCode::FAILURE;
79  }
80 
81  m_evtNplets.reserve(nplets_prop_count / prop_per_nplet);
82  for (std::size_t i = 0; i < nplets_prop_count; i += prop_per_nplet) {
83  m_evtNplets.push_back({
84  // clang-format off
85  .runnbr = static_cast<number_type>( m_evtNpletsProp[i + 0]),
86  .evtnbr = static_cast<event_number_t>(m_evtNpletsProp[i + 1]),
87  .timestamp = static_cast<number_type>( m_evtNpletsProp[i + 2]),
88  .lbknbr = static_cast<number_type>( m_evtNpletsProp[i + 3]),
89  .nevts = static_cast<event_number_t>(m_evtNpletsProp[i + 4]),
90  .flags = static_cast<int>( m_evtNpletsProp[i + 5])
91  // clang-format on
92  });
93  }
94  }
95 
96  // initialize running total of nevts
97  m_numEvtTotals.clear();
98  event_number_t sum = 0;
99  for (const ItemModifier& elem : m_evtNplets) {
100  sum += elem.nevts;
101  m_numEvtTotals.push_back(sum);
102  }
103 
104  if (msgLvl(MSG::DEBUG)) {
105  msg(MSG::DEBUG) << "store being modified: [" << m_evtStoreName << "]"
106  << endmsg << "evtid-modifiers: [ ";
107  for (const ItemModifier& elem : m_evtNplets) {
108  msg(MSG::DEBUG) << "[" << elem.runnbr << ", " << elem.evtnbr << ", "
109  << elem.timestamp << ", " << elem.lbknbr << ", "
110  << elem.nevts << ", flags=0x" << std::hex << elem.flags
111  << std::dec << "], ";
112  }
113  msg(MSG::DEBUG) << "]" << endmsg;
114  }
115 
116  return StatusCode::SUCCESS;
117 }

◆ interfaceID()

const InterfaceID & EvtIdModifierSvc::interfaceID ( )
inlinestatic

Definition at line 109 of file EvtIdModifierSvc.h.

109  {
111 }

◆ modify_evtid()

void EvtIdModifierSvc::modify_evtid ( EventID evt_id,
event_number_t  evt_index,
bool  consume_stream 
)
overridevirtual

modify an EventID's lumi block content.

modify an EventID's content.

Implements IEvtIdModifierSvc.

Definition at line 159 of file EvtIdModifierSvc.cxx.

160  {
161  // Left in to match old observable behaviour:
162  // only when consuming stream is required do we check for a matching
163  // current StoreGate name (ie: typically the case of being called from a T/P
164  // cnv)
165  if (consume_stream) {
167  if (!active) {
168  ATH_MSG_INFO("could not retrieve the active evtstore - bailing out");
169  return;
170  }
171 
172  const std::string& evtStoreName = active->name();
173  ATH_MSG_DEBUG("active store: [" << evtStoreName << "]");
174  if (evtStoreName != m_evtStoreName) {
175  return;
176  }
177  }
178 
179  ATH_MSG_DEBUG("evtid before massaging: " << "(" << evt_id.run_number() << ", "
180  << evt_id.event_number() << ", "
181  << evt_id.time_stamp() << ", "
182  << evt_id.lumi_block() << ")");
183 
184  // event skipping
185  std::int64_t idx =
186  std::int64_t(evt_index) + m_skippedEvents - std::int64_t(m_firstEvtIdx);
187  std::int64_t idx_looped = idx % m_numEvtTotals.back();
188  ATH_MSG_DEBUG("Got event idx " << evt_index << " --(account for skipping)--> "
189  << idx << " --(modulo #modifiers)--> "
190  << idx_looped);
191  if (idx < 0) {
192  ATH_MSG_DEBUG("skip event");
193  return;
194  }
195 
196  // Account for events skipped in
197  std::size_t mod_idx = std::upper_bound(m_numEvtTotals.cbegin(),
198  m_numEvtTotals.cend(), idx_looped) -
199  m_numEvtTotals.cbegin();
200  ItemModifier current = m_evtNplets[mod_idx];
201  ATH_MSG_DEBUG("Unique modifier index " << mod_idx
202  << " (LB: " << current.lbknbr << ")");
203  if (mod_idx >= m_numEvtTotals.size()) {
204  // Shouldn't happen
205  ATH_MSG_ERROR("Somehow run out of modifiers");
206  return;
207  }
208 
209  if (current.flags & ModFlag::RUNNBR) {
210  evt_id.set_run_number(current.runnbr);
211  }
212  if (current.flags & ModFlag::EVTNBR) {
213  evt_id.set_event_number(current.evtnbr);
214  }
215  if (current.flags & ModFlag::TIMESTAMP) {
216  evt_id.set_time_stamp(current.timestamp);
217  }
218  if (current.flags & ModFlag::LBKNBR) {
219  evt_id.set_lumi_block(current.lbknbr);
220  }
221 
222  ATH_MSG_DEBUG("evtid after massaging: " << "(" << evt_id.run_number() << ", "
223  << evt_id.event_number() << ", "
224  << evt_id.time_stamp() << ", "
225  << evt_id.lumi_block() << ")");
226 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ queryInterface()

StatusCode EvtIdModifierSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
overridevirtual

Definition at line 124 of file EvtIdModifierSvc.cxx.

125  {
126  if (IEvtIdModifierSvc::interfaceID().versionMatch(riid)) {
127  *ppvInterface = dynamic_cast<IEvtIdModifierSvc*>(this);
128  } else {
129  // Interface is not directly available : try out a base class
130  return ::AthService::queryInterface(riid, ppvInterface);
131  }
132  addRef();
133  return StatusCode::SUCCESS;
134 }

◆ run_number_list()

std::vector< number_type > EvtIdModifierSvc::run_number_list ( ) const
overridevirtual

return the (sorted) list of run-numbers which will be modified.

Implements IEvtIdModifierSvc.

Definition at line 142 of file EvtIdModifierSvc.cxx.

142  {
143  std::set<number_type> runs;
144 
145  for (const ItemModifier& elem : m_evtNplets) {
146  if (elem.flags & ModFlag::RUNNBR) {
147  runs.insert(elem.runnbr);
148  }
149  }
150  return std::vector(runs.begin(), runs.end());
151 }

Friends And Related Function Documentation

◆ SvcFactory< EvtIdModifierSvc >

friend class SvcFactory< EvtIdModifierSvc >
friend

Definition at line 38 of file EvtIdModifierSvc.h.

Member Data Documentation

◆ m_evtNplets

std::vector<ItemModifier> EvtIdModifierSvc::m_evtNplets
private

db of list of ItemModifiers: (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk, mod-bit)

Definition at line 99 of file EvtIdModifierSvc.h.

◆ m_evtNpletsProp

std::vector<uint64_t> EvtIdModifierSvc::m_evtNpletsProp
private

(prop) list of n-plets (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk, mod-bit)

Definition at line 92 of file EvtIdModifierSvc.h.

◆ m_evtStoreName

std::string EvtIdModifierSvc::m_evtStoreName
private

(prop) Name of the event store whose EventIDs will be modified.

Definition at line 95 of file EvtIdModifierSvc.h.

◆ m_firstEvtIdx

event_number_t EvtIdModifierSvc::m_firstEvtIdx
private

(prop) first event number at which we begin to modify event ids

Definition at line 88 of file EvtIdModifierSvc.h.

◆ m_numEvtTotals

std::vector<event_number_t> EvtIdModifierSvc::m_numEvtTotals
private

Running total of numEvts before each modifier.

Definition at line 102 of file EvtIdModifierSvc.h.

◆ m_skippedEvents

event_number_t EvtIdModifierSvc::m_skippedEvents
private

(prop) number of events skipped in the event selector

Definition at line 86 of file EvtIdModifierSvc.h.


The documentation for this class was generated from the following files:
EvtIdModifierSvc::m_evtNplets
std::vector< ItemModifier > m_evtNplets
db of list of ItemModifiers: (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk,...
Definition: EvtIdModifierSvc.h:99
AthService::AthService
AthService()
ItemModifier
Definition: EvtIdModifierSvc.h:32
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
find_tgc_unfilled_channelids.runs
int runs
Definition: find_tgc_unfilled_channelids.py:10
EvtIdModifierSvc::m_evtStoreName
std::string m_evtStoreName
(prop) Name of the event store whose EventIDs will be modified.
Definition: EvtIdModifierSvc.h:95
AthCommonMsg< Service >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
IEvtIdModifierSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: IEvtIdModifierSvc.h:76
EvtIdModifierSvc::m_firstEvtIdx
event_number_t m_firstEvtIdx
(prop) first event number at which we begin to modify event ids
Definition: EvtIdModifierSvc.h:88
IEvtIdModifierSvc::number_type
EventIDBase::number_type number_type
Definition: IEvtIdModifierSvc.h:42
IEvtIdModifierSvc
Definition: IEvtIdModifierSvc.h:37
EvtIdModifierSvc::m_numEvtTotals
std::vector< event_number_t > m_numEvtTotals
Running total of numEvts before each modifier.
Definition: EvtIdModifierSvc.h:102
event_number_t
EventIDBase::event_number_t event_number_t
Definition: IEvtIdModifierSvc.h:30
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
Trk::active
@ active
Definition: Layer.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
StoreGateSvc::currentStoreGate
static StoreGateSvc * currentStoreGate()
get current StoreGate
Definition: StoreGateSvc.cxx:69
EvtIdModifierSvc::m_evtNpletsProp
std::vector< uint64_t > m_evtNpletsProp
(prop) list of n-plets (run-nbr, evt-nbr, time-stamp, lbk-nbr, nbr-of-events-per-lbk,...
Definition: EvtIdModifierSvc.h:92
EvtIdModifierSvc::m_skippedEvents
event_number_t m_skippedEvents
(prop) number of events skipped in the event selector
Definition: EvtIdModifierSvc.h:86
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15