|
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"
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." );
65 declareProperty(
"MergedEventInfoKey",
67 "StoreGate key for output (merged) event info object. Default is MergedEventInfo ");
68 declareProperty(
"RndmGenSvc",
m_atRndmSvc,
"IAtRndmGenSvc controlling the order with which events are takes from streams");
69 declareProperty(
"RndmStreamName",
m_randomStreamName,
"IAtRndmGenSvc stream used as engine for our random distributions");
70 declareProperty(
"HelperTools",
m_helperTools,
"a collection of selector tools");
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 Gaudi::Utils::TypeNameString selTN(*iToken++);
149 SmartIF<IEvtSelector> pSelector(serviceLocator()->service(selTN));
153 unsigned int firstEvt(boost::lexical_cast<unsigned int>(*iToken++));
154 unsigned int lastEvt(boost::lexical_cast<unsigned int>(*iToken));
157 SmartIF<INamedInterface> pNamed(pSelector);
159 msg() <<
"decodeTrigger: added selector " << pNamed->name()
160 <<
" first event to be read " << firstEvt
161 <<
" last event to be read " << lastEvt <<
endmsg;
166 (
"decodeTrigger: Selector ["
167 << selTN.type() <<
'/' << selTN.name()
172 (
"decodeTrigger: Selector ["
173 << selTN.type() <<
'/' << selTN.name()
174 <<
"] can not be found or created");
176 }
catch (
const boost::bad_lexical_cast&
e) {
178 (
"decodeTrigger: Can't cast ["<< *iToken
179 <<
"] to double(frequency). SKIPPING");
183 (
"decodeTrigger: Badly formatted descriptor ["
184 << triggDescr <<
"]. SKIPPING");
189 #define FORWARD___DEBUG( METHOD )\
190 { ATH_MSG_VERBOSE ("forwarding " << #METHOD << " to service "\
191 << (validTrigger() ? currentTrigger()->name() : "NONE")); }
193 #define FORWARD___DEBUG( METHOD )
201 while (iTr !=
m_trigList.
end() && (
sc=(iTr++)->createContext(pctxt)).isSuccess()) ;
209 #ifdef DEBUG_OUTPUT_STATUS
212 while (
i != iEnd) outfile2 << (*
i++).
toString();
223 std::vector<ToolHandle<IAthenaSelectorTool> >::const_iterator
225 while (
i != iE) ((*
i++)->preNext()).
ignore();
231 while (
sc.isSuccess() && (
i != iE)) {
232 sc =(*i)->postNext();
233 if (
sc.isRecoverable())
234 ATH_MSG_INFO(
"Request skipping event from: " << (*i)->name());
235 else if (
sc.isFailure())
245 IOpaqueAddress*& pAddr)
const {
251 pAddr !=
nullptr) ? StatusCode::SUCCESS : StatusCode::FAILURE;
257 return StatusCode::SUCCESS;
265 return StatusCode::SUCCESS;
273 new GenericAddress (0, mclid),
275 auto dp = std::make_unique<SG::DataProxy> (std::move(tad),
280 return StatusCode::SUCCESS;
285 const EventContext&) {
286 return StatusCode::FAILURE;
289 #undef FORWARD___DEBUG
347 unsigned int nElem(m_trigs.size());
349 unsigned int trigTodo(iTrig->todo());
350 unsigned int trigIndex(iTrig -
begin());
352 string trigName(iTrig->name());
354 m_trigs.erase(iTrig);
355 removed = nElem > m_trigs.size();
360 for (
unsigned int i=trigIndex+1;
i<m_rangeEnd.size(); ++
i)
361 m_rangeEnd[
i] -= trigTodo;
363 m_rangeEnd.erase(m_rangeEnd.begin()+trigIndex);
380 for (
unsigned int i=0;
i<m_trigs.size(); ++
i) {
382 os << m_trigs[
i].name() <<
", already read=" << m_trigs[
i].read()
383 <<
", to do=" << m_trigs[
i].todo()
384 << (m_trigs[
i].done() ?
" done " :
" ")
385 <<
" - endRange: " << m_rangeEnd[
i] <<
'\n';
388 return string(
os.str());
393 iterator iTrig(m_trigs.begin()), eTrig(m_trigs.end());
394 std::vector<unsigned int>::const_iterator iRange(m_rangeEnd.begin());
395 std::vector<unsigned int>::const_iterator eRange(m_rangeEnd.end());
396 while (eRange != iRange && eTrig != iTrig &&
i > *iRange){
403 <<
"elementInRange: rangeEnd=" << *iRange
404 <<
" matches i=" <<
i <<
endmsg;
411 unsigned int firstEvt,
412 unsigned int lastEvt):
413 m_pSelector(pSel), m_firstEvent(firstEvt),
414 m_toRead(lastEvt+1), m_todo(m_toRead-firstEvt), m_reads(0),
420 if (
nullptr == m_current) {
421 IEvtSelector::Context* pTmp(
nullptr);
423 throw GaudiException(
"MixingEventSelector::Trigger::currentContext(): can't create context",
424 name(),StatusCode::FAILURE);
433 os <<
name() <<
", already read=" << m_reads
434 <<
", to do=" << todo() << endl;
435 return string(
os.str());
443 while (
sc.isSuccess() && (++m_reads < m_firstEvent))
452 return selector().previous(currentContext());
458 StatusCode::FAILURE :
478 return (toRead() <= m_reads);
483 return StatusCode::FAILURE;
486 return StatusCode::FAILURE;
489 return StatusCode::FAILURE;
492 return StatusCode::FAILURE;
495 return StatusCode::FAILURE;
498 return StatusCode::FAILURE;
501 IEvtSelector::Context&)
const {
502 return StatusCode::FAILURE;
529 DataObject*& refpObject)
534 (
"addMergedEventInfo: event store does not contain "\
535 "an EventInfo object!");
536 return StatusCode::RECOVERABLE;
540 auto mei = std::make_unique<MergedEventInfo> (*pEInfo,
547 (
const_cast<EventInfo*
>(pEInfo))->setEventID(
550 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
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
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
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
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
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
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