ATLAS Offline Software
EventType.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3  */
4 
14 #include "EventInfo/EventType.h"
15 // #include "AtlasMcWeight.h"
16 
17 // List of EventTypeCodes
18 // To add on a new code, simply extend at the end
22 
23 
25  : m_mc_event_weights(1, 1),
26  m_mc_channel_number(0),
27  m_mc_event_number(0)
28 
29 {}
30 
31 
33 {}
34 
36 bool
37 EventType::operator < (const EventType& rhs) const {
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 }
49 
50 void
52  if (m_bit_mask.size() <= type_code) m_bit_mask.resize(type_code + 1, false);
53  m_bit_mask[type_code] = true;
54 }
55 
56 void
57 EventType::set_user_type(const std::string& user_type) {
59 }
60 
61 bool
62 EventType::test(EventTypeCode type_code) const {
63  if (m_bit_mask.size() <= type_code) return false;
64 
65  return m_bit_mask[type_code];
66 }
67 
68 std::string
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 }
92 
93 std::string
94 EventType::user_type(void) const {
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 }
106 
107 const std::string&
109  return m_user_type;
110 }
111 
112 void
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 }
149 
150 std::string
152  // Concatenate the dd tags to a single string
154 
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 }
163 
166  return m_mc_channel_number;
167 }
168 
169 uint64_t
171  return m_mc_event_number;
172 }
173 
174 float
175 EventType::mc_event_weight(unsigned int iweight) const {
176  if (iweight < m_mc_event_weights.size()) return m_mc_event_weights[iweight];
177 
178  return 0;
179 }
180 
183  return m_bit_mask.begin();
184 }
185 
188  return m_bit_mask.end();
189 }
190 
191 const EventType::BitMask&
193  return m_bit_mask;
194 }
195 
196 void
199 }
200 
201 void
204 }
205 
206 void
207 EventType::set_mc_event_weight(float weight, unsigned int iweight, unsigned int nWeightsMax) {
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 }
212 
213 unsigned int
215  return (unsigned int) m_mc_event_weights.size();
216 }
217 
218 void
221 }
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
EventType::user_type
std::string user_type(void) const
Access to user type.
Definition: EventType.cxx:94
EventType::EventType
EventType()
Definition: EventType.cxx:24
get_generator_info.result
result
Definition: get_generator_info.py:21
EventType::add_type
void add_type(EventTypeCode type_code)
Add a new event type.
Definition: EventType.cxx:51
EventType::BitMask
std::vector< bool > BitMask
Definition: EventType.h:97
EventType::EventTypeCode
BitMask::size_type EventTypeCode
Definition: EventType.h:99
EventType::set_mc_channel_number
void set_mc_channel_number(number_type chan)
Add in the MC generator channel number (aka gen run number)
Definition: EventType.cxx:197
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
EventType::m_user_type
std::string m_user_type
Definition: EventType.h:193
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
EventType::m_mc_event_number
uint64_t m_mc_event_number
Definition: EventType.h:196
EventType::mc_event_weight
float mc_event_weight(unsigned int iweight=0) const
Access to MC weight.
Definition: EventType.cxx:175
EventType::mc_channel_number
number_type mc_channel_number() const
Access to the MC generator channel number (was used as run number for generator events)
Definition: EventType.cxx:165
EventType::number_type
unsigned int number_type
Definition: EventType.h:96
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
EventType::m_mc_channel_number
number_type m_mc_channel_number
Definition: EventType.h:195
EventType::NameTagPair
std::pair< std::string, std::string > NameTagPair
Definition: EventType.h:100
lumiFormat.i
int i
Definition: lumiFormat.py:92
EventType::NameTagPairVec
std::vector< NameTagPair > NameTagPairVec
Definition: EventType.h:101
EventType::operator<
bool operator<(const EventType &rhs) const
Less than comparision needed to create e.g. set<EventType>
Definition: EventType.cxx:37
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
EventType::IS_CALIBRATION
static const EventTypeCode IS_CALIBRATION
true: IS_CALIBRATION, false: IS_PHYSICS
Definition: EventType.h:157
EventType::get_detdescr_tags
std::string get_detdescr_tags() const
Access DetDescr tags as a single string.
Definition: EventType.cxx:151
EventType::m_mc_event_weights
std::vector< float > m_mc_event_weights
Definition: EventType.h:194
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
EventType::IS_SIMULATION
static const EventTypeCode IS_SIMULATION
true: IS_SIMULATION, false: IS_DATA
Definition: EventType.h:151
grepfile.sep
sep
Definition: grepfile.py:38
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
EventType::set_mc_event_weight
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.
Definition: EventType.cxx:207
EventType::IS_TESTBEAM
static const EventTypeCode IS_TESTBEAM
true: IS_TESTBEAM, false: IS_FROM_ATLAS_DET
Definition: EventType.h:154
EventType::set_mc_event_number
void set_mc_event_number(uint64_t evt)
Add in the MC generator event number.
Definition: EventType.cxx:202
EventType::set_user_type
void set_user_type(const std::string &user_type)
Add user (string) type.
Definition: EventType.cxx:57
EventType::mc_event_number
uint64_t mc_event_number() const
Access to the MC generator event number.
Definition: EventType.cxx:170
EventType::test
bool test(EventTypeCode type_code) const
Tests for standard characteristics.
Definition: EventType.cxx:62
EventType::m_bit_mask
BitMask m_bit_mask
Definition: EventType.h:192
DeMoScan.first
bool first
Definition: DeMoScan.py:534
EventType::n_mc_event_weights
unsigned int n_mc_event_weights() const
Total number of MC weights.
Definition: EventType.cxx:214
EventType::bit_mask_begin
BitMaskIterator bit_mask_begin(void) const
Definition: EventType.cxx:182
EventType::reset_detdescr_tags
void reset_detdescr_tags()
Reset DetDescr tags - to remove them from old EventInfo objects being read in.
Definition: EventType.cxx:219
EventType::~EventType
virtual ~EventType()
Definition: EventType.cxx:32
EventType::bit_mask_end
BitMaskIterator bit_mask_end(void) const
Definition: EventType.cxx:187
EventType::typeToString
std::string typeToString() const
Access to standard characteristics in string for - for print out.
Definition: EventType.cxx:69
EventType::user_type_raw
const std::string & user_type_raw(void) const
Access to user type.
Definition: EventType.cxx:108
EventType::BitMaskIterator
BitMask::const_iterator BitMaskIterator
Definition: EventType.h:98
EventType::bit_mask
const BitMask & bit_mask() const
Definition: EventType.cxx:192