Belle II Software development
TOPPulseHeightCollectorModule.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/TOPPulseHeightCollectorModule.h>
10#include <TH1F.h>
11#include <TH2F.h>
12
13using namespace std;
14
15namespace Belle2 {
21 //-----------------------------------------------------------------
23 //-----------------------------------------------------------------
24
25 REG_MODULE(TOPPulseHeightCollector);
26
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30
32 {
33 // set module description and processing properties
34 setDescription("A collector for channel pulse-height distributions");
36
37 // module parameters
38 addParam("nx", m_nx, "number of histogram bins", 200);
39 addParam("xmax", m_xmax, "histogram upper limit [ADC counts]", 2000.0);
40 addParam("pulseWidthWindow", m_widthWindow,
41 "lower and upper bound of pulse-width selection window [ns]. "
42 "Empty list means no selection on the pulse width. "
43 "Note: selection on pulse width will influence pulse-height distribution.",
45 addParam("timeWindow", m_timeWindow,
46 "lower and upper bound of time selection window [ns]. "
47 "Empty list means no selection on photon time.", m_timeWindow);
48
49 }
50
51
53 {
54
55 m_digits.isRequired();
56
57 auto h1a = new TH1F("time", "time distribution (all hits)", 1000, -100, 250);
58 h1a->SetXTitle("time [ns]");
59 registerObject<TH1F>("time", h1a);
60
61 auto h1b = new TH1F("time_sel", "time distribution (selected hits)", 1000, -100, 250);
62 h1b->SetXTitle("time [ns]");
63 registerObject<TH1F>("time_sel", h1b);
64
65 auto h2a = new TH2F("ph_vs_width", "pulse height vs. width (all hits)",
66 200, 0, 10, 200, 0, 2000);
67 h2a->SetXTitle("pulse width [ns]");
68 h2a->SetYTitle("pulse height [ADC counts]");
69 registerObject<TH2F>("ph_vs_width", h2a);
70
71 auto h2b = new TH2F("ph_vs_width_sel", "pulse height vs. width (selected hits)",
72 200, 0, 10, 200, 0, 2000);
73 h2b->SetXTitle("pulse width [ns]");
74 h2b->SetYTitle("pulse height [ADC counts]");
75 registerObject<TH2F>("ph_vs_width_sel", h2b);
76
77 for (int slot = 1; slot <= 16; slot++) {
78 string name = "ph_slot_" + to_string(slot);
79 string title = "pulse-height vs. channel for slot " + to_string(slot);
80 auto h = new TH2F(name.c_str(), title.c_str(), 512, 0, 512, m_nx, 0, m_xmax);
81 h->SetXTitle("channel number");
82 h->SetYTitle("pulse height [ADC counts]");
83 registerObject<TH2F>(name, h);
84 m_names.push_back(name);
85 }
86
87 }
88
89
91 {
92
93 std::vector<TH2F*> slots;
94 for (const auto& name : m_names) {
95 auto h = getObjectPtr<TH2F>(name);
96 slots.push_back(h);
97 }
98
99 auto h1a = getObjectPtr<TH1F>("time");
100 auto h1b = getObjectPtr<TH1F>("time_sel");
101 auto h2a = getObjectPtr<TH2F>("ph_vs_width");
102 auto h2b = getObjectPtr<TH2F>("ph_vs_width_sel");
103
104 for (const auto& digit : m_digits) {
105 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
106 auto t = digit.getTime();
107 auto w = digit.getPulseWidth();
108 auto ph = digit.getPulseHeight();
109 h1a->Fill(t);
110 h2a->Fill(w, ph);
111 if (m_widthWindow.size() == 2) {
112 if (w < m_widthWindow[0] or w > m_widthWindow[1]) continue;
113 }
114 if (m_timeWindow.size() == 2) {
115 if (t < m_timeWindow[0] or t > m_timeWindow[1]) continue;
116 }
117 h1b->Fill(t);
118 h2b->Fill(w, ph);
119 unsigned m = digit.getModuleID() - 1;
120 if (m < slots.size()) slots[m]->Fill(digit.getChannel(), ph);
121 }
122
123 }
124
126}
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_names
histogram names
double m_xmax
histogram upper bound [ADC counts]
std::vector< double > m_widthWindow
lower and upper bound of pulse-width window
std::vector< double > m_timeWindow
lower and upper bound of time window
StoreArray< TOPDigit > m_digits
collection of TOP digits
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.