9 #include <beast/microtpc/modules/TPCStudyModule.h>
10 #include <beast/microtpc/dataobjects/MicrotpcSimHit.h>
11 #include <framework/datastore/StoreArray.h>
12 #include <framework/logging/Logger.h>
13 #include <framework/gearbox/GearDir.h>
14 #include <framework/gearbox/Const.h>
15 #include <boost/foreach.hpp>
26 int co_ctr[4] = {0, 0, 0, 0};
27 int coe_ctr[4] = {0, 0, 0, 0};
28 int h1_ctr[4] = {0, 0, 0, 0};
29 int n_ctr[4] = {0, 0, 0, 0};
30 int he4_ctr[4] = {0, 0, 0, 0};
31 int o16_ctr[4] = {0, 0, 0, 0};
32 int c12_ctr[4] = {0, 0, 0, 0};
33 int ctr_ele[4] = {0, 0, 0, 0};
34 int ctr_pos[4] = {0, 0, 0, 0};
35 int ctr_pro[4] = {0, 0, 0, 0};
36 int ctr_neu[4] = {0, 0, 0, 0};
37 int ctr_good_neu[4] = {0, 0, 0, 0};
38 int ctr_bad_neu[4] = {0, 0, 0, 0};
39 int ctr_bak[4] = {0, 0, 0, 0};
44 using namespace microtpc;
58 setDescription(
"Study module for Microtpcs (BEAST)");
61 addParam(
"ChipRowNb", m_ChipRowNb,
"Chip number of row", 226);
62 addParam(
"ChipColumnNb", m_ChipColumnNb,
"Chip number of column", 80);
63 addParam(
"ChipColumnX", m_ChipColumnX,
"Chip x dimension in cm / 2", 1.0);
64 addParam(
"ChipRowY", m_ChipRowY,
"Chip y dimension in cm / 2", 0.86);
65 addParam(
"z_DG", m_z_DG,
"Drift gap distance [cm]", 12.0);
68 TPCStudyModule::~TPCStudyModule()
73 void TPCStudyModule::defineHisto()
75 for (
int i = 0; i < 11; i ++) {
76 h_tpc_kin[i] =
new TH1F(TString::Format(
"tpc_kin_%d", i),
"", 1000, 0., 100.);
77 h_tpc_xy[i] =
new TH2F(TString::Format(
"tpc_xy_%d", i),
"", 300, -3., 3., 300, -3., 3.);
82 void TPCStudyModule::initialize()
84 B2INFO(
"TPCStudyModule: Initialize");
93 void TPCStudyModule::beginRun()
97 void TPCStudyModule::event()
107 int old_trkID[4] = { -1, -1, -1, -1};
108 int old_trkID_h1[4] = { -1, -1, -1, -1};
109 int old_trkID_he4[4] = { -1, -1, -1, -1};
110 int old_trkID_c12[4] = { -1, -1, -1, -1};
111 int old_trkID_o16[4] = { -1, -1, -1, -1};
112 bool aneu[4] = {
false,
false,
false,
false};
113 bool apro[4] = {
false,
false,
false,
false};
114 bool atrk[4] = {
false,
false,
false,
false};
115 bool aele[4] = {
false,
false,
false,
false};
116 bool apos[4] = {
false,
false,
false,
false};
118 vector <double> RecoilE;
120 int NbofPart[4] = {0, 0, 0, 0};
122 cout <<
"Look at evt " << ctr << endl;
130 double xpos = position.X() / 100. - TPCCenter[detNb].X();
131 double ypos = position.Y() / 100. - TPCCenter[detNb].Y();
132 double zpos = position.Z() / 100. - TPCCenter[detNb].Z() + m_z_DG / 2.;
136 h_tpc_xy[7]->Fill(xpos, ypos);
137 if (pdg == 1000020040) h_tpc_xy[8]->Fill(xpos, ypos);
138 if (pdg == Const::proton.getPDGCode()) h_tpc_xy[9]->Fill(xpos, ypos);
139 if (pdg == Const::electron.getPDGCode()) h_tpc_xy[10]->Fill(xpos, ypos);
142 old_trkID[detNb] = trkID;
143 Pdg[detNb].push_back(pdg);
147 if (pdg == 1000020040) {
153 old_trkID_he4[detNb] = trkID;
163 h_tpc_xy[0]->Fill(xpos, ypos);
166 if (pdg == 1000060120) {
172 old_trkID_c12[detNb] = trkID;
182 h_tpc_xy[1]->Fill(xpos, ypos);
185 if (pdg == 1000080160) {
191 old_trkID_o16[detNb] = trkID;
201 h_tpc_xy[2]->Fill(xpos, ypos);
204 if (pdg == Const::proton.getPDGCode()) {
211 old_trkID_h1[detNb] = trkID;
220 h_tpc_xy[3]->Fill(xpos, ypos);
223 if (pdg == Const::neutron.getPDGCode()) {
226 h_tpc_xy[4]->Fill(xpos, ypos);
230 if (pdg == Const::electron.getPDGCode()) {
233 h_tpc_xy[5]->Fill(xpos, ypos);
236 if (pdg == -Const::electron.getPDGCode()) {
239 h_tpc_xy[6]->Fill(xpos, ypos);
242 for (
int i = 0; i < 4; i ++) {
243 if (apro[i] && atrk[i] && aneu[i]) co_ctr[i]++;
244 if (apro[i] && atrk[i] && aneu[i] && aele[i]) coe_ctr[i]++;
245 if (apro[i] && atrk[i]) {
246 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
247 h_tpc_kin[7]->Fill(RecoilE[j]);
251 if (apro[i] && aneu[i]) ctr_bak[i] ++;
252 if (atrk[i] && aneu[i]) {
253 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
254 h_tpc_kin[8]->Fill(RecoilE[j]);
257 if (NbofPart[i] == 1) ctr_good_neu[i] ++;
258 if (NbofPart[i] > 1) ctr_bad_neu[i] ++;
260 if (atrk[i] && aele[i]) {
261 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
262 h_tpc_kin[9]->Fill(RecoilE[j]);
266 if (atrk[i] && apos[i]) {
267 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
268 h_tpc_kin[10]->Fill(RecoilE[j]);
274 for (
int i = 0; i < 4; i ++) {
275 if (NbofPart[i] > 0) {
276 cout <<
"det # " << i <<
" number of particle " << NbofPart[i] << endl;
277 for (
int j = 0; j < (int) Pdg[i].size(); j ++) {
278 cout <<
" pdg " << Pdg[i][j] << endl;
286 void TPCStudyModule::getXMLData()
288 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name=\"MICROTPC\"]/Content/");
291 BOOST_FOREACH(
const GearDir & activeParams, content.getNodes(
"Active")) {
293 TPCCenter.push_back(TVector3(activeParams.
getLength(
"TPCpos_x"), activeParams.
getLength(
"TPCpos_y"),
298 m_ChipColumnNb = content.getInt(
"ChipColumnNb");
299 m_ChipRowNb = content.getInt(
"ChipRowNb");
300 m_ChipColumnX = content.getDouble(
"ChipColumnX");
301 m_ChipRowY = content.getDouble(
"ChipRowY");
302 m_z_DG = content.getDouble(
"z_DG");
304 B2INFO(
"TpcDigitizer: Aquired tpc locations and gas parameters");
305 B2INFO(
" from MICROTPC.xml. There are " << nTPC <<
" TPCs implemented");
308 void TPCStudyModule::endRun()
315 cout <<
" Total nb of evts " << ctr << endl;
316 for (
int i = 0; i < 4; i ++) {
317 cout <<
"n " << n_ctr[i] <<
" n-recoil-p " << co_ctr[i] <<
" n-recoil " << ctr_neu[i] <<
" p-n " << ctr_bak[i] <<
" p-He4 " <<
318 ctr_pro[i] <<
" H1 " << h1_ctr[i] <<
" He4 " << he4_ctr[i] <<
" C12 " << c12_ctr[i] <<
" O16 " << o16_ctr[i] <<
" good n-recoil " <<
319 ctr_good_neu[i] <<
" bad n-recoil " << ctr_bad_neu[i];
320 cout <<
" w/ e- " << ctr_ele[i] <<
" w/ e+ " << ctr_pos[i] <<
" n-p-recoil-e- " << coe_ctr[i] << endl;
324 void TPCStudyModule::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...
ClassMicrotpcSimHit - Geant4 simulated hit for the Microtpc detector.
float getEnergyDep() const
Return the energy deposition in electrons.
TVector3 gettkPos() const
Return the track position.
int gettkID() const
Return track ID.
float gettkKEnergy() const
Return the kinetic energy of the track.
float getdetNb() const
Return the TPC number.
TVector3 gettkMomDir() const
Return the track momentum direction.
int gettkPDG() const
Return the PDG number of the track.
Accessor to arrays stored in the data store.
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
Study module for TPCs (BEAST)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.