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"
41#ifdef DEBUG_OUTPUT_STATUS
42ofstream outfile2(
"status.txt");
65 if(
nullptr == collEng ) {
67 return StatusCode::FAILURE;
77 return StatusCode::SUCCESS;
85 tool->preFinalize().ignore();
89 ofstream outfile(fname.c_str());
93 while (i != iEnd) outfile << (*i++).
toString();
94 }
else if (!fname.empty()) {
98 return StatusCode::SUCCESS;
104 using std::placeholders::_1;
116 if (tokens.size() == 3) {
117 auto iToken = tokens.begin();
118 Gaudi::Utils::TypeNameString selTN(*iToken++);
120 SmartIF<IEvtSelector> pSelector(serviceLocator()->service(selTN));
124 unsigned int firstEvt{};
125 unsigned int lastEvt{};
126 auto string1 = *iToken++;
127 auto string2 = *iToken;
128 auto [ptr1, ec1] = std::from_chars(string1.data(), string1.data() + string1.size(), firstEvt);
129 auto [ptr2, ec2] = std::from_chars(string2.data(), string2.data() + string2.size(), lastEvt);
130 if ( ec1 != std::errc() || ec2 != std::errc() ) {
131 ATH_MSG_ERROR(
"decodeTrigger: Can't cast [{} {}] to double(frequency). SKIPPING",
135 if (msgLvl(MSG::DEBUG)) {
136 SmartIF<INamedInterface> pNamed(pSelector);
138 msg() <<
"decodeTrigger: added selector " << pNamed->name()
139 <<
" first event to be read " << firstEvt
140 <<
" last event to be read " << lastEvt <<
endmsg;
145 (
"decodeTrigger: Selector [{}/{}] not added",
146 selTN.type(), selTN.name());
151 (
"decodeTrigger: Selector [{}/{}] can not be found or created",
152 selTN.type(), selTN.name());
156 (
"decodeTrigger: Badly formatted descriptor [{}]. SKIPPING",
163#define FORWARD___DEBUG( METHOD )\
164 { ATH_MSG_VERBOSE ("forwarding " << #METHOD << " to service "\
165 << (validTrigger() ? currentTrigger()->name() : "NONE")); }
167#define FORWARD___DEBUG( METHOD )
174 StatusCode
sc(StatusCode::FAILURE);
175 while (iTr !=
m_trigList.end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
181 StatusCode
sc(StatusCode::FAILURE);
183#ifdef DEBUG_OUTPUT_STATUS
186 while (i != iEnd) outfile2 << (*i++).
toString();
197 std::vector<ToolHandle<IAthenaSelectorTool> >::const_iterator
199 while (i != iE) ((*i++)->preNext()).ignore();
205 while (
sc.isSuccess() && (i != iE)) {
206 sc =(*i)->postNext();
207 if (
sc.isRecoverable())
208 ATH_MSG_INFO(
"Request skipping event from: {}", (*i)->name());
209 else if (
sc.isFailure())
219 IOpaqueAddress*& pAddr)
const {
225 pAddr !=
nullptr) ? StatusCode::SUCCESS : StatusCode::FAILURE;
231 return StatusCode::SUCCESS;
239 return StatusCode::SUCCESS;
247 new GenericAddress (0, mclid),
249 auto dp = std::make_unique<SG::DataProxy> (std::move(tad),
254 return StatusCode::SUCCESS;
259 const EventContext&) {
260 return StatusCode::FAILURE;
263#undef FORWARD___DEBUG
309 if (log.level() <= MSG::DEBUG) {
310 log << MSG::DEBUG <<
"add: trigger "
321 unsigned int nElem(
m_trigs.size());
323 unsigned int trigTodo(iTrig->todo());
324 unsigned int trigIndex(iTrig -
begin());
326 string trigName(iTrig->name());
329 removed = nElem >
m_trigs.size();
334 for (
unsigned int i=trigIndex+1; i<
m_rangeEnd.size(); ++i)
340 if (log.level() <= MSG::DEBUG) {
341 log << MSG::DEBUG <<
"remove: trigger "
354 for (
unsigned int i=0; i<
m_trigs.size(); ++i) {
356 std::println (os,
"{}, already read={}, to do={}{} - endRange: {}",
358 (
m_trigs[i].done() ?
" done " :
" "),
362 return string(os.str());
368 std::vector<unsigned int>::const_iterator iRange(
m_rangeEnd.begin());
369 std::vector<unsigned int>::const_iterator eRange(
m_rangeEnd.end());
370 while (eRange != iRange && eTrig != iTrig && i > *iRange){
375 if (log.level() <= MSG::VERBOSE) {
376 if (eRange != iRange) log << MSG::VERBOSE
377 <<
"elementInRange: rangeEnd=" << *iRange
378 <<
" matches i=" << i <<
endmsg;
385 unsigned int firstEvt,
386 unsigned int lastEvt):
395 IEvtSelector::Context* pTmp(
nullptr);
397 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
398 name(),StatusCode::FAILURE);
407 std::println (os,
"{}, already read={}, to do={}",
name(),
m_reads,
todo());
408 return string(os.str());
413 StatusCode
sc(StatusCode::FAILURE);
430 StatusCode::FAILURE :
436 StatusCode
sc(StatusCode::FAILURE);
451 return StatusCode::FAILURE;
454 return StatusCode::FAILURE;
457 return StatusCode::FAILURE;
460 return StatusCode::FAILURE;
463 return StatusCode::FAILURE;
466 return StatusCode::FAILURE;
469 IEvtSelector::Context&)
const {
470 return StatusCode::FAILURE;
497 DataObject*& refpObject)
502 (
"addMergedEventInfo: event store does not contain "\
503 "an EventInfo object!");
504 return StatusCode::RECOVERABLE;
508 auto mei = std::make_unique<MergedEventInfo> (*pEInfo,
515 (
const_cast<EventInfo*
>(pEInfo))->setEventID(
518 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(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.
std::string toString(const float number)
Pipe a number to a string.
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...
This class provides general information about an event.
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
unsigned int todo() const
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)
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
static constexpr CLID ID()