ATLAS Offline Software
Loading...
Searching...
No Matches
EventType Class Reference

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

#include <EventType.h>

Collaboration diagram for EventType:

Public Types

typedefs
typedef unsigned int number_type
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

structors
 EventType ()
virtual ~EventType ()
 EventType (const EventType &)=default
 EventType (EventType &&)=default
EventTypeoperator= (const EventType &)=default
EventTypeoperator= (EventType &&)=default
bool operator< (const EventType &rhs) const
 Less than comparision needed to create e.g. set<EventType>
Accessors
bool test (EventTypeCode type_code) const
 Tests for standard characteristics.
std::string typeToString () const
 Access to standard characteristics in string for - for print out.
std::string user_type (void) const
 Access to user type.
const std::string & user_type_raw (void) const
 Access to user type.
void get_detdescr_tags (NameTagPairVec &pairs) const
 Access DetDescr tags.
std::string get_detdescr_tags () const
 Access DetDescr tags as a single string.
number_type mc_channel_number () const
 Access to the MC generator channel number (was used as run number for generator events)
uint64_t mc_event_number () const
 Access to the MC generator event number.
float mc_event_weight (unsigned int iweight=0) const
 Access to MC weight.
unsigned int n_mc_event_weights () const
 Total number of MC weights.
Iterator access to full set of standard characteristics
BitMaskIterator bit_mask_begin (void) const
BitMaskIterator bit_mask_end (void) const
const BitMaskbit_mask () const

Static Public Attributes

The set of possible characteristic codes:
static const EventTypeCode IS_SIMULATION = 0
 true: IS_SIMULATION, false: IS_DATA
static const EventTypeCode IS_TESTBEAM = 1
 true: IS_TESTBEAM, false: IS_FROM_ATLAS_DET
static const EventTypeCode IS_CALIBRATION = 2
 true: IS_CALIBRATION, false: IS_PHYSICS

Set characteristics:

BitMask m_bit_mask
std::string m_user_type
std::vector< float > m_mc_event_weights
number_type m_mc_channel_number
uint64_t m_mc_event_number
void add_type (EventTypeCode type_code)
 Add a new event type.
void set_user_type (const std::string &user_type)
 Add user (string) type.
void set_mc_channel_number (number_type chan)
 Add in the MC generator channel number (aka gen run number)
void set_mc_event_number (uint64_t evt)
 Add in the MC generator event number.
void set_mc_event_weight (float weight, unsigned int iweight=0, unsigned int nWeightsMax=0)
 Add in MC weight. For more than 1 weight, add with iweight > 0.
void reset_detdescr_tags ()
 Reset DetDescr tags - to remove them from old EventInfo objects being read in.

Detailed Description

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 corresponding new boolean methods.

Definition at line 92 of file EventType.h.

Member Typedef Documentation

◆ BitMask

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

Definition at line 97 of file EventType.h.

◆ BitMaskIterator

typedef BitMask::const_iterator EventType::BitMaskIterator

Definition at line 98 of file EventType.h.

◆ EventTypeCode

typedef BitMask::size_type EventType::EventTypeCode

Definition at line 99 of file EventType.h.

◆ NameTagPair

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

Definition at line 100 of file EventType.h.

◆ NameTagPairVec

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

Definition at line 101 of file EventType.h.

◆ number_type

typedef unsigned int EventType::number_type

Definition at line 96 of file EventType.h.

Constructor & Destructor Documentation

◆ EventType() [1/3]

EventType::EventType ( )

Definition at line 24 of file EventType.cxx.

25 : m_mc_event_weights(1, 1),
28
29{}
number_type m_mc_channel_number
Definition EventType.h:200
std::vector< float > m_mc_event_weights
Definition EventType.h:199
uint64_t m_mc_event_number
Definition EventType.h:201

◆ ~EventType()

EventType::~EventType ( )
virtual

Definition at line 32 of file EventType.cxx.

33{}

◆ EventType() [2/3]

EventType::EventType ( const EventType & )
default

◆ EventType() [3/3]

EventType::EventType ( EventType && )
default

Member Function Documentation

◆ add_type()

void EventType::add_type ( EventTypeCode type_code)

Add a new event type.

Definition at line 51 of file EventType.cxx.

51 {
52 if (m_bit_mask.size() <= type_code) m_bit_mask.resize(type_code + 1, false);
53 m_bit_mask[type_code] = true;
54}
BitMask m_bit_mask
Definition EventType.h:197

◆ bit_mask()

const EventType::BitMask & EventType::bit_mask ( ) const

Definition at line 192 of file EventType.cxx.

192 {
193 return m_bit_mask;
194}

◆ bit_mask_begin()

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

Definition at line 182 of file EventType.cxx.

182 {
183 return m_bit_mask.begin();
184}

◆ bit_mask_end()

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

Definition at line 187 of file EventType.cxx.

187 {
188 return m_bit_mask.end();
189}

◆ get_detdescr_tags() [1/2]

std::string EventType::get_detdescr_tags ( ) const

Access DetDescr tags as a single string.

Definition at line 151 of file EventType.cxx.

151 {
152 // Concatenate the dd tags to a single string
154
155 get_detdescr_tags(pairs);
156 std::string result;
157 result.clear();
158 for (unsigned int i = 0; i < pairs.size(); ++i) {
159 result += pairs[i].first + ' ' + pairs[i].second + ' ';
160 }
161 return(result);
162}
std::string get_detdescr_tags() const
Access DetDescr tags as a single string.
std::vector< NameTagPair > NameTagPairVec
Definition EventType.h:101

◆ get_detdescr_tags() [2/2]

void EventType::get_detdescr_tags ( NameTagPairVec & pairs) const

Access DetDescr tags.

Definition at line 113 of file EventType.cxx.

113 {
114 // We must extract from m_user_type the dd tags for the moment to
115 // avoid schema evolution.
116
117 char sep = '#';
118 bool done = false;
119
120 std::string::size_type beg = m_user_type.find(sep);
121 do {
122 if (beg != std::string::npos) {
123 std::string::size_type end1 = m_user_type.find(sep, beg + 1);
124 if (end1 != std::string::npos) {
125 std::string::size_type end2 = m_user_type.find(sep, end1 + 1);
126 if (end2 != std::string::npos) {
127 // end2 is a new separator
128 std::string first = m_user_type.substr(beg + 1, end1 - beg - 1);
129 std::string second = m_user_type.substr(end1 + 1, end2 - end1 - 1);
130 pairs.push_back(NameTagPair(first, second));
131
132 // continue with new beg
133 beg = end2;
134 } else {
135 // end2 is the end of the string
136 std::string first = m_user_type.substr(beg + 1, end1 - beg - 1);
137 std::string second = m_user_type.substr(end1 + 1, m_user_type.size() - 1);
138 pairs.push_back(NameTagPair(first, second));
139 done = true; // finished
140 }
141 } else {
142 done = true; // finished
143 }
144 } else {
145 done = true; // finished
146 }
147 } while (!done);
148}
std::pair< std::string, std::string > NameTagPair
Definition EventType.h:100
std::string m_user_type
Definition EventType.h:198
bool first
Definition DeMoScan.py:534

◆ mc_channel_number()

EventType::number_type EventType::mc_channel_number ( ) const

Access to the MC generator channel number (was used as run number for generator events)

Definition at line 165 of file EventType.cxx.

165 {
166 return m_mc_channel_number;
167}

◆ mc_event_number()

uint64_t EventType::mc_event_number ( ) const

Access to the MC generator event number.

Definition at line 170 of file EventType.cxx.

170 {
171 return m_mc_event_number;
172}

◆ mc_event_weight()

float EventType::mc_event_weight ( unsigned int iweight = 0) const

Access to MC weight.

Definition at line 175 of file EventType.cxx.

175 {
176 if (iweight < m_mc_event_weights.size()) return m_mc_event_weights[iweight];
177
178 return 0;
179}

◆ n_mc_event_weights()

unsigned int EventType::n_mc_event_weights ( ) const

Total number of MC weights.

Definition at line 214 of file EventType.cxx.

214 {
215 return (unsigned int) m_mc_event_weights.size();
216}

◆ operator<()

bool EventType::operator< ( const EventType & rhs) const

Less than comparision needed to create e.g. set<EventType>

Definition at line 36 of file EventType.cxx.

37 {
38 if (this->m_bit_mask.size() != rhs.m_bit_mask.size()) {
39 return(this->m_bit_mask.size() < rhs.m_bit_mask.size());
40 }
41 for (BitMaskIterator i = this->bit_mask_begin(), j = rhs.bit_mask_begin();
42 i != this->bit_mask_end(); ++i, ++j) {
43 if (*i != *j) {
44 return(*i < *j);
45 }
46 }
47 return(this->m_user_type < rhs.m_user_type);
48}
BitMask::const_iterator BitMaskIterator
Definition EventType.h:98
BitMaskIterator bit_mask_begin(void) const

◆ operator=() [1/2]

EventType & EventType::operator= ( const EventType & )
default

◆ operator=() [2/2]

EventType & EventType::operator= ( EventType && )
default

◆ reset_detdescr_tags()

void EventType::reset_detdescr_tags ( )

Reset DetDescr tags - to remove them from old EventInfo objects being read in.

Definition at line 219 of file EventType.cxx.

219 {
221}
std::string user_type(void) const
Access to user type.
Definition EventType.cxx:94

◆ set_mc_channel_number()

void EventType::set_mc_channel_number ( number_type chan)

Add in the MC generator channel number (aka gen run number)

Definition at line 197 of file EventType.cxx.

◆ set_mc_event_number()

void EventType::set_mc_event_number ( uint64_t evt)

Add in the MC generator event number.

Definition at line 202 of file EventType.cxx.

◆ set_mc_event_weight()

void EventType::set_mc_event_weight ( float weight,
unsigned int iweight = 0,
unsigned int nWeightsMax = 0 )

Add in MC weight. For more than 1 weight, add with iweight > 0.

Definition at line 207 of file EventType.cxx.

207 {
208 if (nWeightsMax > m_mc_event_weights.capacity()) m_mc_event_weights.reserve(nWeightsMax);
209 if (m_mc_event_weights.size() <= iweight) m_mc_event_weights.resize(iweight + 1);
210 m_mc_event_weights[iweight] = weight;
211}

◆ set_user_type()

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

Add user (string) type.

Definition at line 57 of file EventType.cxx.

57 {
59}

◆ test()

bool EventType::test ( EventTypeCode type_code) const

Tests for standard characteristics.

Definition at line 62 of file EventType.cxx.

62 {
63 if (m_bit_mask.size() <= type_code) return false;
64
65 return m_bit_mask[type_code];
66}

◆ typeToString()

std::string EventType::typeToString ( ) const

Access to standard characteristics in string for - for print out.

Definition at line 69 of file EventType.cxx.

69 {
70 std::string result;
71
72 result += "Event type: sim/data - ";
74 result += " is sim ";
75 } else {
76 result += " is data ";
77 }
78 result += ", testbeam/atlas - ";
80 result += " is testbeam ";
81 } else {
82 result += " is atlas ";
83 }
84 result += ", calib/physics - ";
86 result += " is calib ";
87 } else {
88 result += " is physics ";
89 }
90 return(result);
91}
static const EventTypeCode IS_CALIBRATION
true: IS_CALIBRATION, false: IS_PHYSICS
Definition EventType.h:162
static const EventTypeCode IS_SIMULATION
true: IS_SIMULATION, false: IS_DATA
Definition EventType.h:156
bool test(EventTypeCode type_code) const
Tests for standard characteristics.
Definition EventType.cxx:62
static const EventTypeCode IS_TESTBEAM
true: IS_TESTBEAM, false: IS_FROM_ATLAS_DET
Definition EventType.h:159

◆ user_type()

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

Access to user type.

Definition at line 94 of file EventType.cxx.

94 {
95 char sep = '#';
96
97 std::string::size_type beg = m_user_type.find(sep);
98 std::string user_type;
99 if (beg != std::string::npos) {
100 user_type = m_user_type.substr(0, beg);
101 } else {
103 }
104 return user_type;
105}

◆ user_type_raw()

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

Access to user type.

Definition at line 108 of file EventType.cxx.

108 {
109 return m_user_type;
110}

Member Data Documentation

◆ IS_CALIBRATION

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

true: IS_CALIBRATION, false: IS_PHYSICS

Definition at line 162 of file EventType.h.

◆ IS_SIMULATION

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

true: IS_SIMULATION, false: IS_DATA

Definition at line 156 of file EventType.h.

◆ IS_TESTBEAM

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

true: IS_TESTBEAM, false: IS_FROM_ATLAS_DET

Definition at line 159 of file EventType.h.

◆ m_bit_mask

BitMask EventType::m_bit_mask
private

Definition at line 197 of file EventType.h.

◆ m_mc_channel_number

number_type EventType::m_mc_channel_number
private

Definition at line 200 of file EventType.h.

◆ m_mc_event_number

uint64_t EventType::m_mc_event_number
private

Definition at line 201 of file EventType.h.

◆ m_mc_event_weights

std::vector<float> EventType::m_mc_event_weights
private

Definition at line 199 of file EventType.h.

◆ m_user_type

std::string EventType::m_user_type
private

Definition at line 198 of file EventType.h.


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