Belle II Software development
QcsmonitorStudyModule.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 <beast/qcsmonitor/modules/QcsmonitorStudyModule.h>
10#include <beast/qcsmonitor/dataobjects/QcsmonitorSimHit.h>
11#include <beast/qcsmonitor/dataobjects/QcsmonitorHit.h>
12#include <generators/SAD/dataobjects/SADMetaHit.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/gearbox/GearDir.h>
15#include <framework/logging/Logger.h>
16#include <framework/gearbox/Const.h>
17#include <cmath>
18
19#include <string>
20
21int eventNum = 0;
22
23using namespace std;
24
25using namespace Belle2;
26using namespace qcsmonitor;
27
28//-----------------------------------------------------------------
29// Register the Module
30//-----------------------------------------------------------------
31REG_MODULE(QcsmonitorStudy);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38{
39 // Set module properties
40 setDescription("Study module for Qcsmonitors (BEAST)");
41
42 addParam("Ethres", m_Ethres, "Energy threshold in MeV", 0.0);
43}
44
46{
47}
48
49//This module is a histomodule. Any histogram created here will be saved by the HistoManager module
51{
52 for (int i = 0; i < 40; i++) {
53 h_qcss_Evtof1[i] = new TH2F(TString::Format("qcss_Evtof1_%d", i), "Energy deposited [MeV] vs TOF [ns] - all", 500, 0., 1000.,
54 100, 0., 10.);
55 h_qcss_Evtof2[i] = new TH2F(TString::Format("qcss_Evtof2_%d", i), "Energy deposited [MeV] vs TOF [ns] - only photons", 500, 0.,
56 100., 1000, 0., 10.);
57 h_qcss_Evtof3[i] = new TH2F(TString::Format("qcss_Evtof3_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
58 100., 1000, 0., 10.);
59 h_qcss_Evtof4[i] = new TH2F(TString::Format("qcss_Evtof4_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
60 100., 1000, 0., 10.);
61 h_qcss_edep[i] = new TH1F(TString::Format("qcss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
62 h_Wqcss_edep[i] = new TH1F(TString::Format("Wqcss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
63 }
64
65 h_qcss_hitrate0 = new TH1F("qcss_hitrate0", "Hit distributions", 100, 0., 100.);
66 h_qcss_hitrate1 = new TH1F("qcss_hitrate1", "Hit distributions", 100, 0., 100.);
67 h_qcss_hitrate2 = new TH1F("qcss_hitrate2", "Hit distributions", 100, 0., 100.);
68 h_qcss_hitrate1W = new TH1F("qcss_hitrate1W", "Hit distributions", 100, 0., 100.);
69 h_qcss_hitrate2W = new TH1F("qcss_hitrate2W", "Hit distributions", 100, 0., 100.);
70
71 h_qcss_hitrate0->Sumw2();
72 h_qcss_hitrate1->Sumw2();
73 h_qcss_hitrate1W->Sumw2();
74 h_qcss_hitrate2->Sumw2();
75 h_qcss_hitrate2W->Sumw2();
76
77 h_qcss_rs_hitrate1 = new TH2F("qcss_rs_hitrate1", "Hit distributions vs rs", 100, 0., 100., 12, 0., 12.);
78 h_qcss_rs_hitrate2 = new TH2F("qcss_rs_hitrate2", "Hit distributions vs rs", 100, 0., 100., 12, 0., 12.);
79 h_qcss_rs_hitrate1W = new TH2F("qcss_rs_hitrate1W", "Hit distributions vs rs", 100, 0., 100., 12, 0., 12.);
80 h_qcss_rs_hitrate2W = new TH2F("qcss_rs_hitrate2W", "Hit distributions vs rs", 100, 0., 100., 12, 0., 12.);
81
82 h_qcss_rs_hitrate1->Sumw2();
83 h_qcss_rs_hitrate1W->Sumw2();
84 h_qcss_rs_hitrate2->Sumw2();
85 h_qcss_rs_hitrate2W->Sumw2();
86
87 for (int i = 0; i < 40; i++) {
88 h_qcss_rate1[i] = new TH1F(TString::Format("qcss_rate1_%d", i), "PE distributions", 500, 0., 500.);
89 h_qcss_rate2[i] = new TH1F(TString::Format("qcss_rate2_%d", i), "PE distributions", 500, 0., 500.);
90 h_qcss_rate1W[i] = new TH1F(TString::Format("qcss_rate1W_%d", i), "PE distributions", 500, 0., 500.);
91 h_qcss_rate2W[i] = new TH1F(TString::Format("qcss_rate2W_%d", i), "PE distributions", 500, 0., 500.);
92 h_qcss_pe1[i] = new TH2F(TString::Format("qcss_pe1_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
93 h_qcss_pe2[i] = new TH2F(TString::Format("qcss_pe2_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
94 h_qcss_pe1W[i] = new TH2F(TString::Format("qcss_pe1W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
95 h_qcss_pe2W[i] = new TH2F(TString::Format("qcss_pe2W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
96
97 h_qcss_rs_rate1[i] = new TH2F(TString::Format("qcss_rs_rate1_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
98 h_qcss_rs_rate2[i] = new TH2F(TString::Format("qcss_rs_rate2_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
99 h_qcss_rs_rate1W[i] = new TH2F(TString::Format("qcss_rs_rate1W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
100 h_qcss_rs_rate2W[i] = new TH2F(TString::Format("qcss_rs_rate2W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
101
102 h_qcss_rate1[i]->Sumw2();
103 h_qcss_rate2[i]->Sumw2();
104 h_qcss_rate1W[i]->Sumw2();
105 h_qcss_rate2W[i]->Sumw2();
106 h_qcss_rs_rate1[i]->Sumw2();
107 h_qcss_rs_rate2[i]->Sumw2();
108 h_qcss_rs_rate1W[i]->Sumw2();
109 h_qcss_rs_rate2W[i]->Sumw2();
110 h_qcss_pe1[i]->Sumw2();
111 h_qcss_pe2[i]->Sumw2();
112 h_qcss_pe1W[i]->Sumw2();
113 h_qcss_pe2W[i]->Sumw2();
114 }
115}
116
117
119{
120 B2INFO("QcsmonitorStudyModule: Initialize");
121
122 REG_HISTOGRAM
123
124 //get QCSMONITORS parameters ie energy threshold
125 getXMLData();
126}
127
129{
130}
131
133{
134 //Here comes the actual event processing
137 StoreArray<SADMetaHit> MetaHits;
138
139 double rate = 0;
140 int ring_section = -1;
141 for (const auto& MetaHit : MetaHits) {
142 rate = MetaHit.getrate();
143 ring_section = MetaHit.getring_section() - 1;
144 }
145
146 //number of entries in SimHits
147 int nSimHits = SimHits.getEntries();
148
149 //loop over all SimHit entries
150 for (int i = 0; i < nSimHits; i++) {
151 QcsmonitorSimHit* aHit = SimHits[i];
152 int detNB = aHit->getCellId();
153 if (detNB < 40) {
154 //int trkID = aHit->getTrackId();
155 int pdg = aHit->getPDGCode();
156 double Edep = aHit->getEnergyDep() * 1e3; //GeV -> MeV
157 double tof = aHit->getFlightTime(); //ns
158
159 h_qcss_hitrate0->Fill(detNB);
160 h_qcss_Evtof1[detNB]->Fill(tof, Edep);
161 if (pdg == Const::photon.getPDGCode()) h_qcss_Evtof2[detNB]->Fill(tof, Edep);
162 else if (fabs(pdg) == Const::electron.getPDGCode()) h_qcss_Evtof3[detNB]->Fill(tof, Edep);
163 else h_qcss_Evtof4[detNB]->Fill(tof, Edep);
164 if (Edep > m_Ethres) {
165 h_qcss_edep[detNB]->Fill(Edep);
166 h_Wqcss_edep[detNB]->Fill(Edep, rate);
167 }
168 }
169 }
170
171 for (const auto& Hit : Hits) {
172 const int detNb = Hit.getdetNb();
173 if (detNb < 40) {
174 const int timebin = Hit.gettime();
175 const float edep = Hit.getedep();
176 const float pe = Hit.getPE();
177 h_qcss_hitrate1->Fill(detNb);
178 h_qcss_hitrate1W->Fill(detNb, rate);
179 h_qcss_rate1[detNb]->Fill(pe);
180 h_qcss_rate1W[detNb]->Fill(pe, rate);
181 h_qcss_rs_rate1[detNb]->Fill(pe, ring_section);
182 h_qcss_rs_rate1W[detNb]->Fill(pe, ring_section, rate);
183 h_qcss_rs_hitrate1->Fill(detNb, ring_section);
184 h_qcss_rs_hitrate1W->Fill(detNb, ring_section, rate);
185 h_qcss_pe1[detNb]->Fill(timebin, pe);
186 h_qcss_pe1W[detNb]->Fill(timebin, pe, rate);
187 if (edep > m_Ethres) {
188 h_qcss_hitrate2->Fill(detNb);
189 h_qcss_hitrate2W->Fill(detNb, rate);
190 h_qcss_rate2[detNb]->Fill(pe);
191 h_qcss_rate2W[detNb]->Fill(pe, rate);
192 h_qcss_rs_rate2[detNb]->Fill(pe, ring_section);
193 h_qcss_rs_rate2W[detNb]->Fill(pe, ring_section, rate);
194 h_qcss_rs_hitrate2->Fill(detNb, ring_section);
195 h_qcss_rs_hitrate2W->Fill(detNb, ring_section, rate);
196 h_qcss_pe2[detNb]->Fill(timebin, pe);
197 h_qcss_pe2W[detNb]->Fill(timebin, pe, rate);
198 }
199 }
200 }
201
202}
203
204//read energy threshold from QCSMONITOR.xml
206{
207 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"QCSMONITOR\"]/Content/");
208 m_Ethres = content.getDouble("Ethres");
209
210 B2INFO("QcsmonitorStudy");
211}
212
213
215{
216
217
218
219}
220
222{
223}
224
225
static const ParticleType photon
photon particle
Definition: Const.h:673
static const ChargedStable electron
electron particle
Definition: Const.h:659
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
ClassQcsmonitorSimHit - Geant4 simulated hit for the Qcsmonitor crystal in beast.
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
int getCellId() const
Get Cell ID.
double getFlightTime() const
Get Flight time from IP.
double getEnergyDep() const
Get Deposit energy.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
TH2F * h_qcss_Evtof3[48]
Energy deposited vs TOF.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
TH2F * h_qcss_Evtof1[48]
Energy deposited vs TOF.
virtual void endRun() override
End-of-run action.
TH2F * h_qcss_Evtof2[48]
Energy deposited vs TOF.
virtual void getXMLData()
reads data from QCSMONITOR.xml
virtual void terminate() override
Termination action.
QcsmonitorStudyModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void beginRun() override
Called when entering a new run.
TH2F * h_qcss_Evtof4[48]
Energy deposited vs TOF.
virtual void defineHisto() override
Defines the histograms.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:649
Abstract base class for different kinds of events.
STL namespace.
Structure to hold some of the calpulse data.