Skip to content
Snippets Groups Projects
Commit dfa9d351 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

expanded EventContext and EventIDBase

the EventContext class needs to be expanded in two ways
- bring in event identifying information (event#, run#, timestamp,
  lumi#, etc)
- some experiment dependent ptr for other stuff

See merge request !103
parents 9454bdfa 6f4bd16c
No related branches found
No related tags found
No related merge requests found
#ifndef GAUDIKERNEL_EVENTCONTEXT_H #ifndef GAUDIKERNEL_EVENTCONTEXT_H
#define GAUDIKERNEL_EVENTCONTEXT_H #define GAUDIKERNEL_EVENTCONTEXT_H 1
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include <limits>
#include "GaudiKernel/EventIDBase.h"
/** @class EventContext EventContext.h GaudiKernel/EventContext.h /** @class EventContext EventContext.h GaudiKernel/EventContext.h
* *
...@@ -18,41 +20,40 @@ ...@@ -18,41 +20,40 @@
* @date 2012 * @date 2012
**/ **/
class IProxyDict;
class EventContext{ class EventContext{
public: public:
typedef size_t ContextID_t; typedef size_t ContextID_t;
typedef long int ContextEvt_t; typedef size_t ContextEvt_t;
static const ContextID_t INVALID_CONTEXT_ID = 99999; static const ContextID_t INVALID_CONTEXT_ID = std::numeric_limits<ContextID_t>::max();
static const ContextEvt_t INVALID_CONTEXT_EVT = -1; static const ContextEvt_t INVALID_CONTEXT_EVT = std::numeric_limits<ContextEvt_t>::max();
EventContext(): EventContext() {};
m_evt_num(INVALID_CONTEXT_EVT),
m_evt_slot(INVALID_CONTEXT_ID),
m_valid(false),
m_evt_failed(false){};
EventContext(const ContextEvt_t& e, const ContextID_t& s=INVALID_CONTEXT_ID) EventContext(const ContextEvt_t& e, const ContextID_t& s=INVALID_CONTEXT_ID)
:m_evt_num(e), m_evt_slot(s), m_evt_failed(false){ :m_evt_num(e), m_evt_slot(s), m_evt_failed(false) {
m_valid = (e<0 || s == INVALID_CONTEXT_ID) ? false: true; m_valid = (e == INVALID_CONTEXT_EVT || s == INVALID_CONTEXT_ID) ? false: true;
} }
ContextEvt_t evt() const { return m_evt_num; } ContextEvt_t evt() const { return m_evt_num; }
ContextID_t slot() const { return m_evt_slot; } ContextID_t slot() const { return m_evt_slot; }
bool valid() const {return m_valid;} bool valid() const {return m_valid;}
bool evtFail() const { return m_evt_failed; } bool evtFail() const { return m_evt_failed; }
IProxyDict* proxy() const { return m_proxy; }
const EventIDBase& eventID() const { return m_eid; }
void set(const ContextEvt_t& e=0, const ContextID_t& s=INVALID_CONTEXT_ID, void set(const ContextEvt_t& e=0, const ContextID_t& s=INVALID_CONTEXT_ID,
const bool f=false) { const bool f=false) {
m_valid = (e<0 || s == INVALID_CONTEXT_ID) ? false : true; m_valid = (e == INVALID_CONTEXT_EVT || s == INVALID_CONTEXT_ID) ? false : true;
m_evt_num = e; m_evt_num = e;
m_evt_slot = s; m_evt_slot = s;
m_evt_failed = f; m_evt_failed = f;
} }
void setEvt(const ContextEvt_t& e) { void setEvt(const ContextEvt_t& e) {
if (e < 0) setValid(false); if (e == INVALID_CONTEXT_EVT) setValid(false);
m_evt_num = e; m_evt_num = e;
} }
...@@ -73,6 +74,14 @@ public: ...@@ -73,6 +74,14 @@ public:
} }
} }
void setEventID(const EventIDBase& e) {
m_eid = e;
}
void setProxy(IProxyDict* prx) {
m_proxy = prx;
}
EventContext& operator=(const EventContext& c) { EventContext& operator=(const EventContext& c) {
m_evt_num = c.m_evt_num; m_evt_num = c.m_evt_num;
m_evt_slot = c.m_evt_slot; m_evt_slot = c.m_evt_slot;
...@@ -80,12 +89,17 @@ public: ...@@ -80,12 +89,17 @@ public:
m_evt_failed = c.m_evt_failed; m_evt_failed = c.m_evt_failed;
return *this; return *this;
} }
private: private:
ContextEvt_t m_evt_num; ContextEvt_t m_evt_num {INVALID_CONTEXT_EVT};
ContextID_t m_evt_slot; ContextID_t m_evt_slot {INVALID_CONTEXT_ID};
bool m_valid; bool m_valid {false};
bool m_evt_failed; bool m_evt_failed {false};
IProxyDict* m_proxy {0};
EventIDBase m_eid {};
}; };
inline std::ostream& operator<<( std::ostream& os, const EventContext& ctx ) { inline std::ostream& operator<<( std::ostream& os, const EventContext& ctx ) {
......
#ifndef GAUDIKERNEL_EVENTIDBASE_H
#define GAUDIKERNEL_EVENTIDBASE_H 1
/**
* @file EventIDBase.h
*
* @brief This class provides a unique identification for each event,
* in terms of run/event number and/or a time stamp.
*
* @author RD Schaffer <R.D.Schaffer@cern.ch>
* @author Paolo Calafiura <pcalafiura@lbl.gov>
*
*/
//<<<<<< INCLUDES >>>>>>
#include <iostream>
#include <stdint.h>
/**
* @class EventIDBase
*
* @brief This class provides a unique identification for each event,
* in terms of run/event number and/or a time stamp.
*
*/
class EventIDBase {
public:
typedef unsigned int number_type;
/// \name structors
//@{
EventIDBase() {};
EventIDBase(number_type run_number,
uint64_t event_number,
number_type time_stamp=0,
number_type time_stamp_ns_offset=0,
number_type lumi_block=0,
number_type bunch_crossing_id=0);
// Use default copy constructor.
virtual ~EventIDBase();
//@}
/// run number - 32 bit unsigned
number_type run_number () const { return m_run_number; }
/// event number - 64 bit unsigned
uint64_t event_number () const { return m_event_number; }
/// time stamp - posix time in seconds from 1970, 32 bit unsigned
number_type time_stamp () const { return m_time_stamp; }
/// time stamp ns - ns time offset for time_stamp, 32 bit unsigned
number_type time_stamp_ns_offset () const { return m_time_stamp_ns_offset; }
/// luminosity block identifier, 32 bit unsigned
number_type lumi_block () const { return m_lumiBlock; }
/// bunch crossing ID, 32 bit unsigned
number_type bunch_crossing_id () const { return m_bunch_crossing_id; }
/// set run number
void set_run_number (number_type runNumber) { m_run_number = runNumber; }
/// set event number
void set_event_number (uint64_t eventNumber) { m_event_number = eventNumber; }
/// set time stamp
void set_time_stamp (number_type timeStamp) { m_time_stamp = timeStamp; }
/// set time stamp in ns
void set_time_stamp_ns_offset (number_type timeStampNs) {
m_time_stamp_ns_offset = timeStampNs;
}
/// set luminosity block identifier
void set_lumi_block (number_type lumiBlock) { m_lumiBlock = lumiBlock; }
/// set bunch crossing ID
void set_bunch_crossing_id (number_type bcid) { m_bunch_crossing_id = bcid; }
/// Comparison operators
friend bool operator<(const EventIDBase& lhs, const EventIDBase& rhs);
friend bool operator>(const EventIDBase& lhs, const EventIDBase& rhs);
friend bool operator==(const EventIDBase& lhs, const EventIDBase& rhs);
friend bool operator!=(const EventIDBase& lhs, const EventIDBase& rhs);
friend bool operator<=(const EventIDBase& lhs, const EventIDBase& rhs);
friend bool operator>=(const EventIDBase& lhs, const EventIDBase& rhs);
/// Extraction operators
friend std::ostream& operator<<(std::ostream& os, const EventIDBase& rhs);
private:
/// run number
number_type m_run_number {0};
/// event number
uint64_t m_event_number {0};
/// posix time in seconds since 1970/01/01
number_type m_time_stamp {0};
/// time stamp ns - ns time offset for time_stamp, 32 bit unsigned
number_type m_time_stamp_ns_offset {0};
/// luminosity block number:
/// the number which uniquely tags a luminosity block within a run
number_type m_lumiBlock {0};
/// bunch crossing ID, 32 bit unsigned
number_type m_bunch_crossing_id {0};
};
inline bool operator<(const EventIDBase& lhs, const EventIDBase& rhs) {
// We are assuming that ALL events will have run and event numbers,
// and never just a time stamp.
// FIXME: any use for also ordering by lumi-block ?
return lhs.m_run_number<rhs.m_run_number ||
( lhs.m_run_number==rhs.m_run_number &&
lhs.m_event_number<rhs.m_event_number) ;
}
inline bool operator==(const EventIDBase& lhs, const EventIDBase& rhs) {
// We assume that equality via run/event numbers is sufficient
return lhs.m_run_number == rhs.m_run_number &&
lhs.m_event_number == rhs.m_event_number;
}
inline bool operator>(const EventIDBase& lhs, const EventIDBase& rhs) {
return !( (lhs < rhs) || (lhs == rhs));
}
inline bool operator!=(const EventIDBase& lhs, const EventIDBase& rhs) {
return !(lhs == rhs);
}
inline bool operator<=(const EventIDBase& lhs, const EventIDBase& rhs) {
return !(lhs > rhs);
}
inline bool operator>=(const EventIDBase& lhs, const EventIDBase& rhs) {
return !(lhs < rhs);
}
inline std::ostream& operator<<(std::ostream& os, const EventIDBase& rhs) {
os << "["
<< rhs.m_run_number
<< "," << rhs.m_event_number;
if ( rhs.m_time_stamp != 0 ) {
os << "," << rhs.m_time_stamp << ":" << rhs.m_time_stamp_ns_offset;
}
if ( rhs.m_lumiBlock != 0) {
os << ",l:" << rhs.m_lumiBlock;
}
if ( rhs.m_bunch_crossing_id != 0) {
os << ",b:" << rhs.m_bunch_crossing_id;
}
os << "]";
return os;
}
//<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
#endif // EVENTINFO_EVENTID_H
/**
* @file EventIDBase.cpp
*
* @author RD Schaffer <R.D.Schaffer@cern.ch>
* @author Paolo Calafiura <pcalafiura@lbl.gov>
* @author Charles Leggett
*
*/
#include "GaudiKernel/EventIDBase.h"
EventIDBase::EventIDBase(number_type run_number,
uint64_t event_number,
number_type time_stamp,
number_type time_stamp_ns_offset,
number_type lumi_block,
number_type bunch_crossing_id)
:
m_run_number (run_number),
m_event_number (event_number),
m_time_stamp (time_stamp),
m_time_stamp_ns_offset (time_stamp_ns_offset),
m_lumiBlock (lumi_block),
m_bunch_crossing_id (bunch_crossing_id)
{}
EventIDBase::~EventIDBase()
{}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment