9 #include <beast/pindiode/modules/PindiodeStudyModule.h>
10 #include <beast/pindiode/dataobjects/PindiodeSimHit.h>
11 #include <beast/pindiode/dataobjects/PindiodeHit.h>
12 #include <generators/SAD/dataobjects/SADMetaHit.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/logging/Logger.h>
15 #include <framework/gearbox/GearDir.h>
29 using namespace pindiode;
43 setDescription(
"Study module for Pindiodes (BEAST)");
46 addParam(
"CrematGain", m_CrematGain,
"Charge sensitive preamplifier gain [volts/C] ", 1.4);
47 addParam(
"WorkFunction", m_WorkFunction,
"Convert eV to e [e/eV] ", 1.12);
48 addParam(
"FanoFactor", m_FanoFactor,
"e resolution ", 0.1);
51 PindiodeStudyModule::~PindiodeStudyModule()
56 void PindiodeStudyModule::defineHisto()
59 for (
int i = 0; i < 4; i++) {
60 h_pin_rate[i] =
new TH1F(TString::Format(
"pin_rate_%d", i),
"Count", 64, 0., 64.);
61 h_pin_rate[i]->Sumw2();
63 for (
int i = 0; i < 2; i++) {
64 h_pin_rs_rate[i] =
new TH2F(TString::Format(
"pin_rs_rate_%d", i),
"Count vs. ring section", 64, 0., 64., 12, 0., 12.);
65 h_pin_rs_rate[i]->Sumw2();
67 for (
int i = 0; i < 64; i++) {
68 h_pin_dose1[i] =
new TH1F(TString::Format(
"pin_dose1_%d", i),
"", 10000, 0., 10000.);
69 h_pin_dose2[i] =
new TH1F(TString::Format(
"pin_dose2_%d", i),
"", 10000, 0., 10000.);
70 h_pin_dose1Weight[i] =
new TH1F(TString::Format(
"pin_dose1Weight_%d", i),
"", 10000, 0., 10000.);
71 h_pin_dose2Weight[i] =
new TH1F(TString::Format(
"pin_dose2Weight_%d", i),
"", 10000, 0., 10000.);
72 h_pin_volt[i] =
new TH1F(TString::Format(
"pin_volt_%d", i),
"", 10000, 0., 100.);
73 h_pin_time[i] =
new TH1F(TString::Format(
"pin_time_%d", i),
"", 1000, 0., 100.);
74 h_pin_vtime[i] =
new TH1F(TString::Format(
"pin_vtime_%d", i),
"", 1000, 0., 100.);
76 h_pin_idose[i] =
new TH1F(TString::Format(
"pin_idose_%d", i),
"", 10000, 0., 10000.);
77 h_pin_idoseWeight[i] =
new TH1F(TString::Format(
"pin_idoseWeight_%d", i),
"", 10000, 0., 10000.);
79 h_pin_rs_idose[i] =
new TH2F(TString::Format(
"pin_rs_idose_%d", i),
"", 10000, 0., 10000., 12, 0., 12.);
80 h_pin_rs_idoseWeight[i] =
new TH2F(TString::Format(
"pin_rs_idoseWeight_%d", i),
"", 10000, 0., 10000., 12, 0., 12.);
82 h_pin_ivolt[i] =
new TH1F(TString::Format(
"pin_ivolt_%d", i),
"", 10000, 0., 100.);
83 h_pin_itime[i] =
new TH1F(TString::Format(
"pin_itime_%d", i),
"", 1000, 0., 100.);
84 h_pin_ivtime[i] =
new TH1F(TString::Format(
"pin_ivtime_%d", i),
"", 1000, 0., 100.);
86 h_pin_dose1[i]->Sumw2();
87 h_pin_dose2[i]->Sumw2();
88 h_pin_dose1Weight[i]->Sumw2();
89 h_pin_dose2Weight[i]->Sumw2();
90 h_pin_idose[i]->Sumw2();
91 h_pin_idoseWeight[i]->Sumw2();
92 h_pin_rs_idose[i]->Sumw2();
93 h_pin_rs_idoseWeight[i]->Sumw2();
99 void PindiodeStudyModule::initialize()
101 B2INFO(
"PindiodeStudyModule: Initialize");
110 void PindiodeStudyModule::beginRun()
114 void PindiodeStudyModule::event()
124 int ring_section = -1;
125 int section_ordering[12] = {1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
126 for (
const auto& MetaHit : MetaHits) {
127 rate = MetaHit.getrate();
128 double sad_ssraw = MetaHit.getssraw();
130 if (sad_ssraw >= 0) ssraw = sad_ssraw / 100.;
131 else ssraw = 3000. + sad_ssraw / 100.;
133 ring_section = section_ordering[(int)((ssraw) / 250.)] - 1;
142 for (
const auto& SimHit : SimHits) {
143 int detNb = SimHit.getCellId();
145 double edep = SimHit.getEnergyDep();
146 double time = SimHit.getFlightTime();
148 const double meanEl = edep / m_WorkFunction * 1e9;
149 const double sigma = sqrt(m_FanoFactor * meanEl);
150 const int NbEle = (int)gRandom->Gaus(meanEl, sigma);
151 double volt = NbEle * 1.602176565e-19 * m_CrematGain * 1e12;
152 h_pin_dose1[detNb]->Fill(edep * 1e6);
153 h_pin_dose1Weight[detNb]->Fill(edep * 1e6, rate);
154 if ((edep * 1e9) > m_WorkFunction) {
155 h_pin_dose2[detNb]->Fill(edep * 1e6);
156 h_pin_dose2Weight[detNb]->Fill(edep * 1e6, rate);
157 h_pin_volt[detNb]->Fill(volt * 1e3);
158 h_pin_time[detNb]->Fill(time);
159 h_pin_vtime[detNb]->Fill(time, volt);
160 h_pin_rate[0]->Fill(detNb);
161 h_pin_rate[1]->Fill(detNb, rate);
166 for (
const auto&
Hit : Hits) {
167 int detNb =
Hit.getdetNb();
169 double edep =
Hit.getedep();
170 double volt =
Hit.getV();
171 double time =
Hit.gettime();
172 h_pin_idose[detNb]->Fill(edep);
173 h_pin_idoseWeight[detNb]->Fill(edep, rate);
174 h_pin_ivolt[detNb]->Fill(volt * 1e3);
175 h_pin_itime[detNb]->Fill(time);
176 h_pin_ivtime[detNb]->Fill(time, volt);
177 h_pin_rate[2]->Fill(detNb);
178 h_pin_rate[3]->Fill(detNb, rate);
180 h_pin_rs_rate[0]->Fill(detNb, ring_section);
181 h_pin_rs_rate[1]->Fill(detNb, ring_section, rate);
182 h_pin_rs_idose[detNb]->Fill(edep, ring_section);
183 h_pin_rs_idoseWeight[detNb]->Fill(edep, ring_section, rate);
190 void PindiodeStudyModule::getXMLData()
192 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name=\"PINDIODE\"]/Content/");
202 m_CrematGain = content.getDouble(
"CrematGain");
203 m_WorkFunction = content.getDouble(
"WorkFunction");
204 m_FanoFactor = content.getDouble(
"FanoFactor");
206 B2INFO(
"PinDigitizer");
209 void PindiodeStudyModule::endRun()
215 void PindiodeStudyModule::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 Pindiodes (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.