9 #include <beast/he3tube/modules/He3tubeStudyModule.h>
10 #include <beast/he3tube/dataobjects/He3tubeSimHit.h>
11 #include <beast/he3tube/dataobjects/He3tubeHit.h>
12 #include <beast/he3tube/dataobjects/HE3G4TrackInfo.h>
13 #include <generators/SAD/dataobjects/SADMetaHit.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <framework/logging/Logger.h>
16 #include <framework/gearbox/Const.h>
35 using namespace he3tube;
49 setDescription(
"Study module for He3tubes (BEAST)");
52 addParam(
"sampleTime", m_sampletime,
"Length of sample, in us", 10000);
56 He3tubeStudyModule::~He3tubeStudyModule()
61 void He3tubeStudyModule::defineHisto()
63 for (
int i = 0 ; i < 9 ; i++) {
64 h_mche3_kinetic[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_%d", i),
"MC kin. energy [GeV]", 1000, 0., 10.);
65 h_mche3_kinetic_zoom[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_zoom_%d", i),
"MC kin. energy [MeV]", 1000, 0., 10.);
66 h_mche3_tvp[i] =
new TH2F(TString::Format(
"h_mche3_tvp_%d", i),
"theta v phi", 180, 0., 180., 360, -180., 180.);
67 h_mche3_tvpW[i] =
new TH2F(TString::Format(
"h_mche3_tvpW_%d", i),
"theta v phi weighted by kin", 180, 0., 180., 360, -180., 180.);
68 h_mche3_zr[i] =
new TH2F(TString::Format(
"h_mche3_zr_%d", i),
"r v z", 200, -400., 400., 200, 0., 400.);
69 h_mche3_kinetic[i]->Sumw2();
70 h_mche3_kinetic_zoom[i]->Sumw2();
71 h_mche3_tvp[i]->Sumw2();
72 h_mche3_tvpW[i]->Sumw2();
73 h_mche3_zr[i]->Sumw2();
76 h_NeutronHits =
new TH1F(
"NeutronHits",
"Neutron Hits;Tube ", 4, -0.5, 3.5);
77 h_NeutronHitsWeighted =
new TH1F(
"NeutronHitsWeighted",
"Neutron Hits;Tube ", 4, -0.5, 3.5);
78 h_DefNeutronHits =
new TH1F(
"DefNeutronHits",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5);
79 h_DefNeutronHitsWeighted =
new TH1F(
"DefNeutronHitsWeighted",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5);
80 h_NeutronRate =
new TH1F(
"NeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
81 h_DefNeutronRate =
new TH1F(
"DefNeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
83 h_NeutronHitsVrs =
new TH2F(
"NeutronHitsVrs",
"Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
84 h_NeutronHitsWeightedVrs =
new TH2F(
"NeutronHitsWeightedVrs",
"Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
85 h_DefNeutronHitsVrs =
new TH2F(
"DefNeutronHitsVrs",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
86 h_DefNeutronHitsWeightedVrs =
new TH2F(
"DefNeutronHitsWeightedVrs",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
87 h_NeutronRateVrs =
new TH2F(
"NeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
88 h_DefNeutronRateVrs =
new TH2F(
"DefNeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
90 h_Edep1H3H =
new TH1F(
"Edep1H3H" ,
"Energy deposited by Proton and Tritium; MeV", 100, 0.7, 0.8);
91 h_Edep1H3H_detNB =
new TH1F(
"Edep1H3H_tube",
"Energy deposited by Proton and Tritium in each tube;Tube Num; MeV", 4, -0.5, 3.5);
92 h_Edep1H =
new TH1F(
"Edep1H" ,
"Energy deposited by Protons;MeV", 100, 0, 0.7);
93 h_Edep3H =
new TH1F(
"Edep3H" ,
"Energy deposited by Tritiums;MeV", 100, 0, 0.4);
94 h_TotEdep =
new TH1F(
"TotEdep" ,
"Total energy deposited;MeV", 100, 0, 1.5);
95 h_DetN_Edep =
new TH1F(
"DetN_Edep" ,
"Energy deposited vs detector number;Tube Num;MeV", 4, -0.5, 3.5);
97 h_PulseHeights_NotNeutron =
new TH1F(
"PulseHeights_NotNeutron",
"Pulse height of waveforms from non-neutron events", 100, 0, 18000);
98 h_PulseHeights_Neutron =
new TH1F(
"PulseHeights_Neutron" ,
"Pulse height of waveforms from neutron events", 100, 0, 18000);
99 h_PulseHeights_DefNeutron =
new TH1F(
"PulseHeights_DefNeutron" ,
"Pulse height of waveforms from definite neutron events", 100,
101 h_PulseHeights_All =
new TH1F(
"PulseHeights_All" ,
"Pulse height of waveforms from all events", 100, 0, 18000);
103 h_DefNeutronHits->Sumw2();
104 h_DefNeutronRate->Sumw2();
105 h_DefNeutronHitsWeighted->Sumw2();
106 h_NeutronHits->Sumw2();
107 h_NeutronRate->Sumw2();
108 h_NeutronHitsWeighted->Sumw2();
110 h_DefNeutronHitsVrs->Sumw2();
111 h_DefNeutronRateVrs->Sumw2();
112 h_DefNeutronHitsWeightedVrs->Sumw2();
113 h_NeutronHitsVrs->Sumw2();
114 h_NeutronRateVrs->Sumw2();
115 h_NeutronHitsWeightedVrs->Sumw2();
120 void He3tubeStudyModule::initialize()
122 B2INFO(
"He3tubeStudyModule: Initialize");
127 rateCorrection = m_sampletime / 1e6;
130 void He3tubeStudyModule::beginRun()
134 void He3tubeStudyModule::event()
145 int ring_section = -1;
146 for (
const auto& MetaHit : MetaHits) {
147 rate = MetaHit.getrate();
148 ring_section = MetaHit.getring_section() - 1;
151 for (
const auto& mcpart : mcparts) {
152 const double energy = mcpart.getEnergy();
153 const double mass = mcpart.getMass();
154 double kin = energy - mass;
155 const double PDG = mcpart.getPDG();
156 const TVector3 vtx = mcpart.getProductionVertex();
157 const TVector3 mom = mcpart.getMomentum();
158 double theta = mom.Theta() * TMath::RadToDeg();
159 double phi = mom.Phi() * TMath::RadToDeg();
161 double r = sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y());
int partID[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
163 if (PDG == Const::electron.getPDGCode()) partID[0] = 1;
164 else if (PDG == -Const::electron.getPDGCode()) partID[1] = 1;
165 else if (PDG == Const::photon.getPDGCode()) partID[2] = 1;
166 else if (PDG == Const::neutron.getPDGCode()) partID[3] = 1;
167 else if (PDG == Const::proton.getPDGCode()) partID[4] = 1;
168 else if (PDG == 1000080160) partID[5] = 1;
169 else if (PDG == 1000060120) partID[6] = 1;
170 else if (PDG == 1000020040) partID[7] = 1;
172 for (
int i = 0; i < 9; i++) {
173 if (partID[i] == 1) {
174 h_mche3_kinetic[i]->Fill(kin);
175 h_mche3_kinetic_zoom[i]->Fill(kin * 1e3);
176 h_mche3_tvp[i]->Fill(theta, phi);
177 h_mche3_tvpW[i]->Fill(theta, phi, kin);
178 h_mche3_zr[i]->Fill(z, r);
185 double edepSum_1H = 0;
186 double edepSum_3H = 0;
187 double totedepSum = 0;
188 double totedepDet[4] = {0};
190 bool ContainsP[4] = {
false};
191 bool Contains3H[4] = {
false};
193 for (
int i = 0; i < simHits.
getEntries(); i++) {
200 B2WARNING(
"Hit registered in undefined tube, ignoring");
206 h_DetN_Edep->AddBinContent(detNB + 1, edep);
207 totedepSum = totedepSum + edep;
208 totedepDet[detNB] = totedepDet[detNB] + edep;
212 ContainsP[detNB] =
true;
214 h_Edep1H3H_detNB->AddBinContent(detNB + 1, edep);
215 edepSum_1H = edepSum_1H + edep;
216 edepSum = edepSum + edep;
220 if (PID == 1000010030) {
221 Contains3H[detNB] =
true;
223 h_Edep1H3H_detNB->AddBinContent(detNB + 1, edep);
224 edepSum_3H = edepSum_3H + edep;
225 edepSum = edepSum + edep;
231 if (totedepSum != 0) h_TotEdep->Fill(totedepSum);
232 if (edepSum != 0) h_Edep1H3H->Fill(edepSum);
233 if (edepSum_1H != 0) h_Edep1H->Fill(edepSum_1H);
234 if (edepSum_3H != 0) h_Edep3H->Fill(edepSum_3H);
237 int neutronStatus = 0;
245 h_DefNeutronHits->Fill(aHit->
getdetNb());
246 h_DefNeutronHitsWeighted->Fill(aHit->
getdetNb(), rate);
247 h_DefNeutronRate->Fill(aHit->
getdetNb(), 1 / rateCorrection);
248 h_DefNeutronHitsVrs->Fill(aHit->
getdetNb(), ring_section);
249 h_DefNeutronHitsWeightedVrs->Fill(aHit->
getdetNb(), ring_section, rate);
250 h_DefNeutronRateVrs->Fill(aHit->
getdetNb(), ring_section, 1 / rateCorrection);
251 h_PulseHeights_DefNeutron->Fill(aHit->
getPeakV());
257 if (neutronStatus == 0) neutronStatus = 2;
259 h_PulseHeights_Neutron->Fill(aHit->
getPeakV());
260 h_NeutronHits->Fill(aHit->
getdetNb());
261 h_NeutronRate->Fill(aHit->
getdetNb(), 1 / rateCorrection);
262 h_NeutronHitsWeighted->Fill(aHit->
getdetNb(), rate);
263 h_NeutronHitsVrs->Fill(aHit->
getdetNb(), ring_section);
264 h_NeutronRateVrs->Fill(aHit->
getdetNb(), ring_section, 1 / rateCorrection);
265 h_NeutronHitsWeightedVrs->Fill(aHit->
getdetNb(), ring_section, rate);
268 h_PulseHeights_NotNeutron->Fill(aHit->
getPeakV());
270 h_PulseHeights_All->Fill(aHit->
getPeakV());
274 if (neutronStatus == 1) B2DEBUG(80,
"He3tubeStudyModule: Definite Neutron in tube #" << tubeNum);
275 else if (neutronStatus == 2) B2DEBUG(80,
"He3tubeStudyModule: Possible Neutron in tube #" << tubeNum);
277 for (
int i = 0; i < 4; i++) {
278 if (ContainsP[i]) nPhits++;
279 if (Contains3H[i]) n3Hhits++;
288 void He3tubeStudyModule::endRun()
291 B2RESULT(
"He3tubeStudyModule: # of neutrons: " << nNeutronHits);
292 B2RESULT(
" # of definite neutrons " << nDefiniteNeutron);
293 B2RESULT(
" # of 3H hits: " << n3Hhits);
294 B2RESULT(
" # of H hits: " << nPhits);
300 void He3tubeStudyModule::terminate()
ClassHe3Hit - digitization simulated hit for the He3tube detector.
bool definiteNeutron() const
true if this is definitely a neutron event
double getPeakV() const
Return peak.
int getdetNb() const
Return the tube number.
ClassHe3tubeSimHit - Geant4 simulated hit for the He3tube detector.
float getEnergyDep() const
Return the energy deposition in electrons.
float getdetNb() const
Return the He3tube number.
int gettkPDG() const
Return the PDG number of the track.
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 He3tubes (BEAST)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.