Skip to content

Commit 194974e

Browse files
committed
Add optional QA Histograms to CaloStatusSkimmer
Adding histograms, and method to toggle QA output
1 parent fbace92 commit 194974e

File tree

3 files changed

+138
-12
lines changed

3 files changed

+138
-12
lines changed

offline/packages/Skimmers/CaloStatusSkimmer/CaloStatusSkimmer.cc

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,84 @@
11
#include "CaloStatusSkimmer.h"
22

33
#include <fun4all/Fun4AllReturnCodes.h>
4+
#include <fun4all/Fun4AllHistoManager.h>
45

56
#include <phool/PHCompositeNode.h>
67
#include <phool/getClass.h>
78
#include <phool/phool.h>
89

10+
#include <qautils/QAHistManagerDef.h>
11+
912
#include <calobase/TowerInfo.h>
1013
#include <calobase/TowerInfoContainer.h>
1114

15+
#include <cassert>
1216
#include <cstdint>
1317
#include <iostream>
1418

19+
#include <TH1F.h>
20+
1521
//____________________________________________________________________________..
1622
CaloStatusSkimmer::CaloStatusSkimmer(const std::string &name)
1723
: SubsysReco(name)
1824
{
1925
std::cout << "CaloStatusSkimmer::CaloStatusSkimmer(const std::string &name) ""Calling ctor" << std::endl;
2026
}
2127

28+
29+
//____________________________________________________________________________..
30+
int CaloStatusSkimmer::Init([[maybe_unused]] PHCompositeNode *topNode)
31+
{
32+
std::cout << "CaloStatusSkimmer::Init(PHCompositeNode *topNode) This is Init..." << std::endl;
33+
34+
if (b_produce_QA_histograms)
35+
{
36+
auto* hm = QAHistManagerDef::getHistoManager();
37+
assert(hm);
38+
39+
h_EMC_nTowers_notinstr = new TH1F("h_EMC_nTowers_notinstr", "Number of not-instrumented(empty/missing pckt) towers in EMCal; nNotInstrTowers; Counts", 193, -0.5, 192.5);
40+
h_EMC_nTowers_notinstr->SetDirectory(nullptr);
41+
h_HCal_nTowers_notinstr = new TH1F("h_HCal_nTowers_notinstr", "Number of not-instrumented(empty/missing pckt) towers in HCal; nNotInstrTowers; Counts", 193, -0.5, 192.5);
42+
h_HCal_nTowers_notinstr->SetDirectory(nullptr);
43+
h_sEPD_nTowers_notinstr = new TH1F("h_sEPD_nTowers_notinstr", "Number of not-instrumented(empty/missing pckt) towers in sEPD; nNotInstrTowers; Counts", 17, -0.5, 16.5);
44+
h_sEPD_nTowers_notinstr->SetDirectory(nullptr);
45+
h_ZDC_nTowers_notinstr = new TH1F("h_ZDC_nTowers_notinstr", "Number of not-instrumented(empty/missing pckt) towers in ZDC; nNotInstrTowers; Counts", 5, -0.5, 4.5);
46+
h_ZDC_nTowers_notinstr->SetDirectory(nullptr);
47+
48+
h_EMC_nEvents = new TH1F("h_EMC_nEvents", "Number of events", 2, 0.5, 2.5);
49+
h_EMC_nEvents->GetXaxis()->SetBinLabel(1, "Total events processed");
50+
h_EMC_nEvents->GetXaxis()->SetBinLabel(2, "Total events skimmed");
51+
h_EMC_nEvents->SetDirectory(nullptr);
52+
53+
h_HCal_nEvents = new TH1F("h_HCal_nEvents", "Number of events", 2, 0.5, 2.5);
54+
h_HCal_nEvents->GetXaxis()->SetBinLabel(1, "Total events processed");
55+
h_HCal_nEvents->GetXaxis()->SetBinLabel(2, "Total events skimmed");
56+
h_HCal_nEvents->SetDirectory(nullptr);
57+
58+
h_sEPD_nEvents = new TH1F("h_sEPD_nEvents", "Number of events", 2, 0.5, 2.5);
59+
h_sEPD_nEvents->GetXaxis()->SetBinLabel(1, "Total events processed");
60+
h_sEPD_nEvents->GetXaxis()->SetBinLabel(2, "Total events skimmed");
61+
h_sEPD_nEvents->SetDirectory(nullptr);
62+
63+
h_ZDC_nEvents = new TH1F("h_ZDC_nEvents", "Number of events", 2, 0.5, 2.5);
64+
h_ZDC_nEvents->GetXaxis()->SetBinLabel(1, "Total events processed");
65+
h_ZDC_nEvents->GetXaxis()->SetBinLabel(2, "Total events skimmed");
66+
h_ZDC_nEvents->SetDirectory(nullptr);
67+
68+
hm->registerHisto(h_EMC_nTowers_notinstr);
69+
hm->registerHisto(h_HCal_nTowers_notinstr);
70+
hm->registerHisto(h_sEPD_nTowers_notinstr);
71+
hm->registerHisto(h_ZDC_nTowers_notinstr);
72+
73+
hm->registerHisto(h_EMC_nEvents);
74+
hm->registerHisto(h_HCal_nEvents);
75+
hm->registerHisto(h_sEPD_nEvents);
76+
hm->registerHisto(h_ZDC_nEvents);
77+
}
78+
79+
return Fun4AllReturnCodes::EVENT_OK;
80+
}
81+
2282
//____________________________________________________________________________..
2383
int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
2484
{
@@ -32,7 +92,7 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
3292
n_notowernodecounter++;
3393
if (Verbosity() > 0)
3494
{
35-
std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_CEMC" << std::endl;
95+
std::cout << PHWHERE << "CaloStatusSkimmer::process_event: missing TOWERS_CEMC" << std::endl;
3696
}
3797
return Fun4AllReturnCodes::ABORTEVENT;
3898
}
@@ -51,6 +111,11 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
51111
std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in EMCal = " << ntowers << ", not-instrumented(empty/missing pckt) towers in EMCal = " << notinstr_count << std::endl;
52112
}
53113

114+
if (b_produce_QA_histograms)
115+
{
116+
h_EMC_nTowers_notinstr->Fill(notinstr_count);
117+
}
118+
54119
if (notinstr_count >= m_EMC_skim_threshold)
55120
{
56121
n_skimcounter++;
@@ -67,7 +132,7 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
67132
n_notowernodecounter++;
68133
if (Verbosity() > 0)
69134
{
70-
std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_HCALIN or TOWERS_HCALOUT" << std::endl;
135+
std::cout << PHWHERE << "CaloStatusSkimmer::process_event: missing TOWERS_HCALIN or TOWERS_HCALOUT" << std::endl;
71136
}
72137
return Fun4AllReturnCodes::ABORTEVENT;
73138
}
@@ -99,6 +164,12 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
99164
std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in HCalIn = " << ntowers_hcalin << ", not-instrumented(empty/missing pckt) towers in HCalIn = " << notinstr_count_hcalin << ", ntowers in HCalOut = " << ntowers_hcalout << ", not-instrumented(empty/missing pckt) towers in HCalOut = " << notinstr_count_hcalout << std::endl;
100165
}
101166

167+
if (b_produce_QA_histograms)
168+
{
169+
h_HCal_nTowers_notinstr->Fill(notinstr_count_hcalin);
170+
h_HCal_nTowers_notinstr->Fill(notinstr_count_hcalout);
171+
}
172+
102173
if (notinstr_count_hcalin >= m_HCal_skim_threshold ||
103174
notinstr_count_hcalout >= m_HCal_skim_threshold)
104175
{
@@ -116,7 +187,7 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
116187
n_notowernodecounter++;
117188
if (Verbosity() > 0)
118189
{
119-
std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_SEPD" << std::endl;
190+
std::cout << PHWHERE << "CaloStatusSkimmer::process_event: missing TOWERS_SEPD" << std::endl;
120191
}
121192
return Fun4AllReturnCodes::ABORTEVENT;
122193
}
@@ -136,6 +207,11 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
136207
std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in sEPD = " << ntowers << ", not-instrumented(empty/missing pckt) towers in sEPD = " << notinstr_count << std::endl;
137208
}
138209

210+
if(b_produce_QA_histograms)
211+
{
212+
h_sEPD_nTowers_notinstr->Fill(notinstr_count);
213+
}
214+
139215
if (notinstr_count >= m_sEPD_skim_threshold)
140216
{
141217
n_skimcounter++;
@@ -152,7 +228,7 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
152228
n_notowernodecounter++;
153229
if (Verbosity() > 0)
154230
{
155-
std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_ZDC" << std::endl;
231+
std::cout << PHWHERE << "CaloStatusSkimmer::process_event: missing TOWERS_ZDC" << std::endl;
156232
}
157233
return Fun4AllReturnCodes::ABORTEVENT;
158234
}
@@ -172,6 +248,11 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
172248
std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in ZDC = " << ntowers << ", not-instrumented(empty/missing pckt) towers in ZDC = " << notinstr_count << std::endl;
173249
}
174250

251+
if(b_produce_QA_histograms)
252+
{
253+
h_ZDC_nTowers_notinstr->Fill(notinstr_count);
254+
}
255+
175256
if (notinstr_count >= m_ZDC_skim_threshold)
176257
{
177258
n_skimcounter++;
@@ -186,9 +267,25 @@ int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
186267
int CaloStatusSkimmer::End([[maybe_unused]] PHCompositeNode *topNode)
187268
{
188269
std::cout << "CaloStatusSkimmer::End(PHCompositeNode *topNode) This is the End..." << std::endl;
189-
std::cout << "Total events processed: " << n_eventcounter << std::endl;
190-
std::cout << "Total events skimmed: " << n_skimcounter << std::endl;
191-
std::cout << "Total events with missing tower nodes: " << n_notowernodecounter << std::endl;
270+
std::cout << "CaloStatusSkimmer::End Total events processed: " << n_eventcounter << std::endl;
271+
std::cout << "CaloStatusSkimmer::End Total events skimmed: " << n_skimcounter << std::endl;
272+
std::cout << "CaloStatusSkimmer::End Total events with missing tower nodes: " << n_notowernodecounter << std::endl;
273+
274+
if (b_produce_QA_histograms)
275+
{
276+
h_EMC_nEvents->SetBinContent(1, n_eventcounter);
277+
h_EMC_nEvents->SetBinContent(2, n_skimcounter);
278+
279+
h_HCal_nEvents->SetBinContent(1, n_eventcounter);
280+
h_HCal_nEvents->SetBinContent(2, n_skimcounter);
281+
282+
h_sEPD_nEvents->SetBinContent(1, n_eventcounter);
283+
h_sEPD_nEvents->SetBinContent(2, n_skimcounter);
284+
285+
h_ZDC_nEvents->SetBinContent(1, n_eventcounter);
286+
h_ZDC_nEvents->SetBinContent(2, n_skimcounter);
287+
288+
}
192289

193290
return Fun4AllReturnCodes::EVENT_OK;
194291
}

offline/packages/Skimmers/CaloStatusSkimmer/CaloStatusSkimmer.h

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
#include <string>
1111
#include <utility>
1212

13+
#include <TH1F.h>
14+
1315
class PHCompositeNode;
16+
class TH1F;
1417

1518
class CaloStatusSkimmer : public SubsysReco {
1619
public:
1720
CaloStatusSkimmer(const std::string &name = "CaloStatusSkimmer");
1821

1922
~CaloStatusSkimmer() override = default;
2023

24+
int Init(PHCompositeNode* topNode) override;
25+
2126
/** Called for each event.
2227
This is where you do the real work.
2328
*/
@@ -26,27 +31,38 @@ class CaloStatusSkimmer : public SubsysReco {
2631
/// Called at the end of all processing.
2732
int End(PHCompositeNode *topNode) override;
2833

29-
void do_skim_EMCal( uint16_t threshold) {
34+
void do_skim_EMCal( uint16_t threshold)
35+
{
3036
m_EMC_skim_threshold = threshold;
3137
}
3238

33-
void do_skim_HCal( uint16_t threshold) {
39+
void do_skim_HCal( uint16_t threshold)
40+
{
3441
m_HCal_skim_threshold = threshold;
3542
}
3643

37-
void do_skim_sEPD( uint16_t threshold) {
44+
void do_skim_sEPD( uint16_t threshold)
45+
{
3846
m_sEPD_skim_threshold = threshold;
3947
}
4048

41-
void do_skim_ZDC( uint16_t threshold) {
49+
void do_skim_ZDC( uint16_t threshold)
50+
{
4251
m_ZDC_skim_threshold = threshold;
4352
}
4453

54+
void produce_QA_histograms(bool produce)
55+
{
56+
b_produce_QA_histograms = produce;
57+
}
58+
4559
private:
4660
uint32_t n_eventcounter{0};
4761
uint32_t n_skimcounter{0};
4862
uint32_t n_notowernodecounter{0};
4963

64+
bool b_produce_QA_histograms{false};
65+
5066
// If the threshold is set to 0, then the skimming for that subsystem is disabled. If threshold is > 0, then the event is skimmed if nchannels >= threshold not-instrumented (empty/missing packet) channels in that subsystem.
5167
uint16_t m_EMC_skim_threshold{192};
5268
// skim if nchannels >= this many not-instrumented (empty/missing packet) channels in EMCal
@@ -59,6 +75,18 @@ class CaloStatusSkimmer : public SubsysReco {
5975

6076
uint16_t m_ZDC_skim_threshold{1};
6177
// skim if nchannels >= this many not-instrumented (empty/missing packet) channels in ZDC
78+
79+
//histograms
80+
TH1F* h_EMC_nTowers_notinstr = nullptr;
81+
TH1F* h_HCal_nTowers_notinstr = nullptr;
82+
TH1F* h_sEPD_nTowers_notinstr = nullptr;
83+
TH1F* h_ZDC_nTowers_notinstr = nullptr;
84+
85+
TH1F* h_EMC_nEvents = nullptr;
86+
TH1F* h_HCal_nEvents = nullptr;
87+
TH1F* h_sEPD_nEvents = nullptr;
88+
TH1F* h_ZDC_nEvents = nullptr;
89+
6290
};
6391

6492
#endif // CALOSTATUSSKIMMER_H

offline/packages/Skimmers/CaloStatusSkimmer/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ libCaloStatusSkimmer_la_SOURCES = \
2222
libCaloStatusSkimmer_la_LIBADD = \
2323
-lphool \
2424
-lSubsysReco \
25-
-lcalo_io
25+
-lcalo_io \
26+
-lqautils
2627

2728
BUILT_SOURCES = testexternals.cc
2829

0 commit comments

Comments
 (0)