BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EventType.cxx
Go to the documentation of this file.
1/***************************************************************************
2 Event Info Package
3 -----------------------------------------
4 Copyright (C) 2000 by ATLAS Collaboration
5 ***************************************************************************/
6
7//<<<<<< INCLUDES >>>>>>
8
10
11//<<<<<< PRIVATE DEFINES >>>>>>
12//<<<<<< PRIVATE CONSTANTS >>>>>>
13//<<<<<< PRIVATE TYPES >>>>>>
14//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>>
15//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>>
16//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>>
17//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>>
18//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>>
19//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>>
20
21// List of EventTypeCodes
22// To add on a new code, simply extend at the end
26
28
30
32 if ( m_bit_mask.size() <= type_code ) m_bit_mask.resize( type_code + 1, false );
33 m_bit_mask[type_code] = true;
34}
35
36void EventType::set_user_type( const std::string& user_type ) { m_user_type = user_type; }
37
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}
54
55bool EventType::test( EventTypeCode type_code ) const {
56 if ( m_bit_mask.size() <= type_code ) return false;
57 return m_bit_mask[type_code];
58}
59
60const std::string& EventType::user_type( void ) const {
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}
68
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}
113
115 return m_bit_mask.begin();
116}
117
118EventType::BitMaskIterator EventType::bit_mask_end( void ) const { return m_bit_mask.end(); }
void get_detdescr_tags(NameTagPairVec &pairs)
Definition EventType.cxx:69
static const EventTypeCode IS_CALIBRATION
Definition EventType.h:113
std::vector< NameTagPair > NameTagPairVec
Definition EventType.h:91
BitMask::size_type EventTypeCode
Definition EventType.h:89
void set_detdescr_tags(const NameTagPairVec &pairs)
Definition EventType.cxx:38
void set_user_type(const std::string &user_type)
Definition EventType.cxx:36
const std::string & user_type(void) const
Definition EventType.cxx:60
BitMaskIterator bit_mask_end(void) const
BitMask::const_iterator BitMaskIterator
Definition EventType.h:88
virtual ~EventType()
Definition EventType.cxx:29
static const EventTypeCode IS_SIMULATION
Definition EventType.h:111
BitMaskIterator bit_mask_begin(void) const
void add_type(EventTypeCode type_code)
Definition EventType.cxx:31
std::pair< std::string, std::string > NameTagPair
Definition EventType.h:90
bool test(EventTypeCode type_code) const
Definition EventType.cxx:55
static const EventTypeCode IS_TESTBEAM
Definition EventType.h:112