11 #include <beast/microtpc/modules/TPCStudyModule.h>
12 #include <beast/microtpc/dataobjects/MicrotpcSimHit.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/logging/Logger.h>
15 #include <framework/gearbox/GearDir.h>
16 #include <boost/foreach.hpp>
27 int co_ctr[4] = {0, 0, 0, 0};
28 int coe_ctr[4] = {0, 0, 0, 0};
29 int h1_ctr[4] = {0, 0, 0, 0};
30 int n_ctr[4] = {0, 0, 0, 0};
31 int he4_ctr[4] = {0, 0, 0, 0};
32 int o16_ctr[4] = {0, 0, 0, 0};
33 int c12_ctr[4] = {0, 0, 0, 0};
34 int ctr_ele[4] = {0, 0, 0, 0};
35 int ctr_pos[4] = {0, 0, 0, 0};
36 int ctr_pro[4] = {0, 0, 0, 0};
37 int ctr_neu[4] = {0, 0, 0, 0};
38 int ctr_good_neu[4] = {0, 0, 0, 0};
39 int ctr_bad_neu[4] = {0, 0, 0, 0};
40 int ctr_bak[4] = {0, 0, 0, 0};
45 using namespace microtpc;
59 setDescription(
"Study module for Microtpcs (BEAST)");
62 addParam(
"ChipRowNb", m_ChipRowNb,
"Chip number of row", 226);
63 addParam(
"ChipColumnNb", m_ChipColumnNb,
"Chip number of column", 80);
64 addParam(
"ChipColumnX", m_ChipColumnX,
"Chip x dimension in cm / 2", 1.0);
65 addParam(
"ChipRowY", m_ChipRowY,
"Chip y dimension in cm / 2", 0.86);
66 addParam(
"z_DG", m_z_DG,
"Drift gap distance [cm]", 12.0);
69 TPCStudyModule::~TPCStudyModule()
74 void TPCStudyModule::defineHisto()
76 for (
int i = 0; i < 11; i ++) {
77 h_tpc_kin[i] =
new TH1F(TString::Format(
"tpc_kin_%d", i),
"", 1000, 0., 100.);
78 h_tpc_xy[i] =
new TH2F(TString::Format(
"tpc_xy_%d", i),
"", 300, -3., 3., 300, -3., 3.);
83 void TPCStudyModule::initialize()
85 B2INFO(
"TPCStudyModule: Initialize");
94 void TPCStudyModule::beginRun()
98 void TPCStudyModule::event()
108 int old_trkID[4] = { -1, -1, -1, -1};
109 int old_trkID_h1[4] = { -1, -1, -1, -1};
110 int old_trkID_he4[4] = { -1, -1, -1, -1};
111 int old_trkID_c12[4] = { -1, -1, -1, -1};
112 int old_trkID_o16[4] = { -1, -1, -1, -1};
113 bool aneu[4] = {
false,
false,
false,
false};
114 bool apro[4] = {
false,
false,
false,
false};
115 bool atrk[4] = {
false,
false,
false,
false};
116 bool aele[4] = {
false,
false,
false,
false};
117 bool apos[4] = {
false,
false,
false,
false};
119 vector <double> RecoilE;
121 int NbofPart[4] = {0, 0, 0, 0};
123 cout <<
"Look at evt " << ctr << endl;
131 double xpos = position.X() / 100. - TPCCenter[detNb].X();
132 double ypos = position.Y() / 100. - TPCCenter[detNb].Y();
133 double zpos = position.Z() / 100. - TPCCenter[detNb].Z() + m_z_DG / 2.;
137 h_tpc_xy[7]->Fill(xpos, ypos);
138 if (pdg == 1000020040) h_tpc_xy[8]->Fill(xpos, ypos);
139 if (pdg == 2212) h_tpc_xy[9]->Fill(xpos, ypos);
140 if (pdg == 11) h_tpc_xy[10]->Fill(xpos, ypos);
143 old_trkID[detNb] = trkID;
144 Pdg[detNb].push_back(pdg);
148 if (pdg == 1000020040) {
154 old_trkID_he4[detNb] = trkID;
164 h_tpc_xy[0]->Fill(xpos, ypos);
167 if (pdg == 1000060120) {
173 old_trkID_c12[detNb] = trkID;
183 h_tpc_xy[1]->Fill(xpos, ypos);
186 if (pdg == 1000080160) {
192 old_trkID_o16[detNb] = trkID;
202 h_tpc_xy[2]->Fill(xpos, ypos);
212 old_trkID_h1[detNb] = trkID;
221 h_tpc_xy[3]->Fill(xpos, ypos);
227 h_tpc_xy[4]->Fill(xpos, ypos);
234 h_tpc_xy[5]->Fill(xpos, ypos);
240 h_tpc_xy[6]->Fill(xpos, ypos);
243 for (
int i = 0; i < 4; i ++) {
244 if (apro[i] && atrk[i] && aneu[i]) co_ctr[i]++;
245 if (apro[i] && atrk[i] && aneu[i] && aele[i]) coe_ctr[i]++;
246 if (apro[i] && atrk[i]) {
247 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
248 h_tpc_kin[7]->Fill(RecoilE[j]);
252 if (apro[i] && aneu[i]) ctr_bak[i] ++;
253 if (atrk[i] && aneu[i]) {
254 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
255 h_tpc_kin[8]->Fill(RecoilE[j]);
258 if (NbofPart[i] == 1) ctr_good_neu[i] ++;
259 if (NbofPart[i] > 1) ctr_bad_neu[i] ++;
261 if (atrk[i] && aele[i]) {
262 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
263 h_tpc_kin[9]->Fill(RecoilE[j]);
267 if (atrk[i] && apos[i]) {
268 for (
int j = 0; j < (int) RecoilE.size(); j ++) {
269 h_tpc_kin[10]->Fill(RecoilE[j]);
275 for (
int i = 0; i < 4; i ++) {
276 if (NbofPart[i] > 0) {
277 cout <<
"det # " << i <<
" number of particle " << NbofPart[i] << endl;
278 for (
int j = 0; j < (int) Pdg[i].size(); j ++) {
279 cout <<
" pdg " << Pdg[i][j] << endl;
287 void TPCStudyModule::getXMLData()
289 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name=\"MICROTPC\"]/Content/");
292 BOOST_FOREACH(
const GearDir & activeParams, content.getNodes(
"Active")) {
294 TPCCenter.push_back(TVector3(activeParams.
getLength(
"TPCpos_x"), activeParams.
getLength(
"TPCpos_y"),
299 m_ChipColumnNb = content.getInt(
"ChipColumnNb");
300 m_ChipRowNb = content.getInt(
"ChipRowNb");
301 m_ChipColumnX = content.getDouble(
"ChipColumnX");
302 m_ChipRowY = content.getDouble(
"ChipRowY");
303 m_z_DG = content.getDouble(
"z_DG");
305 B2INFO(
"TpcDigitizer: Aquired tpc locations and gas parameters");
306 B2INFO(
" from MICROTPC.xml. There are " << nTPC <<
" TPCs implemented");
309 void TPCStudyModule::endRun()
316 cout <<
" Total nb of evts " << ctr << endl;
317 for (
int i = 0; i < 4; i ++) {
318 cout <<
"n " << n_ctr[i] <<
" n-recoil-p " << co_ctr[i] <<
" n-recoil " << ctr_neu[i] <<
" p-n " << ctr_bak[i] <<
" p-He4 " <<
319 ctr_pro[i] <<
" H1 " << h1_ctr[i] <<
" He4 " << he4_ctr[i] <<
" C12 " << c12_ctr[i] <<
" O16 " << o16_ctr[i] <<
" good n-recoil " <<
320 ctr_good_neu[i] <<
" bad n-recoil " << ctr_bad_neu[i];
321 cout <<
" w/ e- " << ctr_ele[i] <<
" w/ e+ " << ctr_pos[i] <<
" n-p-recoil-e- " << coe_ctr[i] << endl;
325 void TPCStudyModule::terminate()