CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
InductionGar2.cxx
Go to the documentation of this file.
2
3#include "CLHEP/Units/PhysicalConstants.h"
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/DataSvc.h"
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/PropertyMgr.h"
9#include "GaudiKernel/SmartDataPtr.h"
10
11#include "G4DigiManager.hh"
12#include "G4ios.hh"
13#include "Randomize.hh"
14
15#include "CLHEP/Units/PhysicalConstants.h"
16
17#include "TRandom.h"
18#include "TTree.h"
19#include "TSystem.h"
20#include <cmath>
21#include <fstream>
22#include <iomanip>
23#include <iostream>
24#include <limits>
25
26//#define INDUCTIONGAR_DEBUG_RECTANGLE2_FAST_TEST
27//uncomment the previous line to check correctness of results of rectangle2_fast.
28//it will be slow.
29
30//#define INDUCTIONGAR_DEBUG_CONVOLUTION_TBRANCH_FFT_TEST
31//uncomment the previous line to check correctness of results of Convolution_Tbranch_fft and Convolution_Ebranch_fft
32//it will be very slow.
33
34//#define INDUCTIONGAR_DEBUG_CONV1PERGRID_FFT_TEST
35//uncomment the previous line to check equality of 2 conv1PerGrid.
36
37const static int electrons_select_method_threhold = 0; //always use FFT conv here.
38
39const static int _nbins = 2000;
40typedef std::vector<int> Vint;
41using namespace std;
42const static double zeros[_nbins] = { 0};
43static void compareMap(const std::map<int, double> mapQ1[2][2], const std::map<int, double> mapQ2[2][2]);
44static void DrawToFile(const double *h, const char *filename);
45static void checkMemorySize();
46
47
48template <typename T>
49static bool compareVector(const vector<T> &v1, const vector<T> &v2, const char *description, double threshold = 0, bool noOutput = false) {
50 if (threshold < 0) threshold = 0;
51 //static const double threshold=1e-5;
52 //# if std::numeric_limits<T>::is_signed
53 bool found_mismatch = false;
54 const vector<T> *vLarger = &v1;
55 char vLargerName[] = "v1";
56 if (noOutput){
57 if (v1.size() != v2.size()) return false;
58 for (size_t i = 0; i < std::min(v1.size(), v2.size()); i++) {
59 if (max(v1[i], v2[i]) - min(v1[i], v2[i]) > threshold) return false;
60 }
61 }else{
62 if (v1.size() != v2.size()) {
63 {
64 if (not found_mismatch) {
65 cout << "compareVector:" << description << ":found mismatch:" << '\n';
66 found_mismatch = true;
67 }
68 }
69 cout << "\t size not match, v1:" << v1.size() << " v2:" << v2.size() << "\n";
70 if (v1.size() < v2.size()) {
71 vLarger = &v2;
72 vLargerName[1] = '2';
73 }
74 }
75
76 for (size_t i = 0; i < std::min(v1.size(), v2.size()); i++) {
77 if (max(v1[i], v2[i]) - min(v1[i], v2[i]) > threshold) {
78 {
79 if (not found_mismatch) {
80 cout << "compareVector:" << description << ":found mismatch:" << '\n';
81 found_mismatch = true;
82 }
83 }
84 cout << "\t at i=" << i << " not match, v1[i] = " << v1[i] << " v2[i] = " << v2[i] << '\n';
85 }
86 }
87
88 for (size_t i = min(v1.size(), v2.size()); i < max(v1.size(), v2.size()); i++) {
89 {
90 if (not found_mismatch) {
91 cout << "compareVector:" << description << ":found mismatch:" << '\n';
92 found_mismatch = true;
93 }
94 }
95 cout << "\t at i=" << i << ", only has " << vLargerName << "[i] = " << (*vLarger)[i] << '\n';
96 }
97 }
98 return !found_mismatch;
99}
100
101template <typename T>
102static bool compareArray(const T *v1, const T *v2, size_t length, const char *description, double threshold = 0, bool noOutput=false) {
103 if (threshold < 0) threshold = 0;
104 //static const double threshold=1e-5;
105 //# if std::numeric_limits<T>::is_signed
106 bool found_mismatch = false;
107
108 for (size_t i = 0; i < length; i++) {
109 if (max(v1[i], v2[i]) - min(v1[i], v2[i]) > threshold) {
110 {
111 if (noOutput) return false;
112 if (not found_mismatch) {
113 cout << "compareArray:" << description << ":found mismatch:" << '\n';
114 found_mismatch = true;
115 }
116 }
117 cout << "\t at i=" << i << " not match, v1[i] = " << v1[i] << " v2[i] = " << v2[i] << '\n';
118 }
119 }
120 return !found_mismatch;
121}
122
123//-----------------------Convolution of response function---------------------------------
124
125static double rectangle2(double t, double *x, double *y, int Npx) {
126
127 double I = y[0];
128 int id = -1;
129 for (int i = 0; i < Npx - 1; i++) {
130 if (t >= x[i] && t < x[i + 1]) {
131 id = i;
132 break;
133 }
134 }
135 if (id != -1) {
136 I = y[id] + (y[id + 1] - y[id]) * (t - x[id]) / (x[id + 1] - x[id]);
137 }
138
139 return I;
140}
141
142/**
143 * @brief calc estimate using linear interpolation of curve {x,y} , at point t; mimic rectangle2() but faster version
144 * assuming x: from 0 to 1000 and 2000 points.
145 * @param t
146 * @param x
147 * @param y
148 * @param Npx
149 * @return double
150 */
151static double rectangle2_fast(double t, double *x, const double *y, int Npx) {
152
153 const int nbinsx = 2000;
154 const double xmin = 0;
155 const double xmax = 1000;
156 const double binWidth = (xmax - xmin) / nbinsx;
157 double I = y[0];
158 int id = -1;
159
160 if (t > xmin + binWidth / 2 && t < xmax - binWidth / 2) {
161 id = (int)floor((t - binWidth / 2 - xmin) / binWidth);
162 }
163#ifdef INDUCTIONGAR_DEBUG_RECTANGLE2_FAST_TEST // checking results of new and old version. for speed it should not run
164 int id2 = -1;
165 for (int i = 0; i < Npx - 1; i++) {
166 if (t >= x[i] && t < x[i + 1]) {
167 id2 = i;
168 break;
169 } // find the closist id, to make t=x[id]; find root.
170 }
171 if (id2 != id) {
172 cout << "CgemDigitizerSvc::InductionGar2::rectangle2_fast: 2 method calced id doesnot correspond, "
173 << "id new : " << id2 << " id old : " << id << " t : " << t << " x at id old " << x[id2] << '\n';
174 }
175#endif
176 if (id != -1) {
177 I = y[id] + (y[id + 1] - y[id]) * (t - x[id]) / (x[id + 1] - x[id]);
178 } // the tangent of y(i),x(i) at i=id, I is on tangent and at x=t;
179
180 return I;
181}
182
183static double rectangle2(double t, std::vector<double> &x, const double *y, int Npx) {
184
185 double I = y[0];
186 int id = -1;
187 for (int i = 0; i < Npx - 1; i++) {
188 if (t >= x[i] && t < x[i + 1]) {
189 id = i;
190 break;
191 }
192 }
193 if (id != -1) {
194 I = y[id] + (y[id + 1] - y[id]) * (t - x[id]) / (x[id + 1] - x[id]);
195 }
196
197 return I;
198}
199
200static double T_branch2(double t) {
201 double result = 0.;
202 t = t - 10.;
203 if (t > 0) {
204 result = 2000. * (0.00181928 * exp(-t / 3.) - 0.0147059 * exp(-t / 20.) + 0.0128866 * exp(-t / 100.));
205 }
206 return result;
207}
208
209static double E_branch2(double t) {
210 double result = 0.;
211 t = t - 5;
212 if (t > 0) {
213 result = 0.000627357 * (1358.7 * exp(-t * 0.0385647) * t + 1358.7 * exp(-t * 0.0114353) * t + 100164. * exp(-t * 0.0385647) - 100164. * exp(-0.0114353 * t));
214 }
215 return result;
216}
217
218static TH1F Convolution_Tbranch(const double *Input_Curr_plot_001, double xmin, double xmax, int Npx = 2000) // return TIGER output
219{
220
221 TH1F h_signalT("h_signalT", "", Npx, xmin, xmax);
222 std::vector<double> Input_Time_plot_001(Npx);
223 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalT.GetBinCenter(i + 1);
224
225 double xmin_f1(0.), xmax_f1(1000);
226 int nStep_f1(200);
227 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
228 double x_f1(0.0);
229
230 std::vector<double> x(Npx);
231 std::vector<double> y_001(Npx);
232
233 for (int i = 0; i < Npx; i++) {
234 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
235 double fun_001 = 0.0;
236
237 for (int j = 0; j < nStep_f1; j++) {
238 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
239 fun_001 += rectangle2(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * T_branch2(x[i] - x_f1) * step_f1;
240 }
241 y_001[i] = fun_001;
242 }
243
244 for (int init = 0; init < Npx; init++) {
245 h_signalT.SetBinContent(init + 1, -y_001[init]);
246 }
247
248 return h_signalT;
249}
250
251static TH1F Convolution_Tbranch(const double *Input_Curr_plot_001) // return TIGER output
252{
253 double xmin(0), xmax(1000);
254 const int Npx(2000);
255
256 TH1F h_signalT("h_signalT", "", Npx, xmin, xmax);
257 double Input_Time_plot_001[Npx];
258 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalT.GetBinCenter(i + 1);
259
260 double xmin_f1(0.), xmax_f1(1000);
261 int nStep_f1(200);
262 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
263 double x_f1(0.0);
264
265 double x[Npx];
266 double y_001[Npx];
267
268 for (int i = 0; i < Npx; i++) {
269 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
270 double fun_001 = 0.0;
271
272 for (int j = 0; j < nStep_f1; j++) {
273 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
274 fun_001 += rectangle2_fast(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * T_branch2(x[i] - x_f1) * step_f1;
275 }
276 y_001[i] = fun_001;
277 }
278
279 for (int init = 0; init < Npx; init++) {
280 h_signalT.SetBinContent(init + 1, -y_001[init]);
281 }
282
283 return h_signalT;
284}
285
286static TH1F Convolution_Ebranch(const double *Input_Curr_plot_001, double xmin, double xmax, int Npx = 2000) // return TIGER output
287{
288 TH1F h_signalE("h_signalE", "", Npx, xmin, xmax);
289 std::vector<double> Input_Time_plot_001(Npx);
290 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalE.GetBinCenter(i + 1);
291
292 double xmin_f1(0.), xmax_f1(1000);
293 int nStep_f1(200);
294 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
295 double x_f1(0.0);
296
297 std::vector<double> x(Npx);
298 std::vector<double> y_001(Npx);
299
300 for (int i = 0; i < Npx; i++) {
301 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
302 double fun_001 = 0.0;
303
304 for (int j = 0; j < nStep_f1; j++) {
305 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
306 fun_001 += rectangle2(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * E_branch2(x[i] - x_f1) * step_f1;
307 }
308 y_001[i] = fun_001;
309 }
310
311 for (int init = 0; init < Npx; init++) {
312 h_signalE.SetBinContent(init + 1, -y_001[init]);
313 }
314
315 return h_signalE;
316}
317
318static TH1F Convolution_Ebranch(const double *Input_Curr_plot_001) // return TIGER output
319{
320 double xmin(0), xmax(1000);
321 const int Npx(2000);
322
323 TH1F h_signalE("h_signalE", "", Npx, xmin, xmax);
324 double Input_Time_plot_001[Npx];
325 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalE.GetBinCenter(i + 1);
326
327 double xmin_f1(0.), xmax_f1(1000);
328 int nStep_f1(200);
329 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
330 double x_f1(0.0);
331
332 double x[Npx];
333 double y_001[Npx];
334
335 for (int i = 0; i < Npx; i++) {
336 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
337 double fun_001 = 0.0;
338
339 for (int j = 0; j < nStep_f1; j++) {
340 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
341 fun_001 += rectangle2_fast(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * E_branch2(x[i] - x_f1) * step_f1;
342 }
343 y_001[i] = fun_001;
344 }
345
346 for (int init = 0; init < Npx; init++) {
347 h_signalE.SetBinContent(init + 1, -y_001[init]);
348 }
349
350 return h_signalE;
351}
352
353#ifdef INDUCTIONGAR_DEBUG_CONVOLUTION_TBRANCH_FFT_TEST
354/*
355 * @brief works exactly like Convolution_Tbranch, but works on every point rather than 1 in 10.
356 *
357 * @param Input_Curr_plot_001
358 * @return TH1F
359 */
360static TH1F Convolution_Tbranch_noskip(const double *Input_Curr_plot_001) // return TIGER output
361{
362 double xmin(0), xmax(1000);
363 const int Npx(2000);
364
365 TH1F h_signalT("h_signalT", "", Npx, xmin, xmax);
366 double Input_Time_plot_001[Npx];
367 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalT.GetBinCenter(i + 1);
368
369 double xmin_f1(0.), xmax_f1(1000);
370 int nStep_f1(2000);
371 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
372 double x_f1(0.0);
373
374 double x[Npx];
375 double y_001[Npx];
376
377 for (int i = 0; i < Npx; i++) {
378 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
379 double fun_001 = 0.0;
380
381 for (int j = 0; j < nStep_f1; j++) {
382 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
383 fun_001 += rectangle2_fast(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * T_branch2(x[i] - x_f1) * step_f1;
384 }
385 y_001[i] = fun_001;
386 }
387
388 for (int init = 0; init < Npx; init++) {
389 h_signalT.SetBinContent(init + 1, -y_001[init]);
390 }
391
392 return h_signalT;
393}
394
395static TH1F Convolution_Ebranch_noskip(const double *Input_Curr_plot_001) // return TIGER output
396{
397 double xmin(0), xmax(1000);
398 const int Npx(2000);
399
400 TH1F h_signalE("h_signalE", "", Npx, xmin, xmax);
401 double Input_Time_plot_001[Npx];
402 for (int i = 0; i < Npx; i++) Input_Time_plot_001[i] = h_signalE.GetBinCenter(i + 1);
403
404 double xmin_f1(0.), xmax_f1(1000);
405 int nStep_f1(2000);
406 double step_f1 = (xmax_f1 - xmin_f1) / nStep_f1;
407 double x_f1(0.0);
408
409 double x[Npx];
410 double y_001[Npx];
411
412 for (int i = 0; i < Npx; i++) {
413 x[i] = xmin + (xmax - xmin) / Npx * (i + 0.5);
414 double fun_001 = 0.0;
415
416 for (int j = 0; j < nStep_f1; j++) {
417 x_f1 = xmin_f1 + step_f1 * (j + 0.5);
418 fun_001 += rectangle2_fast(x_f1, Input_Time_plot_001, Input_Curr_plot_001, Npx) * E_branch2(x[i] - x_f1) * step_f1;
419 }
420 y_001[i] = fun_001;
421 }
422
423 for (int init = 0; init < Npx; init++) {
424 h_signalE.SetBinContent(init + 1, -y_001[init]);
425 }
426
427 return h_signalE;
428}
429#endif
431 double xmin(0), xmax(1000);
432 const int Npx(2000);
433 TBranch.resize(Npx); // TBranch at x<0 is 0
434 double *p_TBranch = &(TBranch.front());
435 for (int i = 0; i < Npx; i++) {
436 double x = xmin + (xmax - xmin) * i / Npx;
437 TBranch[i] = T_branch2(x);
438 } // set initial TBranch values.
439 // basically, a N and a (2N-1) needs (3N-2) bins to avoid overlap.
440 conv = new ConvolveWithConst(p_TBranch, Npx, Npx);
441 //TBranch_fft.resize(Npx*3-2);
442
443 //conv.convolve
444}
446 delete conv;
447}
448/**
449 * @brief return convolve of Input_Curr_plot_001 and T_Branch2, a function; tries to mimic Convolution_Tbranch
450 * has a option to test correctness.
451 *
452 * @param Input_Curr_plot_001
453 * @return TH1D
454 */
455TH1D CTF2::Convolution_Tbranch_fft(const double *Input_Curr_plot_001) // return TIGER output; note it returns DOUBLE typed hist, rather than original float.
456{
457 double xmin(0), xmax(1000);
458 const int Npx(2000);
459
460 TH1D h_signal("h_signal", "", Npx, xmin, xmax);
461 double *p_signal = h_signal.GetArray() + 1; //considering underflow.
462 this->conv->convolve(p_signal, Input_Curr_plot_001, 0, Npx, -0.5); // the '-' before 0.5: from original function.
463
464#ifdef INDUCTIONGAR_DEBUG_CONVOLUTION_TBRANCH_FFT_TEST
465 const double dx_abs_threhold = 1e-6; // think about the accurancy of float; warn if |x| > threhold
466 const double dx_ref_threhold = 1e-6; //think about the accurancy of float; warn if |dx/x| > threhold
467 TH1F h_signal_ref = Convolution_Tbranch_noskip(Input_Curr_plot_001);
468 bool found_mismatch = false;
469 for (int i = 1; i <= Npx; i++) {
470 if (abs((h_signal[i] - h_signal_ref[i]) / h_signal_ref[i]) > dx_ref_threhold and abs(h_signal[i] - h_signal_ref[i]) > dx_abs_threhold) {
471 if (not found_mismatch) {
472 std::cout << "CgemDigitizerSvc::InductionGar2::Convolution_Tbranch_fft found results not match: ";
473 found_mismatch = true;
474 }
475 std::cout << "ref: " << h_signal_ref[i] << "; this: " << h_signal[i] << "; at i=" << i << ";threhold abs=" << dx_abs_threhold << "; ref=" << dx_ref_threhold << '\n';
476 }
477 }
478#endif
479
480 return h_signal;
481}
482
484 double xmin(0), xmax(1000);
485 const int Npx(2000);
486 EBranch.resize(Npx); // EBranch at x<0 is 0
487 double *p_EBranch = &(EBranch.front());
488 for (int i = 0; i < Npx; i++) {
489 double x = xmin + (xmax - xmin) * i / Npx;
490 EBranch[i] = E_branch2(x);
491 } // set initial EBranch values.
492 // basically, a N and a (2N-1) needs (3N-2) bins to avoid overlap.
493 conv = new ConvolveWithConst(p_EBranch, Npx, Npx);
494 //EBranch_fft.resize(Npx*3-2);
495
496 //conv.convolve
497}
499 delete conv;
500}
501/**
502 * @brief return convolve of Input_Curr_plot_001 and T_Branch2, a function; tries to mimic Convolution_Ebranch
503 * has a option to test correctness.
504 *
505 * @param Input_Curr_plot_001
506 * @return TH1D
507 */
508TH1D CEF2::Convolution_Ebranch_fft(const double *Input_Curr_plot_001) // return TIGER output; note it returns DOUBLE typed hist, rather than original float.
509{
510 double xmin(0), xmax(1000);
511 const int Npx(2000);
512
513 TH1D h_signal("h_signalE", "", Npx, xmin, xmax);
514 double *p_signal = h_signal.GetArray() + 1; //considering underflow.
515 this->conv->convolve(p_signal, Input_Curr_plot_001, 0, Npx, -0.5);
516
517#ifdef INDUCTIONGAR_DEBUG_CONVOLUTION_TBRANCH_FFT_TEST
518 const double dx_abs_threhold = 1e-6; // think about the accurancy of float; warn if |x| > threhold
519 const double dx_ref_threhold = 1e-6; //think about the accurancy of float; warn if |dx/x| > threhold
520 TH1F h_signal_ref = Convolution_Ebranch_noskip(Input_Curr_plot_001);
521 bool found_mismatch = false;
522 for (int i = 1; i <= Npx; i++) {
523 if (abs((h_signal[i] - h_signal_ref[i]) / h_signal_ref[i]) > dx_ref_threhold and abs(h_signal[i] - h_signal_ref[i]) > dx_abs_threhold) {
524 if (not found_mismatch) {
525 std::cout << "CgemDigitizerSvc::InductionGar2::Convolution_Ebranch_fft found results not match: ";
526 found_mismatch = true;
527 }
528 std::cout << "ref: " << h_signal_ref[i] << "; this: " << h_signal[i] << "; at i=" << i << ";threhold abs=" << dx_abs_threhold << "; ref=" << dx_ref_threhold << '\n';
529 }
530 }
531#endif
532
533 return h_signal;
534}
535
537 string testPath = getenv("CGEMDIGITIZERSVCROOT");
538 m_LUTFilePath = "/bes3fs/cgemCosmic/data/CGEM_cosmic_look_up_table_from_10_to_17.root";
539 m_V2EfineFile = testPath + "testFIle/V2Efine.root";
540 sample_delay = 162.5;
541 storeFlag = false;
542 m_saturation = true;
543
544
545 m_QinGausSigma[0]=2;
546 m_QinGausSigma[1]=2;
547}
548
550}
551
552void InductionGar2::init(ICgemGeomSvc *geomSvc, double magConfig) {
553 m_geomSvc = geomSvc;
554 m_magConfig = magConfig;
555 std::cout << "InductionGar2 sampling time : " << sample_delay << std::endl;
556
557 string filePath_ratio = getenv("CGEMDIGITIZERSVCROOT");
558 string fileName;
559 if (0 == m_magConfig)
560 fileName = filePath_ratio + "/dat/par_InductionGar_0T.txt";
561 else
562 fileName = filePath_ratio + "/dat/par_InductionGar_1T.txt";
563 ifstream fin(fileName.c_str(), ios::in);
564 cout << "InductionGar2 fileName: " << fileName << endl;
565
566 string strline;
567 string strpar;
568 if (!fin.is_open()) {
569 cout << "ERROR: can not open file " << fileName << endl;
570 }
571
572 for (int m = 0; m < 3; m++) {
573 for (int l = 0; l < 5; l++) {
574 for (int k = 0; k < 5; k++) {
575 for (int i = 0; i < 4; i++) {
576 fin >> RatioX[m][l][k][i];
577 }
578 for (int j = 0; j < 3; j++) {
579 fin >> RatioV[m][l][k][j];
580 }
581 }
582 }
583 }
584 fin.close();
585
586 string fileName1 = filePath_ratio + "/dat/VQ_relation.txt";
587 ifstream VQin(fileName1.c_str(), ios::in);
588 VQin >> VQ_slope >> VQ_const;
589 VQin.close();
590 //cout<<VQ_slope<<" "<<VQ_const<<endl;
591
592 string filePath = getenv("CGEMDIGITIZERSVCROOT");
593 for (int i = 0; i < 3; i++) { // layer
594 for (int j = 0; j < 5; j++) { // Grid-x
595 for (int k = 0; k < 5; k++) { // Grid-v
596 char temp1[1];
597 sprintf(temp1, "%i", (i + 1));
598 char temp2[2];
599 sprintf(temp2, "%i", ((j + 1) * 10 + k + 1));
600 if (0 == m_magConfig)
601 fileName = filePath + "/dat/InducedCurrent_Root_0T/layer" + temp1 + "_" + temp2 + ".root";
602 else
603 fileName = filePath + "/dat/InducedCurrent_Root_1T/layer" + temp1 + "_" + temp2 + ".root";
604 TFile *file_00 = TFile::Open(fileName.c_str(), "read");
605 TH1 *readThis_x3 = 0;
606 TH1 *readThis_x4 = 0;
607 TH1 *readThis_x5 = 0;
608 TH1 *readThis_x6 = 0;
609 TH1 *readThis_v5 = 0;
610 TH1 *readThis_v6 = 0;
611 TH1 *readThis_v7 = 0;
612 file_00->GetObject("readThis_x3", readThis_x3);
613 file_00->GetObject("readThis_x4", readThis_x4);
614 file_00->GetObject("readThis_v5", readThis_v5);
615 file_00->GetObject("readThis_x5", readThis_x5);
616 file_00->GetObject("readThis_v6", readThis_v6);
617 file_00->GetObject("readThis_x6", readThis_x6);
618 file_00->GetObject("readThis_v7", readThis_v7);
619
620 double scaleX=m_ScaleSignalX;
621 double scaleV=(1-scaleX*(RatioX[i][j][k][0]+RatioX[i][j][k][1]+RatioX[i][j][k][2]+RatioX[i][j][k][3]))/(RatioV[i][j][k][0]+RatioV[i][j][k][1]+RatioV[i][j][k][2]);
622 for (int init = 0; init < 100; init++) {
623 SignalX[i][j][k][0][init] = scaleX*readThis_x3->GetBinContent(init + 1);
624 SignalX[i][j][k][1][init] = scaleX*readThis_x4->GetBinContent(init + 1);
625 SignalX[i][j][k][2][init] = scaleX*readThis_x5->GetBinContent(init + 1);
626 SignalX[i][j][k][3][init] = scaleX*readThis_x6->GetBinContent(init + 1);
627 SignalV[i][j][k][0][init] = scaleV*readThis_v5->GetBinContent(init + 1);
628 SignalV[i][j][k][1][init] = scaleV*readThis_v6->GetBinContent(init + 1);
629 SignalV[i][j][k][2][init] = scaleV*readThis_v7->GetBinContent(init + 1);
630 }
631 double temp[7][200];
632 for (int init = 0; init < 100; init++) { // since it was used like 2 bins eventually.
633 temp[0][init * 2] = SignalX[i][j][k][0][init];
634 temp[1][init * 2] = SignalX[i][j][k][1][init];
635 temp[2][init * 2] = SignalX[i][j][k][2][init];
636 temp[3][init * 2] = SignalX[i][j][k][3][init];
637 temp[4][init * 2] = SignalV[i][j][k][0][init];
638 temp[5][init * 2] = SignalV[i][j][k][1][init];
639 temp[6][init * 2] = SignalV[i][j][k][2][init];
640 temp[0][init * 2 + 1] = SignalX[i][j][k][0][init];
641 temp[1][init * 2 + 1] = SignalX[i][j][k][1][init];
642 temp[2][init * 2 + 1] = SignalX[i][j][k][2][init];
643 temp[3][init * 2 + 1] = SignalX[i][j][k][3][init];
644 temp[4][init * 2 + 1] = SignalV[i][j][k][0][init];
645 temp[5][init * 2 + 1] = SignalV[i][j][k][1][init];
646 temp[6][init * 2 + 1] = SignalV[i][j][k][2][init];
647 }
648 // since we actually used only index 1~80.
649 Signal_ConvolverX[i][j][k][0].init(temp[0] + 2, 160, 2000);
650 Signal_ConvolverX[i][j][k][1].init(temp[1] + 2, 160, 2000);
651 Signal_ConvolverX[i][j][k][2].init(temp[2] + 2, 160, 2000);
652 Signal_ConvolverX[i][j][k][3].init(temp[3] + 2, 160, 2000);
653 Signal_ConvolverV[i][j][k][0].init(temp[4] + 2, 160, 2000);
654 Signal_ConvolverV[i][j][k][1].init(temp[5] + 2, 160, 2000);
655 Signal_ConvolverV[i][j][k][2].init(temp[6] + 2, 160, 2000);
656 }
657 }
658 }
659
660 TFile *LUTFile = TFile::Open(m_LUTFilePath.c_str(), "read");
661 TTree *tree = (TTree *)LUTFile->Get("tree");
662 Float_t V_th_T, V_th_E, QDC_a, QDC_b, QDC_saturation;
663 Int_t layer, sheet, strip_v, strip_x;
664 tree->SetBranchAddress("strip_x_boss", &strip_x);
665 tree->SetBranchAddress("strip_v_boss", &strip_v);
666 tree->SetBranchAddress("layer", &layer);
667 tree->SetBranchAddress("sheet", &sheet);
668 tree->SetBranchAddress("calib_QDC_slope", &QDC_a);
669 tree->SetBranchAddress("calib_QDC_const", &QDC_b);
670 tree->SetBranchAddress("calib_QDC_saturation", &QDC_saturation);
671 tree->SetBranchAddress("v_thr_T_mV", &V_th_T);
672 tree->SetBranchAddress("v_thr_E_mV", &V_th_E);
673
674 double thresholdMin_X_T = 999;
675 double thresholdMin_V_T = 999;
676 double thresholdMin_X_Q = 999;
677 double thresholdMin_V_Q = 999;
678 for (int i = 0; i < tree->GetEntries(); i++) {
679 tree->GetEntry(i);
680 if (strip_x != -1) {
681 T_thr_V[layer][sheet][0][strip_x] = V_th_T;
682 if (V_th_T > 0 && V_th_T < thresholdMin_X_T) thresholdMin_X_T = V_th_T;
683 //if(V_th_T<0) T_thr_V[layer][sheet][0][strip_x] =12.;
684 E_thr_V[layer][sheet][0][strip_x] = V_th_E;
685 if (V_th_E > 0 && V_th_E < thresholdMin_X_Q) thresholdMin_X_Q = V_th_E;
686 //if(V_th_E<0) E_thr_V[layer][sheet][0][strip_x] =12.;
687 QDC_slope[layer][sheet][0][strip_x] = QDC_a;
688 QDC_const[layer][sheet][0][strip_x] = QDC_b;
689 Qsaturation[layer][sheet][0][strip_x] = QDC_saturation;
690 }
691 if (strip_v != -1) {
692 T_thr_V[layer][sheet][1][strip_v] = V_th_T;
693 if (V_th_T > 0 && V_th_T < thresholdMin_V_T) thresholdMin_V_T = V_th_T;
694 //if(V_th_T<0) T_thr_V[layer][sheet][1][strip_v] =12.;
695 E_thr_V[layer][sheet][1][strip_v] = V_th_E;
696 if (V_th_E > 0 && V_th_E < thresholdMin_V_Q) thresholdMin_V_Q = V_th_E;
697 //if(V_th_E<0) E_thr_V[layer][sheet][1][strip_v] =12.;
698 QDC_slope[layer][sheet][1][strip_v] = QDC_a;
699 QDC_const[layer][sheet][1][strip_v] = QDC_b;
700 Qsaturation[layer][sheet][1][strip_v] = QDC_saturation;
701 }
702 }
703 for (int i = 0; i < tree->GetEntries(); i++) {
704 tree->GetEntry(i);
705 if (strip_x != -1) {
706 if (V_th_T <= 0) T_thr_V[layer][sheet][0][strip_x] = thresholdMin_X_T;
707 if (V_th_E <= 0) E_thr_V[layer][sheet][0][strip_x] = thresholdMin_X_Q;
708 }
709 if (strip_v != -1) {
710 if (V_th_T <= 0) T_thr_V[layer][sheet][1][strip_v] = thresholdMin_V_T;
711 if (V_th_E <= 0) E_thr_V[layer][sheet][1][strip_v] = thresholdMin_V_Q;
712 }
713 }
714
715 //3rd layer
716 for (int i = 0; i < 832; i++) {
717 T_thr_V[2][0][0][i] = 12.;
718 E_thr_V[2][0][0][i] = 12.;
719 QDC_slope[2][0][0][i] = -10.47;
720 QDC_const[2][0][0][i] = 482.3;
721 Qsaturation[2][0][0][i] = 45.;
722 T_thr_V[2][1][0][i] = 10.;
723 E_thr_V[2][1][0][i] = 10.;
724 QDC_slope[2][1][0][i] = -10.47;
725 QDC_const[2][1][0][i] = 482.3;
726 Qsaturation[2][1][0][i] = 45.;
727 }
728
729 for (int i = 0; i < 1395; i++) {
730 T_thr_V[2][0][1][i] = 12.;
731 E_thr_V[2][0][1][i] = 12.;
732 QDC_slope[2][0][1][i] = -10.47;
733 QDC_const[2][0][1][i] = 482.3;
734 Qsaturation[2][0][1][i] = 45.;
735 T_thr_V[2][1][1][i] = 10.;
736 E_thr_V[2][1][1][i] = 10.;
737 QDC_slope[2][1][1][i] = -10.47;
738 QDC_const[2][1][1][i] = 482.3;
739 Qsaturation[2][1][1][i] = 45.;
740 }
741
742 LUTFile->Close();
743 /*
744 TFile *V_Efine_File = new TFile(m_V2EfineFile.c_str());
745 TTree *tree_V2E = (TTree*)V_Efine_File->Get("tree");
746 Double_t V_ref,V2E_slope,V2E_const;
747 Int_t layer_,sheet_,stripv,stripx;
748 tree_V2E->SetBranchAddress("strip_x", &stripx);
749 tree_V2E->SetBranchAddress("strip_v", &stripv);
750 tree_V2E->SetBranchAddress("layer", &layer_);
751 tree_V2E->SetBranchAddress("sheet", &sheet_);
752 tree_V2E->SetBranchAddress("V2E_slope", &V2E_slope);
753 tree_V2E->SetBranchAddress("V2E_const", &V2E_const);
754 tree_V2E->SetBranchAddress("V_ref", &V_ref);
755
756
757 for(int i=0;i<tree_V2E->GetEntries();i++){
758 tree_V2E->GetEntry(i);
759 if(stripx!=-1){
760 Vref[layer_][sheet_][0][stripx] = V_ref;
761 toE_slope[layer_][sheet_][0][stripx] = V2E_slope;
762 toE_const[layer_][sheet_][0][stripx] = V2E_const;
763 }
764 if(stripv!=-1){
765 Vref[layer_][sheet_][1][stripv] = V_ref;
766 toE_slope[layer_][sheet_][1][stripv] = V2E_slope;
767 toE_const[layer_][sheet_][1][stripv] = V2E_const;
768 }
769 }
770
771 V_Efine_File->Close();
772 */
773
774 cout<<"InductionGar: "<<endl;
775 cout<<"QinGausSigma="<<m_QinGausSigma[0]
776 <<", "<<m_QinGausSigma[1]
777 <<endl;
778 //m_deadStrip[3][2]
779 m_deadStrip[0][0][0].insert(40);//x_0_down
780 m_deadStrip[0][0][0].insert(189);
781 m_deadStrip[0][0][0].insert(322);
782 m_deadStrip[0][0][0].insert(350);
783 m_deadStrip[0][0][0].insert(457);//x_0_up
784 m_deadStrip[0][0][1].insert(282);//v_0_down
785 m_deadStrip[0][0][1].insert(467);
786 m_deadStrip[0][0][1].insert(715);
787 m_deadStrip[0][0][1].insert(773);
788 m_deadStrip[0][0][1].insert(795);
789 m_deadStrip[0][0][1].insert(803);
790 m_deadStrip[1][0][1].insert(305);//v_1_down
791 m_deadStrip[1][0][1].insert(307);
792 m_deadStrip[1][0][1].insert(381);
793 m_deadStrip[1][0][1].insert(443);
794 m_deadStrip[1][0][1].insert(486);
795 m_deadStrip[1][0][1].insert(550);
796 m_deadStrip[1][0][1].insert(620);
797 m_deadStrip[1][0][1].insert(631);
798 m_deadStrip[1][0][1].insert(660);
799 m_deadStrip[1][0][1].insert(681);
800 m_deadStrip[1][1][1].insert(425);//v_1_up
801 m_deadStrip[1][1][1].insert(455);
802 m_deadStrip[1][1][1].insert(459);
803 m_deadStrip[1][1][1].insert(461);
804 m_deadStrip[1][1][1].insert(535);
805 m_deadStrip[1][1][1].insert(536);
806 m_deadStrip[1][1][1].insert(614);
807 m_deadStrip[1][1][1].insert(672);
808}
809
810void InductionGar2::setMultiElectrons(int layer, const HitHistMap &hitmap, const PVectorXYZT *debug_ref_electrons) {
811 bool bShowRef=false;
812 if (debug_ref_electrons!=0)bShowRef=true;
813
814 #pragma region
815 m_xstripSheet.clear();
816 m_xstripID.clear();
817 m_vstripSheet.clear();
818 m_vstripID.clear();
819 m_xstripQ.clear();
820 m_vstripQ.clear();
821 m_xstripT_Branch.clear();
822 m_vstripT_Branch.clear();
823 m_xstripQ_Branch.clear();
824 m_vstripQ_Branch.clear();
825 m_xTfirst.clear();
826 m_vTfirst.clear();
827
828 //int m000_nXstrips;
829 //int m000_nVstrips;
830 std::vector<int> m000_xstripSheet;
831 std::vector<int> m000_xstripID;
832 std::vector<int> m000_vstripSheet;
833 std::vector<int> m000_vstripID;
834 std::vector<double> m000_xstripQ;
835 std::vector<double> m000_vstripQ;
836 std::vector<double> m000_xstripT_Branch;
837 std::vector<double> m000_vstripT_Branch;
838 std::vector<double> m000_xstripQ_Branch;
839 std::vector<double> m000_vstripQ_Branch;
840
841 //m000_xstripSheet.clear();
842 //m000_xstripID.clear();
843 //m000_vstripSheet.clear();
844 //m000_vstripID.clear();
845 //m000_xstripQ.clear();
846 //m000_vstripQ.clear();
847 //m000_xstripT_Branch.clear();
848 //m000_vstripT_Branch.clear();
849 //m000_xstripQ_Branch.clear();
850 //m000_vstripQ_Branch.clear();
851
852 CgemGeoLayer *CgemLayer;
853 CgemGeoReadoutPlane *CgemReadoutPlane;
854 CgemLayer = m_geomSvc->getCgemLayer(layer);
855 int NSheet = CgemLayer->getNumberOfSheet();
856
857 Vint Save_Sheetx, Save_Sheetv;
858 Vint Save_FinalstripIDx, Save_FinalstripIDv;
859 Vint Save_Gridx, Save_Gridv;
860 Vint Save_IDx, Save_IDv;
861 Vint Save_Tx, Save_Tv; //CAUTION! precision: 1, or 2bins; bias -0.5
862 //Save_Tx.clear();
863 //Save_Tv.clear();
864 //Save_IDx.clear();
865 //Save_IDv.clear();
866 //Save_Gridx.clear();
867 //Save_Gridv.clear();
868 //Save_Sheetx.clear();
869 //Save_Sheetv.clear();
870 //Save_FinalstripIDx.clear();
871 //Save_FinalstripIDv.clear();
872 for (int i = 0; i < 2; i++) {
873 for (int k = 0; k < 2; k++) {
874 m_mapQ[i][k].clear();
875 //m_mapT[i][k].clear();
876 }
877 }
878 #pragma endregion
879 // this loop works on m_mapQ, Save_{Grid,T,ID}{xv} (represents info {grid, time, strip} of electron . looks all in hitmap), Save_Sheet{XV}( sheet_id*10000 + stripID )
880 //std::cout << "nElectrons = " << nElectrons << std::endl;
881 //std::cout << "size of HitHistMap: "<<hitmap.size() <<" x "<<hitmap.begin()->second.capacity() <<" x "<<sizeof(hitmap.begin()->second[0])<<endl;
882
883 if (bShowRef) { // check if HitHistMap and electron list has same hit number.
884 int Nelec = 0;
885 HitHistMap::const_iterator itm = hitmap.begin();
886 for (; itm != hitmap.end(); itm++) {
887 const Vint &hist = itm->second;
888 for (int num = 0; num < hist.size(); num++) {
889 Nelec += hist[num];
890 }
891 }
892 if (Nelec != debug_ref_electrons->x->size()) {
893 cout << "oops! given different electrons! map gives " << Nelec << " while list gives" << debug_ref_electrons->x->size() << endl;
894 }
895 }
896
897
898 if (bShowRef) {
899 const vector<float> &x = *debug_ref_electrons->x;
900 const vector<float> &y = *debug_ref_electrons->y;
901 const vector<float> &z = *debug_ref_electrons->z;
902 const vector<float> &t = *debug_ref_electrons->t;
903 const int nElectrons = x.size();
904
905 for (int i = 0; i < nElectrons; i++) {
906 //cout<<i<<endl;
907 double phi_electron = atan2(y[i], x[i]);
908 double z_electron = z[i];
909 G4ThreeVector pos(x[i], y[i], z[i]);
910 for (int j = 0; j < NSheet; j++) {
911 CgemReadoutPlane = m_geomSvc->getReadoutPlane(layer, j);
912 if (CgemReadoutPlane->OnThePlane(phi_electron, z_electron)) {
913 int xID;
914 double distX = CgemReadoutPlane->getDist2ClosestXStripCenter(phi_electron, xID);
915 int vID;
916 double distV = CgemReadoutPlane->getDist2ClosestVStripCenter(pos, vID);
917
918 //std::cout << "-------------" << std::endl;
919 //std::cout << "xID, distX = " << xID << "," << distX << std::endl;
920 //std::cout << "vID, distV = " << vID << "," << distV << std::endl;
921
922 int grid_x = 1;
923 int grid_v = 1;
924
925 //
926 //--- Calculation of grid index-------------
927 //
928 double L_XPitch = CgemReadoutPlane->getXPitch();
929 double L_VPitch = CgemReadoutPlane->getVPitch();
930 grid_v = floor(distX / L_XPitch * 5. + 2.5);
931 grid_x = floor(distV / L_VPitch * 5. + 2.5);
932 //std::cout << i << " " << j << " " << grid_x << " " << grid_v << std::endl;
933 //std::cout << "L_XPitch,L_VPitch = " << L_XPitch << "," << L_VPitch << std::endl;
934 //std::cout << "grid_x, grid_v = " << grid_x << "," << grid_v << std::endl;
935
936 if (xID >= 0 && vID >= 0) {
937 map<int, double>::iterator itx = m_mapQ[j][0].find(xID);
938 map<int, double>::iterator itv = m_mapQ[j][1].find(vID);
939 if (RatioX[layer][grid_x][grid_v][2] != 0) {
940 if (itx == m_mapQ[j][0].end()) {
941 m_mapQ[j][0][xID] = RatioX[layer][grid_x][grid_v][2];
942 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 2);
943 Save_IDx.push_back(j * 10000 + xID);
944 Save_Tx.push_back(t[i]);
945 //std::cout << i << " " << j << "x-strip : " << RatioX[layer][grid_x][grid_v][2] << std::endl;
946 } else {
947 double Q = (itx->second) + RatioX[layer][grid_x][grid_v][2];
948 m_mapQ[j][0][xID] = Q;
949 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 2);
950 Save_IDx.push_back(j * 10000 + xID);
951 Save_Tx.push_back(t[i]);
952 //std::cout << i << " " << j << "x-strip : Add " << Q << std::endl;
953 }
954 vector<int>::iterator result_Sheetx = find(Save_Sheetx.begin(), Save_Sheetx.end(), j * 10000 + xID);
955 if (result_Sheetx == Save_Sheetx.end()) {
956 Save_Sheetx.push_back(j * 10000 + xID);
957 }
958 }
959 if (RatioV[layer][grid_x][grid_v][1] != 0) {
960 if (itv == m_mapQ[j][1].end()) {
961 m_mapQ[j][1][vID] = RatioV[layer][grid_x][grid_v][1];
962 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 1);
963 Save_IDv.push_back(j * 10000 + vID);
964 Save_Tv.push_back(t[i]);
965 } else {
966 double Q = (itv->second) + RatioV[layer][grid_x][grid_v][1];
967 m_mapQ[j][1][vID] = Q;
968 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 1);
969 Save_IDv.push_back(j * 10000 + vID);
970 Save_Tv.push_back(t[i]);
971 }
972 vector<int>::iterator result_Sheetv = find(Save_Sheetv.begin(), Save_Sheetv.end(), j * 10000 + vID);
973 if (result_Sheetv == Save_Sheetv.end()) {
974 Save_Sheetv.push_back(j * 10000 + vID);
975 }
976 }
977 }
978
979 if ((xID >= 0 && vID >= 0) && (xID + 1) < CgemReadoutPlane->getNXstrips()) {
980 map<int, double>::iterator itx = m_mapQ[j][0].find(xID + 1);
981 if (RatioX[layer][grid_x][grid_v][3] != 0) {
982 if (itx == m_mapQ[j][0].end()) {
983 m_mapQ[j][0][xID + 1] = RatioX[layer][grid_x][grid_v][3];
984 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 3);
985 Save_IDx.push_back(j * 10000 + xID + 1);
986 Save_Tx.push_back(t[i]);
987 //std::cout << i << " " << j << "x-strip : " << RatioX[layer][grid_x][grid_v][3] << std::endl;
988 } else {
989 double Q = (itx->second) + RatioX[layer][grid_x][grid_v][3];
990 m_mapQ[j][0][xID + 1] = Q;
991 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 3);
992 Save_IDx.push_back(j * 10000 + xID + 1);
993 Save_Tx.push_back(t[i]);
994 }
995
996 vector<int>::iterator result_Sheetx = find(Save_Sheetx.begin(), Save_Sheetx.end(), j * 10000 + xID + 1);
997 if (result_Sheetx == Save_Sheetx.end()) {
998 Save_Sheetx.push_back(j * 10000 + xID + 1);
999 }
1000 }
1001 }
1002
1003 if ((xID >= 0 && vID >= 0) && (vID + 1) < CgemReadoutPlane->getNVstrips()) {
1004 map<int, double>::iterator itv = m_mapQ[j][1].find(vID + 1);
1005 if (RatioV[layer][grid_x][grid_v][2] != 0) {
1006 if (itv == m_mapQ[j][1].end()) {
1007 m_mapQ[j][1][vID + 1] = RatioV[layer][grid_x][grid_v][2];
1008 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 2);
1009 Save_IDv.push_back(j * 10000 + vID + 1);
1010 Save_Tv.push_back(t[i]);
1011 } else {
1012 double Q = (itv->second) + RatioV[layer][grid_x][grid_v][2];
1013 m_mapQ[j][1][vID + 1] = Q;
1014 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 2);
1015 Save_IDv.push_back(j * 10000 + vID + 1);
1016 Save_Tv.push_back(t[i]);
1017 }
1018
1019 vector<int>::iterator result_Sheetv = find(Save_Sheetv.begin(), Save_Sheetv.end(), j * 10000 + vID + 1);
1020 if (result_Sheetv == Save_Sheetv.end()) {
1021 Save_Sheetv.push_back(j * 10000 + vID + 1);
1022 }
1023 }
1024 }
1025
1026 if ((xID >= 0 && vID >= 0) && (xID - 2) >= 0) {
1027 map<int, double>::iterator itx = m_mapQ[j][0].find(xID - 2);
1028 if (RatioX[layer][grid_x][grid_v][0] != 0) {
1029 if (itx == m_mapQ[j][0].end()) {
1030 m_mapQ[j][0][xID - 2] = RatioX[layer][grid_x][grid_v][0];
1031 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 0);
1032 Save_IDx.push_back(j * 10000 + xID - 2);
1033 Save_Tx.push_back(t[i]);
1034 //std::cout << i << " " << j << "x-strip : " << RatioX[layer][grid_x][grid_v][0] << std::endl;
1035 } else {
1036 double Q = (itx->second) + RatioX[layer][grid_x][grid_v][0];
1037 m_mapQ[j][0][xID - 2] = Q;
1038 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 0);
1039 Save_IDx.push_back(j * 10000 + xID - 2);
1040 Save_Tx.push_back(t[i]);
1041 }
1042
1043 vector<int>::iterator result_Sheetx = find(Save_Sheetx.begin(), Save_Sheetx.end(), j * 10000 + xID - 2);
1044 if (result_Sheetx == Save_Sheetx.end()) {
1045 Save_Sheetx.push_back(j * 10000 + xID - 2);
1046 }
1047 }
1048 }
1049
1050 if ((xID >= 0 && vID >= 0) && (xID - 1) >= 0) {
1051 map<int, double>::iterator itx = m_mapQ[j][0].find(xID - 1);
1052 if (RatioX[layer][grid_x][grid_v][1] != 0) {
1053 if (itx == m_mapQ[j][0].end()) {
1054 m_mapQ[j][0][xID - 1] = RatioX[layer][grid_x][grid_v][1];
1055 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 1);
1056 Save_IDx.push_back(j * 10000 + xID - 1);
1057 Save_Tx.push_back(t[i]);
1058 } else {
1059 double Q = (itx->second) + RatioX[layer][grid_x][grid_v][1];
1060 m_mapQ[j][0][xID - 1] = Q;
1061 Save_Gridx.push_back(grid_x * 100 + grid_v * 10 + 1);
1062 Save_IDx.push_back(j * 10000 + xID - 1);
1063 Save_Tx.push_back(t[i]);
1064 }
1065
1066 vector<int>::iterator result_Sheetx = find(Save_Sheetx.begin(), Save_Sheetx.end(), j * 10000 + xID - 1);
1067 if (result_Sheetx == Save_Sheetx.end()) {
1068 Save_Sheetx.push_back(j * 10000 + xID - 1);
1069 }
1070 }
1071 }
1072
1073 if ((xID >= 0 && vID >= 0) && (vID - 1) >= 0) {
1074 map<int, double>::iterator itv = m_mapQ[j][1].find(vID - 1);
1075 if (RatioV[layer][grid_x][grid_v][0] != 0) {
1076 if (itv == m_mapQ[j][1].end()) {
1077 m_mapQ[j][1][vID - 1] = RatioV[layer][grid_x][grid_v][0];
1078 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 0);
1079 Save_IDv.push_back(j * 10000 + vID - 1);
1080 Save_Tv.push_back(t[i]);
1081 } else {
1082 double Q = (itv->second) + RatioV[layer][grid_x][grid_v][0];
1083 m_mapQ[j][1][vID - 1] = Q;
1084 Save_Gridv.push_back(grid_x * 100 + grid_v * 10 + 0);
1085 Save_IDv.push_back(j * 10000 + vID - 1);
1086 Save_Tv.push_back(t[i]);
1087 }
1088
1089 vector<int>::iterator result_Sheetv = find(Save_Sheetv.begin(), Save_Sheetv.end(), j * 10000 + vID - 1);
1090 if (result_Sheetv == Save_Sheetv.end()) {
1091 Save_Sheetv.push_back(j * 10000 + vID - 1);
1092 }
1093 }
1094 }
1095 }
1096 }
1097 }
1098 }
1099
1100
1101
1102 //std::cout << "loop electron finished " << std::endl;
1103
1104 // the above loop comes to
1105 std::map<IndexGar,std::vector<double> > hitFFTMap; // size is 2* HalfPlus1 aka 2* (m_length/2+1)
1106
1107 if (bShowRef) {
1108 std::map<int, double> mapQ[2][2];
1109
1110 calcMapQFromHitHistMap(hitmap, layer, mapQ);
1111 Vint Save_Sheetx2, Save_Sheetv2;
1112 calcSaveSheetXVFromMapQ(Save_Sheetx2, Save_Sheetv2, mapQ);
1113
1114 compareMap(m_mapQ, mapQ);
1115
1116 // TODO: check Save_Sheet* and Save_Sheet*2
1117 compareVector(Save_Sheetx, Save_Sheetx2, "Save_Sheetx", 1e-5);
1118 compareVector(Save_Sheetv, Save_Sheetv2, "Save_Sheetv", 1e-5);
1119 } else {
1120
1121 calcMapQFromHitHistMap(hitmap, layer, m_mapQ);
1122 calcSaveSheetXVFromMapQ(Save_Sheetx, Save_Sheetv, m_mapQ);
1123
1124 calcHitHistFftMap(hitFFTMap, hitmap);
1125 }
1126
1127 //-----Q Threshold = 45ADC = 1.5fC = 1.5*1e-15 C --------
1128 //-----Q Satruation = 45fC
1129 //-----Q Resolution = 0.256fC
1130 //-----T jitter = 2ns
1131
1132 double Q_threshold = 1.5e-15 / 1.602176565e-19;
1133 double Q_saturation = 45.e-15 / 1.602176565e-19;
1134 double Q_resolution = 0.256e-15 / 1.602176565e-19;
1135 double T_threshold = 12; // 12 mV
1136 //double T_threshold = 24; // 24 mV
1137 //double T_threshold = 18; // 18 mV
1138
1139 // cout << "---------------------" << endl;
1140
1141 //m000_nXstrips = m_mapQ[0][0].size() + m_mapQ[1][0].size();
1142 //m000_nVstrips = m_mapQ[0][1].size() + m_mapQ[1][1].size();
1143
1144 //cout << m000_nXstrips << " " << Nx_below_threshold << " " << m000_nVstrips << " " << Nv_below_threshold << endl;
1145
1146 for (int i = 0; i < Save_Sheetx.size(); i++) {
1147 int sheetx_id = Save_Sheetx[i] / 10000;
1148 int stripx_id = Save_Sheetx[i] % 10000;
1149 //if(m_mapQ[sheetx_id][0][stripx_id]>=Q_threshold){
1150 Save_FinalstripIDx.push_back(Save_Sheetx[i]);
1151 //std::cout << "zhaojy check InductionGar2 sheet -> " << m000_xstripSheet.size() << " " << sheetx_id << " " << stripx_id << std::endl;
1152 m000_xstripSheet.push_back(sheetx_id);
1153 m000_xstripID.push_back(stripx_id);
1154 m000_xstripQ.push_back(m_mapQ[sheetx_id][0][stripx_id]);
1155 //}
1156 }
1157
1158 for (int i = 0; i < Save_Sheetv.size(); i++) {
1159 int sheetv_id = Save_Sheetv[i] / 10000;
1160 int stripv_id = Save_Sheetv[i] % 10000;
1161 //if(m_mapQ[sheetv_id][1][stripv_id]>=Q_threshold){
1162 Save_FinalstripIDv.push_back(Save_Sheetv[i]);
1163 m000_vstripSheet.push_back(sheetv_id);
1164 m000_vstripID.push_back(stripv_id);
1165 m000_vstripQ.push_back(m_mapQ[sheetv_id][1][stripv_id]);
1166 //}
1167 }
1168
1169 double Tmin, Tmin2;
1170 std::vector<double> xTfirst; //time when first electron leave 3rd gem
1171 std::vector<double> vTfirst;
1172 //T_Branch & E_Branch
1173 for (int h = 0; h < Save_FinalstripIDx.size(); h++) {
1174
1175 std::map<int, std::vector<int> > electron_hit_tmp;
1176 const int _low = 0;
1177 const int _up = 1000;
1178 const int _nbins = 2000;
1179 double binsize = (double)(_up - _low) / _nbins;
1180 int sheetx_id = Save_FinalstripIDx[h] / 10000;
1181 int stripx_id = Save_FinalstripIDx[h] % 10000;
1182 double histX_bin_Content[_nbins] = {0};
1183 double histX_bin_Content2[_nbins] = {0};
1184 Tmin = Tmin2 = 999999;
1185 if (isDeadStrip(layer,sheetx_id,0,stripx_id)) {
1186 xTfirst.push_back(Tmin);
1187 double T_th = -99.;
1188 m000_xstripT_Branch.push_back(T_th);
1189 double Qin = -99.;
1190 m000_xstripQ_Branch.push_back(Qin);
1191 continue;
1192 };
1193 // we might want to change this into a easier version
1194 // input: Electrons, etc.........
1195 // out: the current of this strip
1196 if (bShowRef) {
1197 int original_affected_elec = 0;
1198
1199 for (int i = 0; i < Save_Gridx.size(); i++) {
1200 //int z_grid_x = Save_Gridx[i]/100;
1201 //int z_grid_v = Save_Gridx[i]%100/10;
1202 //int z_index = Save_Gridx[i]%10;
1203 int z_IDx = Save_IDx[i];
1204 int start_bin = Save_Tx[i] / binsize;
1205 // std::cout << "start_bin x" << start_bin << std::endl;
1206
1207 if (z_IDx == Save_FinalstripIDx[h]) {
1208 if (Save_Tx[i] < Tmin) Tmin = Save_Tx[i];
1209 if (start_bin < _nbins and start_bin >= 0) {
1210 electron_hit_tmp[Save_Gridx[i]].push_back(start_bin); //prepare the hit list. should have boundary check
1211 //discards evt >= _nbins or evt < 0.
1212 original_affected_elec++;
1213 }
1214 //for(int addi = start_bin; addi < start_bin+160; addi+=2){
1215 // histX_bin_Content[addi]+=SignalX[layer][z_grid_x][z_grid_v][z_index][(addi-start_bin)/2+1];
1216 // histX_bin_Content[addi+1]+=SignalX[layer][z_grid_x][z_grid_v][z_index][(addi-start_bin)/2+1];
1217 //}
1218 }
1219 }
1220
1221 for (std::map<int, std::vector<int> >::iterator it = electron_hit_tmp.begin();
1222 it != electron_hit_tmp.end(); it++) {
1223 std::vector<int> &hitlist = it->second;
1224 const int &Save_Grid = it->first;
1225 // legacy
1226 if (hitlist.size() < electrons_select_method_threhold) {
1227 conv1PerGrid_legacy(Save_Grid, histX_bin_Content, hitlist, layer, 0);
1228 } else {
1229 conv1PerGrid_fft(Save_Grid, histX_bin_Content, hitlist, layer, 0);
1230 }
1231 }
1232
1233 cout << "original_affected_elec " << original_affected_elec << " ";
1234 calcStripCurrent(histX_bin_Content2, Tmin2,hitFFTMap, hitmap, layer, sheetx_id, stripx_id, 0);
1235
1236 if (Tmin != Tmin2) {
1237 cout << "at stripX " << stripx_id << "Tmin: " << Tmin << " Tmin2: " << Tmin2 << "\n";
1238 }
1239 { // compare results
1240
1241 //histX_bin_Content2 and histX_bin_Content
1242 compareArray(histX_bin_Content, histX_bin_Content2, _nbins, "hist_bin_content", 1e-5);
1243 string emptyStr = "";
1244 DrawToFile(histX_bin_Content, (emptyStr + "st" + (long)stripx_id + "old").Data());
1245 DrawToFile(histX_bin_Content2, (emptyStr + "st" + (long)stripx_id + "new").Data());
1246 }
1247
1248 // electronic parts
1249
1250 } else {
1251 //calcStripCurrent(histX_bin_Content, Tmin, hitmap, layer, sheetx_id, stripx_id, 0);
1252 calcStripCurrent(histX_bin_Content2, Tmin,hitFFTMap, hitmap, layer, sheetx_id, stripx_id, 0);
1253 //compareArray(histX_bin_Content,histX_bin_Content2, _nbins,"hitHistFftMethod", 1e-5);
1254 }
1255
1256 xTfirst.push_back(Tmin);
1257
1258 #pragma region
1259 //TH1F h_signalT = Convolution_Tbranch(histX_bin_Content);
1260 TH1D h_signalT = ctf.Convolution_Tbranch_fft(histX_bin_Content);
1261
1262 int flg_xT = 0;
1263 double T_th = 0.;
1264 T_threshold = T_thr_V[layer][sheetx_id][0][stripx_id];
1265 //if(T_threshold<=0) T_threshold=thresholdMin_X_T;
1266 //T_threshold = 46.7;
1267 for (int init = 1; init < _nbins; init++) {
1268 if (flg_xT == 0 && fabs(h_signalT.GetBinContent(init + 1)) >= fabs(T_threshold)) {
1269 T_th = _low + binsize * (init - 1) + fabs(T_threshold - h_signalT.GetBinContent(init)) * binsize / fabs(h_signalT.GetBinContent(init + 1) - h_signalT.GetBinContent(init)) + gRandom->Gaus(0, 2);
1270 m000_xstripT_Branch.push_back(T_th); // jitter 2ns
1271 flg_xT = 1;
1272 }
1273 }
1274 if (flg_xT == 0) {
1275 T_th = -99.;
1276 m000_xstripT_Branch.push_back(T_th);
1277 }
1278 double V_sampling = 0.;
1279 double Qin = 0.;
1280 double Efine = 0.;
1281
1282 if (T_th > 0) {
1283 //TH1D h_signalE = Convolution_Ebranch(histX_bin_Content);//debug; do not need to do if V_T(max) < T_threshold(mV)
1284 TH1D h_signalE = cef.Convolution_Ebranch_fft(histX_bin_Content); //debug; do not need to do if V_T(max) < T_threshold(mV)
1285 double T_sample = T_th + sample_delay; //ns
1286 int sample_bin = T_sample / binsize;
1287 double sample_bin_ = T_sample / binsize;
1288 V_sampling = h_signalE.GetBinContent(sample_bin) + (h_signalE.GetBinContent(sample_bin + 1) - h_signalE.GetBinContent(sample_bin)) * double(sample_bin_ - sample_bin);
1289 int over_th = 0;
1290
1291
1292 if (h_signalE.GetMaximum() > E_thr_V[layer][sheetx_id][0][stripx_id]) over_th = 1;
1293
1294 if (over_th == 1) {
1295 Qin = V_sampling*VQ_slope + VQ_const+gRandom->Gaus(0,m_QinGausSigma[0]);
1296 if (m_saturation && Qin > Qsaturation[layer][sheetx_id][0][stripx_id])
1297 Qin = Qsaturation[layer][sheetx_id][0][stripx_id];
1298 } else
1299 Qin = -99;
1300 } else {
1301 V_sampling = -99.;
1302 Qin = -99.;
1303 //m000_xstripQ_Branch.push_back(Qin);
1304 }
1305
1306 m000_xstripQ_Branch.push_back(Qin);
1307 #pragma endregion
1308
1309 }
1310
1311 for (int h = 0; h < Save_FinalstripIDv.size(); h++) {
1312 std::map<int, std::vector<int> > electron_hit_tmp;
1313 const int _low = 0;
1314 const int _up = 1000;
1315 const int _nbins = 2000;
1316 double binsize = (double)(_up - _low) / _nbins;
1317 int sheetv_id = Save_FinalstripIDv[h] / 10000;
1318 int stripv_id = Save_FinalstripIDv[h] % 10000;
1319 double histV_bin_Content[_nbins] = {0};
1320 Tmin = 999999;
1321
1322 if (isDeadStrip(layer,sheetv_id,1,stripv_id)) {
1323 vTfirst.push_back(Tmin);
1324 double T_th = -99.;
1325 m000_vstripT_Branch.push_back(T_th);
1326 double Qin = -99.;
1327 m000_vstripQ_Branch.push_back(Qin);
1328 continue;
1329 };
1330
1331 calcStripCurrent(histV_bin_Content, Tmin, hitFFTMap,hitmap, layer, sheetv_id, stripv_id, 1);
1332
1333 vTfirst.push_back(Tmin);
1334
1335 TH1D h_signalT = ctf.Convolution_Tbranch_fft(histV_bin_Content);
1336
1337 int flg_vT = 0;
1338 double T_th = 0.;
1339 T_threshold = T_thr_V[layer][sheetv_id][1][stripv_id];
1340 //if(T_threshold<=0) T_threshold=thresholdMin_V_T;
1341 //T_threshold = 46.7;
1342 for (int init = 1; init < _nbins; init++) {
1343 if (flg_vT == 0 && fabs(h_signalT.GetBinContent(init + 1)) >= fabs(T_threshold)) {
1344 T_th = _low + binsize * (init - 1) + fabs(T_threshold - h_signalT.GetBinContent(init)) * binsize / fabs(h_signalT.GetBinContent(init + 1) - h_signalT.GetBinContent(init)) + gRandom->Gaus(0, 2);
1345 m000_vstripT_Branch.push_back(T_th); // jitter 2ns
1346 flg_vT = 1;
1347 }
1348 }
1349 if (flg_vT == 0) {
1350 T_th = -99.;
1351 m000_vstripT_Branch.push_back(T_th);
1352 }
1353 double V_sampling = 0.;
1354 double Qin = 0.;
1355 double Efine = 0.;
1356 if (T_th > 0) {
1357 //TH1F h_signalE = Convolution_Ebranch(histV_bin_Content);
1358 TH1D h_signalE = cef.Convolution_Ebranch_fft(histV_bin_Content);
1359 double T_sample = T_th + sample_delay; //ns
1360 int sample_bin = T_sample / binsize;
1361 double sample_bin_ = T_sample / binsize;
1362 V_sampling = h_signalE.GetBinContent(sample_bin) + (h_signalE.GetBinContent(sample_bin + 1) - h_signalE.GetBinContent(sample_bin)) * double(sample_bin_ - sample_bin);
1363 int over_th = 0;
1364
1365 if (h_signalE.GetMaximum() > E_thr_V[layer][sheetv_id][1][stripv_id]) over_th = 1;
1366
1367 if (over_th == 1) {
1368 Qin = V_sampling*VQ_slope + VQ_const+gRandom->Gaus(0,m_QinGausSigma[1]);
1369 if (m_saturation && Qin > Qsaturation[layer][sheetv_id][1][stripv_id])
1370 Qin = Qsaturation[layer][sheetv_id][1][stripv_id];
1371 } else
1372 Qin = -99;
1373 } else {
1374 V_sampling = -99.;
1375 Qin = -99.;
1376 //m000_vstripQ_Branch.push_back(Qin);
1377 }
1378
1379 m000_vstripQ_Branch.push_back(Qin);
1380 // cout<<"V layer:"<<layer<<" sheet:"<<sheetv_id<<" strip:"<<stripv_id<<" T_Branch:"<<T_th<<" V_sample:"<<V_sampling<<endl;
1381 /*
1382 int layer_tem = layer;
1383 char temp0[1]; sprintf(temp0, "%i", layer_tem);
1384 char temp1[1]; sprintf(temp1, "%i", sheetv_id);
1385 char temp2[3]; sprintf(temp2, "%i", stripv_id);
1386 string FILEname = FilePath + "/share/output/V-" + temp0 + '-' + temp1 + '-' + temp2 + ".root";
1387 TFile* f_x1 = new TFile(FILEname.c_str(), "recreate"); f_x1->cd(); sig_current.Write(); h_signalT.Write(); f_x1->Close(); delete f_x1;
1388 */
1389 }
1390
1391 //-------------------------------------------------------------------------------
1392 //cout<<"push back"<<endl;
1393 double q_to_fC_factor = 1.602176565e-4;
1394 //std::cout << "loop V_Q finished " << std::endl;
1395
1396 //cout<<"X"<<endl;
1397 if (storeFlag) {
1398 m_nXstrips = 0;
1399 for (int i = 0; i < m000_xstripSheet.size(); i++) {
1400 m_xstripSheet.push_back(m000_xstripSheet[i]);
1401 m_xstripID.push_back(m000_xstripID[i]);
1402 m_xstripQ.push_back(m000_xstripQ[i] * q_to_fC_factor);
1403 m_xstripT_Branch.push_back(m000_xstripT_Branch[i]);
1404 m_xstripQ_Branch.push_back(m000_xstripQ_Branch[i]);
1405 m_xTfirst.push_back(xTfirst[i]);
1406 m_nXstrips++;
1407 }
1408 m_nVstrips = 0;
1409 //cout<<"V"<<endl;
1410 for (int i = 0; i < m000_vstripSheet.size(); i++) {
1411 m_vstripSheet.push_back(m000_vstripSheet[i]);
1412 m_vstripID.push_back(m000_vstripID[i]);
1413 m_vstripQ.push_back(m000_vstripQ[i] * q_to_fC_factor);
1414 m_vstripT_Branch.push_back(m000_vstripT_Branch[i]);
1415 m_vstripQ_Branch.push_back(m000_vstripQ_Branch[i]);
1416 m_vTfirst.push_back(vTfirst[i]);
1417 m_nVstrips++;
1418 }
1419 } else {
1420 m_nXstrips = 0;
1421 for (int i = 0; i < m000_xstripSheet.size(); i++) {
1422 if (m000_xstripQ_Branch[i] >= 0) {
1423 m_xstripSheet.push_back(m000_xstripSheet[i]);
1424 m_xstripID.push_back(m000_xstripID[i]);
1425 m_xstripQ.push_back(m000_xstripQ[i] * q_to_fC_factor);
1426 m_xstripT_Branch.push_back(m000_xstripT_Branch[i]);
1427 m_xstripQ_Branch.push_back(m000_xstripQ_Branch[i]);
1428 m_xTfirst.push_back(xTfirst[i]);
1429 m_nXstrips++;
1430 // cout<<m000_xstripQ[i]*q_to_fC_factor<<" "<<m000_xstripQ_Branch[i]<<endl;
1431 }
1432 }
1433 m_nVstrips = 0;
1434 //cout<<"V"<<endl;
1435 for (int i = 0; i < m000_vstripSheet.size(); i++) {
1436 if (m000_vstripQ_Branch[i] >= 0) {
1437 m_vstripSheet.push_back(m000_vstripSheet[i]);
1438 m_vstripID.push_back(m000_vstripID[i]);
1439 m_vstripQ.push_back(m000_vstripQ[i] * q_to_fC_factor);
1440 m_vstripT_Branch.push_back(m000_vstripT_Branch[i]);
1441 m_vstripQ_Branch.push_back(m000_vstripQ_Branch[i]);
1442 m_vTfirst.push_back(vTfirst[i]);
1443 m_nVstrips++;
1444 // cout<<m000_vstripQ[i]*q_to_fC_factor<<" "<<m000_vstripQ_Branch[i]<<endl;
1445 }
1446 }
1447 }
1448 //checkMemorySize();
1449
1450 //cout<<"InductionGar2::setMultiElectrons() ends"<<endl;
1451}
1452
1453/**
1454 * @brief calcs m_mapQ, Q integrated from
1455 *
1456 * @param histmap
1457 * @param layer
1458 */
1459void InductionGar2::calcMapQFromHitHistMap(const HitHistMap &histmap, int layer, std::map<int, double> mapQ[2][2]) const {
1460 for (HitHistMap::const_iterator it = histmap.begin(); it != histmap.end(); ++it) {
1461 const IndexGar &index = it->first;
1462 const Vint &hist = it->second;
1463 int xID = index.stripX;
1464 int vID = index.stripV;
1465 int grid_x = index.gridX;
1466 int grid_v = index.gridV;
1467 int sheet = index.sheet;
1468 if (xID < 0 || vID < 0) continue;
1469 CgemGeoReadoutPlane *CgemReadoutPlane = m_geomSvc->getReadoutPlane(layer, sheet);
1470 int nXID = CgemReadoutPlane->getNXstrips();
1471 int nVID = CgemReadoutPlane->getNVstrips();
1472 int nElectrons = 0;
1473 for (int i = 0; i < _nbins + 1; i++) { // last bin mean overflow.
1474 nElectrons += hist[i];
1475 }
1476 for (int indexOID = 0; indexOID < 4; indexOID++) { // X
1477 int dID = indexOID - 2; //i.e. indexOID==2 show it is on this strip
1478 if (0 <= xID + dID && xID + dID < nXID) {
1479 mapQ[sheet][0][xID + dID] += RatioX[layer][grid_x][grid_v][indexOID] * nElectrons;
1480 }
1481 }
1482 for (int indexOID = 0; indexOID < 3; indexOID++) { // V
1483 int dID = indexOID - 1; //i.e. indexOID==1 show it is on this strip
1484 if (0 <= vID + dID && vID + dID < nVID) {
1485 mapQ[sheet][1][vID + dID] += RatioV[layer][grid_x][grid_v][indexOID] * nElectrons;
1486 }
1487 }
1488 } // may contain Q==0.
1489 // as far as i know, numbering scheme for XV strip is like {{1,...,n_max_sheet1},{n_max_sheet1+1,...n_max_sheet2}} (CITE:https://docbes3.ihep.ac.cn/~offlinesoftware/images/d/da/CGEM-IT_geometry_from_the_final_design.pdf)
1490 //is but here, and in Induction and GeomSvc, the ID of strips appears to begin from 0 in its both sheet. OK.
1491}
1492void InductionGar2::calcSaveSheetXVFromMapQ(Vint &Save_Sheetx, Vint &Save_Sheetv, std::map<int, double> const mapQ[2][2]) const {
1493 //std::map<int, double> m_mapQ[2][2]; //[nSheet][XV-view] {index of ID, Q}
1494 for (int sheet = 0; sheet < 2; sheet++) {
1495 for (int xvView = 0; xvView < 2; xvView++) {
1496 Vint &save_sheet = xvView ? Save_Sheetv : Save_Sheetx; //0 as x and 1 as v
1497 for (std::map<int, double>::const_iterator it = mapQ[sheet][xvView].begin();
1498 it != mapQ[sheet][xvView].end(); it++) {
1499 if (it->second != 0) {
1500 save_sheet.push_back(sheet * 10000 + it->first);
1501 }
1502 }
1503 }
1504 }
1505}
1506/**
1507 * @brief calcs
1508 *
1509 * @param strip_current the current of strip. this func will not initialize the current.
1510 * @param histmap
1511 * @param layer
1512 * @param req_sheetid
1513 * @param req_stripid
1514 * @param xvaxis
1515 */
1516void InductionGar2::calcStripCurrent(double *strip_current, double &timeFirstHit, const HitHistMap &histmap, int layer, int req_sheetid, int req_stripid, int xvaxis) const {
1517
1518 const int _low = 0;
1519 const int _up = 1000;
1520 const int _nbins = 2000;
1521 double binsize = (double)(_up - _low) / _nbins;
1522 ConvolveWithConst(&Signal_Convolver)[3][5][5][4] = const_cast<ConvolveWithConst(&)[3][5][5][4]>(xvaxis ? Signal_ConvolverV : Signal_ConvolverX);
1523 // x[ ][ ][m][ ]
1524 // v[ ][m][ ][0]
1525 int indexTimeFirstHit = 9999;
1526 int affectedElectron = 0;
1527 for (HitHistMap::const_iterator it = histmap.begin(); it != histmap.end(); ++it) {
1528 const IndexGar &index = it->first;
1529 const Vint &hist = it->second;
1530
1531 int xID = index.stripX;
1532 int vID = index.stripV;
1533 int strip = xvaxis ? vID : xID;
1534 int grid_x = index.gridX;
1535 int grid_v = index.gridV;
1536 int sheet = index.sheet;
1537 int indexOID;
1538 if (xID < 0 || vID < 0) continue;
1539 //if (req_sheetid!=sheet || req_stripid != strip) continue;
1540 if (req_sheetid != sheet) continue;
1541 if (xvaxis == 0) { //x
1542 //indexOID=strip-req_stripid+2;//
1543 indexOID = req_stripid - strip + 2; //
1544 if (indexOID < 0 || indexOID >= 4) continue;
1545 if (RatioX[layer][grid_x][grid_v][indexOID] == 0) continue;
1546
1547 } else { //v
1548 //indexOID=strip-req_stripid+1;
1549 indexOID = req_stripid - strip + 2;
1550 if (indexOID < 0 || indexOID >= 3) continue;
1551 if (RatioV[layer][grid_x][grid_v][indexOID] == 0) continue;
1552 }
1553 // now we get valid coordinates that interfere with the strip.
1554
1555 double electron_hit_tmp_hist[_nbins] = {0};
1556 for (int i = 0; i < _nbins; i++) electron_hit_tmp_hist[i] = hist[i];
1557
1558 double strip_current_tmp[_nbins] = {0};
1559 Signal_Convolver[layer][grid_x][grid_v][indexOID].convolve(strip_current_tmp, electron_hit_tmp_hist, 0, _nbins);
1560 for (int i = 0; i < _nbins; i++) {
1561 strip_current[i] += strip_current_tmp[i];
1562 }
1563
1564 // for Tmin stuff.
1565 int indexTimeFirstHitLocal = 9999;
1566 for (int i = 0; i < _nbins; i++) {
1567 if (hist[i] != 0) {
1568 indexTimeFirstHitLocal = i;
1569 break;
1570 }
1571 }
1572 if (indexTimeFirstHitLocal < indexTimeFirstHit) indexTimeFirstHit = indexTimeFirstHitLocal;
1573
1574 // affected Electrons
1575 for (int i = 0; i < _nbins; i++) {
1576 affectedElectron += hist[i];
1577 }
1578 }
1579 timeFirstHit = binsize * (indexTimeFirstHit); // const error: binsize
1580 //cout<<"laterFffectedElectron "<< affectedElectron<<endl;
1581}
1582void InductionGar2::calcStripCurrent(double *strip_current, double &timeFirstHit, const std::map<IndexGar,std::vector<double> > &histFFTmap,const HitHistMap &histmap, int layer, int req_sheetid, int req_stripid, int xvaxis) const {
1583
1584 const int _low = 0;
1585 const int _up = 1000;
1586 const int _nbins = 2000;
1587 double binsize = (double)(_up - _low) / _nbins;
1588 const ConvolveWithConst(&Signal_Convolver)[3][5][5][4] = xvaxis ? Signal_ConvolverV : Signal_ConvolverX;
1589 // x[ ][ ][m][ ]
1590 // v[ ][m][ ][0]
1591 int indexTimeFirstHit = 9999;
1592 int affectedElectron = 0;
1593
1594 const int length_Inner=Signal_ConvolverX[0][0][0][0].getLength();
1595 const int HalfPlus1=(length_Inner/2+1);
1596 vector<double> stripCurrentFFT ;
1597 stripCurrentFFT.resize(HalfPlus1*2);
1598 double* pStripCurrentFFT=&stripCurrentFFT.front();
1599 for (HitHistMap::const_iterator it = histmap.begin(); it != histmap.end(); ++it) {
1600 const IndexGar &index = it->first;
1601 const Vint &hist = it->second;
1602
1603 const std::vector<double> &histFft =histFFTmap.at(index);
1604 const double * pHistFft=&histFft.front();
1605
1606 int xID = index.stripX;
1607 int vID = index.stripV;
1608 int strip = xvaxis ? vID : xID;
1609 int grid_x = index.gridX;
1610 int grid_v = index.gridV;
1611 int sheet = index.sheet;
1612 int indexOID;
1613 if (xID < 0 || vID < 0) continue;
1614 //if (req_sheetid!=sheet || req_stripid != strip) continue;
1615 if (req_sheetid != sheet) continue;
1616 if (xvaxis == 0) { //x
1617 //indexOID=strip-req_stripid+2;//
1618 indexOID = req_stripid - strip + 2; //
1619 if (indexOID < 0 || indexOID >= 4) continue;
1620 if (RatioX[layer][grid_x][grid_v][indexOID] == 0) continue;
1621
1622 } else { //v
1623 //indexOID=strip-req_stripid+1;
1624 indexOID = req_stripid - strip + 2;
1625 if (indexOID < 0 || indexOID >= 3) continue;
1626 if (RatioV[layer][grid_x][grid_v][indexOID] == 0) continue;
1627 }
1628 // now we get valid coordinates that interfere with the strip.
1629
1630
1631 ////double electron_hit_tmp_hist[_nbins] = {0};
1632 ////for (int i = 0; i < _nbins; i++) electron_hit_tmp_hist[i] = hist[i];
1633//
1634 Signal_Convolver[layer][grid_x][grid_v][indexOID].MultiplyAndAdd((ConvolveWithConst::Complex*)pStripCurrentFFT,(ConvolveWithConst::Complex*)pHistFft);
1635 //if (compareArray(pStripCurrentFFT,zeros,_nbins/2,"",1e-10,true))cout<<"CgemDigi...::Induc...r2::calcCurrent: ffound all bin empty!!!! "<<endl;
1636 //double strip_current_tmp[_nbins] = {0};
1637 //Signal_Convolver[layer][grid_x][grid_v][indexOID].convolve(strip_current_tmp, electron_hit_tmp_hist, 0, _nbins);
1638 //for (int i = 0; i < _nbins; i++) {
1639 // strip_current[i] += strip_current_tmp[i];
1640 //}
1641
1642
1643 // for Tmin stuff.
1644 int indexTimeFirstHitLocal = 9999;
1645 for (int i = 0; i < _nbins; i++) {
1646 if (hist[i] != 0) {
1647 indexTimeFirstHitLocal = i;
1648 break;
1649 }
1650 }
1651 if (indexTimeFirstHitLocal < indexTimeFirstHit) indexTimeFirstHit = indexTimeFirstHitLocal;
1652
1653 // affected Electrons
1654 for (int i = 0; i < _nbins; i++) {
1655 affectedElectron += hist[i];
1656 }
1657 }
1658 //if (compareArray(pStripCurrentFFT,zeros,_nbins/2,"",1e-10,true))cout<<"CgemDigi...::Induc...r2::calcCurrent aftersum: found all bin empty!! "<<endl;
1659 Signal_ConvolverX[0][0][0][0].IFFT(strip_current,(ConvolveWithConst::Complex*)pStripCurrentFFT,_nbins,HalfPlus1*2);
1660 //if (compareArray(strip_current,zeros,_nbins/2,"",1e-10,true))cout<<"CgemDigi...::Induc...r2::calcCurrent strip_current: found all bin empty!! "<<endl;
1661 timeFirstHit = binsize * (indexTimeFirstHit); // const error: binsize
1662 //cout<<"laterFffectedElectron "<< affectedElectron<<endl;
1663}
1664
1665void InductionGar2::calcHitHistFftMap(std::map<IndexGar,std::vector<double> > &histFFTMap,const HitHistMap &histmap)const{
1666
1667 //TVirtualFFT* fft=Signal_ConvolverX[0][0][0][0].getFFT();
1668 const int length_Inner=Signal_ConvolverX[0][0][0][0].getLength();
1669 vector<double> vIn;
1670 vIn.resize(_nbins);
1671 double* pIn=&vIn.front();
1672 //vector<double> vOut;
1673 //vOut.resize(length_Inner+2);
1674 //ConvolveWithConst::Complex* pcOut=(ConvolveWithConst::Complex*) &vOut.front();
1675 for (HitHistMap::const_iterator it = histmap.begin(); it != histmap.end(); ++it){
1676 IndexGar index=it->first;
1677 const Vint &hist=it->second;
1678 histFFTMap[index] .resize((length_Inner/2+1)*2);
1679 double * pOut=&histFFTMap[index].front();
1680 //int * pIn=&histmap[index].front();
1681 for(int i=0; i<_nbins; i++){
1682 vIn[i]=hist[i];
1683 }
1684 Signal_ConvolverX[0][0][0][0].FFT((ConvolveWithConst::Complex*)pOut,pIn,(length_Inner/2+1)*2,_nbins);
1685 //if (compareArray(pOut,zeros,_nbins/2,"",1e-10,true))cout<<"CgemDigi...::Induc...r2::calcHitHistFFT : found all bins empty at strip= "<<index.stripX<<": "<<index.stripV <<endl;
1686 //vIn.clear();
1687 //for (int i=0; i<_nbins; ++i){
1688 // vIn[i]=it->second[i];
1689 //}
1690 //fft->SetPoints(pIn);
1691 //fft->Transform();
1692 //fft->GetPoints(pOut);
1693 }
1694}
1695//i may want to warp this into a function
1696/**
1697 * @brief legacy method of doing conv1 at a single grid for a strip. additive on hist_bin_Content
1698 * discards t > _nbins or t <0 events
1699 * @param Save_Grid [grid_x]*100+[grid_v]*10+[z_index]*1
1700 * @param hist_bin_content to be summed on
1701 * @param hitlist list of hits;
1702 * @param layer layer.
1703 * @param axis 0:X, 1:V
1704 */
1705void InductionGar2::conv1PerGrid_legacy(int Save_Grid, double *hist_bin_Content,
1706 const std::vector<int> &hitlist, int layer, int axis) const {
1707 //double ***** Signal=0;
1708 // this should not work, since you get no dimention info
1709 // and this following one might work.
1710
1711 double const(&Signal)[3][5][5][4][100] = axis ? SignalV : SignalX;
1712 // our old C++ compiler cling(from old ROOT) complains about this.
1713 // thankfully, our g++ does not.
1714
1715 const int _nbins = 2000;
1716 int z_grid_x = Save_Grid / 100;
1717 int z_grid_v = Save_Grid % 100 / 10;
1718 int z_index = Save_Grid % 10;
1719 for (std::vector<int>::const_iterator it_start_bin = hitlist.begin(); it_start_bin != hitlist.end(); it_start_bin++) {
1720 if (*it_start_bin < 0) continue;
1721 for (int addi = *it_start_bin; (addi < *it_start_bin + 160) and (addi < _nbins - 1); addi += 2) { // 160 cell-layer move. i believe more hits in a semi-cell make fft-convolve relatively faster.
1722 hist_bin_Content[addi] += Signal[layer][z_grid_x][z_grid_v][z_index][(addi - *it_start_bin) / 2 + 1]; // caution, its indice starts from...1?
1723 hist_bin_Content[addi + 1] += Signal[layer][z_grid_x][z_grid_v][z_index][(addi - *it_start_bin) / 2 + 1];
1724 } // here its content is like stage with step size 2;
1725 }
1726}
1727
1728/**
1729 * @brief fft method of doing conv1 at a single grid for a strip. same usage as conv1PerGrid_legacy
1730 * discards t > _nbins or t <0 events
1731 * @param Save_Grid [grid_x]*100+[grid_v]*10+[z_index]*1
1732 * @param hist_bin_content to be summed on
1733 * @param hitlist list of hits
1734 * @param layer layer.
1735 * @param axis 0:X, 1:V
1736 */
1737void InductionGar2::conv1PerGrid_fft(int Save_Grid, double *hist_bin_Content,
1738 const std::vector<int> &hitlist, int layer, int axis) const {
1739 ConvolveWithConst(&Signal_Convolver)[3][5][5][4] = const_cast<ConvolveWithConst(&)[3][5][5][4]>(axis ? Signal_ConvolverV : Signal_ConvolverX);
1740
1741 const int _nbins = 2000;
1742 double hist_tmp[_nbins] = {0};
1743 int z_grid_x = Save_Grid / 100;
1744 int z_grid_v = Save_Grid % 100 / 10;
1745 int z_index = Save_Grid % 10;
1746
1747 //bool found_mismatch = false;
1748 double electron_hit_tmp_hist[_nbins] = {0};
1749
1750 for (std::vector<int>::const_iterator it_start_bin = hitlist.begin(); it_start_bin != hitlist.end(); it_start_bin++) {
1751 if (*it_start_bin < _nbins and *it_start_bin >= 0) electron_hit_tmp_hist[*it_start_bin] += 1;
1752 }
1753 Signal_Convolver[layer][z_grid_x][z_grid_v][z_index].convolve(hist_tmp, electron_hit_tmp_hist, 0, _nbins);
1754
1755#ifdef INDUCTIONGAR_DEBUG_CONV1PERGRID_FFT_TEST
1756 {
1757 double hist_tmp2[_nbins] = {0};
1758 bool found_mismatch = false;
1759 const double Accept_Threshold = 1e-5;
1760 const double Accept_Threshold_ref = 1e-5;
1761 conv1PerGrid_legacy(Save_Grid, hist_tmp2, hitlist, layer, axis);
1762 for (int i = 0; i < _nbins; i++) {
1763 if (abs(hist_tmp[i] - hist_tmp2[i]) >= Accept_Threshold and abs((hist_tmp[i] - hist_tmp2[i]) / hist_tmp2[i]) >= Accept_Threshold_ref) {
1764 if (not found_mismatch) {
1765 std::cout << "CgemDigitizerSvc::InductionGar2::conv1PerGrid_fft found results not match: " << endl;
1766 found_mismatch = true;
1767 }
1768 std::cout << " previous: " << hist_tmp[i] << "; new " << hist_tmp2[i] << "; at i=" << i << '\n'
1769 }
1770 }
1771 }
1772#endif
1773
1774 //add
1775 for (int i = 0; i < _nbins; i++) {
1776 hist_bin_Content[i] += hist_tmp[i];
1777 }
1778}
1779
1780/**
1781 * @brief fft method of doing conv1 at a single grid for a strip.
1782 *
1783 * @param gridX
1784 * @param gridV
1785 * @param indexOID
1786 * @param hist_bin_Content
1787 * @param elecHitHist
1788 * @param layer
1789 * @param axis
1790 */
1791void InductionGar2::conv1PerGrid_legacy(int gridX, int gridV, int indexOID, double *hist_bin_Content,
1792 const std::vector<int> &elecHitHist, int layer, int axis) const {
1793 //double ***** Signal=0;
1794 // this should not work, since you get no dimention info
1795 // and this following one might work.
1796
1797 const double(&Signal)[3][5][5][4][100] = axis ? SignalV : SignalX;
1798
1799 // our old C++ compiler cling(from old ROOT) complains about this.
1800 // thankfully, our g++ does not.
1801
1802 const int _nbins = 2000;
1803
1804 for (int start_bin = 0; start_bin < _nbins; start_bin++) {
1805 int nElec = elecHitHist[start_bin];
1806 for (int addi = start_bin; (addi < start_bin + 160) and (addi < _nbins - 1); addi += 2) {
1807 hist_bin_Content[addi] += Signal[layer][gridX][gridV][indexOID][(addi - start_bin) / 2 + 1] * nElec;
1808 hist_bin_Content[addi + 1] += Signal[layer][gridX][gridV][indexOID][(addi - start_bin) / 2 + 1] * nElec;
1809 } // a step2 thing.
1810 }
1811
1812 //int z_grid_x = Save_Grid / 100;
1813 //int z_grid_v = Save_Grid % 100 / 10;
1814 //int z_index = Save_Grid % 10;
1815 //for (std::vector<int>::const_iterator it_start_bin = hitlist.begin(); it_start_bin != hitlist.end(); it_start_bin++) {
1816 // if (*it_start_bin < 0) continue;
1817 // for (int addi = *it_start_bin; (addi < *it_start_bin + 160) and (addi < _nbins - 1); addi += 2) { // 160 cell-layer move. i believe more hits in a semi-cell make fft-convolve relatively faster.
1818 // hist_bin_Content[addi] += Signal[layer][z_grid_x][z_grid_v][z_index][(addi - *it_start_bin) / 2 + 1]; // caution, its indice starts from...1?
1819 // hist_bin_Content[addi + 1] += Signal[layer][z_grid_x][z_grid_v][z_index][(addi - *it_start_bin) / 2 + 1];
1820 // } // here its content is like stage with step size 2;
1821 //}
1822}
1823
1824void InductionGar2::conv1PerGrid_fft(int gridX, int gridV, int indexOID, double *hist_bin_Content,
1825 const std::vector<int> &elecHitHist, int layer, int axis) const {
1826 ConvolveWithConst(&Signal_Convolver)[3][5][5][4] = const_cast<ConvolveWithConst(&)[3][5][5][4]>(axis ? Signal_ConvolverV : Signal_ConvolverX);
1827
1828 const int _nbins = 2000;
1829 double hist_tmp[_nbins] = {0};
1830 int z_grid_x = gridX;
1831 int z_grid_v = gridV;
1832 int z_index = indexOID;
1833
1834 //bool found_mismatch = false;
1835 double electron_hit_tmp_hist[_nbins] = {0};
1836 for (int i = 0; i < _nbins; i++) {
1837 electron_hit_tmp_hist[i] = elecHitHist[i];
1838 }
1839 //
1840 //for (std::vector<int>::const_iterator it_start_bin = hitlist.begin(); it_start_bin != hitlist.end(); it_start_bin++) {
1841 // if (*it_start_bin < _nbins and *it_start_bin >= 0) electron_hit_tmp_hist[*it_start_bin] += 1;
1842 //}
1843
1844 Signal_Convolver[layer][z_grid_x][z_grid_v][z_index].convolve(hist_tmp, electron_hit_tmp_hist, 0, _nbins);
1845
1846#ifdef INDUCTIONGAR_DEBUG_CONV1PERGRID_FFT_TEST
1847 {
1848 double hist_tmp2[_nbins] = {0};
1849 bool found_mismatch = false;
1850 const double Accept_Threshold = 1e-10;
1851 const double Accept_Threshold_ref = 1e-5;
1852 conv1PerGrid_legacy(gridX, gridV, indexOID, hist_tmp2, elecHitHist, layer, axis);
1853 for (int i = 0; i < _nbins; i++) {
1854 if (abs(hist_tmp[i] - hist_tmp2[i]) >= Accept_Threshold and abs((hist_tmp[i] - hist_tmp2[i]) / hist_tmp2[i]) >= Accept_Threshold_ref) {
1855 if (not found_mismatch) {
1856 std::cout << "CgemDigitizerSvc::InductionGar2::conv1PerGrid_fft found results not match: " << endl;
1857 found_mismatch = true;
1858 }
1859 std::cout << " previous: " << hist_tmp[i] << "; new " << hist_tmp2[i] << "; at i=" << i << '\n'
1860 }
1861 }
1862 }
1863#endif
1864
1865 //add
1866 for (int i = 0; i < _nbins; i++) {
1867 hist_bin_Content[i] += hist_tmp[i];
1868 }
1869}
1870
1871
1872
1873/**
1874 * @brief checks if all entries in mapQ1 are same in mapQ2.
1875 *
1876 * @param mapQ1
1877 * @param mapQ2
1878 */
1879static void compareMap(const std::map<int, double> mapQ1[2][2], const std::map<int, double> mapQ2[2][2]) {
1880
1881 for (int sheet = 0; sheet < 2; sheet++) {
1882 for (int xvView = 0; xvView < 2; xvView++) {
1883 const std::map<int, double> &m1 = mapQ1[sheet][xvView];
1884 const std::map<int, double> &m2 = mapQ2[sheet][xvView];
1885 cout << "CgemDigitizerSvc::InductionGar2::compareMap current sheet " << sheet << "; xvView " << xvView << endl;
1886 if (m1.size() != m2.size()) {
1887 cout << "\tcompareMap: size of maps not match: map1: " << m1.size() << ";\tmap2: " << m2.size() << '\n';
1888 }
1889 for (std::map<int, double>::const_iterator it = m2.begin(); it != m2.end(); it++) {
1890 int key = it->first;
1891 double value = it->second;
1892 try {
1893 if (value != m1.at(key)) {
1894 std::cout << "\tcompareMap: value at key " << key << " not match: map1:" << m1.at(key) << "\tmap2:" << m2.at(key) << '\n';
1895 }
1896 } catch (const std::out_of_range &e) {
1897 std::cout << "\tcompareMap: key " << key << "in map2 " << m2.at(key) << " has no coresponding entry in map1 \n";
1898 }
1899 }
1900 }
1901 }
1902}
1903
1904static void DrawToFile(const double *h, const char *filename) {
1905 TH1D h1("h_InductionGar2", "", _nbins, 0, 1000);
1906 for (int i = 0; i < _nbins; i++) {
1907 h1.SetBinContent(i + 1, h[i]);
1908 }
1909 TCanvas cx1("cx1", "", 1);
1910 h1.Draw();
1911
1912 string filebase = "save/";
1913 string fn = filebase + filename + ".png";
1914 cx1.Print(fn.c_str());
1915}
1916
1917
1918
1919static void checkMemorySize()
1920{
1921 ProcInfo_t info;
1922 gSystem->GetProcInfo(&info);
1923 double currentMemory = info.fMemResident/1024;// MB
1924 cout<<"CgemDigitizerSvc::InductionGar2: current memory size "<<currentMemory<<" MB"<<endl;
1925}
1926
1927
1928bool InductionGar2::isDeadStrip(int layer, int sheet, int XVview, int strip)
1929{
1930 std::set<int> &deadStrips= m_deadStrip[layer][sheet][XVview];
1931 //cout<<"layer "<<layer<<" sheet "<<sheet<<" XVview "<<XVview<<" strip "<<strip;
1932 if (deadStrips.count(strip)==1){
1933 //cout<<"is dead strip"<<endl;
1934 return true;
1935 }
1936 //cout<<"is not dead"<<endl;
1937 return false;
1938}
float Float_t
double length
Double_t x[10]
const DifComplex I
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
std::vector< int > Vint
Definition: Gam4pikp.cxx:52
std::map< IndexGar, std::vector< int > > HitHistMap
Definition: IndexGar.h:41
std::vector< int > Vint
TH1F Convolution_Tbranch(const double *Input_Curr_plot_001, double xmin, double xmax, int Npx=2000)
double rectangle2(double t, double *x, double *y, int Npx)
TH1F Convolution_Ebranch(const double *Input_Curr_plot_001, double xmin, double xmax, int Npx=2000)
double rectangle2_fast(double t, double *x, const double *y, int Npx)
calc estimate using linear interpolation of curve {x,y} , at point t; mimic rectangle2() but faster v...
double E_branch2(double t)
double T_branch2(double t)
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42
ConvolveWithConst * conv
Definition: InductionGar2.h:34
std::vector< double > EBranch
Definition: InductionGar2.h:35
TH1D Convolution_Ebranch_fft(const double *Input_Curr_plot_001)
return convolve of Input_Curr_plot_001 and T_Branch2, a function; tries to mimic Convolution_Ebranch ...
ConvolveWithConst * conv
Definition: InductionGar2.h:22
TH1D Convolution_Tbranch_fft(const double *Input_Curr_plot_001)
return convolve of Input_Curr_plot_001 and T_Branch2, a function; tries to mimic Convolution_Tbranch ...
std::vector< double > TBranch
Definition: InductionGar2.h:23
int getNumberOfSheet() const
Definition: CgemGeoLayer.h:215
double getDist2ClosestXStripCenter(double phi, int &id)
bool OnThePlane(double phi, double z) const
double getDist2ClosestVStripCenter(G4ThreeVector pos, int &id)
basically, convolve with fft. convolves 1-d. if size of 2 inputs are fixed, it may yield optimal spee...
std::complex< double > Complex
void FFT(Complex *outHalfPlus1, const double *inNormalLength, int LengthOutAsDouble, int LengthIn) const
Do fft with respect of getLength();.
void init(const double *ConstArray, const int ConstArrayLength, const int Blength, TransformOptimOpt opt=opt_EX, TransformLengthOpt optL=opt_AsShortAsPsb)
void convolve(double *output, const double *B, const int leftIndex, const int sizeofOut, double factor=1) const
do a convolve of stored const A and B, and put results to output.
void IFFT(double *outNormalLength, const Complex *inHalfPlus1, int lengthOut, int lengthInAsDouble) const
Do ifft with respect of getLength();.
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const =0
virtual CgemGeoLayer * getCgemLayer(int i) const =0
void init(ICgemGeomSvc *geomSvc, double magConfig)
void setMultiElectrons(int layer, int nElectrons, const std::vector< Float_t > &x, const std::vector< Float_t > &y, const std::vector< Float_t > &z, const std::vector< Float_t > &t)
Definition: InductionGar2.h:54
int num[96]
Definition: ranlxd.c:373
char gridX
Definition: IndexGar.h:9
char sheet
Definition: IndexGar.h:10
int stripV
Definition: IndexGar.h:8
int stripX
Definition: IndexGar.h:7
char gridV
Definition: IndexGar.h:9
const std::vector< Float_t > * z
const std::vector< Float_t > * t
const std::vector< Float_t > * x
const std::vector< Float_t > * y
int t()
Definition: t.c:1