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
16#include <string>
17
18using namespace std;
19
20using namespace Belle2;
21using namespace claws;
22
23//-----------------------------------------------------------------
24// Register the Module
25//-----------------------------------------------------------------
26REG_MODULE(ClawsStudy);
27
28//-----------------------------------------------------------------
29// Implementation
30//-----------------------------------------------------------------
31
33{
34 // Set module properties
35 setDescription("Study module for Clawss (BEAST)");
36
37 addParam("Ethres", m_Ethres, "Energy threshold in MeV", 0.0);
38}
39
41{
42}
43
44//This module is a histomodule. Any histogram created here will be saved by the HistoManager module
46{
47 /*
48 for (int i = 0; i < 16; i++) {
49 h_clawss_Evtof1[i] = new TH2F(TString::Format("clawss_Evtof1_%d", i), "Energy deposited [MeV] vs TOF [ns] - all", 500, 0., 1000.,
50 100, 0., 10.);
51 h_clawss_Evtof2[i] = new TH2F(TString::Format("clawss_Evtof2_%d", i), "Energy deposited [MeV] vs TOF [ns] - only photons", 500, 0.,
52 100., 1000, 0., 10.);
53 h_clawss_Evtof3[i] = new TH2F(TString::Format("clawss_Evtof3_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
54 100., 1000, 0., 10.);
55 h_clawss_Evtof4[i] = new TH2F(TString::Format("clawss_Evtof4_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 500, 0.,
56 100., 1000, 0., 10.);
57 h_clawss_edep[i] = new TH1F(TString::Format("clawss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
58 h_Wclawss_edep[i] = new TH1F(TString::Format("Wclawss_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 10.);
59 }
60 */
61 h_clawss_hitrate1 = new TH1F("clawss_hitrate1", "Hit distributions", 16, 0., 16.);
62 h_clawss_hitrate2 = new TH1F("clawss_hitrate2", "Hit distributions", 16, 0., 16.);
63 h_clawss_hitrate1W = new TH1F("clawss_hitrate1W", "Hit distributions", 16, 0., 16.);
64 h_clawss_hitrate2W = new TH1F("clawss_hitrate2W", "Hit distributions", 16, 0., 16.);
65
66 h_clawss_hitrate1->Sumw2();
67 h_clawss_hitrate1W->Sumw2();
68 h_clawss_hitrate2->Sumw2();
69 h_clawss_hitrate2W->Sumw2();
70
71 h_clawss_rs_hitrate1 = new TH2F("clawss_rs_hitrate1", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
72 h_clawss_rs_hitrate2 = new TH2F("clawss_rs_hitrate2", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
73 h_clawss_rs_hitrate1W = new TH2F("clawss_rs_hitrate1W", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
74 h_clawss_rs_hitrate2W = new TH2F("clawss_rs_hitrate2W", "Hit distributions vs rs", 16, 0., 16., 12, 0., 12.);
75
76 h_clawss_rs_hitrate1->Sumw2();
77 h_clawss_rs_hitrate1W->Sumw2();
78 h_clawss_rs_hitrate2->Sumw2();
79 h_clawss_rs_hitrate2W->Sumw2();
80
81 for (int i = 0; i < 16; i++) {
82 h_clawss_rate1[i] = new TH1F(TString::Format("clawss_rate1_%d", i), "PE distributions", 500, 0., 500.);
83 h_clawss_rate2[i] = new TH1F(TString::Format("clawss_rate2_%d", i), "PE distributions", 500, 0., 500.);
84 h_clawss_rate1W[i] = new TH1F(TString::Format("clawss_rate1W_%d", i), "PE distributions", 500, 0., 500.);
85 h_clawss_rate2W[i] = new TH1F(TString::Format("clawss_rate2W_%d", i), "PE distributions", 500, 0., 500.);
86 h_clawss_pe1[i] = new TH2F(TString::Format("clawss_pe1_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
87 h_clawss_pe2[i] = new TH2F(TString::Format("clawss_pe2_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
88 h_clawss_pe1W[i] = new TH2F(TString::Format("clawss_pe1W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
89 h_clawss_pe2W[i] = new TH2F(TString::Format("clawss_pe2W_%d", i), "PE distributions", 500, 0., 500., 100, 0., 1000.);
90
91 h_clawss_rs_rate1[i] = new TH2F(TString::Format("clawss_rs_rate1_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
92 h_clawss_rs_rate2[i] = new TH2F(TString::Format("clawss_rs_rate2_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
93 h_clawss_rs_rate1W[i] = new TH2F(TString::Format("clawss_rs_rate1W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
94 h_clawss_rs_rate2W[i] = new TH2F(TString::Format("clawss_rs_rate2W_%d", i), "PE distributions", 500, 0., 500., 12, 0., 12.);
95
96 h_clawss_rate1[i]->Sumw2();
97 h_clawss_rate2[i]->Sumw2();
98 h_clawss_rate1W[i]->Sumw2();
99 h_clawss_rate2W[i]->Sumw2();
100 h_clawss_rs_rate1[i]->Sumw2();
101 h_clawss_rs_rate2[i]->Sumw2();
102 h_clawss_rs_rate1W[i]->Sumw2();
103 h_clawss_rs_rate2W[i]->Sumw2();
104 h_clawss_pe1[i]->Sumw2();
105 h_clawss_pe2[i]->Sumw2();
106 h_clawss_pe1W[i]->Sumw2();
107 h_clawss_pe2W[i]->Sumw2();
108 }
109}
110
111
113{
114 B2INFO("ClawsStudyModule: Initialize");
115
116 REG_HISTOGRAM
117
118 //get CLAWSS parameters ie energy threshold
119 getXMLData();
120}
121
123{
124}
125
127{
128 //Here comes the actual event processing
130 StoreArray<SADMetaHit> MetaHits;
131
132 double rate = 0;
133 int ring_section = -1;
134 for (const auto& MetaHit : MetaHits) {
135 rate = MetaHit.getrate();
136 ring_section = MetaHit.getring_section() - 1;
137 }
138
139 /*
140 //number of entries in SimHits
141 int nSimHits = SimHits.getEntries();
142
143 //loop over all SimHit entries
144 for (int i = 0; i < nSimHits; i++) {
145 CLAWSSimHit* aHit = SimHits[i];
146 int lad = aHit->getLadder();
147 int sen = aHit->getSensor();
148 //const int detNb = SimHit.getCellId();
149 //int pdg = SimHit.getPDGCode();
150 int detNB = (lad - 1) * 8 + sen - 1;
151 //int detNB = aHit->getCellId();
152 if (detNB < 16) {
153 //int trkID = aHit->getTrackId();
154 int pdg = aHit->getPDG();
155 double Edep = aHit->getEnergyVisible() * 1e3; //GeV -> MeV
156 double tof = aHit->getTime(); //ns
157
158 //h_clawss_Evtof1[detNB]->Fill(tof, Edep);
159 //if (pdg == Const::photon.getPDGCode()) h_clawss_Evtof2[detNB]->Fill(tof, Edep);
160 //else if (fabs(pdg) == Const::electron.getPDGCode()) h_clawss_Evtof3[detNB]->Fill(tof, Edep);
161 //else h_clawss_Evtof4[detNB]->Fill(tof, Edep);
162 if (Edep > m_Ethres) {
163 //h_clawss_edep[detNB]->Fill(Edep);
164 //h_Wclawss_edep[detNB]->Fill(Edep, rate);
165 }
166
167 }
168 }
169 */
170 for (const auto& Hit : Hits) {
171 const int detNb = Hit.getdetNb();
172 if (detNb < 16) {
173 const int timebin = Hit.gettime();
174 const float edep = Hit.getedep();
175 const float pe = Hit.getPE();
176 h_clawss_hitrate1->Fill(detNb);
177 h_clawss_hitrate1W->Fill(detNb, rate);
178 h_clawss_rate1[detNb]->Fill(pe);
179 h_clawss_rate1W[detNb]->Fill(pe, rate);
180 h_clawss_rs_rate1[detNb]->Fill(pe, ring_section);
181 h_clawss_rs_rate1W[detNb]->Fill(pe, ring_section, rate);
182 h_clawss_rs_hitrate1->Fill(detNb, ring_section);
183 h_clawss_rs_hitrate1W->Fill(detNb, ring_section, rate);
184 h_clawss_pe1[detNb]->Fill(timebin, pe);
185 h_clawss_pe1W[detNb]->Fill(timebin, pe, rate);
186 if (edep > m_Ethres) {
187 h_clawss_hitrate2->Fill(detNb);
188 h_clawss_hitrate2W->Fill(detNb, rate);
189 h_clawss_rate2[detNb]->Fill(pe);
190 h_clawss_rate2W[detNb]->Fill(pe, rate);
191 h_clawss_rs_rate2[detNb]->Fill(pe, ring_section);
192 h_clawss_rs_rate2W[detNb]->Fill(pe, ring_section, rate);
193 h_clawss_rs_hitrate2->Fill(detNb, ring_section);
194 h_clawss_rs_hitrate2W->Fill(detNb, ring_section, rate);
195 h_clawss_pe2[detNb]->Fill(timebin, pe);
196 h_clawss_pe2W[detNb]->Fill(timebin, pe, rate);
197 }
198 }
199 }
200
201}
202
203//read energy threshold from CLAWS.xml
205{
206 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CLAWS\"]/Content/");
207 m_Ethres = content.getDouble("Ethres");
208
209 B2INFO("ClawsStudy");
210}
211
212
214{
215
216
217
218}
219
221{
222}
223
224
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: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.