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"
27#include <boost/tokenizer.hpp>
38using boost::tokenizer;
39using boost::char_separator;
42#ifdef DEBUG_OUTPUT_STATUS
43ofstream outfile2(
"status.txt");
66 if(
nullptr == collEng ) {
68 return StatusCode::FAILURE;
78 return StatusCode::SUCCESS;
86 tool->preFinalize().ignore();
90 ofstream outfile(fname.c_str());
94 while (i != iEnd) outfile << (*i++).toString();
95 }
else if (!fname.empty()) {
99 return StatusCode::SUCCESS;
105 using std::placeholders::_1;
115 typedef tokenizer<char_separator<char> > Tokenizer;
116 Tokenizer tokens(triggDescr, char_separator<char>(
" :"));
118 if ( (distance(tokens.begin(), tokens.end()) == 3) ||
119 (distance(tokens.begin(), tokens.end()) == 3) ){
120 Tokenizer::iterator iToken(tokens.begin());
121 Gaudi::Utils::TypeNameString selTN(*iToken++);
123 SmartIF<IEvtSelector> pSelector(serviceLocator()->service(selTN));
127 unsigned int firstEvt{};
128 unsigned int lastEvt{};
129 auto string1 = *iToken++;
130 auto string2 = *iToken;
131 auto [ptr1, ec1] = std::from_chars(string1.data(), string1.data() + string1.size(), firstEvt);
132 auto [ptr2, ec2] = std::from_chars(string2.data(), string2.data() + string2.size(), lastEvt);
133 if ( ec1 != std::errc() || ec2 != std::errc() ) {
134 ATH_MSG_ERROR(
"decodeTrigger: Can't cast ["<< string1 <<
" " << string2 <<
"] to double(frequency). SKIPPING");
137 if (msgLvl(MSG::DEBUG)) {
138 SmartIF<INamedInterface> pNamed(pSelector);
140 msg() <<
"decodeTrigger: added selector " << pNamed->name()
141 <<
" first event to be read " << firstEvt
142 <<
" last event to be read " << lastEvt <<
endmsg;
147 (
"decodeTrigger: Selector ["
148 << selTN.type() <<
'/' << selTN.name()
154 (
"decodeTrigger: Selector ["
155 << selTN.type() <<
'/' << selTN.name()
156 <<
"] can not be found or created");
160 (
"decodeTrigger: Badly formatted descriptor ["
161 << triggDescr <<
"]. SKIPPING");
166#define FORWARD___DEBUG( METHOD )\
167 { ATH_MSG_VERBOSE ("forwarding " << #METHOD << " to service "\
168 << (validTrigger() ? currentTrigger()->name() : "NONE")); }
170#define FORWARD___DEBUG( METHOD )
177 StatusCode
sc(StatusCode::FAILURE);
178 while (iTr !=
m_trigList.end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
184 StatusCode
sc(StatusCode::FAILURE);
186#ifdef DEBUG_OUTPUT_STATUS
189 while (i != iEnd) outfile2 << (*i++).toString();
200 std::vector<ToolHandle<IAthenaSelectorTool> >::const_iterator
202 while (i != iE) ((*i++)->preNext()).ignore();
208 while (
sc.isSuccess() && (i != iE)) {
209 sc =(*i)->postNext();
210 if (
sc.isRecoverable())
211 ATH_MSG_INFO(
"Request skipping event from: " << (*i)->name());
212 else if (
sc.isFailure())
222 IOpaqueAddress*& pAddr)
const {
228 pAddr !=
nullptr) ? StatusCode::SUCCESS : StatusCode::FAILURE;
234 return StatusCode::SUCCESS;
242 return StatusCode::SUCCESS;
250 new GenericAddress (0, mclid),
252 auto dp = std::make_unique<SG::DataProxy> (std::move(tad),
257 return StatusCode::SUCCESS;
262 const EventContext&) {
263 return StatusCode::FAILURE;
266#undef FORWARD___DEBUG
312 if (log.level() <= MSG::DEBUG) {
313 log << MSG::DEBUG <<
"add: trigger "
324 unsigned int nElem(
m_trigs.size());
326 unsigned int trigTodo(iTrig->todo());
327 unsigned int trigIndex(iTrig -
begin());
329 string trigName(iTrig->name());
332 removed = nElem >
m_trigs.size();
337 for (
unsigned int i=trigIndex+1; i<
m_rangeEnd.size(); ++i)
343 if (log.level() <= MSG::DEBUG) {
344 log << MSG::DEBUG <<
"remove: trigger "
357 for (
unsigned int i=0; i<
m_trigs.size(); ++i) {
360 <<
", to do=" <<
m_trigs[i].todo()
361 << (
m_trigs[i].done() ?
" done " :
" ")
365 return string(os.str());
371 std::vector<unsigned int>::const_iterator iRange(
m_rangeEnd.begin());
372 std::vector<unsigned int>::const_iterator eRange(
m_rangeEnd.end());
373 while (eRange != iRange && eTrig != iTrig && i > *iRange){
378 if (log.level() <= MSG::VERBOSE) {
379 if (eRange != iRange) log << MSG::VERBOSE
380 <<
"elementInRange: rangeEnd=" << *iRange
381 <<
" matches i=" << i <<
endmsg;
388 unsigned int firstEvt,
389 unsigned int lastEvt):
398 IEvtSelector::Context* pTmp(
nullptr);
400 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
401 name(),StatusCode::FAILURE);
411 <<
", to do=" <<
todo() << endl;
412 return string(os.str());
417 StatusCode
sc(StatusCode::FAILURE);
435 StatusCode::FAILURE :
441 StatusCode
sc(StatusCode::FAILURE);
460 return StatusCode::FAILURE;
463 return StatusCode::FAILURE;
466 return StatusCode::FAILURE;
469 return StatusCode::FAILURE;
472 return StatusCode::FAILURE;
475 return StatusCode::FAILURE;
478 IEvtSelector::Context&)
const {
479 return StatusCode::FAILURE;
506 DataObject*& refpObject)
511 (
"addMergedEventInfo: event store does not contain "\
512 "an EventInfo object!");
513 return StatusCode::RECOVERABLE;
517 auto mei = std::make_unique<MergedEventInfo> (*pEInfo,
524 (
const_cast<EventInfo*
>(pEInfo))->setEventID(
527 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
void decodeTrigger(std::string triggDescr)
functor that creates a Trigger object and adds it to m_trigList
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
virtual StatusCode last(IEvtSelector::Context &) const override
MixingEventSelector(const std::string &name, ISvcLocator *svc)
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)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)