![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
11 #include "EventInfo/EventInfo.h"
21 #include "GaudiKernel/GaudiException.h"
22 #include "GaudiKernel/ListItem.h"
23 #include "GaudiKernel/MsgStream.h"
24 #include "GaudiKernel/GenericAddress.h"
25 #include "CLHEP/Random/RandFlat.h"
26 #include <boost/lexical_cast.hpp>
27 #include <boost/tokenizer.hpp>
38 using boost::lexical_cast;
39 using boost::tokenizer;
40 using boost::char_separator;
43 #ifdef DEBUG_OUTPUT_STATUS
44 ofstream outfile2(
"status.txt");
50 m_trigList(), m_pCurrentTrigger(m_trigList.
end()),
52 m_pEventStore(
"StoreGateSvc",
name ),
53 m_atRndmSvc(
"AtRndmGenSvc",
name),
54 m_randomStreamName(
"MixingEventSelectorStream"),
55 m_chooseRangeRand(nullptr)
58 "list of triggers (streams) to be used. Format is SelectorType/SelectorName:firstEventToUse:lastEventToUse. One assumes events are consecutively numbered.");
62 "list of event numbers to be used for output stream. If list empty or not long enough, event numbers are assigned consucutively after last one in list");
64 "Name of the file recording the last event used and how many were available for each stream. Default is to produce no file." );
67 "StoreGate key for output (merged) event info object. Default is MergedEventInfo ");
87 if(
nullptr == collEng ) {
89 return StatusCode::FAILURE;
95 std::vector<ToolHandle<IAthenaSelectorTool> >
::iterator
97 while (
sc.isSuccess() && (
i != iE))
sc = (*
i++)->postInitialize();
107 std::vector<ToolHandle<IAthenaSelectorTool> >
::iterator
109 while (
i != iE) ((*
i++)->preFinalize()).
ignore();
117 }
else if (!
fname.empty()) {
130 using std::placeholders::_1;
140 typedef tokenizer<char_separator<char> >
Tokenizer;
147 ListItem selTN(*iToken++);
148 const bool CREATEIF(
true);
150 IEvtSelector* pSelector(
nullptr);
151 if ((serviceLocator()->service(selTN.type(), selTN.name(), pSelector, CREATEIF)).isSuccess()) {
153 if (
nullptr !=
dynamic_cast<IEvtSelector*
>(pSelector) ) {
156 unsigned int firstEvt(boost::lexical_cast<unsigned int>(*iToken++));
157 unsigned int lastEvt(boost::lexical_cast<unsigned int>(*iToken));
160 INamedInterface *pNamed(
dynamic_cast<INamedInterface*
>(pSelector));
161 if (
nullptr != pNamed) {
162 msg() <<
"decodeTrigger: added selector " << pNamed->name()
163 <<
" first event to be read " << firstEvt
164 <<
" last event to be read " << lastEvt <<
endmsg;
169 (
"decodeTrigger: Selector ["
170 << selTN.type() <<
'/' << selTN.name()
180 (
"decodeTrigger: Selector ["
181 << selTN.type() <<
'/' << selTN.name()
182 <<
"] not an IEvtSelector, not added");
186 (
"decodeTrigger: Selector ["
187 << selTN.type() <<
'/' << selTN.name()
188 <<
"] can not be found or created");
190 }
catch (
const boost::bad_lexical_cast&
e) {
192 (
"decodeTrigger: Can't cast ["<< *iToken
193 <<
"] to double(frequency). SKIPPING");
197 (
"decodeTrigger: Badly formatted descriptor ["
198 << triggDescr <<
"]. SKIPPING");
203 #define FORWARD___DEBUG( METHOD )\
204 { ATH_MSG_VERBOSE ("forwarding " << #METHOD << " to service "\
205 << (validTrigger() ? currentTrigger()->name() : "NONE")); }
207 #define FORWARD___DEBUG( METHOD )
215 while (iTr !=
m_trigList.
end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
223 #ifdef DEBUG_OUTPUT_STATUS
226 while (
i != iEnd) outfile2 << (*
i++).
toString();
237 std::vector<ToolHandle<IAthenaSelectorTool> >::const_iterator
239 while (
i != iE) ((*
i++)->preNext()).
ignore();
245 while (
sc.isSuccess() && (
i != iE)) {
246 sc =(*i)->postNext();
247 if (
sc.isRecoverable())
248 ATH_MSG_INFO(
"Request skipping event from: " << (*i)->name());
249 else if (
sc.isFailure())
259 IOpaqueAddress*& pAddr)
const {
265 pAddr !=
nullptr) ? StatusCode::SUCCESS : StatusCode::FAILURE;
271 return StatusCode::SUCCESS;
279 return StatusCode::SUCCESS;
287 new GenericAddress (0, mclid),
289 auto dp = std::make_unique<SG::DataProxy> (std::move(tad),
294 return StatusCode::SUCCESS;
299 const EventContext&) {
300 return StatusCode::FAILURE;
303 #undef FORWARD___DEBUG
361 unsigned int nElem(m_trigs.size());
363 unsigned int trigTodo(iTrig->todo());
364 unsigned int trigIndex(iTrig -
begin());
366 string trigName(iTrig->name());
368 m_trigs.erase(iTrig);
369 removed = nElem > m_trigs.size();
374 for (
unsigned int i=trigIndex+1;
i<m_rangeEnd.size(); ++
i)
375 m_rangeEnd[
i] -= trigTodo;
377 m_rangeEnd.erase(m_rangeEnd.begin()+trigIndex);
394 for (
unsigned int i=0;
i<m_trigs.size(); ++
i) {
396 os << m_trigs[
i].name() <<
", already read=" << m_trigs[
i].read()
397 <<
", to do=" << m_trigs[
i].todo()
398 << (m_trigs[
i].done() ?
" done " :
" ")
399 <<
" - endRange: " << m_rangeEnd[
i] <<
'\n';
402 return string(
os.str());
407 iterator iTrig(m_trigs.begin()), eTrig(m_trigs.end());
408 std::vector<unsigned int>::const_iterator iRange(m_rangeEnd.begin());
409 std::vector<unsigned int>::const_iterator eRange(m_rangeEnd.end());
410 while (eRange != iRange && eTrig != iTrig &&
i > *iRange){
417 <<
"elementInRange: rangeEnd=" << *iRange
418 <<
" matches i=" <<
i <<
endmsg;
425 unsigned int firstEvt,
426 unsigned int lastEvt):
427 m_pSelector(pSel), m_firstEvent(firstEvt),
428 m_toRead(lastEvt+1), m_todo(m_toRead-firstEvt), m_reads(0),
434 if (
nullptr == m_current) {
435 IEvtSelector::Context* pTmp(
nullptr);
437 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
438 name(),StatusCode::FAILURE);
448 os <<
name() <<
", already read=" << m_reads
449 <<
", to do=" << todo() << endl;
450 return string(
os.str());
458 while (
sc.isSuccess() && (++m_reads < m_firstEvent))
467 return selector().previous(currentContext());
473 StatusCode::FAILURE :
493 return (toRead() <= m_reads);
498 return StatusCode::FAILURE;
501 return StatusCode::FAILURE;
504 return StatusCode::FAILURE;
507 return StatusCode::FAILURE;
510 return StatusCode::FAILURE;
513 return StatusCode::FAILURE;
516 IEvtSelector::Context&)
const {
517 return StatusCode::FAILURE;
544 DataObject*& refpObject)
549 (
"addMergedEventInfo: event store does not contain "\
550 "an EventInfo object!");
551 return StatusCode::RECOVERABLE;
555 auto mei = std::make_unique<MergedEventInfo> (*pEInfo,
562 (
const_cast<EventInfo*
>(pEInfo))->setEventID(
565 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
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
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
DataObject * asStorable(T *pObject)
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
StringArrayProperty m_triggerListProp
the recipe
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
get all new addresses from Provider for this Event.
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)
IntegerProperty m_outputRunNumber
ToolHandleArray< IAthenaSelectorTool > m_helperTools
virtual StatusCode setConversionSvc(IConversionSvc *pService) override
iterator elementInRange(unsigned int)
StatusCode previous() const
static const CLID & ID()
the CLID of T
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.
boost::tokenizer< Separator > Tokenizer
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
::StatusCode StatusCode
StatusCode definition for legacy code.
UnsignedLongArrayProperty m_eventNumbers
use these as event numbers
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
CLHEP::RandFlat * m_chooseRangeRand
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
update a transient Address The ctx argument will give the current event information.
StringProperty m_mergedEventInfoKey
SG key of MergedEventInfo.
void setUpTriggerList(Gaudi::Details::PropertyBase &trigList)
TriggerList property call-back.
StringProperty m_randomStreamName
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
the list of available selectors with their frequency range
#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
get all addresses from Provider : Called before Begin Event
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
StringProperty m_statusFileName
optional stream output snapshot
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
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
bool validTrigger() const
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
StoreGateSvc_t m_pEventStore
virtual StatusCode resetCriteria(const std::string &cr, IEvtSelector::Context &c) const override
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override