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>
22#include <Math/Vector3D.h>
30using namespace he3tube;
60 for (
int i = 0 ; i < 9 ; i++) {
61 h_mche3_kinetic[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_%d", i),
"MC kin. energy [GeV]", 1000, 0., 10.);
62 h_mche3_kinetic_zoom[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_zoom_%d", i),
"MC kin. energy [MeV]", 1000, 0., 10.);
63 h_mche3_tvp[i] =
new TH2F(TString::Format(
"h_mche3_tvp_%d", i),
"theta v phi", 180, 0., 180., 360, -180., 180.);
64 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.);
65 h_mche3_zr[i] =
new TH2F(TString::Format(
"h_mche3_zr_%d", i),
"r v z", 200, -400., 400., 200, 0., 400.);
73 h_NeutronHits =
new TH1F(
"NeutronHits",
"Neutron Hits;Tube ", 4, -0.5, 3.5);
75 h_DefNeutronHits =
new TH1F(
"DefNeutronHits",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5);
77 h_NeutronRate =
new TH1F(
"NeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
78 h_DefNeutronRate =
new TH1F(
"DefNeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
80 h_NeutronHitsVrs =
new TH2F(
"NeutronHitsVrs",
"Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
82 h_DefNeutronHitsVrs =
new TH2F(
"DefNeutronHitsVrs",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
84 h_NeutronRateVrs =
new TH2F(
"NeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
85 h_DefNeutronRateVrs =
new TH2F(
"DefNeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
87 h_Edep1H3H =
new TH1F(
"Edep1H3H",
"Energy deposited by Proton and Tritium; MeV", 100, 0.7, 0.8);
88 h_Edep1H3H_detNB =
new TH1F(
"Edep1H3H_tube",
"Energy deposited by Proton and Tritium in each tube;Tube Num; MeV", 4, -0.5, 3.5);
89 h_Edep1H =
new TH1F(
"Edep1H",
"Energy deposited by Protons;MeV", 100, 0, 0.7);
90 h_Edep3H =
new TH1F(
"Edep3H",
"Energy deposited by Tritiums;MeV", 100, 0, 0.4);
91 h_TotEdep =
new TH1F(
"TotEdep",
"Total energy deposited;MeV", 100, 0, 1.5);
92 h_DetN_Edep =
new TH1F(
"DetN_Edep",
"Energy deposited vs detector number;Tube Num;MeV", 4, -0.5, 3.5);
94 h_PulseHeights_NotNeutron =
new TH1F(
"PulseHeights_NotNeutron",
"Pulse height of waveforms from non-neutron events", 100, 0, 18000);
95 h_PulseHeights_Neutron =
new TH1F(
"PulseHeights_Neutron",
"Pulse height of waveforms from neutron events", 100, 0, 18000);
96 h_PulseHeights_DefNeutron =
new TH1F(
"PulseHeights_DefNeutron",
"Pulse height of waveforms from definite neutron events", 100,
98 h_PulseHeights_All =
new TH1F(
"PulseHeights_All",
"Pulse height of waveforms from all events", 100, 0, 18000);
119 B2INFO(
"He3tubeStudyModule: Initialize");
139 int ring_section = -1;
140 for (
const auto& MetaHit : MetaHits) {
141 rate = MetaHit.getrate();
142 ring_section = MetaHit.getring_section() - 1;
145 for (
const auto& mcpart : mcparts) {
146 const double energy = mcpart.getEnergy();
147 const double mass = mcpart.getMass();
148 double kin = energy - mass;
149 const double PDG = mcpart.getPDG();
150 const ROOT::Math::XYZVector vtx = mcpart.getProductionVertex();
151 const ROOT::Math::XYZVector mom = mcpart.getMomentum();
152 double theta = mom.Theta() * TMath::RadToDeg();
153 double phi = mom.Phi() * TMath::RadToDeg();
155 double r =
sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y());
int partID[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
162 else if (PDG == 1000080160) partID[5] = 1;
163 else if (PDG == 1000060120) partID[6] = 1;
164 else if (PDG == 1000020040) partID[7] = 1;
166 for (
int i = 0; i < 9; i++) {
167 if (partID[i] == 1) {
179 double edepSum_1H = 0;
180 double edepSum_3H = 0;
181 double totedepSum = 0;
182 double totedepDet[4] = {0};
184 bool ContainsP[4] = {
false};
185 bool Contains3H[4] = {
false};
187 for (
int i = 0; i < simHits.
getEntries(); i++) {
194 B2WARNING(
"Hit registered in undefined tube, ignoring");
201 totedepSum = totedepSum + edep;
202 totedepDet[detNB] = totedepDet[detNB] + edep;
206 ContainsP[detNB] =
true;
209 edepSum_1H = edepSum_1H + edep;
210 edepSum = edepSum + edep;
214 if (PID == 1000010030) {
215 Contains3H[detNB] =
true;
218 edepSum_3H = edepSum_3H + edep;
219 edepSum = edepSum + edep;
225 if (totedepSum != 0)
h_TotEdep->Fill(totedepSum);
227 if (edepSum_1H != 0)
h_Edep1H->Fill(edepSum_1H);
228 if (edepSum_3H != 0)
h_Edep3H->Fill(edepSum_3H);
231 int neutronStatus = 0;
251 if (neutronStatus == 0) neutronStatus = 2;
268 if (neutronStatus == 1) B2DEBUG(80,
"He3tubeStudyModule: Definite Neutron in tube #" << tubeNum);
269 else if (neutronStatus == 2) B2DEBUG(80,
"He3tubeStudyModule: Possible Neutron in tube #" << tubeNum);
271 for (
int i = 0; i < 4; i++) {
272 if (ContainsP[i])
nPhits++;
285 B2RESULT(
"He3tubeStudyModule: # of neutrons: " <<
nNeutronHits);
287 B2RESULT(
" # of 3H hits: " <<
n3Hhits);
288 B2RESULT(
" # of H hits: " <<
nPhits);
static const ParticleType neutron
neutron particle
static const ChargedStable proton
proton particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
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...
void setDescription(const std::string &description)
Sets the description of the module.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
int nNeutronHits
Number of neutrons.
TH2F * h_NeutronHitsVrs
Neutron Hits.
TH1F * h_Edep1H3H_detNB
Energy deposited by Proton and Tritium in each tube.
virtual ~He3tubeStudyModule()
Destructor.
TH2F * h_NeutronHitsWeightedVrs
Neutron Hits.
TH2F * h_NeutronRateVrs
Neutron Hits per second.
int m_sampletime
The sample time in us.
TH1F * h_PulseHeights_NotNeutron
Pulse height of waveforms from non-neutrons.
TH1F * h_NeutronRate
Neutron Hits per second.
virtual void initialize() override
Initialize the Module.
TH1F * h_PulseHeights_Neutron
Pulse height of waveforms from neutrons.
TH1F * h_NeutronHitsWeighted
Neutron Hits.
int n3Hhits
number of Tritium hits
virtual void event() override
Event processor.
He3tubeStudyModule()
Constructor: Sets the description, the properties and the parameters of the module.
TH1F * h_Edep1H3H
Energy deposited by Proton and Tritium.
TH2F * h_DefNeutronHitsWeightedVrs
Definite Neutron Hits.
TH2F * h_DefNeutronRateVrs
Definite Neutron Hits per second.
virtual void endRun() override
End-of-run action.
TH1F * h_DefNeutronRate
Definite Neutron Hits per second.
TH1F * h_NeutronHits
Neutron Hits.
virtual void terminate() override
Termination action.
TH1F * h_mche3_kinetic[10]
MC kin energy dis.
TH2F * h_mche3_zr[10]
r v z
virtual void beginRun() override
Called when entering a new run.
TH1F * h_PulseHeights_DefNeutron
Pulse height of waveforms from definite neutrons.
int nPhits
number of proton hits
TH1F * h_DefNeutronHitsWeighted
Definite Neutron Hits.
TH1F * h_DefNeutronHits
Definite Neutron Hits.
TH1F * h_Edep3H
Energy deposited by Tritiums.
TH2F * h_mche3_tvpW[10]
theta v phi dis
TH2F * h_mche3_tvp[10]
theta v phi dis
TH1F * h_mche3_kinetic_zoom[10]
Neutron kin energy dis.
TH1F * h_TotEdep
Momentum of neutrons.
int nDefiniteNeutron
Number of definite neutrons.
TH1F * h_Edep1H
Energy deposited by Protons.
TH1F * h_PulseHeights_All
Pulse heught of all waveforms.
TH1F * h_DetN_Edep
Energy deposited vs detector number
TH2F * h_DefNeutronHitsVrs
Definite Neutron Hits.
double rateCorrection
converts sample time to rate in s
virtual void defineHisto() override
Defines the histograms.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.