ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
DataQualityUtils
src
MonitoringFile_L1CaloPostProcess.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// **********************************************************************
6
// L1Calo post processing jobs
7
// Author: Peter Faulkner
8
// **********************************************************************
9
10
#include "
DataQualityUtils/MonitoringFile.h
"
11
12
#include <string>
13
#include <format>
14
15
#include <TDirectory.h>
16
#include <TFile.h>
17
#include <TH1.h>
18
#include <TKey.h>
19
#include <TObject.h>
20
21
#ifndef L1CALOPOSTPROCESSDEBUG
22
#define L1CALOPOSTPROCESSDEBUG false
23
#endif
24
25
namespace
dqutils
{
26
//--------------------------------------------------------------------------------
27
// main process
28
//--------------------------------------------------------------------------------
29
void
MonitoringFile::L1CaloPostProcess
(
const
std::string& inFilename,
bool
/* isIncremental */
) {
30
//bool debug = L1CALOPOSTPROCESSDEBUG;
31
32
//if (debug) std::cout << "--> L1CaloPostProcess: Begin L1Calo post-processing" << std::endl;
33
34
//open root file
35
TFile* f = TFile::Open(inFilename.c_str(),
"UPDATE"
);
36
37
//check files are loaded.
38
if
(f == 0 || !f->IsOpen()) {
39
std::cerr <<
"--> L1CaloPostProcess: Input file not opened"
<< std::endl;
40
delete
f;
41
return
;
42
}
43
44
//zombie files?
45
if
(f->IsZombie()) {
46
std::cerr <<
"--> L1CaloPostProcess: Input file "
<< inFilename <<
" cannot be opened. "
<< std::endl;
47
delete
f;
48
return
;
49
}
50
51
//check file size is not too small.
52
if
(f->GetSize() < 1000.) {
53
std::cerr <<
"--> L1CaloPostProcess: Input file empty"
<< std::endl;
54
f->Close();
55
delete
f;
56
return
;
57
}
58
59
//build iterator
60
TIter next_run(f->GetListOfKeys());
61
TKey* key_run(0);
62
static
const
std::string energies[6] = {
63
"10"
,
"20"
,
"30"
,
"50"
,
"100"
,
"200"
64
};
65
static
const
double
threshold
[6] = {
66
3., 3., 3., 6., 4., 2.
67
};
68
//loop over keys in root directory
69
while
((key_run =
dynamic_cast<
TKey*
>
(next_run())) != 0) {
70
TObject* obj_run = key_run->ReadObj();
71
TDirectory* tdir_run =
dynamic_cast<
TDirectory*
>
(obj_run);
72
73
//check we have a valid pointer
74
if
(tdir_run == 0) {
75
delete
obj_run;
76
continue
;
77
}
78
79
//check name
80
std::string runDirName(tdir_run->GetName());
81
//if (debug) std::cout << "Run_directory: " << runDirName << std::endl;
82
83
if
(runDirName.find(
"run"
) == std::string::npos) {
84
delete
obj_run;
85
continue
;
86
}
87
88
// Stability RMS histograms
89
std::string stabilityDirName = runDirName +
"/L1Calo/PPM/Stability"
;
90
L1CaloStabilityRMS
(f, stabilityDirName +
"/FineTime"
,
"fineTime"
);
91
L1CaloStabilityRMS
(f, stabilityDirName +
"/Pedestal"
,
"pedestal"
);
92
L1CaloStabilityRMS
(f, stabilityDirName +
"/EtCorrelation"
,
"etCorrelation"
);
93
94
// Trigger efficiency eta-phi histograms
95
int
items = 16;
96
int
binSkip = 8;
97
98
for
(
int
i = 0; i < 3; ++i) {
99
std::string effDir = runDirName +
"/L1Calo/Reco/EmEfficiencies/ClusterRaw_"
100
+ energies[i] +
"GeV_EtaVsPhi"
;
101
std::string nameDen =
"ClusterRaw_"
+ energies[i] +
"GeV_Eta_vs_Phi"
;
102
std::string nameEff = nameDen +
"_trig_Eff"
;
103
L1CaloResetEfficiencies
(f, effDir, nameDen, nameEff, items,
threshold
[i], binSkip);
104
}
105
items = 8;
106
binSkip = 6;
107
int
itemsF = 4;
108
int
binSkipF = 0;
109
for
(
int
i = 3; i < 6; ++i) {
110
std::string effDir = runDirName +
"/L1Calo/Reco/JetEfficiencies/JetEmScale_"
111
+ energies[i] +
"GeV_EtaVsPhi"
;
112
std::string nameDen =
"JetEmScale_"
+ energies[i] +
"GeV_Eta_vs_Phi"
;
113
std::string nameEff = nameDen +
"_J_Eff_item"
;
114
std::string nameEffF = nameDen +
"_FJ_J_Eff_item"
;
115
L1CaloResetEfficiencies
(f, effDir, nameDen, nameEff, items,
threshold
[i], binSkip);
116
L1CaloResetEfficiencies
(f, effDir, nameDen, nameEffF, itemsF,
threshold
[i], binSkipF);
117
}
118
}
119
120
f->Close();
121
delete
f;
122
//if (debug) std::cout << "--> L1CaloPostProcess: finished L1Calo post-processing"
123
// << std::endl;
124
}
125
126
// Get RMS from stability profiles
127
128
void
MonitoringFile::L1CaloStabilityRMS
(TFile* f,
const
std::string& nameDir,
129
const
std::string& nameTag) {
130
std::string nameData(
"ppm_em_2d_profile_etaPhi_adc_"
+ nameTag);
131
std::string nameError(
"ppm_em_2d_etaPhi_adc_"
+ nameTag +
"RMS"
);
132
133
L1CaloFillWithError
(f, nameDir, nameData, nameError);
134
nameData =
"ppm_had_2d_profile_etaPhi_adc_"
+ nameTag;
135
nameError =
"ppm_had_2d_etaPhi_adc_"
+ nameTag +
"RMS"
;
136
L1CaloFillWithError
(f, nameDir, nameData, nameError);
137
}
138
139
// Fill second histogram with error from first
140
141
void
MonitoringFile::L1CaloFillWithError
(TFile* f,
const
std::string& nameDir,
142
const
std::string& nameData,
const
std::string& nameError) {
143
//const bool debug = L1CALOPOSTPROCESSDEBUG;
144
145
// Check directory
146
if
(!(f->GetDirectory(nameDir.c_str()))) {
147
//if (debug) std::cout << "--> L1CaloPostProcess: directory "
148
// << nameDir << " not found." << std::endl;
149
return
;
150
}
151
if
(f->cd(nameDir.c_str()) == 0) {
152
//if (debug) std::cout << "dir " << nameDir << " isn't there!" << std::endl;
153
return
;
154
}
155
156
// Data histogram
157
std::string p1 = nameDir +
"/"
+ nameData;
158
if
(!
CheckHistogram
(f, p1.c_str())) {
159
//if (debug) std::cout << " histo " << p1.Data() << " is not in file "
160
// << f->GetName() << std::endl;
161
return
;
162
}
163
TH1* h1 = (TH1*) (f->Get(p1.c_str()));
164
165
// Error histogram
166
std::string p2 = nameDir +
"/"
+ nameError;
167
if
(!
CheckHistogram
(f, p2.c_str())) {
168
//if (debug) std::cout << " histo " << p2.Data() << " is not in file "
169
// << f->GetName() << std::endl;
170
return
;
171
}
172
TH1* h2 = (TH1*) (f->Get(p2.c_str()));
173
174
// Consistency checks
175
const
int
dim = h1->GetDimension();
176
if
(dim != h2->GetDimension()) {
177
//if (debug) std::cout << "Histograms have different dimension" << std::endl;
178
return
;
179
}
180
if
(h1->GetNbinsX() != h2->GetNbinsX() ||
181
((dim == 2) && (h1->GetNbinsY() != h2->GetNbinsY()))) {
182
//if (debug) std::cout << "Histograms have different number of bins" << std::endl;
183
return
;
184
}
185
186
// Fill error histogram
187
h2->Reset();
188
int
nbins = h1->GetNbinsX() + 2;
189
if
(dim == 2) nbins *= (h1->GetNbinsY() + 2);
190
for
(
int
bin
= 0;
bin
< nbins; ++
bin
) {
191
double
error
= h1->GetBinError(
bin
);
192
if
(
error
!= 0.) h2->SetBinContent(
bin
,
error
);
193
}
194
195
// And save
196
h2->Write(
""
, TObject::kOverwrite);
197
f->Write();
198
}
199
200
// Reset efficiencies to 100% for bins with low stats
201
202
void
MonitoringFile::L1CaloResetEfficiencies
(TFile* f,
const
std::string& effDir,
203
const
std::string& nameDen,
const
std::string& nameEff,
204
int
items,
double
threshold
,
int
binSkip) {
205
//const bool debug = L1CALOPOSTPROCESSDEBUG;
206
207
// Check directory
208
if
(!(f->GetDirectory(effDir.c_str()))) {
209
//if (debug) std::cout << "--> L1CaloPostProcess: directory "
210
// << effDir << " not found." << std::endl;
211
return
;
212
}
213
if
(f->cd(effDir.c_str()) == 0) {
214
//if (debug) std::cout << "dir " << effDir << " isn't there!" << std::endl;
215
return
;
216
}
217
218
// Denominator histogram
219
std::string denPath = effDir +
"/denominator/"
+ nameDen;
220
TH1* h1 = (TH1*) (f->Get(denPath.c_str()));
221
if
(!h1) {
222
//if (debug) std::cout << " histo " << denPath << " is not in file "
223
// << f->GetName() << std::endl;
224
return
;
225
}
226
if
(h1->GetDimension() != 2) {
227
//if (debug) std::cout << " histo " << denPath << " has unexpected dimension"
228
// << std::endl;
229
return
;
230
}
231
232
// Efficiency histograms
233
int
xbins = h1->GetNbinsX();
234
int
ybins = h1->GetNbinsY();
235
std::vector<TH1*> effVec;
236
std::string effBase = effDir +
"/"
+ nameEff;
237
for
(
int
i = 0; i < items; ++i) {
238
std::string effPath = effBase + std::format(
"_{:d}"
, i);
239
TH1* h2 = (TH1*) (f->Get(effPath.c_str()));
240
if
(!h2) {
241
//if (debug) std::cout << " histo " << effPath << " is not in file "
242
// << f->GetName() << std::endl;
243
continue
;
244
}
245
if
(h2->GetDimension() != 2) {
246
//if (debug) std::cout << " histo " << effPath << " has unexpected dimension"
247
// << std::endl;
248
continue
;
249
}
250
if
(xbins != h2->GetNbinsX() || ybins != h2->GetNbinsY()) {
251
//if (debug) std::cout << " histos " << denPath << " and " << effPath
252
// << " have different number of bins" << std::endl;
253
continue
;
254
}
255
effVec.push_back(h2);
256
}
257
if
(effVec.empty()) {
258
//if (debug) std::cout << "No valid histograms in " << effDir << std::endl;
259
return
;
260
}
261
std::vector<TH1*>::iterator iter;
262
std::vector<TH1*>::iterator iterEnd = effVec.end();
263
264
// Loop over bins in denominator looking for entries below threshold
265
for
(
int
x
= 1 + binSkip;
x
<= xbins - binSkip; ++
x
) {
266
for
(
int
y
= 1;
y
<= ybins; ++
y
) {
267
if
(h1->GetBinContent(
x
,
y
) <
threshold
) {
268
// Loop over efficiency histograms and set bin to 100% efficiency
269
for
(iter = effVec.begin(); iter != iterEnd; ++iter) {
270
(*iter)->SetBinContent(
x
,
y
, 100.0);
271
}
272
}
273
}
274
}
275
276
// Save the updated histograms
277
for
(iter = effVec.begin(); iter != iterEnd; ++iter) {
278
(*iter)->Write(
""
, TObject::kOverwrite);
279
}
280
f->Write();
281
}
282
}
283
284
#undef L1CALOPOSTPROCESSDEBUG
MonitoringFile.h
y
#define y
x
#define x
bin
Definition
BinsDiffFromStripMedian.h:43
dqutils::MonitoringFile::L1CaloPostProcess
static void L1CaloPostProcess(const std::string &inFileName, bool isIncremental=false)
Definition
MonitoringFile_L1CaloPostProcess.cxx:29
dqutils::MonitoringFile::L1CaloStabilityRMS
static void L1CaloStabilityRMS(TFile *f, const std::string &nameDir, const std::string &nameTag)
Definition
MonitoringFile_L1CaloPostProcess.cxx:128
dqutils::MonitoringFile::L1CaloFillWithError
static void L1CaloFillWithError(TFile *f, const std::string &nameDir, const std::string &nameData, const std::string &nameError)
Definition
MonitoringFile_L1CaloPostProcess.cxx:141
dqutils::MonitoringFile::L1CaloResetEfficiencies
static void L1CaloResetEfficiencies(TFile *f, const std::string &effDir, const std::string &nameDen, const std::string &nameEff, int items, double threshold, int binSkip)
Definition
MonitoringFile_L1CaloPostProcess.cxx:202
dqutils::MonitoringFile::CheckHistogram
static bool CheckHistogram(TFile *f, const char *HistoName)
dqutils
Definition
CoolMdt.h:51
error
Definition
IImpactPoint3dEstimator.h:72
threshold
Definition
chainparser.cxx:74
Generated on
for ATLAS Offline Software by
1.17.0