Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventInfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
14 #include <memory>
15 
16 #include "EventInfo/EventInfo.h"
17 #include "EventInfo/EventID.h"
18 #include "EventInfo/EventType.h"
19 #include "EventInfo/TriggerInfo.h"
20 
22  : m_event_ID(std::make_unique<EventID>(0, 0)),
23  m_event_type(std::make_unique<EventType>()),
24  m_trigger_info(std::make_unique<TriggerInfo>()) {}
25 
27  : EventInfo(std::unique_ptr<EventID>(id),
28  std::unique_ptr<EventType>(type)) {}
29 
30 EventInfo::EventInfo(std::unique_ptr<EventID> id,
31  std::unique_ptr<EventType> type)
32  : m_event_ID(std::move(id)),
33  m_event_type(std::move(type)),
34  m_trigger_info(std::make_unique<TriggerInfo>()) {}
35 
37  owner<TriggerInfo*> trig_info)
38  : EventInfo(std::unique_ptr<EventID>(id), std::unique_ptr<EventType>(type),
39  std::unique_ptr<TriggerInfo>(trig_info)) {}
40 
41 EventInfo::EventInfo(std::unique_ptr<EventID> id,
42  std::unique_ptr<EventType> type,
43  std::unique_ptr<TriggerInfo> trig_info)
44  : m_event_ID(std::move(id)),
45  m_event_type(std::move(type)),
46  m_trigger_info(std::move(trig_info)) {}
47 
49  : m_event_ID(e.m_event_ID ? std::make_unique<EventID>(*(e.m_event_ID))
50  : std::make_unique<EventID>(0, 0)),
51  m_event_type(e.m_event_type
52  ? std::make_unique<EventType>(*(e.m_event_type))
53  : std::make_unique<EventType>()),
54  m_trigger_info(e.m_trigger_info
55  ? std::make_unique<TriggerInfo>(*(e.m_trigger_info))
56  : std::make_unique<TriggerInfo>()),
57  m_event_flags(e.m_event_flags) {}
58 
60  if (this != &e) {
61  setEventID(e.m_event_ID ? std::make_unique<EventID>(*(e.m_event_ID))
62  : std::make_unique<EventID>(0, 0));
63 
64  setEventType(e.m_event_type ? std::make_unique<EventType>(*(e.m_event_type))
65  : std::make_unique<EventType>());
66 
67  setTriggerInfo(e.m_trigger_info
68  ? std::make_unique<TriggerInfo>(*(e.m_trigger_info))
69  : std::make_unique<TriggerInfo>());
70 
71  m_event_flags = e.m_event_flags;
72  }
73  return *this;
74 }
75 
76 // Needs to be defined here as unique_ptr's deleter needs the pointee's type to
77 // be a complete type when called
78 EventInfo::~EventInfo() = default;
79 EventInfo::EventInfo(EventInfo&& e) noexcept = default;
80 EventInfo& EventInfo::operator=(EventInfo&& e) noexcept = default;
81 
83  m_event_ID.reset(pid);
84 }
85 
86 void EventInfo::setEventID(std::unique_ptr<EventID> pid) {
87  m_event_ID = std::move(pid);
88 }
89 
91  m_event_type.reset(pType);
92 }
93 
94 void EventInfo::setEventType(std::unique_ptr<EventType> pType) {
95  m_event_type = std::move(pType);
96 }
97 
99  m_trigger_info.reset(pTrig);
100 }
101 
102 void EventInfo::setTriggerInfo(std::unique_ptr<TriggerInfo> pTrig) {
103  m_trigger_info = std::move(pTrig);
104 }
105 
106 bool
108  // If event_flags has been cleared on input, reset size to just
109  // before lumi
110  if (m_event_flags.size() < (unsigned int) Lumi) m_event_flags.resize(Lumi, 0);
111  if ((unsigned) subDet < m_event_flags.size()) {
112  // Combine potentially-existing error states with new flags
113  m_event_flags[subDet] = (EF_ERROR_BITS & m_event_flags[subDet]) | (EF_BITS & flags);
114  return(true);
115  }
116  return(false);
117 }
118 
119 bool
120 EventInfo::setEventFlagBit(EventFlagSubDet subDet, unsigned char bit, bool set) {
121  // If event_flags has been cleared on input, reset size to just
122  // before lumi
123  if (m_event_flags.size() < (unsigned int) Lumi) m_event_flags.resize(Lumi, 0);
124  if ((unsigned) subDet < m_event_flags.size() && bit < EF_ERROR_SHIFT) {
125  if (set) {
126  m_event_flags[subDet] = (EF_ERROR_BITS & m_event_flags[subDet]) |
127  ((1u << bit) | m_event_flags[subDet]);
128  } else {
129  unsigned int mask = EF_BITS ^ (1u << bit);
130  m_event_flags[subDet] = (EF_ERROR_BITS & m_event_flags[subDet]) |
131  (mask & m_event_flags[subDet]);
132  }
133  return(true);
134  }
135  return(false);
136 }
137 
138 bool
140  // If event_flags has been cleared on input, reset size to just
141  // before lumi
142  if (m_event_flags.size() < (unsigned int) Lumi) m_event_flags.resize(Lumi, 0);
143  // check that subdet index is in range and that we have a valid error state
144  if ((unsigned) subDet < m_event_flags.size() &&
145  (errorState == NotSet || errorState == Warning || errorState == Error)) {
146  // Combine potentially-existing flags with new error states
147  m_event_flags[subDet] =
148  (unsigned int) ((EF_BITS & m_event_flags[subDet]) | ((unsigned int) errorState << EF_ERROR_SHIFT));
149  return(true);
150  }
151  return(false);
152 }
153 
155 void
157  // pack interaction into 16 bits saving the precision to the 0.01
158  // level
159  unsigned int ivalue = (unsigned int) (interactions * 100.f);
160 
161  if (ivalue > ACTUAL_INTERACTS_BITS) {
162  std::cout <<
163  "EventInfo::setActualInteractionsPerCrossing *** ERROR ***: trying to store too large of value: interactions/ivalue/max value: "
164  << interactions << " " << ivalue << " " << ACTUAL_INTERACTS_BITS << std::endl;
165  }
166  ivalue &= ACTUAL_INTERACTS_BITS;
167  // If event_flags has been cleared on input, reset size AND INCLUDE lumi
168  if (m_event_flags.size() < nDets) m_event_flags.resize(nDets, 0);
169  m_event_flags[Lumi] |= ivalue; // store lower 16 bits
170 }
171 
172 void
174  // pack interaction into 16 bits saving the precision to the 0.01
175  // level
176  unsigned int ivalue = (unsigned int) (interactions * 100.f);
177 
178  if (ivalue > ACTUAL_INTERACTS_BITS) {
179  std::cout <<
180  "EventInfo::setAverageInteractionsPerCrossing *** ERROR ***: trying to store too large of value: interactions/ivalue/max value: "
181  << interactions << " " << ivalue << " " << ACTUAL_INTERACTS_BITS << std::endl;
182  }
183  ivalue = (ivalue << AVE_INTERACTS_SHIFT) & AVE_INTERACTS_BITS;
184  // If event_flags has been cleared on input, reset size AND INCLUDE lumi
185  if (m_event_flags.size() < nDets) m_event_flags.resize(nDets, 0);
186  m_event_flags[Lumi] |= ivalue; // store upper 16 bits
187 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
EventInfo::setEventID
void setEventID(owner< EventID * > pid)
Definition: EventInfo.cxx:82
EventInfo::Error
@ Error
Definition: EventInfo/EventInfo/EventInfo.h:67
EventInfo::setEventType
void setEventType(owner< EventType * >)
Definition: EventInfo.cxx:90
EventInfo::m_event_type
std::unique_ptr< EventType > m_event_type
Definition: EventInfo/EventInfo/EventInfo.h:216
EventInfo::Warning
@ Warning
Definition: EventInfo/EventInfo/EventInfo.h:67
EventInfo::m_trigger_info
std::unique_ptr< TriggerInfo > m_trigger_info
Definition: EventInfo/EventInfo/EventInfo.h:217
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
EventInfo::m_event_flags
std::vector< unsigned int > m_event_flags
Definition: EventInfo/EventInfo/EventInfo.h:218
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
TriggerInfo.h
This class contains trigger related information.
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
EventInfo::AVE_INTERACTS_BITS
@ AVE_INTERACTS_BITS
Definition: EventInfo/EventInfo/EventInfo.h:212
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
EventInfo::EF_ERROR_BITS
@ EF_ERROR_BITS
Definition: EventInfo/EventInfo/EventInfo.h:209
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
EventInfo::EF_BITS
@ EF_BITS
Definition: EventInfo/EventInfo/EventInfo.h:208
EventInfo::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
return error state for a particular sub-detector
Definition: EventInfo/EventInfo/EventInfo.h:274
EventInfo::m_event_ID
std::unique_ptr< EventID > m_event_ID
Definition: EventInfo/EventInfo/EventInfo.h:215
EventInfo::setEventFlagBit
bool setEventFlagBit(EventFlagSubDet subDet, unsigned char bit, bool set=true)
Set a bit for an event flag of a particular sub detector.
Definition: EventInfo.cxx:120
EventInfo::nDets
@ nDets
Definition: EventInfo/EventInfo/EventInfo.h:61
EventInfo::EventFlagErrorState
EventFlagErrorState
Definition: EventInfo/EventInfo/EventInfo.h:66
EventInfo::setErrorState
bool setErrorState(EventFlagSubDet subDet, EventFlagErrorState errorState)
Set error state flag for a particular sub detector.
Definition: EventInfo.cxx:139
EventInfo::setActualInteractionsPerCrossing
void setActualInteractionsPerCrossing(float interactions)
Setting the number of interactions per crossing:
Definition: EventInfo.cxx:156
EventInfo::setTriggerInfo
void setTriggerInfo(owner< TriggerInfo * > pTrig)
Add TriggerInfo to existing object.
Definition: EventInfo.cxx:98
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventInfo::NotSet
@ NotSet
Definition: EventInfo/EventInfo/EventInfo.h:67
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
hist_file_dump.f
f
Definition: hist_file_dump.py:141
EventInfo::operator=
EventInfo & operator=(const EventInfo &e)
Definition: EventInfo.cxx:59
EventInfo::owner
T owner
Definition: EventInfo/EventInfo/EventInfo.h:54
EventInfo::setAverageInteractionsPerCrossing
void setAverageInteractionsPerCrossing(float interactions)
average interactions per crossing for all BCIDs - for out-of-time pile-up
Definition: EventInfo.cxx:173
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
EventInfo::EventInfo
EventInfo()
Definition: EventInfo.cxx:21
TriggerInfo
This class contains trigger related information.
Definition: TriggerInfo.h:77
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
EventInfo::ACTUAL_INTERACTS_BITS
@ ACTUAL_INTERACTS_BITS
Definition: EventInfo/EventInfo/EventInfo.h:211
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
EventInfo::EF_ERROR_SHIFT
@ EF_ERROR_SHIFT
Definition: EventInfo/EventInfo/EventInfo.h:210
EventInfo::Lumi
@ Lumi
Definition: EventInfo/EventInfo/EventInfo.h:61
EventInfo::~EventInfo
virtual ~EventInfo()
EventInfo::setEventFlags
bool setEventFlags(EventFlagSubDet subDet, unsigned int flags)
Set event flag for a particular sub detector - maximun size is 28 bits.
Definition: EventInfo.cxx:107
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
EventInfo::EventFlagSubDet
EventFlagSubDet
Definition: EventInfo/EventInfo/EventInfo.h:60
EventInfo::AVE_INTERACTS_SHIFT
@ AVE_INTERACTS_SHIFT
Definition: EventInfo/EventInfo/EventInfo.h:213