BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EventType Class Reference

#include <EventType.h>

Public Types

typedef std::vector< bool > BitMask
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

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

Definition at line 87 of file EventType.h.

◆ BitMaskIterator

typedef BitMask::const_iterator EventType::BitMaskIterator

Definition at line 88 of file EventType.h.

◆ EventTypeCode

typedef BitMask::size_type EventType::EventTypeCode

Definition at line 89 of file EventType.h.

◆ NameTagPair

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

Definition at line 90 of file EventType.h.

◆ NameTagPairVec

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

Definition at line 91 of file EventType.h.

Constructor & Destructor Documentation

◆ EventType()

EventType::EventType ( )

Definition at line 27 of file EventType.cxx.

27{}

◆ ~EventType()

EventType::~EventType ( )
virtual

Definition at line 29 of file EventType.cxx.

29{}

Member Function Documentation

◆ add_type()

void EventType::add_type ( EventTypeCode type_code)

Definition at line 31 of file EventType.cxx.

31 {
32 if ( m_bit_mask.size() <= type_code ) m_bit_mask.resize( type_code + 1, false );
33 m_bit_mask[type_code] = true;
34}

◆ bit_mask_begin()

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

Definition at line 114 of file EventType.cxx.

114 {
115 return m_bit_mask.begin();
116}

◆ bit_mask_end()

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

Definition at line 118 of file EventType.cxx.

118{ return m_bit_mask.end(); }

◆ get_detdescr_tags()

void EventType::get_detdescr_tags ( NameTagPairVec & pairs)

Definition at line 69 of file EventType.cxx.

69 {
70 // We must extract from m_user_type the dd tags for the moment to
71 // avoid schema evolution.
72
73 char sep = '#';
74 bool done = false;
75 std::string::size_type beg = m_user_type.find( sep );
76 do {
77 if ( beg != std::string::npos )
78 {
79 std::string::size_type end1 = m_user_type.find( sep, beg + 1 );
80 if ( end1 != std::string::npos )
81 {
82 std::string::size_type end2 = m_user_type.find( sep, end1 + 1 );
83 if ( end2 != std::string::npos )
84 {
85 // end2 is a new separator
86 std::string first = m_user_type.substr( beg + 1, end1 - beg - 1 );
87 std::string second = m_user_type.substr( end1 + 1, end2 - end1 - 1 );
88 pairs.push_back( NameTagPair( first, second ) );
89
90 // continue with new beg
91 beg = end2;
92 }
93 else
94 {
95 // end2 is the end of the string
96 std::string first = m_user_type.substr( beg + 1, end1 - beg - 1 );
97 std::string second = m_user_type.substr( end1 + 1, m_user_type.size() - 1 );
98 pairs.push_back( NameTagPair( first, second ) );
99 done = true; // finished
100 }
101 }
102 else
103 {
104 done = true; // finished
105 }
106 }
107 else
108 {
109 done = true; // finished
110 }
111 } while ( !done );
112}
std::pair< std::string, std::string > NameTagPair
Definition EventType.h:90
Index second(Pair i)
Index first(Pair i)

◆ set_detdescr_tags()

void EventType::set_detdescr_tags ( const NameTagPairVec & pairs)

Definition at line 38 of file EventType.cxx.

38 {
39 // We must save in m_user_type the dd tags for the moment to avoid
40 // schema evolution. Overwrite if existing "sep" is found.
41
42 // Force overwrite:
43 m_user_type = user_type();
44
45 char sep = '#';
46 for ( unsigned int i = 0; i < pairs.size(); ++i )
47 {
48 m_user_type += sep;
49 m_user_type += pairs[i].first;
50 m_user_type += sep;
51 m_user_type += pairs[i].second;
52 }
53}
const std::string & user_type(void) const
Definition EventType.cxx:60

◆ set_user_type()

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

Definition at line 36 of file EventType.cxx.

36{ m_user_type = user_type; }

◆ test()

bool EventType::test ( EventTypeCode type_code) const

Definition at line 55 of file EventType.cxx.

55 {
56 if ( m_bit_mask.size() <= type_code ) return false;
57 return m_bit_mask[type_code];
58}

◆ user_type()

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

Definition at line 60 of file EventType.cxx.

60 {
61 char sep = '#';
62 std::string::size_type beg = m_user_type.find( sep );
63 static std::string user_type;
64 if ( beg != std::string::npos ) { user_type = m_user_type.substr( 0, beg ); }
65 else { user_type = m_user_type; }
66 return user_type;
67}

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 113 of file EventType.h.

◆ IS_SIMULATION

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

Definition at line 111 of file EventType.h.

◆ IS_TESTBEAM

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

Definition at line 112 of file EventType.h.


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