Belle II Software development
ClawsStudyModule.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/claws/modules/ClawsStudyModule.h>
10#include <beast/claws/dataobjects/ClawsHit.h>
11#include <generators/SAD/dataobjects/SADMetaHit.h>
12#include <framework/datastore/StoreArray.h>
13#include <framework/gearbox/GearDir.h>
14#include <framework/logging/Logger.h>
15#include <framework/gearbox/Const.h>
16
17#include <fstream>
18#include <string>
19
20// ROOT
21#include <TH1.h>
22#include <TH2.h>
23
24using namespace std;
25
26using namespace Belle2;
27using namespace claws;
28
29//-----------------------------------------------------------------
30// Register the Module
31//-----------------------------------------------------------------
32REG_MODULE(ClawsStudy);
33
34//-----------------------------------------------------------------
35// Implementation
36//-----------------------------------------------------------------
37
39{
40 // Set module properties
41 setDescription("Study module for Clawss (BEAST)");
42
43 addParam("Ethres", m_Ethres, "Energy threshold in MeV", 0.0);
44}
45
47{
48}
49
50//This module is a histomodule. Any histogram created here will be saved by the HistoManager module
52{
53 /*
54 for (int i = 0; i < 16; i++) {
55 h_clawss_Evtof1[i] = new TH2F(TString::Format("clawss_Evtof1_%d", i), "Energy deposited [MeV] vs TOF [ns] - all", 500, 0., 1000.,
56 100, 0., 10.);
57 h_clawss_Evtof2[i] = new TH2F(TString::Format("clawss_Evtof2_%d", i), "Energy deposited [MeV] vs TOF [ns] - only photons", 500, 0.,
58 100., 1000, 0., 10.);
59 h_clawss_Evtof3[i] = new TH2F(TString::Format("clawss_Evtof3_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
60 100., 1000, 0., 10.);
61 h_clawss_Evtof4[i] = new TH2F(TString::Format("clawss_Evtof4_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
62 100., 1000, 0., 10.);
63 h_clawss_edep[i] = new TH1F(TString::Format("clawss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
64 h_Wclawss_edep[i] = new TH1F(TString::Format("Wclawss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
65 }
66 */
67 h_clawss_hitrate1 = new TH1F("clawss_hitrate1", "Hit distributions", 16, 0., 16.);
68 h_clawss_hitrate2 = new TH1F("clawss_hitrate2", "Hit distributions", 16, 0., 16.);
69 h_clawss_hitrate1W = new TH1F("clawss_hitrate1W", "Hit distributions", 16, 0., 16.);
70 h_clawss_hitrate2W = new TH1F("clawss_hitrate2W", "Hit distributions", 16, 0., 16.);
71
72 h_clawss_hitrate1->Sumw2();
73 h_clawss_hitrate1W->Sumw2();
74 h_clawss_hitrate2->Sumw2();
75 h_clawss_hitrate2W->Sumw2();
76
77 h_clawss_rs_hitrate1 = new TH2F("clawss_rs_hitrate1", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
78 h_clawss_rs_hitrate2 = new TH2F("clawss_rs_hitrate2", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
79 h_clawss_rs_hitrate1W = new TH2F("clawss_rs_hitrate1W", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
80 h_clawss_rs_hitrate2W = new TH2F("clawss_rs_hitrate2W", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
81
82 h_clawss_rs_hitrate1->Sumw2();
83 h_clawss_rs_hitrate1W->Sumw2();
84 h_clawss_rs_hitrate2->Sumw2();
85 h_clawss_rs_hitrate2W->Sumw2();
86
87 for (int i = 0; i < 16; i++) {
88 h_clawss_rate1[i] = new TH1F(TString::Format("clawss_rate1_%d", i), "PE distributions", 500, 0., 500.);
89 h_clawss_rate2[i] = new TH1F(TString::Format("clawss_rate2_%d", i), "PE distributions", 500, 0., 500.);
90 h_clawss_rate1W[i] = new TH1F(TString::Format("clawss_rate1W_%d", i), "PE distributions", 500, 0., 500.);
91 h_clawss_rate2W[i] = new TH1F(TString::Format("clawss_rate2W_%d", i), "PE distributions", 500, 0., 500.);
92 h_clawss_pe1[i] = new TH2F(TString::Format("clawss_pe1_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
93 h_clawss_pe2[i] = new TH2F(TString::Format("clawss_pe2_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
94 h_clawss_pe1W[i] = new TH2F(TString::Format("clawss_pe1W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
95 h_clawss_pe2W[i] = new TH2F(TString::Format("clawss_pe2W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
96
97 h_clawss_rs_rate1[i] = new TH2F(TString::Format("clawss_rs_rate1_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
98 h_clawss_rs_rate2[i] = new TH2F(TString::Format("clawss_rs_rate2_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
99 h_clawss_rs_rate1W[i] = new TH2F(TString::Format("clawss_rs_rate1W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
100 h_clawss_rs_rate2W[i] = new TH2F(TString::Format("clawss_rs_rate2W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
101
102 h_clawss_rate1[i]->Sumw2();
103 h_clawss_rate2[i]->Sumw2();
104 h_clawss_rate1W[i]->Sumw2();
105 h_clawss_rate2W[i]->Sumw2();
106 h_clawss_rs_rate1[i]->Sumw2();
107 h_clawss_rs_rate2[i]->Sumw2();
108 h_clawss_rs_rate1W[i]->Sumw2();
109 h_clawss_rs_rate2W[i]->Sumw2();
110 h_clawss_pe1[i]->Sumw2();
111 h_clawss_pe2[i]->Sumw2();
112 h_clawss_pe1W[i]->Sumw2();
113 h_clawss_pe2W[i]->Sumw2();
114 }
115}
116
117
119{
120 B2INFO("ClawsStudyModule: Initialize");
121
122 REG_HISTOGRAM
123
124 //get CLAWSS paramters ie energy threshold
125 getXMLData();
126}
127
129{
130}
131
133{
134 //Here comes the actual event processing
136 StoreArray<SADMetaHit> MetaHits;
137
138 double rate = 0;
139 int ring_section = -1;
140 for (const auto& MetaHit : MetaHits) {
141 rate = MetaHit.getrate();
142 ring_section = MetaHit.getring_section() - 1;
143 }
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 CLAWSSimHit* aHit = SimHits[i];
152 int lad = aHit->getLadder();
153 int sen = aHit->getSensor();
154 //const int detNb = SimHit.getCellId();
155 //int pdg = SimHit.getPDGCode();
156 int detNB = (lad - 1) * 8 + sen - 1;
157 //int detNB = aHit->getCellId();
158 if (detNB < 16) {
159 //int trkID = aHit->getTrackId();
160 int pdg = aHit->getPDG();
161 double Edep = aHit->getEnergyVisible() * 1e3; //GeV -> MeV
162 double tof = aHit->getTime(); //ns
163
164 //h_clawss_Evtof1[detNB]->Fill(tof, Edep);
165 //if (pdg == Const::photon.getPDGCode()) h_clawss_Evtof2[detNB]->Fill(tof, Edep);
166 //else if (fabs(pdg) == Const::electron.getPDGCode()) h_clawss_Evtof3[detNB]->Fill(tof, Edep);
167 //else h_clawss_Evtof4[detNB]->Fill(tof, Edep);
168 if (Edep > m_Ethres) {
169 //h_clawss_edep[detNB]->Fill(Edep);
170 //h_Wclawss_edep[detNB]->Fill(Edep, rate);
171 }
172
173 }
174 }
175 */
176 for (const auto& Hit : Hits) {
177 const int detNb = Hit.getdetNb();
178 if (detNb < 16) {
179 const int timebin = Hit.gettime();
180 const float edep = Hit.getedep();
181 const float pe = Hit.getPE();
182 h_clawss_hitrate1->Fill(detNb);
183 h_clawss_hitrate1W->Fill(detNb, rate);
184 h_clawss_rate1[detNb]->Fill(pe);
185 h_clawss_rate1W[detNb]->Fill(pe, rate);
186 h_clawss_rs_rate1[detNb]->Fill(pe, ring_section);
187 h_clawss_rs_rate1W[detNb]->Fill(pe, ring_section, rate);
188 h_clawss_rs_hitrate1->Fill(detNb, ring_section);
189 h_clawss_rs_hitrate1W->Fill(detNb, ring_section, rate);
190 h_clawss_pe1[detNb]->Fill(timebin, pe);
191 h_clawss_pe1W[detNb]->Fill(timebin, pe, rate);
192 if (edep > m_Ethres) {
193 h_clawss_hitrate2->Fill(detNb);
194 h_clawss_hitrate2W->Fill(detNb, rate);
195 h_clawss_rate2[detNb]->Fill(pe);
196 h_clawss_rate2W[detNb]->Fill(pe, rate);
197 h_clawss_rs_rate2[detNb]->Fill(pe, ring_section);
198 h_clawss_rs_rate2W[detNb]->Fill(pe, ring_section, rate);
199 h_clawss_rs_hitrate2->Fill(detNb, ring_section);
200 h_clawss_rs_hitrate2W->Fill(detNb, ring_section, rate);
201 h_clawss_pe2[detNb]->Fill(timebin, pe);
202 h_clawss_pe2W[detNb]->Fill(timebin, pe, rate);
203 }
204 }
205 }
206
207}
208
209//read energy threshold from CLAWS.xml
211{
212 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CLAWS\"]/Content/");
213 m_Ethres = content.getDouble("Ethres");
214
215 B2INFO("ClawsStudy");
216}
217
218
220{
221
222
223
224}
225
227{
228}
229
230
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
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
TH2F * h_clawss_rs_hitrate1
Energy deposited.
TH2F * h_clawss_rs_rate1[16]
Energy deposited.
TH1F * h_clawss_hitrate2W
Energy deposited.
TH2F * h_clawss_pe1[16]
Energy deposited.
TH2F * h_clawss_rs_hitrate2W
Energy deposited.
virtual void initialize() override
Initialize the Module.
TH2F * h_clawss_rs_hitrate2
Energy deposited.
TH1F * h_clawss_hitrate1
Energy deposited.
virtual void event() override
Event processor.
TH1F * h_clawss_rate1[16]
Energy deposited vs TOF.
virtual void endRun() override
End-of-run action.
virtual void getXMLData()
reads data from CLAWS.xml
virtual void terminate() override
Termination action.
TH1F * h_clawss_hitrate1W
Energy deposited.
ClawsStudyModule()
Constructor: Sets the description, the properties and the parameters of the module.
TH2F * h_clawss_pe1W[16]
Energy deposited.
TH2F * h_clawss_pe2[16]
Energy deposited.
TH1F * h_clawss_rate2W[16]
Energy deposited.
virtual void beginRun() override
Called when entering a new run.
TH1F * h_clawss_rate1W[16]
Energy deposited.
virtual ~ClawsStudyModule()
Destructor.
TH1F * h_clawss_hitrate2
Energy deposited.
TH1F * h_clawss_rate2[16]
Energy deposited.
TH2F * h_clawss_rs_rate2[16]
Energy deposited.
double m_Ethres
Energy threshold.
TH2F * h_clawss_rs_rate2W[16]
Energy deposited.
TH2F * h_clawss_rs_hitrate1W
Energy deposited.
TH2F * h_clawss_rs_rate1W[16]
Energy deposited.
virtual void defineHisto() override
Defines the histograms.
TH2F * h_clawss_pe2W[16]
Energy deposited.
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
Abstract base class for different kinds of events.
STL namespace.
Structure to hold some of the calpulse data.