Belle II Software development
BgoStudyModule.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/bgo/modules/BgoStudyModule.h>
10#include <beast/bgo/dataobjects/BgoSimHit.h>
11#include <beast/bgo/dataobjects/BgoHit.h>
12#include <framework/datastore/StoreArray.h>
13#include <framework/logging/Logger.h>
14#include <framework/gearbox/Const.h>
15#include <cmath>
16
17#include <string>
18
19#include <generators/SAD/dataobjects/SADMetaHit.h>
20
21using namespace std;
22
23using namespace Belle2;
24using namespace bgo;
25
26//-----------------------------------------------------------------
27// Register the Module
28//-----------------------------------------------------------------
29REG_MODULE(BgoStudy);
30
31//-----------------------------------------------------------------
32// Implementation
33//-----------------------------------------------------------------
34
36{
37 // Set module properties
38 setDescription("Study module for Bgos (BEAST)");
39
40 addParam("Ethres", m_Ethres, "Energy threshold in MeV");
41}
42
44{
45}
46
47//This module is a histomodule. Any histogram created here will be saved by the HistoManager module
49{
50 for (int i = 0; i < 2; i++) {
51 h_bgo_rate[i] = new TH1F(TString::Format("bgo_rate_%d", i), "count", 18, 0., 18.);
52 h_bgo_rate[i]->Sumw2();
53
54 h_bgo_rs_rate[i] = new TH2F(TString::Format("bgo_rs_rate_%d", i), "count v. ring section", 18, 0., 18., 12, 0., 12.);
55 h_bgo_rs_rate[i]->Sumw2();
56 }
57 for (int i = 0; i < 18; i++) {
58 h_bgo_Evtof[i] = new TH2F(TString::Format("bgo_Evtof_%d", i), "Energy deposited [MeV] vs TOF [ns] - all", 5000, 0., 1000.,
59 1000, 0., 400.);
60 h_bgo_Evtof1[i] = new TH2F(TString::Format("bgo_Evtof1_%d", i), "Energy deposited [MeV] vs TOF [ns] - all", 5000, 0., 1000.,
61 1000, 0., 400.);
62 h_bgo_Evtof2[i] = new TH2F(TString::Format("bgo_Evtof2_%d", i), "Energy deposited [MeV] vs TOF [ns] - only photons", 5000, 0.,
63 1000., 1000, 0., 400.);
64 h_bgo_Evtof3[i] = new TH2F(TString::Format("bgo_Evtof3_%d", i), "Energy deposited [MeV] vs TOF [ns] - only e+/e-", 5000, 0.,
65 1000., 1000, 0., 400.);
66
67 h_bgo_edep[i] = new TH1F(TString::Format("bgo_edep_%d", i), "Energy deposited [MeV]", 5000, 0., 400.);
68 h_bgo_edep1[i] = new TH1F(TString::Format("bgo_edep1_%d", i), "Energy deposited [MeV]", 5000, 0., 400.);
69 h_bgo_edep2[i] = new TH1F(TString::Format("bgo_edep2_%d", i), "Energy deposited [MeV]", 5000, 0., 400.);
70 h_bgo_edep1Weight[i] = new TH1F(TString::Format("bgo_edep1Weight_%d", i), "Energy deposited [MeV]", 5000, 0., 400.);
71 h_bgo_edep2Weight[i] = new TH1F(TString::Format("bgo_edep2Weight_%d", i), "Energy deposited [MeV]", 5000, 0., 400.);
72
73 h_bgo_rs_edep1[i] = new TH2F(TString::Format("bgo_rs_edep1_%d", i), "Energy deposited [MeV]", 5000, 0., 400., 12, 0., 12.);
74 h_bgo_rs_edep2[i] = new TH2F(TString::Format("bgo_rs_edep2_%d", i), "Energy deposited [MeV]", 5000, 0., 400., 12, 0., 12.);
75 h_bgo_rs_edep1Weight[i] = new TH2F(TString::Format("bgo_rs_edep1Weight_%d", i), "Energy deposited [MeV]", 5000, 0., 400., 12, 0.,
76 12.);
77 h_bgo_rs_edep2Weight[i] = new TH2F(TString::Format("bgo_rs_edep2Weight_%d", i), "Energy deposited [MeV]", 5000, 0., 400., 12, 0.,
78 12.);
79
80 h_bgo_edep[i]->Sumw2();
81 h_bgo_edep1[i]->Sumw2();
82 h_bgo_edep2[i]->Sumw2();
83 h_bgo_edep1Weight[i]->Sumw2();
84 h_bgo_edep2Weight[i]->Sumw2();
85 h_bgo_rs_edep1[i]->Sumw2();
86 h_bgo_rs_edep2[i]->Sumw2();
87 h_bgo_rs_edep1Weight[i]->Sumw2();
88 h_bgo_rs_edep2Weight[i]->Sumw2();
89 }
90
91}
92
93
95{
96 B2INFO("BgoStudyModule: Initialize");
97
98 //read bgo xml file
99 //getXMLData();
100
101 REG_HISTOGRAM
102
103}
104
106{
107}
108
110{
111 //Here comes the actual event processing
112 StoreArray<BgoSimHit> SimHits;
114 StoreArray<SADMetaHit> MetaHits;
115
116 //Skip events with no Hits
117 if (SimHits.getEntries() == 0) {
118 return;
119 }
120
121 //Look at the meta data to extract IR rate and scattering ring section
122 double rate = 0;
123 int ring_section = -1;
124 const int section_ordering[12] = {1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
125 for (const auto& MetaHit : MetaHits) {
126 rate = MetaHit.getrate();
127 double sad_ssraw = MetaHit.getssraw();
128 double ssraw = 0;
129 if (sad_ssraw >= 0) ssraw = sad_ssraw / 100.;
130 else ssraw = 3000. + sad_ssraw / 100.;
131 //else if (sad_ssraw < 0) ssraw = 3000. + sad_ssraw / 100.;
132 ring_section = section_ordering[(int)((ssraw) / 250.)] - 1;
133 //ring_section = MetaHit.getring_section() - 1;
134 }
135 //Loop over SimHit
136 for (const auto& SimHit : SimHits) {
137 int detNB = SimHit.getCellId();
138 int pdg = SimHit.getPDGCode();
139 double Edep = SimHit.getEnergyDep() * 1e3; //GeV -> MeV
140 double tof = SimHit.getFlightTime(); //ns
141
142 h_bgo_edep[detNB]->Fill(Edep);
143 h_bgo_Evtof[detNB]->Fill(tof, Edep);
144 if (pdg == Const::photon.getPDGCode()) h_bgo_Evtof1[detNB]->Fill(tof, Edep);
145 else if (fabs(pdg) == Const::electron.getPDGCode()) h_bgo_Evtof2[detNB]->Fill(tof, Edep);
146 double RecEdep = Edep;
147 h_bgo_rate[0]->Fill(detNB);
148 h_bgo_rate[1]->Fill(detNB, rate);
149 h_bgo_edep1[detNB]->Fill(Edep);
150 h_bgo_edep2[detNB]->Fill(RecEdep);
151 h_bgo_edep1Weight[detNB]->Fill(Edep, rate);
152 h_bgo_edep2Weight[detNB]->Fill(RecEdep, rate);
153 h_bgo_Evtof3[detNB]->Fill(tof, RecEdep);
154 h_bgo_rs_rate[0]->Fill(detNB, ring_section);
155 h_bgo_rs_rate[1]->Fill(detNB, ring_section, rate);
156 h_bgo_rs_edep1[detNB]->Fill(Edep, ring_section);
157 h_bgo_rs_edep2[detNB]->Fill(RecEdep, ring_section);
158 h_bgo_rs_edep1Weight[detNB]->Fill(Edep, ring_section, rate);
159 h_bgo_rs_edep2Weight[detNB]->Fill(RecEdep, ring_section, rate);
160 }
161 /*
162 //Loop over DigiHit
163 for (const auto& Hit : Hits) {
164 int detNB = Hit.getCellId();
165 double Edep = Hit.getEnergyDep() * 1e3; //GeV -> MeV
166 double RecEdep = Hit.getEnergyRecDep() * 1e3; //GeV -> MeV
167 double tof = Hit.getFlightTime(); //ns
168 h_bgo_rate[0]->Fill(detNB);
169 h_bgo_rate[1]->Fill(detNB, rate);
170 h_bgo_edep1[detNB]->Fill(Edep);
171 h_bgo_edep2[detNB]->Fill(RecEdep);
172 h_bgo_edep1Weight[detNB]->Fill(Edep, rate);
173 h_bgo_edep2Weight[detNB]->Fill(RecEdep, rate);
174 h_bgo_Evtof3[detNB]->Fill(tof, RecEdep);
175 h_bgo_rs_rate[0]->Fill(detNB, ring_section);
176 h_bgo_rs_rate[1]->Fill(detNB, ring_section, rate);
177 h_bgo_rs_edep1[detNB]->Fill(Edep, ring_section);
178 h_bgo_rs_edep2[detNB]->Fill(RecEdep, ring_section);
179 h_bgo_rs_edep1Weight[detNB]->Fill(Edep, ring_section, rate);
180 h_bgo_rs_edep2Weight[detNB]->Fill(RecEdep, ring_section, rate);
181 }
182 */
183}
184/*
185//read tube centers, impulse response, and garfield drift data filename from BGO.xml
186void BgoStudyModule::getXMLData()
187{
188 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"BGO\"]/Content/");
189 m_Ethres = content.getDouble("Ethres");
190
191 B2INFO("BgoStudy");
192
193}
194*/
196{
197
198
199}
200
202{
203}
204
205
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ParticleType photon
photon particle
Definition: Const.h:673
static const ChargedStable electron
electron particle
Definition: Const.h:659
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
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
std::vector< Double_t > m_Ethres
reads data from BGO.xml: tube location, drift data filename, sigma of impulse response function
virtual ~BgoStudyModule()
Destructor.
TH1F * h_bgo_edep[18]
Energy deposited.
TH1F * h_bgo_edep1[18]
Energy deposited.
virtual void initialize() override
Initialize the Module.
TH2F * h_bgo_rs_edep2[18]
Energy deposited.
virtual void event() override
Event processor.
TH2F * h_bgo_rs_edep1Weight[18]
Energy deposited.
virtual void endRun() override
End-of-run action.
TH2F * h_bgo_Evtof[18]
Energy deposited vs TOF.
virtual void terminate() override
Termination action.
TH1F * h_bgo_edep2[18]
Energy deposited.
TH2F * h_bgo_rs_edep1[18]
Energy deposited.
virtual void beginRun() override
Called when entering a new run.
BgoStudyModule()
Constructor: Sets the description, the properties and the parameters of the module.
TH1F * h_bgo_edep1Weight[18]
Energy deposited.
TH2F * h_bgo_Evtof1[18]
Energy deposited vs TOF.
TH1F * h_bgo_edep2Weight[18]
Energy deposited.
TH2F * h_bgo_Evtof2[18]
Energy deposited vs TOF.
TH2F * h_bgo_Evtof3[18]
Energy deposited vs TOF.
TH2F * h_bgo_rs_edep2Weight[18]
Energy deposited.
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.