CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
EventType Class Reference

#include <EventType.h>

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::string & user_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
 

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

◆ BitMask

std::vector<bool> EventType::BitMask

Definition at line 88 of file EventType.h.

◆ BitMaskIterator

BitMask::const_iterator EventType::BitMaskIterator

Definition at line 89 of file EventType.h.

◆ EventTypeCode

BitMask::size_type EventType::EventTypeCode

Definition at line 90 of file EventType.h.

◆ NameTagPair

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

Definition at line 91 of file EventType.h.

◆ NameTagPairVec

Definition at line 92 of file EventType.h.

Constructor & Destructor Documentation

◆ EventType()

EventType::EventType ( )

Definition at line 29 of file EventType.cxx.

30{}

◆ ~EventType()

EventType::~EventType ( )
virtual

Definition at line 33 of file EventType.cxx.

34{}

Member Function Documentation

◆ add_type()

void EventType::add_type ( EventTypeCode type_code)

Definition at line 38 of file EventType.cxx.

39{
40 if(m_bit_mask.size() <= type_code) m_bit_mask.resize(type_code + 1, false);
41 m_bit_mask[type_code] = true;
42}

◆ bit_mask_begin()

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

Definition at line 135 of file EventType.cxx.

136{
137 return m_bit_mask.begin();
138}

◆ bit_mask_end()

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

Definition at line 141 of file EventType.cxx.

142{
143 return m_bit_mask.end();
144}

◆ get_detdescr_tags()

void EventType::get_detdescr_tags ( NameTagPairVec & pairs)

Definition at line 93 of file EventType.cxx.

94{
95 // We must extract from m_user_type the dd tags for the moment to
96 // avoid schema evolution.
97
98 char sep = '#';
99 bool done = false;
100 std::string::size_type beg = m_user_type.find(sep);
101 do {
102 if (beg != std::string::npos) {
103 std::string::size_type end1 = m_user_type.find(sep, beg+1);
104 if (end1 != std::string::npos) {
105 std::string::size_type end2 = m_user_type.find(sep, end1+1);
106 if (end2 != std::string::npos) {
107 // end2 is a new separator
108 std::string first = m_user_type.substr(beg+1, end1-beg-1);
109 std::string second = m_user_type.substr(end1+1, end2-end1-1);
110 pairs.push_back(NameTagPair(first,second));
111
112 // continue with new beg
113 beg = end2;
114 }
115 else {
116 // end2 is the end of the string
117 std::string first = m_user_type.substr(beg+1, end1-beg-1);
118 std::string second = m_user_type.substr(end1+1, m_user_type.size()-1);
119 pairs.push_back(NameTagPair(first,second));
120 done = true; // finished
121 }
122 }
123 else {
124 done = true; // finished
125 }
126 }
127 else {
128 done = true; // finished
129 }
130 } while (!done);
131}
std::pair< std::string, std::string > NameTagPair
Definition EventType.h:91
_EXTERN_ CalibPairCol pairs
Definition CalibModel.h:111
Index second(Pair i)
Index first(Pair i)

◆ set_detdescr_tags()

void EventType::set_detdescr_tags ( const NameTagPairVec & pairs)

Definition at line 51 of file EventType.cxx.

52{
53 // We must save in m_user_type the dd tags for the moment to avoid
54 // schema evolution. Overwrite if existing "sep" is found.
55
56 // Force overwrite:
57 m_user_type = user_type();
58
59 char sep = '#';
60 for (unsigned int i = 0; i < pairs.size(); ++i) {
61 m_user_type += sep;
62 m_user_type += pairs[i].first;
63 m_user_type += sep;
64 m_user_type += pairs[i].second;
65 }
66}
const std::string & user_type(void) const
Definition EventType.cxx:77

◆ set_user_type()

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

Definition at line 45 of file EventType.cxx.

46{
47 m_user_type = user_type;
48}

◆ test()

bool EventType::test ( EventTypeCode type_code) const

Definition at line 70 of file EventType.cxx.

71{
72 if (m_bit_mask.size() <= type_code) return false;
73 return m_bit_mask[type_code];
74}

◆ user_type()

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

Definition at line 77 of file EventType.cxx.

78{
79 char sep = '#';
80 std::string::size_type beg = m_user_type.find(sep);
81 static std::string user_type;
82 if (beg != std::string::npos) {
83 user_type = m_user_type.substr(0, beg);
84 }
85 else {
86 user_type = m_user_type;
87 }
88 return user_type;
89}

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

Member Data Documentation

◆ IS_CALIBRATION

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

Definition at line 115 of file EventType.h.

◆ IS_SIMULATION

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

Definition at line 113 of file EventType.h.

◆ IS_TESTBEAM

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

Definition at line 114 of file EventType.h.


The documentation for this class was generated from the following files: