9 #include <beast/beamabort/modules/BeamabortStudyModule.h>
10 #include <beast/beamabort/dataobjects/BeamabortSimHit.h>
11 #include <beast/beamabort/dataobjects/BeamabortHit.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/logging/Logger.h>
14 #include <framework/gearbox/GearDir.h>
25 #include <generators/SAD/dataobjects/SADMetaHit.h>
30 using namespace beamabort;
44 setDescription(
"Study module for Beamaborts (BEAST)");
47 addParam(
"WorkFunction", m_WorkFunction,
"Convert eV to e [e/eV] ", 1.12);
48 addParam(
"FanoFactor", m_FanoFactor,
"e resolution ", 0.1);
51 BeamabortStudyModule::~BeamabortStudyModule()
55 void BeamabortStudyModule::defineHisto()
57 B2INFO(
"BeamabortStudyModule: Initialize");
59 for (
int i = 0; i < 8; i++) {
60 h_dia_dose[i] =
new TH1F(TString::Format(
"dia_dose_%d", i),
"", 10000, 0., 10000.);
61 h_dia_dose[i]->Sumw2();
69 void BeamabortStudyModule::initialize()
76 for (
int i = 0; i < 4; i++) {
77 h_dia_rate[i] =
new TH1F(TString::Format(
"dia_rate_%d", i),
"Count", 8, 0., 8.);
78 h_dia_rate[i]->Sumw2();
80 for (
int i = 0; i < 2; i++) {
81 h_dia_rs_rate[i] =
new TH2F(TString::Format(
"dia_rs_rate_%d", i),
"Count vs ring section", 8, 0., 8., 12, 0., 12.);
82 h_dia_rs_rate[i]->Sumw2();
85 for (
int i = 0; i < 8; i++) {
86 h_dia_doseWeight[i] =
new TH1F(TString::Format(
"dia_doseWeight_%d", i),
"", 10000, 0., 10000.);
87 h_dia_amp[i] =
new TH1F(TString::Format(
"dia_amp_%d", i),
"", 10000, 0., 10000.);
88 h_dia_time[i] =
new TH1F(TString::Format(
"dia_time_%d", i),
"", 1000, 0., 100.);
89 h_dia_vtime[i] =
new TH1F(TString::Format(
"dia_vtime_%d", i),
"", 1000, 0., 100.);
90 h_dia_idose[i] =
new TH1F(TString::Format(
"dia_idose_%d", i),
"", 10000, 0., 10000.);
91 h_dia_idoseWeight[i] =
new TH1F(TString::Format(
"dia_idoseWeight_%d", i),
"", 10000, 0., 10000.);
92 h_dia_rs_idose[i] =
new TH2F(TString::Format(
"dia_rs_idose_%d", i),
"", 10000, 0., 10000., 12, 0., 12.);
93 h_dia_rs_idoseWeight[i] =
new TH2F(TString::Format(
"dia_rs_idoseWeight_%d", i),
"", 10000, 0., 10000., 12, 0., 12.);
94 h_dia_iamp[i] =
new TH1F(TString::Format(
"dia_iamp_%d", i),
"", 10000, 0., 10000.);
95 h_dia_itime[i] =
new TH1F(TString::Format(
"dia_itime_%d", i),
"", 1000, 0., 100.);
96 h_dia_ivtime[i] =
new TH1F(TString::Format(
"dia_ivtime_%d", i),
"", 1000, 0., 100.);
97 h_dia_Amp[i] =
new TH1F(TString::Format(
"dia_Amp_%d", i),
"", 100000, 0., 100000.);
98 h_dia_edep[i] =
new TH1F(TString::Format(
"dia_edep_%d", i),
"", 4000, 0., 4000.);
100 h_dia_doseWeight[i]->Sumw2();
101 h_dia_idose[i]->Sumw2();
102 h_dia_idoseWeight[i]->Sumw2();
103 h_dia_rs_idose[i]->Sumw2();
104 h_dia_rs_idoseWeight[i]->Sumw2();
111 void BeamabortStudyModule::beginRun()
115 void BeamabortStudyModule::event()
120 for (
int i = 0; i < 8; i++) {
135 int ring_section = -1;
136 int section_ordering[12] = {1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
137 for (
const auto& MetaHit : MetaHits) {
138 rate = MetaHit.getrate();
139 double sad_ssraw = MetaHit.getssraw();
141 if (sad_ssraw >= 0) ssraw = sad_ssraw / 100.;
142 else ssraw = 3000. + sad_ssraw / 100.;
144 ring_section = section_ordering[(int)((ssraw) / 250.)] - 1;
148 for (
const auto& SimHit : SimHits) {
149 int detNb = SimHit.getCellId();
151 double edep = SimHit.getEnergyDep();
152 double time = SimHit.getFlightTime();
153 double meanEl = edep / m_WorkFunction * 1e9;
154 double sigma = sqrt(m_FanoFactor * meanEl);
155 int NbEle = (int)gRandom->Gaus(meanEl, sigma);
156 double Amp = NbEle / (6.25 * 1e18);
159 h_dia_dose[detNb]->Fill(edep * 1e6);
160 h_dia_doseWeight[detNb]->Fill(edep * 1e6, rate);
161 h_dia_amp[detNb]->Fill(Amp * 1e15);
162 h_dia_time[detNb]->Fill(time);
163 h_dia_vtime[detNb]->Fill(time, Amp * 1e15);
164 h_dia_rate[0]->Fill(detNb);
165 h_dia_rate[1]->Fill(detNb, rate);
169 for (
int i = 0; i < 4; i++) {
170 if (curr[i] > 0 && Edep[i] > 0) {
171 h_dia_Amp[i]->Fill(curr[i] * 1e15);
172 h_dia_edep[i]->Fill(Edep[i] * 1e6);
176 for (
const auto&
Hit : Hits) {
177 int detNb =
Hit.getdetNb();
178 double edep =
Hit.getedep();
179 double current =
Hit.getI();
180 double time =
Hit.gettime();
181 h_dia_idose[detNb]->Fill(edep);
182 h_dia_idoseWeight[detNb]->Fill(edep, rate);
183 h_dia_rs_idose[detNb]->Fill(edep, ring_section);
184 h_dia_rs_idoseWeight[detNb]->Fill(edep, ring_section, rate);
185 h_dia_iamp[detNb]->Fill(current * 1e6);
186 h_dia_itime[detNb]->Fill(time);
187 h_dia_ivtime[detNb]->Fill(time, current * 1e6);
188 h_dia_rate[2]->Fill(detNb);
189 h_dia_rate[3]->Fill(detNb, rate);
191 h_dia_rs_rate[0]->Fill(detNb, ring_section);
192 h_dia_rs_rate[1]->Fill(detNb, ring_section, rate);
198 void BeamabortStudyModule::getXMLData()
200 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name=\"BEAMABORT\"]/Content/");
210 m_WorkFunction = content.getDouble(
"WorkFunction");
211 m_FanoFactor = content.getDouble(
"FanoFactor");
213 B2INFO(
"BeamabortStudy");
216 void BeamabortStudyModule::endRun()
222 void BeamabortStudyModule::terminate()
GearDir is the basic class used for accessing the parameter store.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Study module for Beamaborts (BEAST)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Structure to hold some of the calpulse data.