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>
25#include <Math/Vector3D.h>
35using namespace he3tube;
65 for (
int i = 0 ; i < 9 ; i++) {
66 h_mche3_kinetic[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_%d", i),
"MC kin. energy [GeV]", 1000, 0., 10.);
67 h_mche3_kinetic_zoom[i] =
new TH1F(TString::Format(
"h_mche3_kinetic_zoom_%d", i),
"MC kin. energy [MeV]", 1000, 0., 10.);
68 h_mche3_tvp[i] =
new TH2F(TString::Format(
"h_mche3_tvp_%d", i),
"theta v phi", 180, 0., 180., 360, -180., 180.);
69 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.);
70 h_mche3_zr[i] =
new TH2F(TString::Format(
"h_mche3_zr_%d", i),
"r v z", 200, -400., 400., 200, 0., 400.);
78 h_NeutronHits =
new TH1F(
"NeutronHits",
"Neutron Hits;Tube ", 4, -0.5, 3.5);
80 h_DefNeutronHits =
new TH1F(
"DefNeutronHits",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5);
82 h_NeutronRate =
new TH1F(
"NeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
83 h_DefNeutronRate =
new TH1F(
"DefNeutronRate",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5);
85 h_NeutronHitsVrs =
new TH2F(
"NeutronHitsVrs",
"Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
87 h_DefNeutronHitsVrs =
new TH2F(
"DefNeutronHitsVrs",
"Definite Neutron Hits;Tube ", 4, -0.5, 3.5, 12, 0., 12.);
89 h_NeutronRateVrs =
new TH2F(
"NeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
90 h_DefNeutronRateVrs =
new TH2F(
"DefNeutronRateVrs",
"Neutron Hits per second;Tube; Rate (Hz)", 4, -0.5, 3.5, 12, 0., 12.);
92 h_Edep1H3H =
new TH1F(
"Edep1H3H",
"Energy deposited by Proton and Tritium; MeV", 100, 0.7, 0.8);
93 h_Edep1H3H_detNB =
new TH1F(
"Edep1H3H_tube",
"Energy deposited by Proton and Tritium in each tube;Tube Num; MeV", 4, -0.5, 3.5);
94 h_Edep1H =
new TH1F(
"Edep1H",
"Energy deposited by Protons;MeV", 100, 0, 0.7);
95 h_Edep3H =
new TH1F(
"Edep3H",
"Energy deposited by Tritiums;MeV", 100, 0, 0.4);
96 h_TotEdep =
new TH1F(
"TotEdep",
"Total energy deposited;MeV", 100, 0, 1.5);
97 h_DetN_Edep =
new TH1F(
"DetN_Edep",
"Energy deposited vs detector number;Tube Num;MeV", 4, -0.5, 3.5);
99 h_PulseHeights_NotNeutron =
new TH1F(
"PulseHeights_NotNeutron",
"Pulse height of waveforms from non-neutron events", 100, 0, 18000);
100 h_PulseHeights_Neutron =
new TH1F(
"PulseHeights_Neutron",
"Pulse height of waveforms from neutron events", 100, 0, 18000);
101 h_PulseHeights_DefNeutron =
new TH1F(
"PulseHeights_DefNeutron",
"Pulse height of waveforms from definite neutron events", 100,
103 h_PulseHeights_All =
new TH1F(
"PulseHeights_All",
"Pulse height of waveforms from all events", 100, 0, 18000);
124 B2INFO(
"He3tubeStudyModule: Initialize");
144 int ring_section = -1;
145 for (
const auto& MetaHit : MetaHits) {
146 rate = MetaHit.getrate();
147 ring_section = MetaHit.getring_section() - 1;
150 for (
const auto& mcpart : mcparts) {
151 const double energy = mcpart.getEnergy();
152 const double mass = mcpart.getMass();
153 double kin = energy - mass;
154 const double PDG = mcpart.getPDG();
155 const ROOT::Math::XYZVector vtx = mcpart.getProductionVertex();
156 const ROOT::Math::XYZVector mom = mcpart.getMomentum();
157 double theta = mom.Theta() * TMath::RadToDeg();
158 double phi = mom.Phi() * TMath::RadToDeg();
160 double r =
sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y());
int partID[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
167 else if (PDG == 1000080160) partID[5] = 1;
168 else if (PDG == 1000060120) partID[6] = 1;
169 else if (PDG == 1000020040) partID[7] = 1;
171 for (
int i = 0; i < 9; i++) {
172 if (partID[i] == 1) {
184 double edepSum_1H = 0;
185 double edepSum_3H = 0;
186 double totedepSum = 0;
187 double totedepDet[4] = {0};
189 bool ContainsP[4] = {
false};
190 bool Contains3H[4] = {
false};
192 for (
int i = 0; i < simHits.
getEntries(); i++) {
199 B2WARNING(
"Hit registered in undefined tube, ignoring");
206 totedepSum = totedepSum + edep;
207 totedepDet[detNB] = totedepDet[detNB] + edep;
211 ContainsP[detNB] =
true;
214 edepSum_1H = edepSum_1H + edep;
215 edepSum = edepSum + edep;
219 if (PID == 1000010030) {
220 Contains3H[detNB] =
true;
223 edepSum_3H = edepSum_3H + edep;
224 edepSum = edepSum + edep;
230 if (totedepSum != 0)
h_TotEdep->Fill(totedepSum);
232 if (edepSum_1H != 0)
h_Edep1H->Fill(edepSum_1H);
233 if (edepSum_3H != 0)
h_Edep3H->Fill(edepSum_3H);
236 int neutronStatus = 0;
256 if (neutronStatus == 0) neutronStatus = 2;
273 if (neutronStatus == 1) B2DEBUG(80,
"He3tubeStudyModule: Definite Neutron in tube #" << tubeNum);
274 else if (neutronStatus == 2) B2DEBUG(80,
"He3tubeStudyModule: Possible Neutron in tube #" << tubeNum);
276 for (
int i = 0; i < 4; i++) {
277 if (ContainsP[i])
nPhits++;
290 B2RESULT(
"He3tubeStudyModule: # of neutrons: " <<
nNeutronHits);
292 B2RESULT(
" # of 3H hits: " <<
n3Hhits);
293 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 definte 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.