ATLAS Offline Software
Loading...
Searching...
No Matches
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
7
10#include "TMath.h"
11#include "TEllipse.h"
12#include "TBox.h"
13
14#include <iostream>
15using std::cout;
16using std::endl;
17
18using 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
32EventData::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
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
57
58
59int EventData::run() const
60{
61 if (!runData()) return -1;
62 return runData()->run();
63}
64
65
66std::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
75void EventData::setTriggerData(const std::vector<unsigned int>& l1Words)
76{
77 m_eventData.insert(m_eventData.end(), l1Words.begin(), l1Words.end());
78}
79
80
81unsigned int EventData::triggerWord(unsigned int i) const
82{
83 if (i >= nTriggerWords()) return 0;
84 return m_eventData[i + 4];
85}
86
87
88bool 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
98bool 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
107TString 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
122TString 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
131TString 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
147void 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
156void 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
165void 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
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
@ Data
Definition BaseObject.h:11
bool bit(unsigned int pos) const
Definition EventData.cxx:98
virtual ~EventData()
Destructor.
Definition EventData.cxx:53
std::vector< unsigned int > triggerData() const
Definition EventData.cxx:66
EventData()
Constructor.
Definition EventData.cxx:21
bool isPassed(const TString &bitName) const
Definition EventData.cxx:88
TString description(unsigned int verbosity) const
void setTriggerData(const std::vector< unsigned int > &words)
Definition EventData.cxx:75
TString roIs() const
unsigned int triggerWord(unsigned int i) const
Definition EventData.cxx:81
TString triggers() const
void drawBoxRoIs(double etaSize=0.2, double phiSize=0.2) const
void drawDRRoIs(double roISize=0.1) const
static void drawBoxRoI(double eta, double phi, double etaSize=0.2, double phiSize=0.2)
int run() const
Definition RunData.h:36
int triggerBitPosition(const TString &triggerBitName) const
Definition RunData.cxx:37
Definition index.py:1
Definition run.py:1