 |
ATLAS Offline Software
|
Go to the documentation of this file.
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>
38 using boost::tokenizer;
39 using boost::char_separator;
42 #ifdef DEBUG_OUTPUT_STATUS
43 ofstream outfile2(
"status.txt");
48 m_pCurrentTrigger(m_trigList.
end()),
49 m_pEventStore(
"StoreGateSvc",
name )
66 if(
nullptr == collEng ) {
68 return StatusCode::FAILURE;
78 return StatusCode::SUCCESS;
86 tool->preFinalize().ignore();
95 }
else if (!
fname.empty()) {
99 return StatusCode::SUCCESS;
105 using std::placeholders::_1;
115 typedef tokenizer<char_separator<char> >
Tokenizer;
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");
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 )
178 while (iTr !=
m_trigList.
end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
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
324 unsigned int nElem(m_trigs.size());
326 unsigned int trigTodo(iTrig->todo());
327 unsigned int trigIndex(iTrig -
begin());
329 string trigName(iTrig->name());
331 m_trigs.erase(iTrig);
332 removed = nElem > m_trigs.size();
337 for (
unsigned int i=trigIndex+1;
i<m_rangeEnd.size(); ++
i)
338 m_rangeEnd[
i] -= trigTodo;
340 m_rangeEnd.erase(m_rangeEnd.begin()+trigIndex);
357 for (
unsigned int i=0;
i<m_trigs.size(); ++
i) {
359 os << m_trigs[
i].name() <<
", already read=" << m_trigs[
i].read()
360 <<
", to do=" << m_trigs[
i].todo()
361 << (m_trigs[
i].done() ?
" done " :
" ")
362 <<
" - endRange: " << m_rangeEnd[
i] <<
'\n';
365 return string(
os.str());
370 iterator iTrig(m_trigs.begin()), eTrig(m_trigs.end());
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){
380 <<
"elementInRange: rangeEnd=" << *iRange
381 <<
" matches i=" <<
i <<
endmsg;
388 unsigned int firstEvt,
389 unsigned int lastEvt):
390 m_pSelector(pSel), m_firstEvent(firstEvt),
391 m_toRead(lastEvt+1), m_todo(m_toRead-firstEvt), m_reads(0),
397 if (
nullptr == m_current) {
398 IEvtSelector::Context* pTmp(
nullptr);
400 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
401 name(),StatusCode::FAILURE);
410 os <<
name() <<
", already read=" << m_reads
411 <<
", to do=" << todo() << endl;
412 return string(
os.str());
420 while (
sc.isSuccess() && (++m_reads < m_firstEvent))
429 return selector().previous(currentContext());
435 StatusCode::FAILURE :
455 return (toRead() <= m_reads);
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;
JetConstituentVector::iterator iterator
TriggerList::iterator m_pCurrentTrigger
the current trigger
TriggerList m_trigList
the ingredients
MixingEventSelector(const std::string &name, ISvcLocator *svc)
std::string toString() const
virtual SmartIF< IConversionSvc > & conversionSvc() const override
singleton-like access to IMessageSvc via open function and helper
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
std::string find(const std::string &s)
return a remapped string
virtual long repSvcType() const override
convert to and from a SG storable
Gaudi::Property< std::string > m_statusFileName
virtual const CLID & objType() const override
virtual StatusCode releaseContext(IEvtSelector::Context *&refCtxt) const override
std::vector< unsigned int > m_rangeEnd
virtual StatusCode setDataProvider(IDataProviderSvc *pService) override
virtual StatusCode last(IEvtSelector::Context &) const override
Gaudi::Property< std::vector< unsigned long > > m_eventNumbers
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
This class contains trigger related information.
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
unsigned int todo() const
unsigned int todo() const
virtual StatusCode next(IEvtSelector::Context &refCtxt) const override
TriggerList::iterator currentTrigger() const
"intelligent" accessor to the above
virtual StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
unsigned long getEventNo() const
setup and lookup m_evtsNotUsedSoFar. Returns next event no
unsigned long m_eventPos
the internal event number
IMessageSvc * getMessageSvc(bool quiet=false)
ToolHandleArray< IAthenaSelectorTool > m_helperTools
virtual StatusCode setConversionSvc(IConversionSvc *pService) override
iterator elementInRange(unsigned int)
StatusCode previous() const
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
This class provides general information about an event. It extends MergedEventInfo with a list of sub...
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
std::vector< Trigger >::iterator iterator
void decodeTrigger(std::string triggDescr)
functor that creates a Trigger object and adds it to m_trigList
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
std::unique_ptr< CLHEP::RandFlat > m_chooseRangeRand
boost::tokenizer< Separator > Tokenizer
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Gaudi::Property< std::string > m_randomStreamName
ServiceHandle< StoreGateSvc > m_pEventStore
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual SmartIF< IDataProviderSvc > & dataProvider() const override
#define FORWARD___DEBUG(METHOD)
virtual StatusCode rewind(IEvtSelector::Context &refCtxt) const override
AthROOTErrorHandlerSvc * svc
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
TriggerList::iterator setCurrentTrigger() const
choose current trigger at random. Actually modifies state (use mutables)
uint32_t CLID
The Class ID type.
std::vector< Trigger > m_trigs
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
void setUpTriggerList(Gaudi::Details::PropertyBase &trigList)
TriggerList property call-back.
This class provides general information about an event. Event information is provided by the accessor...
virtual StatusCode finalize() override
std::string toString() const
virtual StatusCode previous(IEvtSelector::Context &) const override
virtual ~MixingEventSelector()
a selector with an associated frequency
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
bool add(const Trigger &)
std::vector< Trigger >::const_iterator const_iterator
const std::string & name() const
#define ATH_MSG_WARNING(x)
virtual StatusCode initialize() override
virtual StatusCode createContext(IEvtSelector::Context *&refpCtxt) const override
virtual StatusCode preLoadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
Trigger(IEvtSelector *pSel, unsigned int firstEvt, unsigned int lastEvt)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
std::list< SG::TransientAddress * > tadList
virtual StatusCode createAddress(const IEvtSelector::Context &refCtxt, IOpaqueAddress *&) const override
StatusCode createContext(IEvtSelector::Context *&pCtxt) const
virtual SmartIF< IAddressCreator > & addressCreator() const override
Define macros for attributes used to control the static checker.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
a stream of events read from different selectors.
IEvtSelector::Context & currentContext() const
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
StatusCode createAddress(IOpaqueAddress *&) const
Gaudi::Property< std::string > m_mergedEventInfoKey
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
bool validTrigger() const
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
virtual StatusCode resetCriteria(const std::string &cr, IEvtSelector::Context &c) const override
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Gaudi::Property< int > m_outputRunNumber
Gaudi::Property< std::vector< std::string > > m_triggerListProp
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override