Belle II Software development
TOPChannelMaskCollectorModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <top/modules/collectors/TOPChannelMaskCollectorModule.h>
10#include <TH1F.h>
11#include <TH2F.h>
12
13using namespace std;
14
15namespace Belle2 {
21 //-----------------------------------------------------------------
23 //-----------------------------------------------------------------
24
25 REG_MODULE(TOPChannelMaskCollector);
26
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30
32 {
33 // set module description and processing properties
34 setDescription("A collector for preparing masks of dead and hot channels");
36 }
37
38
40 {
41
42 m_digits.isRequired();
43
44 auto nhits = new TH1F("nhits", "Number of good hits per event; hits per event; entries per bin", 200, 0, 2000);
45 registerObject<TH1F>("nhits", nhits);
46
47 for (int slot = 1; slot <= 16; slot++) {
48 string name = "hits_" + to_string(slot);
49 string title = "Channel occupancies for slot " + to_string(slot);
50 auto h = new TH1F(name.c_str(), title.c_str(), 512, 0, 512);
51 h->SetXTitle("channel number");
52 h->SetYTitle("number of hits per channel");
53 registerObject<TH1F>(name, h);
54 m_names.push_back(name);
55 }
56
57 for (int slot = 1; slot <= 16; slot++) {
58 string name = "window_vs_asic_" + to_string(slot);
59 string title = "Window vs. asic for slot " + to_string(slot);
60 auto h = new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 512, 0, 512);
61 h->SetXTitle("ASIC number");
62 h->SetYTitle("window number w.r.t reference window");
63 registerObject<TH2F>(name, h);
64 m_asicNames.push_back(name);
65 }
66
67 }
68
69
71 {
72
73 std::vector<TH1F*> slots;
74 for (const auto& name : m_names) {
75 auto h = getObjectPtr<TH1F>(name);
76 slots.push_back(h);
77 }
78
79 std::vector<TH2F*> asics;
80 for (const auto& name : m_asicNames) {
81 auto h = getObjectPtr<TH2F>(name);
82 asics.push_back(h);
83 }
84
85 int NGood = 0;
86 for (const auto& digit : m_digits) {
87 if (digit.getHitQuality() == TOPDigit::c_Junk) continue;
88 NGood++;
89 unsigned m = digit.getModuleID() - 1;
90 if (m < slots.size()) slots[m]->Fill(digit.getChannel());
91 if (m < asics.size()) asics[m]->Fill(digit.getChannel() / 8, digit.getRawTime() / 64 + 220);
92 }
93
94 auto h = getObjectPtr<TH1F>("nhits");
95 h->Fill(NGood);
96
97 }
98
100}
101
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
std::vector< std::string > m_asicNames
histogram names: window vs.
std::vector< std::string > m_names
histogram names: channel occupancies
StoreArray< TOPDigit > m_digits
collection of TOP digits
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
virtual void collect() final
Replacement for event().
virtual void prepare() final
Replacement for initialize().
Abstract base class for different kinds of events.
STL namespace.