ATLAS Offline Software
MixingEventSelector.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef ATHENASERVICES_MIXINGEVENTSELECTOR_H
8 #define ATHENASERVICES_MIXINGEVENTSELECTOR_H
9 
16 ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // non-MT EventSelector
17 
18 #include <cassert>
19 #include <ostream>
20 #include <vector>
21 
26 
27 #include "GaudiKernel/ServiceHandle.h"
28 #include "GaudiKernel/IEvtSelector.h"
29 #include "GaudiKernel/IConverter.h"
30 #include "GaudiKernel/ToolHandle.h"
31 #include "GaudiKernel/StatusCode.h"
32 #include "Gaudi/Property.h" /*StringArrayProperty*/
33 
34 class ISvcLocator;
35 
36 class MixingEventIterator;
37 
38 class StoreGateSvc;
39 
40 namespace CLHEP {
41  class RandFlat;
42 }
43 
44 
69  : public extends<AthService, IEvtSelector, IConverter, IAddressProvider>
70 {
71 public:
75  struct Context : public IEvtSelector::Context {
76  virtual ~Context() {}
77  virtual void* identifier() const {
78  return (void*)0;
79  }
80  } ;
82 
83  virtual StatusCode next(IEvtSelector::Context& refCtxt) const override;
84  virtual StatusCode createAddress(const IEvtSelector::Context& refCtxt,
85  IOpaqueAddress*&) const override;
86 
87  virtual StatusCode createContext(IEvtSelector::Context*& refpCtxt) const override;
88  virtual StatusCode last(IEvtSelector::Context&) const override;
89  virtual StatusCode next(IEvtSelector::Context&, int) const override;
90  virtual StatusCode previous(IEvtSelector::Context&) const override;
91  virtual StatusCode previous(IEvtSelector::Context&,int) const override;
92  virtual StatusCode rewind(IEvtSelector::Context& refCtxt) const override;
93  virtual StatusCode releaseContext(IEvtSelector::Context*& refCtxt) const override;
94  virtual StatusCode resetCriteria(const std::string& cr,IEvtSelector::Context& c) const override;
96 
98 
99  virtual StatusCode preLoadAddresses(StoreID::type storeID ,
100  IAddressProvider::tadList& tads ) override;
101  virtual StatusCode loadAddresses(StoreID::type storeID ,
102  IAddressProvider::tadList& tads ) override;
103  virtual StatusCode updateAddress(StoreID::type storeID ,
105  const EventContext& ctx) override;
107 
108 
110 
111  virtual const CLID& objType() const override;
112  virtual long repSvcType() const override;
113  virtual StatusCode createObj(IOpaqueAddress* pAddress, DataObject*& refpObject) override;
114 
115  // The rest of these are dummies.
116  virtual StatusCode setDataProvider(IDataProviderSvc* pService) override;
117  virtual SmartIF<IDataProviderSvc>& dataProvider() const override;
118  virtual StatusCode setConversionSvc(IConversionSvc* pService) override;
119  virtual SmartIF<IConversionSvc>& conversionSvc() const override;
120  virtual StatusCode setAddressCreator(IAddressCreator* creator) override;
121  virtual SmartIF<IAddressCreator>& addressCreator() const override;
122  virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
123  virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject) override;
124  virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
125  virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
126  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
127  virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject) override;
128  virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
130 
131 
133 
134  virtual StatusCode initialize() override;
135  virtual StatusCode finalize() override;
137 
140  void setUpTriggerList(Gaudi::Details::PropertyBase& trigList);
142  void decodeTrigger(std::string triggDescr);
143 
145 
146  MixingEventSelector(const std::string& name, ISvcLocator* svc);
147  virtual ~MixingEventSelector();
149 
150 private:
151  bool validTrigger() const { return (m_trigList.end()!=m_pCurrentTrigger);}
153 
154  StringProperty m_statusFileName;
155  StringArrayProperty m_triggerListProp;
156  IntegerProperty m_outputRunNumber;
157  UnsignedLongArrayProperty m_eventNumbers;
158  StringProperty m_mergedEventInfoKey;
159  ToolHandleArray<IAthenaSelectorTool> m_helperTools;
160 
162 
163 
167  class Trigger {
168  private:
169  IEvtSelector* m_pSelector;
170  unsigned int m_firstEvent;
171  unsigned int m_toRead;
172  unsigned int m_todo;
173  mutable unsigned int m_reads;
174  mutable IEvtSelector::Context* m_current;
175 
176  public:
177  Trigger(IEvtSelector* pSel,
178  //IEvtSelector::Context* pContext,
179  unsigned int firstEvt, unsigned int lastEvt);
180 
181  unsigned int todo() const { return m_todo; }
182  unsigned int toRead() const { return m_toRead; }
183  unsigned int read() const { return m_reads; }
184  bool done() const;
185 
186  StatusCode next() const;
187  StatusCode previous() const;
188  StatusCode createAddress(IOpaqueAddress*&) const;
189  StatusCode createContext(IEvtSelector::Context*& pCtxt) const;
190 
191  bool operator == (const Trigger& rhs) const {
192  return ( m_pSelector == rhs.m_pSelector );
193  }
194  bool operator != (const Trigger& rhs) const {
195  return ( m_pSelector != rhs.m_pSelector );
196  }
197  bool operator < (const Trigger& rhs) const {
198  return ( m_todo < rhs.m_todo ||
199  ((m_todo == rhs.m_todo) && (m_pSelector < rhs.m_pSelector)) );
200  }
201 
202  const std::string& name() const {
203  return dynamic_cast<IService&>(selector()).name();
204  }
205  std::string toString() const ;
206 
207  private:
208  IEvtSelector::Context& currentContext() const; //throws GaudiException
209  IEvtSelector& selector() const {
210  assert( m_pSelector );
211  return *m_pSelector;
212  }
213 
214  };
215 
219  class TriggerList {
220  private:
221  std::vector<Trigger> m_trigs;
222  std::vector<unsigned int> m_rangeEnd;
223  unsigned int m_todo;
224  public:
226  typedef std::vector<Trigger>::const_iterator const_iterator;
228  bool add(const Trigger&);
229  bool remove(iterator);
230  iterator begin() { return m_trigs.begin(); }
231  iterator end() { return m_trigs.end(); }
232  const_iterator begin() const { return m_trigs.begin(); }
233  const_iterator end() const { return m_trigs.end(); }
234  bool empty() const { return m_trigs.empty(); }
235  iterator elementInRange(unsigned int);
236  unsigned int todo() const { return m_todo; }
237  std::string toString() const;
238  };
239 
241 
243 
248 
249 
251 
252  unsigned long getEventNo() const;
254  mutable unsigned long m_eventPos;
255 
259  StringProperty m_randomStreamName;
260  CLHEP::RandFlat* m_chooseRangeRand;
261 
262 };
263 #endif // ATHENASERVICES_MIXINGEVENTSELECTOR_H
264 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MixingEventSelector::m_pCurrentTrigger
TriggerList::iterator m_pCurrentTrigger
the current trigger
Definition: MixingEventSelector.h:246
MixingEventSelector::m_trigList
TriggerList m_trigList
the ingredients
Definition: MixingEventSelector.h:240
MixingEventSelector
a stream of events read from different selectors.
Definition: MixingEventSelector.h:70
MixingEventSelector::MixingEventSelector
MixingEventSelector(const std::string &name, ISvcLocator *svc)
Definition: MixingEventSelector.cxx:47
MixingEventSelector::Trigger::toString
std::string toString() const
Definition: MixingEventSelector.cxx:431
MixingEventSelector::conversionSvc
virtual SmartIF< IConversionSvc > & conversionSvc() const override
Definition: MixingEventSelector.cxx:567
MixingEventSelector::m_atRndmSvc
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
Definition: MixingEventSelector.h:258
MixingEventSelector::TriggerList::remove
bool remove(iterator)
Definition: MixingEventSelector.cxx:345
MixingEventSelector::repSvcType
virtual long repSvcType() const override
Definition: MixingEventSelector.cxx:511
MixingEventSelector::objType
virtual const CLID & objType() const override
Definition: MixingEventSelector.cxx:507
MixingEventSelector::Context::~Context
virtual ~Context()
Definition: MixingEventSelector.h:76
MixingEventSelector::Trigger::m_todo
unsigned int m_todo
Definition: MixingEventSelector.h:172
MixingEventSelector::releaseContext
virtual StatusCode releaseContext(IEvtSelector::Context *&refCtxt) const override
Definition: MixingEventSelector.cxx:497
MixingEventSelector::TriggerList::m_rangeEnd
std::vector< unsigned int > m_rangeEnd
Definition: MixingEventSelector.h:222
SG::TransientAddress
Definition: TransientAddress.h:32
MixingEventSelector::setDataProvider
virtual StatusCode setDataProvider(IDataProviderSvc *pService) override
Definition: MixingEventSelector.cxx:555
MixingEventSelector::last
virtual StatusCode last(IEvtSelector::Context &) const override
Definition: MixingEventSelector.cxx:482
MixingEventSelector::Trigger::operator==
bool operator==(const Trigger &rhs) const
Definition: MixingEventSelector.h:191
MixingEventSelector::setAddressCreator
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
Definition: MixingEventSelector.cxx:571
IAthenaSelectorTool.h
This file contains the class definition for the IAthenaSelectorTool class.
MixingEventSelector::TriggerList::end
iterator end()
Definition: MixingEventSelector.h:231
MixingEventSelector::TriggerList::empty
bool empty() const
Definition: MixingEventSelector.h:234
MixingEventSelector::TriggerList::todo
unsigned int todo() const
Definition: MixingEventSelector.h:236
MixingEventSelector::Trigger::todo
unsigned int todo() const
Definition: MixingEventSelector.h:181
MixingEventSelector::m_triggerListProp
StringArrayProperty m_triggerListProp
the recipe
Definition: MixingEventSelector.h:155
MixingEventSelector::Trigger::selector
IEvtSelector & selector() const
Definition: MixingEventSelector.h:209
MixingEventSelector::next
virtual StatusCode next(IEvtSelector::Context &refCtxt) const override
Definition: MixingEventSelector.cxx:206
MixingEventSelector::currentTrigger
TriggerList::iterator currentTrigger() const
"intelligent" accessor to the above
Definition: MixingEventSelector.cxx:322
MixingEventSelector::Trigger::m_pSelector
IEvtSelector * m_pSelector
Definition: MixingEventSelector.h:169
MixingEventSelector::loadAddresses
virtual StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
Definition: MixingEventSelector.cxx:261
MixingEventSelector::getEventNo
unsigned long getEventNo() const
setup and lookup m_evtsNotUsedSoFar. Returns next event no
Definition: MixingEventSelector.cxx:291
MixingEventSelector::m_eventPos
unsigned long m_eventPos
the internal event number
Definition: MixingEventSelector.h:254
MixingEventSelector::m_outputRunNumber
IntegerProperty m_outputRunNumber
Definition: MixingEventSelector.h:156
MixingEventSelector::Trigger::read
unsigned int read() const
Definition: MixingEventSelector.h:183
MixingEventSelector::m_helperTools
ToolHandleArray< IAthenaSelectorTool > m_helperTools
Definition: MixingEventSelector.h:159
MixingEventSelector::setConversionSvc
virtual StatusCode setConversionSvc(IConversionSvc *pService) override
Definition: MixingEventSelector.cxx:563
MixingEventSelector::TriggerList::elementInRange
iterator elementInRange(unsigned int)
Definition: MixingEventSelector.cxx:392
MixingEventSelector::Trigger::previous
StatusCode previous() const
Definition: MixingEventSelector.cxx:451
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
MixingEventSelector::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: MixingEventSelector.cxx:528
MixingEventSelector::TriggerList::iterator
std::vector< Trigger >::iterator iterator
Definition: MixingEventSelector.h:227
MixingEventSelector::decodeTrigger
void decodeTrigger(std::string triggDescr)
functor that creates a Trigger object and adds it to m_trigList
Definition: MixingEventSelector.cxx:138
MixingEventSelector::Trigger::m_toRead
unsigned int m_toRead
Definition: MixingEventSelector.h:171
MixingEventSelector::Context::identifier
virtual void * identifier() const
Definition: MixingEventSelector.h:77
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MixingEventSelector::m_eventNumbers
UnsignedLongArrayProperty m_eventNumbers
use these as event numbers
Definition: MixingEventSelector.h:157
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
MixingEventSelector::dataProvider
virtual SmartIF< IDataProviderSvc > & dataProvider() const override
Definition: MixingEventSelector.cxx:559
MixingEventSelector::Trigger::operator<
bool operator<(const Trigger &rhs) const
Definition: MixingEventSelector.h:197
MixingEventSelector::Trigger::next
StatusCode next() const
Definition: MixingEventSelector.cxx:439
MixingEventSelector::TriggerList::begin
iterator begin()
Definition: MixingEventSelector.h:230
MixingEventSelector::rewind
virtual StatusCode rewind(IEvtSelector::Context &refCtxt) const override
Definition: MixingEventSelector.cxx:494
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
MixingEventSelector::StoreGateSvc_t
ServiceHandle< StoreGateSvc > StoreGateSvc_t
Definition: MixingEventSelector.h:256
MixingEventSelector::setCurrentTrigger
TriggerList::iterator setCurrentTrigger() const
choose current trigger at random. Actually modifies state (use mutables)
Definition: MixingEventSelector.cxx:299
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
MixingEventSelector::TriggerList::m_trigs
std::vector< Trigger > m_trigs
Definition: MixingEventSelector.h:221
MixingEventSelector::m_chooseRangeRand
CLHEP::RandFlat * m_chooseRangeRand
Definition: MixingEventSelector.h:260
MixingEventSelector::TriggerList::m_todo
unsigned int m_todo
Definition: MixingEventSelector.h:223
MixingEventSelector::Trigger::m_firstEvent
unsigned int m_firstEvent
Definition: MixingEventSelector.h:170
IAtRndmGenSvc.h
MixingEventSelector::TriggerList::TriggerList
TriggerList()
Definition: MixingEventSelector.h:225
MixingEventSelector::updateObj
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Definition: MixingEventSelector.cxx:583
MixingEventSelector::updateAddress
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
Definition: MixingEventSelector.cxx:284
MixingEventSelector::TriggerList::end
const_iterator end() const
Definition: MixingEventSelector.h:233
MixingEventSelector::m_mergedEventInfoKey
StringProperty m_mergedEventInfoKey
SG key of MergedEventInfo.
Definition: MixingEventSelector.h:158
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MixingEventSelector::setUpTriggerList
void setUpTriggerList(Gaudi::Details::PropertyBase &trigList)
TriggerList property call-back.
Definition: MixingEventSelector.cxx:129
MixingEventSelector::m_randomStreamName
StringProperty m_randomStreamName
Definition: MixingEventSelector.h:259
MixingEventSelector::finalize
virtual StatusCode finalize() override
Definition: MixingEventSelector.cxx:103
MixingEventSelector::Context
dummy for now
Definition: MixingEventSelector.h:75
MixingEventSelector::TriggerList::toString
std::string toString() const
Definition: MixingEventSelector.cxx:378
MixingEventSelector::Trigger::m_current
IEvtSelector::Context * m_current
Definition: MixingEventSelector.h:174
MixingEventSelector::previous
virtual StatusCode previous(IEvtSelector::Context &) const override
Definition: MixingEventSelector.cxx:488
MixingEventSelector::~MixingEventSelector
virtual ~MixingEventSelector()
Definition: MixingEventSelector.cxx:74
MixingEventSelector::Trigger
a selector with an associated frequency
Definition: MixingEventSelector.h:167
MixingEventSelector::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Definition: MixingEventSelector.cxx:595
MixingEventSelector::TriggerList::add
bool add(const Trigger &)
Definition: MixingEventSelector.cxx:327
MixingEventSelector::TriggerList::const_iterator
std::vector< Trigger >::const_iterator const_iterator
Definition: MixingEventSelector.h:226
MixingEventSelector::Trigger::name
const std::string & name() const
Definition: MixingEventSelector.h:202
MixingEventSelector::Trigger::done
bool done() const
Definition: MixingEventSelector.cxx:473
StoreID::type
type
Definition: StoreID.h:24
MixingEventSelector::TriggerList
the list of available selectors with their frequency range
Definition: MixingEventSelector.h:219
MixingEventSelector::Trigger::toRead
unsigned int toRead() const
Definition: MixingEventSelector.h:182
MixingEventSelector::initialize
virtual StatusCode initialize() override
Definition: MixingEventSelector.cxx:78
MixingEventSelector::createContext
virtual StatusCode createContext(IEvtSelector::Context *&refpCtxt) const override
Definition: MixingEventSelector.cxx:196
MixingEventSelector::preLoadAddresses
virtual StatusCode preLoadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
Definition: MixingEventSelector.cxx:255
MixingEventSelector::Trigger::Trigger
Trigger(IEvtSelector *pSel, unsigned int firstEvt, unsigned int lastEvt)
Definition: MixingEventSelector.cxx:410
MixingEventSelector::Trigger::m_reads
unsigned int m_reads
Definition: MixingEventSelector.h:173
IAddressProvider::tadList
std::list< SG::TransientAddress * > tadList
Definition: IAddressProvider.h:32
AthService.h
MixingEventSelector::createAddress
virtual StatusCode createAddress(const IEvtSelector::Context &refCtxt, IOpaqueAddress *&) const override
Definition: MixingEventSelector.cxx:244
IAddressProvider.h
MixingEventSelector::Trigger::createContext
StatusCode createContext(IEvtSelector::Context *&pCtxt) const
Definition: MixingEventSelector.cxx:463
MixingEventSelector::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator() const override
Definition: MixingEventSelector.cxx:575
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: MixingEventSelector.h:16
MixingEventSelector::Trigger::operator!=
bool operator!=(const Trigger &rhs) const
Definition: MixingEventSelector.h:194
MixingEventSelector::m_statusFileName
StringProperty m_statusFileName
optional stream output snapshot
Definition: MixingEventSelector.h:154
checker_macros.h
Define macros for attributes used to control the static checker.
MixingEventSelector::TriggerList::begin
const_iterator begin() const
Definition: MixingEventSelector.h:232
MixingEventSelector::updateRep
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Definition: MixingEventSelector.cxx:599
MixingEventSelector::Trigger::currentContext
IEvtSelector::Context & currentContext() const
Definition: MixingEventSelector.cxx:418
python.compressB64.c
def c
Definition: compressB64.py:93
MixingEventSelector::Trigger::createAddress
StatusCode createAddress(IOpaqueAddress *&) const
Definition: MixingEventSelector.cxx:456
MixingEventSelector::fillObjRefs
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Definition: MixingEventSelector.cxx:579
MixingEventSelector::validTrigger
bool validTrigger() const
Definition: MixingEventSelector.h:151
MixingEventSelector::updateObjRefs
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Definition: MixingEventSelector.cxx:587
MixingEventSelector::m_pEventStore
StoreGateSvc_t m_pEventStore
Definition: MixingEventSelector.h:257
MixingEventSelector::resetCriteria
virtual StatusCode resetCriteria(const std::string &cr, IEvtSelector::Context &c) const override
Definition: MixingEventSelector.cxx:500
MixingEventSelector::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Definition: MixingEventSelector.cxx:591
MixingEventSelector::updateRepRefs
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Definition: MixingEventSelector.cxx:603
ServiceHandle< StoreGateSvc >