EventType Class Reference

#include <EventType.h>

List of all members.

Public Types

typedef std::vector< boolBitMask
typedef BitMask::const_iterator BitMaskIterator
typedef BitMask::size_type EventTypeCode
typedef std::pair< std::string,
std::string
NameTagPair
typedef std::vector< NameTagPairNameTagPairVec

Public Member Functions

 EventType ()
virtual ~EventType ()
void add_type (EventTypeCode type_code)
void set_user_type (const std::string &user_type)
void set_detdescr_tags (const NameTagPairVec &pairs)
bool test (EventTypeCode type_code) const
const std::stringuser_type (void) const
void get_detdescr_tags (NameTagPairVec &pairs)
BitMaskIterator bit_mask_begin (void) const
BitMaskIterator bit_mask_end (void) const

Static Public Attributes

static const EventTypeCode IS_SIMULATION = 0
static const EventTypeCode IS_TESTBEAM = 1
static const EventTypeCode IS_CALIBRATION = 2

Private Attributes

BitMask m_bit_mask
std::string m_user_type


Detailed Description

class EventType

This class represents the "type of event" where the type is given by one or more "characteristics".

Standard characteristics: -------------------------

IS_SIMULATION // false means IS_DATA IS_TESTBEAM // false means IS_FROM_ATLAS_DET IS_CALIBRATION // false means IS_PHYSICS

Since an event may have MORE than one characteristic, a testbeam simulation event would respond true to first two of the above characteristics, whereas an offline simulation event would respond true to ONLY IS_SIMULATION.

These are set with:

void add_type (EventTypeCode type_code);

where the possible EventTypeCode's are provided as constants, e.g.:

static const EventTypeCode IS_SIMULATION;

Thus, one would set IS_SIMULATION by:

an_event_type.set_type_bit(EventType::IS_SIMULATION);

User-defined characteristics: -----------------------------

There is a possible to set and get a "user-defined" characteristic in terms of a string:

void add_type (const string& user_type); const string& user_type (void) const;

Access to the full set of characteristics: ------------------------------------------

This is possible via:

BitMaskIterator bit_mask_begin (void) const; BitMaskIterator bit_mask_end (void) const;

Implementation details: -----------------------

The full set of characteristics is provided by static constants. One may add new event characteristics BOTH by adding more static constants AND by providing the cooresponding new boolean methods.

Definition at line 84 of file EventType.h.


Member Typedef Documentation

typedef std::vector<bool> EventType::BitMask

Definition at line 88 of file EventType.h.

typedef BitMask::const_iterator EventType::BitMaskIterator

Definition at line 89 of file EventType.h.

typedef BitMask::size_type EventType::EventTypeCode

Definition at line 90 of file EventType.h.

typedef std::pair<std::string,std::string> EventType::NameTagPair

Definition at line 91 of file EventType.h.

typedef std::vector<NameTagPair> EventType::NameTagPairVec

Definition at line 92 of file EventType.h.


Constructor & Destructor Documentation

EventType::EventType (  ) 

Definition at line 29 of file EventType.cxx.

00030 {}

EventType::~EventType (  )  [virtual]

Definition at line 33 of file EventType.cxx.

00034 {}


Member Function Documentation

void EventType::add_type ( EventTypeCode  type_code  ) 

Definition at line 38 of file EventType.cxx.

References m_bit_mask.

00039 {
00040     if(m_bit_mask.size() <= type_code) m_bit_mask.resize(type_code + 1, false);
00041     m_bit_mask[type_code] = true;
00042 }

EventType::BitMaskIterator EventType::bit_mask_begin ( void   )  const

Definition at line 135 of file EventType.cxx.

References m_bit_mask.

00136 {
00137     return m_bit_mask.begin();
00138 }

EventType::BitMaskIterator EventType::bit_mask_end ( void   )  const

Definition at line 141 of file EventType.cxx.

References m_bit_mask.

00142 {
00143     return m_bit_mask.end();
00144 }

void EventType::get_detdescr_tags ( NameTagPairVec pairs  ) 

Definition at line 93 of file EventType.cxx.

References first, m_user_type, RealDBUtil::npos, EvtCyclic3::second(), and deljobs::string.

00094 {
00095     // We must extract from m_user_type the dd tags for the moment to
00096     // avoid schema evolution.
00097 
00098     char sep = '#';
00099     bool done = false;
00100     std::string::size_type beg = m_user_type.find(sep);
00101     do {
00102         if (beg != std::string::npos) {
00103           std::string::size_type end1 = m_user_type.find(sep, beg+1);
00104             if (end1 != std::string::npos) {
00105               std::string::size_type end2 = m_user_type.find(sep, end1+1);
00106                 if (end2 != std::string::npos) {
00107                     // end2 is a new separator
00108                     std::string first  = m_user_type.substr(beg+1, end1-beg-1);
00109                     std::string second = m_user_type.substr(end1+1, end2-end1-1);
00110                     pairs.push_back(NameTagPair(first,second));
00111 
00112                     // continue with new beg
00113                     beg = end2;
00114                 }
00115                 else {
00116                     // end2 is the end of the string
00117                     std::string first  = m_user_type.substr(beg+1, end1-beg-1);
00118                     std::string second = m_user_type.substr(end1+1, m_user_type.size()-1);
00119                     pairs.push_back(NameTagPair(first,second));
00120                     done = true; // finished
00121                 }
00122             }
00123             else {
00124                 done = true; // finished
00125             }
00126         }
00127         else {
00128             done = true; // finished
00129         }
00130     } while (!done);
00131 }

void EventType::set_detdescr_tags ( const NameTagPairVec pairs  ) 

Definition at line 51 of file EventType.cxx.

References genRecEmupikp::i, m_user_type, and user_type().

00052 {
00053     // We must save in m_user_type the dd tags for the moment to avoid
00054     // schema evolution. Overwrite if existing "sep" is found.
00055 
00056     // Force overwrite:
00057     m_user_type = user_type(); 
00058 
00059     char sep = '#';
00060     for (unsigned int i = 0; i < pairs.size(); ++i) {
00061         m_user_type += sep;
00062         m_user_type += pairs[i].first;
00063         m_user_type += sep;
00064         m_user_type += pairs[i].second;
00065     }
00066 }

void EventType::set_user_type ( const std::string user_type  ) 

Definition at line 45 of file EventType.cxx.

References m_user_type.

00046 {
00047     m_user_type = user_type;
00048 }

bool EventType::test ( EventTypeCode  type_code  )  const

Definition at line 70 of file EventType.cxx.

References m_bit_mask.

00071 {
00072     if (m_bit_mask.size() <= type_code) return false;
00073     return m_bit_mask[type_code];
00074 }

const std::string & EventType::user_type ( void   )  const

Definition at line 77 of file EventType.cxx.

References m_user_type, RealDBUtil::npos, and deljobs::string.

Referenced by set_detdescr_tags().

00078 {
00079     char sep = '#';
00080     std::string::size_type beg = m_user_type.find(sep);
00081     static std::string user_type;
00082     if (beg != std::string::npos) {
00083         user_type = m_user_type.substr(0, beg);
00084     }
00085     else {
00086         user_type = m_user_type;
00087     }
00088     return user_type;
00089 }


Member Data Documentation

const EventType::EventTypeCode EventType::IS_CALIBRATION = 2 [static]

Definition at line 115 of file EventType.h.

const EventType::EventTypeCode EventType::IS_SIMULATION = 0 [static]

Definition at line 113 of file EventType.h.

const EventType::EventTypeCode EventType::IS_TESTBEAM = 1 [static]

Definition at line 114 of file EventType.h.

BitMask EventType::m_bit_mask [private]

Definition at line 123 of file EventType.h.

Referenced by add_type(), bit_mask_begin(), bit_mask_end(), and test().

std::string EventType::m_user_type [private]

Definition at line 124 of file EventType.h.

Referenced by get_detdescr_tags(), set_detdescr_tags(), set_user_type(), and user_type().


Generated on Tue Nov 29 23:18:50 2016 for BOSS_7.0.2 by  doxygen 1.4.7