ATLAS Offline Software
EventData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "LArCafJobs/EventData.h"
7 
8 #include "LArCafJobs/RunData.h"
10 #include "TMath.h"
11 #include "TEllipse.h"
12 #include "TBox.h"
13 
14 #include <iostream>
15 using std::cout;
16 using std::endl;
17 
18 using namespace LArSamples;
19 
20 
22  m_runData(nullptr)
23 {
25  m_eventData.push_back(0); // event
26  m_eventData.push_back(0); // run
27  m_eventData.push_back(0); // LB
28  m_eventData.push_back(0); // BCID
29 }
30 
31 
32 EventData::EventData(const EventData& other, int newRunIndex)
33  : m_eventData(other.m_eventData),
34  m_rois(other.m_rois),
35  m_runData(other.m_runData)
36 {
38  if (newRunIndex != -1) setRunIndex(newRunIndex);
39 }
40 
41 
42 EventData::EventData(int event, int run, int lumiBlock, int bunchId) :
43  m_runData(nullptr)
44 {
46  m_eventData.push_back(event);
47  m_eventData.push_back(run);
48  m_eventData.push_back(lumiBlock);
49  m_eventData.push_back(bunchId);
50 }
51 
52 
54 {
56 }
57 
58 
59 int EventData::run() const
60 {
61  if (!runData()) return -1;
62  return runData()->run();
63 }
64 
65 
66 std::vector<unsigned int> EventData::triggerData() const
67 {
68  std::vector<unsigned int> trigData;
69  if (m_eventData.size() < 4) return trigData; // should never happen
70  trigData.insert(trigData.end(), m_eventData.begin() + 4, m_eventData.end());
71  return trigData;
72 }
73 
74 
75 void EventData::setTriggerData(const std::vector<unsigned int>& l1Words)
76 {
77  m_eventData.insert(m_eventData.end(), l1Words.begin(), l1Words.end());
78 }
79 
80 
81 unsigned int EventData::triggerWord(unsigned int i) const
82 {
83  if (i >= nTriggerWords()) return 0;
84  return m_eventData[i + 4];
85 }
86 
87 
88 bool EventData::isPassed(const TString& bitName) const
89 {
90  if (!runData()) return false;
91  int index = runData()->triggerBitPosition(bitName);
92  if (index < 0 && bitName == "L1_MBTS_1_1") index = 228;
93  if (index < 0) return false;
94  return bit((unsigned int)index);
95 }
96 
97 
98 bool EventData::bit(unsigned int pos) const
99 {
100  unsigned int word = pos/32;
101  unsigned int bpos = pos%32;
102  if (word >= nTriggerWords()) return false;
103  return ((triggerWord(word) >> bpos) & 0x1);
104 }
105 
106 
107 TString EventData::triggers() const
108 {
109  TString triggers = "";
110  if (!runData()) return triggers;
111  for (const std::pair<const TString, unsigned int>& p : runData()->triggerConfig())
112  {
113  if (isPassed(p.first)) {
114  if (triggers != "") triggers += " ";
115  triggers += p.first;
116  }
117  }
118  return triggers;
119 }
120 
121 
122 TString EventData::roIs() const
123 {
124  TString str = "";
125  for (unsigned int i = 0; i < nRoIs(); i++)
126  str += Form("(%4.2f, %4.2f) ", roI(i).eta, roI(i).phi);
127  return str;
128 }
129 
130 
131 TString EventData::description(unsigned int verbosity) const
132 {
133  TString printout = "";
134  if (verbosity & 1)
135  printout += Form("run %6d, event %8d, lb = %4d", run(), event(), lumiBlock());
136  if (verbosity & 2)
137  printout += Form(", triggers = %40s", triggers().Data());
138  if (verbosity & 4) {
139  printout += ", RoIs = ";
140  for (unsigned int i = 0; i < nRoIs(); i++)
141  printout += Form("%-20s(%5.2f, %5.2f) ", roI(i).name.Data(), roI(i).eta, roI(i).phi);
142  }
143  return printout;
144 }
145 
146 
147 void EventData::drawDRRoIs(double roISize) const
148 {
149  TEllipse ell;
150  ell.SetFillStyle(0);
151 
152  for (unsigned int i = 0; i < nRoIs(); i++)
153  ell.DrawEllipse(roI(i).eta, roI(i).phi, roISize, roISize, 0, 360, 0);
154 }
155 
156 void EventData::drawBoxRoIs(double etaSize, double phiSize) const
157 {
158  TBox box;
159  box.SetFillStyle(0);
160 
161  for (unsigned int i = 0; i < nRoIs(); i++) drawBoxRoI(roI(i).eta, roI(i).phi, etaSize, phiSize);
162 }
163 
164 
165 void EventData::drawBoxRoI(double eta, double phi, double etaSize, double phiSize)
166 {
167  TBox box;
168  box.SetFillStyle(0);
169 
170  box.DrawBox(eta - etaSize/2, phi - phiSize/2, eta + etaSize/2, phi + phiSize/2);
171 }
172 
RunData.h
LArSamples::EventData::triggers
TString triggers() const
Definition: EventData.cxx:107
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LArSamples::EventData::nTriggerWords
unsigned int nTriggerWords() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:59
LArSamples::RoIPosition::name
TString name
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:26
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
LArSamples::EventData::bit
bool bit(unsigned int pos) const
Definition: EventData.cxx:98
LArSamples::EventData::event
int event() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
index
Definition: index.py:1
Data
@ Data
Definition: BaseObject.h:11
LArSamples::RunData::triggerBitPosition
int triggerBitPosition(const TString &triggerBitName) const
Definition: RunData.cxx:37
LArSamples::EventData::isPassed
bool isPassed(const TString &bitName) const
Definition: EventData.cxx:88
LArSamples::EventData::~EventData
virtual ~EventData()
Destructor.
Definition: EventData.cxx:53
runZdcNtuple.triggerConfig
triggerConfig
Definition: runZdcNtuple.py:28
LArSamples
Definition: AbsShape.h:24
LArSamples::EventData::roI
RoIPosition roI(unsigned int i) const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:64
LArSamples::EventData::nRoIs
unsigned int nRoIs() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:63
LArSamples::EventData::bunchId
unsigned int bunchId() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:50
LArSamples::EventData::m_eventData
std::vector< unsigned int > m_eventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:93
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArSamples::EventData::drawBoxRoIs
void drawBoxRoIs(double etaSize=0.2, double phiSize=0.2) const
Definition: EventData.cxx:156
LArSamples::ClassCounts::decrementInstanceCount
void decrementInstanceCount() const
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:33
LArSamples::EventData::setRunIndex
void setRunIndex(int idx)
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:91
LArSamples::EventData::run
int run() const
Definition: EventData.cxx:59
LArSamples::EventData::setTriggerData
void setTriggerData(const std::vector< unsigned int > &words)
Definition: EventData.cxx:75
run
Definition: run.py:1
LArSamples::EventData::drawDRRoIs
void drawDRRoIs(double roISize=0.1) const
Definition: EventData.cxx:147
EventData.h
LArSamples::EventData::EventData
EventData()
Constructor
Definition: EventData.cxx:21
LArSamples::EventData::triggerData
std::vector< unsigned int > triggerData() const
Definition: EventData.cxx:66
LArSamples::EventData::triggerWord
unsigned int triggerWord(unsigned int i) const
Definition: EventData.cxx:81
LArSamples::EventData::drawBoxRoI
static void drawBoxRoI(double eta, double phi, double etaSize=0.2, double phiSize=0.2)
Definition: EventData.cxx:165
LArSamples::ClassCounts::incrementInstanceCount
void incrementInstanceCount() const
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:32
covarianceTool.verbosity
verbosity
Definition: covarianceTool.py:513
LArSamples::RoIPosition::phi
double phi
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:25
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LArSamples::RunData::run
int run() const
Definition: RunData.h:36
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
LArSamples::RoIPosition::eta
double eta
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:25
str
Definition: BTagTrackIpAccessor.cxx:11
LArSamples::EventData::lumiBlock
unsigned int lumiBlock() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:47
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
LArSamples::EventData::roIs
TString roIs() const
Definition: EventData.cxx:122
LArSamples::EventData::description
TString description(unsigned int verbosity) const
Definition: EventData.cxx:131
LArSamples::EventData::runData
const RunData * runData() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:76
ClassCounts.h