11#include "EventInfo/EventInfo.h"
21#include "GaudiKernel/GaudiException.h"
22#include "GaudiKernel/TypeNameString.h"
23#include "GaudiKernel/MsgStream.h"
24#include "GaudiKernel/GenericAddress.h"
25#include "CLHEP/Random/RandFlat.h"
40#ifdef DEBUG_OUTPUT_STATUS
41ofstream outfile2(
"status.txt");
64 if(
nullptr == collEng ) {
66 return StatusCode::FAILURE;
76 return StatusCode::SUCCESS;
84 tool->preFinalize().ignore();
88 ofstream outfile(fname.c_str());
92 while (i != iEnd) outfile << (*i++).toString();
93 }
else if (!fname.empty()) {
97 return StatusCode::SUCCESS;
103 using std::placeholders::_1;
115 if (tokens.size() == 3) {
116 auto iToken = tokens.begin();
117 Gaudi::Utils::TypeNameString selTN(*iToken++);
119 SmartIF<IEvtSelector> pSelector(serviceLocator()->service(selTN));
123 unsigned int firstEvt{};
124 unsigned int lastEvt{};
125 auto string1 = *iToken++;
126 auto string2 = *iToken;
127 auto [ptr1, ec1] = std::from_chars(string1.data(), string1.data() + string1.size(), firstEvt);
128 auto [ptr2, ec2] = std::from_chars(string2.data(), string2.data() + string2.size(), lastEvt);
129 if ( ec1 != std::errc() || ec2 != std::errc() ) {
130 ATH_MSG_ERROR(
"decodeTrigger: Can't cast ["<< string1 <<
" " << string2 <<
"] to double(frequency). SKIPPING");
133 if (msgLvl(MSG::DEBUG)) {
134 SmartIF<INamedInterface> pNamed(pSelector);
136 msg() <<
"decodeTrigger: added selector " << pNamed->name()
137 <<
" first event to be read " << firstEvt
138 <<
" last event to be read " << lastEvt <<
endmsg;
143 (
"decodeTrigger: Selector ["
144 << selTN.type() <<
'/' << selTN.name()
150 (
"decodeTrigger: Selector ["
151 << selTN.type() <<
'/' << selTN.name()
152 <<
"] can not be found or created");
156 (
"decodeTrigger: Badly formatted descriptor ["
157 << triggDescr <<
"]. SKIPPING");
162#define FORWARD___DEBUG( METHOD )\
163 { ATH_MSG_VERBOSE ("forwarding " << #METHOD << " to service "\
164 << (validTrigger() ? currentTrigger()->name() : "NONE")); }
166#define FORWARD___DEBUG( METHOD )
173 StatusCode
sc(StatusCode::FAILURE);
174 while (iTr !=
m_trigList.end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
180 StatusCode
sc(StatusCode::FAILURE);
182#ifdef DEBUG_OUTPUT_STATUS
185 while (i != iEnd) outfile2 << (*i++).toString();
196 std::vector<ToolHandle<IAthenaSelectorTool> >::const_iterator
198 while (i != iE) ((*i++)->preNext()).ignore();
204 while (
sc.isSuccess() && (i != iE)) {
205 sc =(*i)->postNext();
206 if (
sc.isRecoverable())
207 ATH_MSG_INFO(
"Request skipping event from: " << (*i)->name());
208 else if (
sc.isFailure())
218 IOpaqueAddress*& pAddr)
const {
224 pAddr !=
nullptr) ? StatusCode::SUCCESS : StatusCode::FAILURE;
230 return StatusCode::SUCCESS;
238 return StatusCode::SUCCESS;
246 new GenericAddress (0, mclid),
248 auto dp = std::make_unique<SG::DataProxy> (std::move(tad),
253 return StatusCode::SUCCESS;
258 const EventContext&) {
259 return StatusCode::FAILURE;
262#undef FORWARD___DEBUG
308 if (log.level() <= MSG::DEBUG) {
309 log << MSG::DEBUG <<
"add: trigger "
320 unsigned int nElem(
m_trigs.size());
322 unsigned int trigTodo(iTrig->todo());
323 unsigned int trigIndex(iTrig -
begin());
325 string trigName(iTrig->name());
328 removed = nElem >
m_trigs.size();
333 for (
unsigned int i=trigIndex+1; i<
m_rangeEnd.size(); ++i)
339 if (log.level() <= MSG::DEBUG) {
340 log << MSG::DEBUG <<
"remove: trigger "
353 for (
unsigned int i=0; i<
m_trigs.size(); ++i) {
356 <<
", to do=" <<
m_trigs[i].todo()
357 << (
m_trigs[i].done() ?
" done " :
" ")
361 return string(os.str());
367 std::vector<unsigned int>::const_iterator iRange(
m_rangeEnd.begin());
368 std::vector<unsigned int>::const_iterator eRange(
m_rangeEnd.end());
369 while (eRange != iRange && eTrig != iTrig && i > *iRange){
374 if (log.level() <= MSG::VERBOSE) {
375 if (eRange != iRange) log << MSG::VERBOSE
376 <<
"elementInRange: rangeEnd=" << *iRange
377 <<
" matches i=" << i <<
endmsg;
384 unsigned int firstEvt,
385 unsigned int lastEvt):
394 IEvtSelector::Context* pTmp(
nullptr);
396 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
397 name(),StatusCode::FAILURE);
407 <<
", to do=" <<
todo() << endl;
408 return string(os.str());
413 StatusCode
sc(StatusCode::FAILURE);
431 StatusCode::FAILURE :
437 StatusCode
sc(StatusCode::FAILURE);
456 return StatusCode::FAILURE;
459 return StatusCode::FAILURE;
462 return StatusCode::FAILURE;
465 return StatusCode::FAILURE;
468 return StatusCode::FAILURE;
471 return StatusCode::FAILURE;
474 IEvtSelector::Context&)
const {
475 return StatusCode::FAILURE;
502 DataObject*& refpObject)
507 (
"addMergedEventInfo: event store does not contain "\
508 "an EventInfo object!");
509 return StatusCode::RECOVERABLE;
513 auto mei = std::make_unique<MergedEventInfo> (*pEInfo,
520 (
const_cast<EventInfo*
>(pEInfo))->setEventID(
523 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
This class provides general information about an event.
uint32_t CLID
The Class ID type.
This class provides general information about an event.
#define FORWARD___DEBUG(METHOD)
a stream of events read from different selectors.
convert to and from a SG storable
This class contains trigger related information.
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
std::list< SG::TransientAddress * > tadList
the list of available selectors with their frequency range
std::string toString() const
bool add(const Trigger &)
std::vector< Trigger >::iterator iterator
std::vector< Trigger > m_trigs
std::vector< unsigned int > m_rangeEnd
std::vector< Trigger >::const_iterator const_iterator
iterator elementInRange(unsigned int)
a selector with an associated frequency
StatusCode createContext(IEvtSelector::Context *&pCtxt) const
Trigger(IEvtSelector *pSel, unsigned int firstEvt, unsigned int lastEvt)
const std::string & name() const
IEvtSelector * m_pSelector
StatusCode createAddress(IOpaqueAddress *&) const
unsigned int toRead() const
IEvtSelector & selector() const
std::string toString() const
IEvtSelector::Context * m_current
unsigned int m_firstEvent
IEvtSelector::Context & currentContext() const
unsigned int todo() const
StatusCode previous() const
Gaudi::Property< std::string > m_mergedEventInfoKey
virtual StatusCode setConversionSvc(IConversionSvc *pService) override
TriggerList::iterator currentTrigger() const
"intelligent" accessor to the above
Gaudi::Property< std::string > m_statusFileName
virtual StatusCode createContext(IEvtSelector::Context *&refpCtxt) const override
virtual StatusCode initialize() override
TriggerList::iterator setCurrentTrigger() const
choose current trigger at random. Actually modifies state (use mutables)
virtual StatusCode next(IEvtSelector::Context &refCtxt) const override
virtual SmartIF< IDataProviderSvc > & dataProvider() const override
virtual StatusCode createAddress(const IEvtSelector::Context &refCtxt, IOpaqueAddress *&) const override
virtual StatusCode rewind(IEvtSelector::Context &refCtxt) const override
Gaudi::Property< int > m_outputRunNumber
virtual StatusCode previous(IEvtSelector::Context &) const override
Gaudi::Property< std::vector< unsigned long > > m_eventNumbers
unsigned long getEventNo() const
setup and lookup m_evtsNotUsedSoFar. Returns next event no
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
virtual StatusCode last(IEvtSelector::Context &) const override
MixingEventSelector(const std::string &name, ISvcLocator *svc)
void decodeTrigger(const std::string &triggDescr)
functor that creates a Trigger object and adds it to m_trigList
virtual ~MixingEventSelector()
Gaudi::Property< std::string > m_randomStreamName
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Gaudi::Property< std::vector< std::string > > m_triggerListProp
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
virtual StatusCode releaseContext(IEvtSelector::Context *&refCtxt) const override
virtual const CLID & objType() const override
bool validTrigger() const
TriggerList m_trigList
the ingredients
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual StatusCode finalize() override
virtual StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual SmartIF< IAddressCreator > & addressCreator() const override
virtual StatusCode preLoadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
TriggerList::iterator m_pCurrentTrigger
the current trigger
ServiceHandle< StoreGateSvc > m_pEventStore
virtual StatusCode setDataProvider(IDataProviderSvc *pService) override
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
virtual long repSvcType() const override
unsigned long m_eventPos
the internal event number
void setUpTriggerList(Gaudi::Details::PropertyBase &trigList)
TriggerList property call-back.
std::unique_ptr< CLHEP::RandFlat > m_chooseRangeRand
ToolHandleArray< IAthenaSelectorTool > m_helperTools
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
virtual SmartIF< IConversionSvc > & conversionSvc() const override
virtual StatusCode resetCriteria(const std::string &cr, IEvtSelector::Context &c) const override
singleton-like access to IMessageSvc via open function and helper
std::string find(const std::string &s)
return a remapped string
IMessageSvc * getMessageSvc(bool quiet=false)
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
static constexpr CLID ID()