9#include <framework/datastore/StoreArray.h>
10#include <framework/gearbox/Unit.h>
12#include <ecl/geometry/ECLGeometryPar.h>
13#include <ecl/dataobjects/ECLSimHit.h>
14#include <ecl/dataobjects/ECLHit.h>
16#include "trg/ecl/TrgEclDigitizer.h"
19#include "trg//ecl/dataobjects/TRGECLDigi0.h"
20#include "trg/ecl/dataobjects/TRGECLWaveform.h"
33 TimeRange(0), _waveform(0), _FADC(1), _BeambkgTag(0)
41 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
44 for (
int iTime = 0; iTime < 80; iTime++) {
52 for (
int iii = 0; iii < 60 ; iii++) {
57 for (
int iii = 0; iii < 64 ; iii++) {
95 std::vector< std::vector<float> > E_cell(8736, std::vector<float>(80, 0.0));
96 std::vector< std::vector<float> > T_ave(8736, std::vector<float>(80, 0.0));
97 std::vector< std::vector<float> > Tof_ave(8736, std::vector<float>(80, 0.0));
98 std::vector< std::vector<float> > beambkg_tag(8736, std::vector<float>(80, 0.0));
105 if (SourceOfTC == 1) {
111 for (
int iHits = 0; iHits < nHits_hit; iHits++) {
113 ECLHit* aECLHit = eclHitArray[iHits];
117 int hitCellId = aECLHit->
getCellId() - 1;
120 if (aveT < - TimeRange || aveT >
TimeRange) {
continue;}
121 int TimeIndex = (int)((aveT +
TimeRange) / 100);
124 TCEnergy[iTCIdm][TimeIndex] += hitE;
125 TCTiming[iTCIdm][TimeIndex] += hitE * aveT;
130 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
131 for (
int iTime = 0; iTime < nBinTime; iTime++) {
133 if (
TCEnergy[iTCIdm][iTime] < 1e-9) {
continue;}
143 for (
int iXtalIdm = 0; iXtalIdm < 8736; iXtalIdm++) {
145 if (iTCIdm != iTCId) {
continue;}
146 if (maxbkgE < E_cell[iXtalIdm][iTime]) {
147 maxbkgE = E_cell[iXtalIdm][iTime];
148 maxbkgtag = beambkg_tag[iXtalIdm][iTime];
159 if (SourceOfTC == 2) {
167 for (
int iHits = 0; iHits < nHits; iHits++) {
171 int hitCellId = aECLSimHit->
getCellId() - 1;
175 G4ThreeVector t = aECLSimHit->
getPosIn();
176 ROOT::Math::XYZVector HitInPos(t.x(), t.y(), t.z());
177 ROOT::Math::XYZVector PosCell = eclp->
GetCrystalPos(hitCellId);
178 ROOT::Math::XYZVector VecCell = eclp->
GetCrystalVec(hitCellId);
179 float local_pos_r = 15.0 - (HitInPos - PosCell).Dot(VecCell);
180 if (hitTOF < - TimeRange || hitTOF >
TimeRange) {
continue;}
181 int TimeIndex = (int)((hitTOF +
TimeRange) / 100);
182 E_cell[hitCellId][TimeIndex] = E_cell[hitCellId][TimeIndex] + hitE;
183 T_ave[hitCellId][TimeIndex] = T_ave[hitCellId][TimeIndex] + hitE * local_pos_r;
184 Tof_ave[hitCellId][TimeIndex] = Tof_ave[hitCellId][TimeIndex] + hitE * hitTOF;
192 for (
int iECLCell = 0; iECLCell < 8736; iECLCell++) {
193 for (
int TimeIndex = 0; TimeIndex < nBinTime; TimeIndex++) {
195 if (E_cell[iECLCell][TimeIndex] < 1e-9) {
continue;}
197 T_ave[iECLCell][TimeIndex] = T_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex];
198 T_ave[iECLCell][TimeIndex] =
200 0.0749 * T_ave[iECLCell][TimeIndex] -
201 0.00112 * T_ave[iECLCell][TimeIndex] * T_ave[iECLCell][TimeIndex];
202 Tof_ave[iECLCell][TimeIndex] = Tof_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex];
209 for (
int iXtalIdm = 0; iXtalIdm < 8736; iXtalIdm++) {
211 for (
int iTime = 0; iTime < nBinTime; iTime++) {
213 if (E_cell[iXtalIdm][iTime] < 1e-9) {
continue;}
214 TCEnergy[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];
215 TCTiming[iTCIdm][iTime] += E_cell[iXtalIdm][iTime] * (T_ave[iXtalIdm][iTime]);
216 if (beambkg_tag[iXtalIdm][iTime] > 0) {
TCBkgContribution[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];}
217 if (beambkg_tag[iXtalIdm][iTime] == 0) {
TCSigContribution[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];}
221 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
222 for (
int iTime = 0; iTime < nBinTime; iTime++) {
228 if (
TCEnergy[iTCIdm][iTime] < 1e-9) {
continue;}
234 for (
int iXtalIdm = 0; iXtalIdm < 8736; iXtalIdm++) {
236 if (iTCIdm != iTCId) {
continue;}
237 if (maxbkgE < E_cell[iXtalIdm][iTime]) {
238 maxbkgE = E_cell[iXtalIdm][iTime];
239 maxbkgtag = beambkg_tag[iXtalIdm][iTime];
253 if (SourceOfTC == 3) {
259 for (
int iHits = 0; iHits < nHits_hit; iHits++) {
261 ECLHit* aECLHit = eclHitArray[iHits];
263 int hitCellId = aECLHit->
getCellId() - 1;
267 if (aveT < - TimeRange || aveT >
TimeRange) {
continue;}
269 int TimeIndex = (int)((aveT +
TimeRange) / 100);
272 TCEnergy[iTCIdm][TimeIndex] += hitE;
273 TCTiming[iTCIdm][TimeIndex] += hitE * aveT;
279 double tcbg_t = ttt.getTimeAve();
283 int TimeIndex = (int)((tcbg_t +
TimeRange) / 100);
285 double tcbg_e = ttt.getEnergyDep();
287 int iTCIdm = ttt.getTCId() - 1;
289 double tc_e =
TCEnergy[iTCIdm][TimeIndex];
290 double tc_t =
TCTiming[iTCIdm][TimeIndex];
291 TCEnergy[iTCIdm][TimeIndex] += tcbg_e;
292 TCTiming[iTCIdm][TimeIndex] += (tcbg_e * tcbg_t + tc_e * tc_t);
294 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
295 for (
int iTime = 0; iTime < nBinTime; iTime++) {
303 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
304 for (
int iTime = 40; iTime < 50; iTime++) {
318 std::vector<std::vector<double>>& TCDigiT)
321 TCDigiE.resize(576, vector<double>(64, 0));
323 TCDigiT.resize(576, vector<double>(64, 0));
326 double cut_energy_tot = 0.03;
327 int nbin_pedestal = 4;
328 double fam_sampling_interval = 125;
332 std::vector< std::vector<float> > noise_pileup(576, std::vector<float>(64, 0.0));
333 std::vector< std::vector<float> > noise_parallel(576, std::vector<float>(64, 0.0));
334 std::vector< std::vector<float> > noise_serial(576, std::vector<float>(64, 0.0));
335 std::vector<float> X_pr(64, 0.0);
336 std::vector<float> X_sr(64, 0.0);
340 double random_sampling_correction = 0;
341 random_sampling_correction = gRandom->Rndm() * fam_sampling_interval;
345 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
346 for (
int iTimeBin = 0; iTimeBin < 80; iTimeBin++) {
348 if (
TCEnergy[iTCIdm][iTimeBin] < 0.0001) {
continue;}
349 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
352 = (-
TCTiming[iTCIdm][iTimeBin] -
TimeRange + (-nbin_pedestal + iSampling) * fam_sampling_interval) * 0.001;
353 inputTiming += random_sampling_correction * 0.001;
354 if (inputTiming < 0 || inputTiming > 2.0) {
continue;}
357 TCDigiE[iTCIdm][iSampling] +=
interFADC(inputTiming) *
TCEnergy[iTCIdm][iTimeBin];
363 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
364 TCDigiT[iTCIdm][iSampling] = (-nbin_pedestal + iSampling -
TimeRange / fam_sampling_interval) * fam_sampling_interval;
365 TCDigiT[iTCIdm][iSampling] += random_sampling_correction;
373 FILE* f_out_dat = fopen(
"ztsim.no_noise.dat",
"w");
374 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
375 if (
TCEnergy_tot[iTCIdm] < cut_energy_tot) {
continue; }
376 fprintf(f_out_dat,
"%5i %8.5f %8.5f %8.1f ",
378 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
379 fprintf(f_out_dat,
"%7.4f ", TCDigiE[iTCIdm][iSampling]);
381 fprintf(f_out_dat,
"\n");
388 double tmin_noise = -4;
390 int bkg_level = 1030;
397 double frac_pileup = 0.035;
398 double frac_parallel = 0.023;
399 double frac_serial = 0.055;
400 double times_pileup = 1;
401 double times_parallel = 3.15;
402 double times_serial = 3.15;
404 double corr_pileup = times_pileup * frac_pileup *
sqrt(fam_sampling_interval * 0.001);
405 double corr_parallel = times_parallel * frac_parallel *
sqrt(fam_sampling_interval * 0.001);
406 double corr_serial = times_serial * frac_serial *
sqrt(fam_sampling_interval * 0.001);
410 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
411 if (
TCEnergy_tot[iTCIdm] < cut_energy_tot) {
continue; }
412 for (
int jjj = 0; jjj < bkg_level; jjj++) {
413 ttt0 = -(tmin_noise + tgen * gRandom->Rndm());
414 ttt1 = -(tmin_noise + tgen * gRandom->Rndm());
415 ttt2 = -(tmin_noise + tgen * gRandom->Rndm());
416 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
418 if (ttt0 > 0) { TCDigiE[iTCIdm][iSampling] +=
SimplifiedFADC(0, ttt0) * corr_pileup * 0.001; }
420 if (ttt1 > 0) { TCDigiE[iTCIdm][iSampling] +=
SimplifiedFADC(1, ttt1) * corr_parallel; }
422 if (ttt2 > 0) { TCDigiE[iTCIdm][iSampling] +=
SimplifiedFADC(2, ttt2) * corr_serial; }
423 ttt0 += fam_sampling_interval * 0.001;
424 ttt1 += fam_sampling_interval * 0.001;
425 ttt2 += fam_sampling_interval * 0.001;
431 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
433 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
434 X_pr[iSampling] = gRandom ->Gaus(0, 1);
435 X_sr[iSampling] = gRandom ->Gaus(0, 1);
438 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
439 for (
int jSampling = 0; jSampling < NSampling; jSampling++) {
440 noise_parallel[iTCIdm][iSampling] += 10 * corr_parallel *
MatrixParallel[iSampling][jSampling] * X_pr[jSampling];
441 noise_serial[iTCIdm][iSampling] += 10 * corr_serial *
MatrixSerial[iSampling][jSampling] * X_sr[jSampling];
445 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
447 TCDigiE[iTCIdm][iSampling] += noise_pileup[iTCIdm][iSampling] + noise_parallel[iTCIdm][iSampling] +
448 noise_serial[iTCIdm][iSampling];
452 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
453 if (
TCEnergy_tot[iTCIdm] < cut_energy_tot) {
continue; }
454 for (
int jjj = 0; jjj < bkg_level; jjj++) {
455 ttt0 = -(tmin_noise + tgen * gRandom->Rndm());
456 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
458 if (ttt0 > 0) { TCDigiE[iTCIdm][iSampling] +=
SimplifiedFADC(0, ttt0) * corr_pileup * 0.001; }
459 ttt0 += fam_sampling_interval * 0.001;
468 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
469 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
470 WaveForm[iTCIdm][iSampling] = TCDigiE[iTCIdm][iSampling];
484 TCDigiE.resize(576, vector<double>(666, 0));
486 TCDigiT.resize(576, vector<double>(666, 0));
487 double cut_energy_tot = 0.03;
488 int nbin_pedestal = 100;
489 float fam_sampling_interval = 12;
491 std::vector< std::vector<float> > TCDigiEnergy(576, std::vector<float>(666, 0.0));
492 std::vector< std::vector<float> > TCDigiTiming(576, std::vector<float>(666, 0.0));
496 float random_sampling_correction = 0;
497 random_sampling_correction = gRandom->Rndm() * fam_sampling_interval;
498 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
500 for (
int iTimeBin = 0; iTimeBin < 80; iTimeBin++) {
501 if (
TCEnergy[iTCIdm][iTimeBin] < 0.0001) {
continue; }
502 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
505 = (-
TCTiming[iTCIdm][iTimeBin] -
TimeRange + (-nbin_pedestal + iSampling) * fam_sampling_interval) * 0.001;
507 inputTiming += random_sampling_correction * 0.001;
508 if (inputTiming < 0 || inputTiming > 2.0) {
continue;}
510 TCDigiEnergy[iTCIdm][iSampling] +=
FADC(0, inputTiming) *
TCEnergy[iTCIdm][iTimeBin];
513 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
514 TCDigiTiming[iTCIdm][iSampling] = (-nbin_pedestal + iSampling -
TimeRange / fam_sampling_interval) * fam_sampling_interval;
515 TCDigiTiming[iTCIdm][iSampling] += random_sampling_correction;
522 double tmin_noise = -4;
524 int bkg_level = 1030;
537 double corr_pileup = 0.011068;
538 double corr_parallel = 0.00727324;
539 double corr_serial = 0.0173925;
542 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
543 if (
TCEnergy_tot[iTCIdm] < cut_energy_tot) {
continue; }
544 for (
int jjj = 0; jjj < bkg_level; jjj++) {
545 ttt0 = -(tmin_noise + tgen * gRandom->Rndm());
546 ttt1 = -(tmin_noise + tgen * gRandom->Rndm());
547 ttt2 = -(tmin_noise + tgen * gRandom->Rndm());
548 for (
int iSampling = 0; iSampling < NSampling; iSampling++) {
550 if (ttt0 > 0) { TCDigiEnergy[iTCIdm][iSampling] +=
FADC(0, ttt0) * corr_pileup * 0.001; }
552 if (ttt1 > 0) { TCDigiEnergy[iTCIdm][iSampling] +=
FADC(1, ttt1) * corr_parallel; }
554 if (ttt2 > 0) { TCDigiEnergy[iTCIdm][iSampling] +=
FADC(2, ttt2) * corr_serial; }
555 ttt0 += fam_sampling_interval * 0.001;
556 ttt1 += fam_sampling_interval * 0.001;
557 ttt2 += fam_sampling_interval * 0.001;
573 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
574 for (
int iBinTime = 0; iBinTime < 80; iBinTime++) {
575 if (
TCEnergy[iTCIdm][iBinTime] < 0.001) {
continue;}
580 TCDigiArray[m_hitNum]->setEventId(m_nEvent);
581 TCDigiArray[m_hitNum]->setTCId(iTCIdm + 1);
582 TCDigiArray[m_hitNum]->setiBinTime(iBinTime);
583 TCDigiArray[m_hitNum]->setRawEnergy(
TCEnergy[iTCIdm][iBinTime]);
584 TCDigiArray[m_hitNum]->setRawTiming(
TCTiming[iTCIdm][iBinTime]);
585 TCDigiArray[m_hitNum]->setBeamBkgTag(
TCBeambkgTag[iTCIdm][iBinTime]);
591 for (
int iTCIdm = 0; iTCIdm < 576; iTCIdm++) {
592 if (iTCIdm == 80) iTCIdm = 512;
612 std::vector<double> SignalAmp;
613 std::vector<double> SignalTime;
618 timing = timing * 1000;
619 int startbin = (int)(timing) / 12;
620 int endbin = startbin + 1;
622 SignalAmp = { 0, 3.47505e-06, 0.000133173, 0.000939532, 0.00337321, 0.00845977, 0.0170396, 0.0296601, 0.0465713, 0.0677693, 0.0930545, 0.122086, 0.154429, 0.189595, 0.227068, 0.266331, 0.306882, 0.348243, 0.389971, 0.431664, 0.472959, 0.513539, 0.553127, 0.59149, 0.628431, 0.663791, 0.697445, 0.729297, 0.759281, 0.787354, 0.813494, 0.837698, 0.859982, 0.880372, 0.898908, 0.915639, 0.930622, 0.943919, 0.955598, 0.965731, 0.97439, 0.98165, 0.987587, 0.992275, 0.995788, 0.9982, 0.999581, 1, 0.999525, 0.998219, 0.996143, 0.993356, 0.989846, 0.985364, 0.979439, 0.971558, 0.961304, 0.948421, 0.932809, 0.914509, 0.893664, 0.870494, 0.845267, 0.818279, 0.789837, 0.76025, 0.729815, 0.698815, 0.667511, 0.636141, 0.604919, 0.574035, 0.543654, 0.513915, 0.484939, 0.456822, 0.429643, 0.403462, 0.378324, 0.354259, 0.331286, 0.309412, 0.288633, 0.26894, 0.250316, 0.232736, 0.216174, 0.200597, 0.185972, 0.172262, 0.159428, 0.147431, 0.136232, 0.12579, 0.116067, 0.107022, 0.0986191, 0.0908193, 0.0835871, 0.0768874, 0.0706867, 0.0649528, 0.0596551, 0.0547641, 0.0502523, 0.0460932, 0.042262, 0.0387353, 0.0354909, 0.0325082, 0.0297677, 0.0272511, 0.0249416, 0.0228232, 0.020881, 0.0191014, 0.0174714, 0.0159792, 0.0146138, 0.0133649, 0.012223, 0.0111793, 0.0102258, 0.00935504, 0.00856, 0.00783438, 0.00717232, 0.00656842, 0.00601773, 0.00551567, 0.00505807, 0.00464106, 0.00426114, 0.00391506, 0.00359985, 0.0033128, 0.00305143, 0.00281346, 0.00259681, 0.00239957, 0.00222002, 0.00205655, 0.00190773, 0.00177223, 0.00164885, 0.00153648, 0.00143413, 0.00134087, 0.00125589, 0.00117842, 0.00110777, 0.00104332, 0.000984488, 0.000930766, 0.000881678, 0.000836798, 0.000795734, 0.000758134, 0.000723677, 0.00069207, 0.000663051, 0.000636377, 0.000611832, 0.000589219, 0.000568358, 0.000549086, 0.000531258, 0.000514738, 0.000499407, 0.000485156, 0.000471884, 0.000459502, 0.00044793, 0.000437092, 0.000426923, 0.000417363, 0.000408356, 0.000399853, 0.000391811, 0.000384187, 0.000376946, 0.000370055, 0.000363483, 0.000357203, 0.000351192, 0.000345426, 0.000339886, 0.000334554, 0.000329413, 0.000324448, 0.000319645, 0.000314993, 0.000310481, 0.000306098, 0.000301836, 0.000297686, 0.00029364, 0.000289693, 0.000285837, 0.000282068, 0.00027838, 0.000274768, 0.000271229, 0.000267759, 0.000264354, 0.000261011, 0.000257727, 0.000254499, 0.000251326, 0.000248204, 0.000245132, 0.000242108, 0.000239131, 0.000236198, 0.000233308, 0.00023046, 0.000227653, 0.000224885, 0.000222155, 0.000219463, 0.000216807, 0.000214187, 0.000211602, 0.00020905, 0.000206532, 0.000204046, 0.000201593, 0.00019917, 0.000196779, 0.000194417, 0.000192085, 0.000189782, 0.000187508, 0.000185262, 0.000183044, 0.000180853, 0.000178689, 0.000176552, 0.000174441, 0.000172355, 0.000170295, 0.00016826, 0.000166249, 0.000164263, 0.000162301, };
624 SignalTime = { 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960, 972, 984, 996, 1008, 1020, 1032, 1044, 1056, 1068, 1080, 1092, 1104, 1116, 1128, 1140, 1152, 1164, 1176, 1188, 1200, 1212, 1224, 1236, 1248, 1260, 1272, 1284, 1296, 1308, 1320, 1332, 1344, 1356, 1368, 1380, 1392, 1404, 1416, 1428, 1440, 1452, 1464, 1476, 1488, 1500, 1512, 1524, 1536, 1548, 1560, 1572, 1584, 1596, 1608, 1620, 1632, 1644, 1656, 1668, 1680, 1692, 1704, 1716, 1728, 1740, 1752, 1764, 1776, 1788, 1800, 1812, 1824, 1836, 1848, 1860, 1872, 1884, 1896, 1908, 1920, 1932, 1944, 1956, 1968, 1980, 1992, 2004, 2016, 2028, 2040, 2052, 2064, 2076, 2088, 2100, 2112, 2124, 2136, 2148, 2160, 2172, 2184, 2196, 2208, 2220, 2232, 2244, 2256, 2268, 2280, 2292, 2304, 2316, 2328, 2340, 2352, 2364, 2376, 2388, 2400, 2412, 2424, 2436, 2448, 2460, 2472, 2484, 2496, 2508, 2520, 2532, 2544, 2556, 2568, 2580, 2592, 2604, 2616, 2628, 2640, 2652, 2664, 2676, 2688, 2700, 2712, 2724, 2736, 2748, 2760, 2772, 2784, 2796, 2808, 2820, 2832, 2844, 2856, 2868, 2880, 2892, 2904, 2916, 2928, };
628 if (timing < 0 || timing > 2928) {
return E_out;}
630 if (timing > SignalTime[startbin] && timing < SignalTime[endbin]) {
631 E_out = (((SignalAmp[endbin] - SignalAmp[startbin])) / (SignalTime[endbin] - SignalTime[startbin])) *
632 (timing - SignalTime[startbin]) + SignalAmp[startbin];
658 static double tc, tc2, tsc, tris, b1, b2;
659 static double amp, dft, as;
660 static double td, t1, t2;
685 while (flag_once == 0) {
687 for (
int j = 1; j <= 1000; j++) {
690 (
ShapeF(tc, t1, b1, t2, b2, td, tsc) -
691 ShapeF(tc, t1, b1, t2, b2, td, tris) * 0.01) -
692 (
ShapeF(tc2, t1, b1, t2, b2, td, tsc) -
693 ShapeF(tc2, t1, b1, t2, b2, td, tris) * 0.01) * as;
699 double dt = tt / 1000;
725 (
ShapeF(timing, t1, b1, t2, b2, td, tsc) -
726 ShapeF(timing, t1, b1, t2, b2, td, tris) * 0.01) -
727 (
ShapeF(tc2, t1, b1, t2, b2, td, tsc) -
728 ShapeF(tc2, t1, b1, t2, b2, td, tris) * 0.01) * as);
729 }
else if (flag_gen == 1) {
734 ShapeF(timing, t1, b1, t2, b2, td, tsh) -
735 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as);
742 ShapeF(timing, t1, b1, t2, b2, td, tsh) -
743 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as);
746 if (tc < 0) { tc = 0; }
750 ShapeF(tc, t1, b1, t2, b2, td, tsh) -
751 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as) - pdf) / dd;
771 double das1, das0, dac0;
772 double dcs0s, dsn0s, dcs0d, dsn0d;
773 double dcs1s, dsn1s, dcs1d, dsn1d;
776 if (t00 < 0)
return 0;
778 dr = (ts1 - td1) / td1;
779 if (fabs(dr) <= 1.0e-5) {
780 if (ts1 > td1) { ts1 = td1 * 1.00001; }
781 else { ts1 = td1 * 0.99999; }
784 dr = (pow((t01 - t02), 2) + pow((tb1 - tb2), 2)) / (pow((t01), 2) + pow((tb1), 2));
786 if (t01 < t02) { t01 = t02 / 1.00001; }
787 else { t01 = t02 / 0.99999; }
789 if (t00 <= 0.0)
return 0;
800 das0 = b2 * (pow((b1 - a1), 2) + (b2 + a2) * (b2 - a2));
801 dac0 = -2 * (b1 - a1) * a2 * b2;
802 das1 = a2 * (pow((b1 - a1), 2) - (b2 + a2) * (b2 - a2));
804 dsn0s = ((c2 - a1) * das0 - (-a2) * dac0) / (pow(a2, 2) + pow((c2 - a1), 2));
805 dcs0s = ((-a2) * das0 + (c2 - a1) * dac0) / (pow(a2, 2) + pow((c2 - a1), 2));
807 dsn1s = ((c2 - b1) * das1 - (-b2) * (-dac0)) / (pow(b2, 2) + pow((c2 - b1), 2));
808 dcs1s = ((-b2) * das1 + (c2 - b1) * (-dac0)) / (pow(b2, 2) + pow((c2 - b1), 2));
810 dsn0d = ((c1 - a1) * das0 - (-a2) * dac0) / (pow(a2, 2) + pow((c1 - a1), 2));
811 dcs0d = ((-a2) * das0 + (c1 - a1) * dac0) / (pow(a2, 2) + pow((c1 - a1), 2));
813 dsn1d = ((c1 - b1) * das1 - (-b2) * (-dac0)) / (pow(b2, 2) + pow((c1 - b1), 2));
814 dcs1d = ((-b2) * das1 + (c1 - b1) * (-dac0)) / (pow(b2, 2) + pow((c1 - b1), 2));
818 dzna = (pow((b1 - a1), 2) + pow((b2 - a2), 2)) * (pow((b1 - a1), 2) + pow((a2 + b2), 2));
821 (dcs0s + dcs1s) * exp(-c2 * t00) * (-1) +
822 (dcs0d + dcs1d) * exp(-c1 * t00) +
823 ((dsn0s - dsn0d) * sin(a2 * t00) + (dcs0s - dcs0d) * cos(a2 * t00)) * exp(-a1 * t00) +
824 ((dsn1s - dsn1d) * sin(b2 * t00) + (dcs1s - dcs1d) * cos(b2 * t00)) * exp(-b1 * t00)
826 / dzna / (1 / c2 - 1 / c1);
851 static double tc, tc2, tsc, tris;
852 static double amp, dft, as;
861 const double td = 0.10;
862 const double t1 = 0.10;
864 const double t2 = 0.01;
881 while (flag_once == 0) {
882 double dt = tt / 1000;
885 for (
int j = 1; j <= 1000; j++) {
889 ShapeF(tc, tris) * 0.01) -
891 ShapeF(tc2, tris) * 0.01) * as;
907 dt = tm * 0.02 / 1000;
924 ShapeF(timing, tris) * 0.01) -
926 ShapeF(tc2, tris) * 0.01) * as);
927 }
else if (flag_gen == 1) {
944 if (tc < 0) { tc = 0; }
949 ShapeF(tc2, tsh) * as) - pdf) / dd;
959 static const double realNaN = std::numeric_limits<double>::quiet_NaN();
965 double a1, a2, b1, b2, c1, c2 =
realNaN;
968 if (t00 <= 0.0)
return 0;
997 dcs0s = -0.000204983;
1000 dcs1s = 0.000204894;
1007 dcs1d = -0.00323517;
1014 (dcs0s + dcs1s) * exp(-c2 * t00) * (-1) +
1015 (dcs0d + dcs1d) * exp(-c1 * t00) +
1016 ((dsn0s - dsn0d) * sin(a2 * t00) + (dcs0s - dcs0d) * cos(a2 * t00)) * exp(-a1 * t00) +
1017 ((dsn1s - dsn1d) * sin(b2 * t00) + (dcs1s - dcs1d) * cos(b2 * t00)) * exp(-b1 * t00)
1019 / dzna / (1 / c2 - 1 / c1);
1029 if (aaa > bbb) {
return aaa; }
1030 else {
return bbb; }
Class to store simulated hits which equate to average of ECLSImHit on crystals input for digitization...
double getTimeAve() const
Get average time.
int getCellId() const
Get Cell ID.
double getEnergyDep() const
Get deposit energy.
ClassECLSimHit - Geant4 simulated hit for the ECL.
int getCellId() const
Get Cell ID.
double getFlightTime() const
Get Flight time from IP.
double getEnergyDep() const
Get Deposit energy.
G4ThreeVector getPosIn() const
Get Position.
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
ROOT::Math::XYZVector GetCrystalVec(int cid)
The direction of crystal.
virtual unsigned short getBackgroundTag() const
Get background tag.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
int _FADC
Flag of choosing the method of waveform generation function 0: use simplifiedFADC,...
double TCTiming_tot[576]
TC Timing converted from Xtarl Timing [GeV].
virtual ~TrgEclDigitizer()
Destructor.
void save(int)
save fitting result into tables
double TCBkgContribution[576][80]
Beambackground contribution.
void setup(int)
setup fam module
double WaveForm[576][64]
TC Energy converted from Xtarl Energy [GeV].
double TCRawTiming[576][60]
Input TC timing[ns]
double TCEnergy[576][80]
TC Energy converted from Xtarl Energy [GeV].
double TCSigContribution[576][80]
Signal contribution.
std::vector< std::vector< double > > MatrixParallel
Noise Matrix of Parallel and Serial Noise.
TrgEclDataBase * _DataBase
Object of DataBase.
double TCTiming[576][80]
TC Timing converted from Xtarl Timing [GeV].
double TCRawBkgTag[576][60]
Input Beambackground tag
void digitization01(std::vector< std::vector< double > > &, std::vector< std::vector< double > > &)
fit method, digi with 125ns interval
double interFADC(double)
Faster FADC using interpolation.
TrgEclDigitizer()
Constructor.
std::vector< std::vector< double > > MatrixSerial
Noise Low triangle Matrix of Serial noise
double TCRawEnergy[576][60]
Input TC energy[GeV].
double TimeRange
time range(default : -4000 ~ 4000 ns )
int _BeambkgTag
Flag of saving beam background tag or not.
double FADC(int, double)
FADC
double SimplifiedFADC(int, double)
FADC.
double u_max(double, double)
Find max value between 2 vals;.
int _waveform
Flag of waveform table.
int TCBeambkgTag[576][80]
Beambackground tag.
double ShapeF(double, double, double, double, double, double, double)
return shape using FADC function
void digitization02(std::vector< std::vector< double > > &, std::vector< std::vector< double > > &)
original no fit method, digi with 12ns interval
void getTCHit(int)
get TC Hits from Xtal hits
TrgEclMapping * _TCMap
Object of TC Mapping.
double TCEnergy_tot[576]
TC Energy converted from Xtarl Energy [GeV].
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
int getTCIdFromXtalId(int)
get [TC ID] from [Xtal ID]
int getTCPhiIdFromTCId(int)
get [TC Phi ID] from [TC ID]
static const double ns
Standard of [time].
static const double GeV
Standard of [energy, momentum, mass].
static const double realNaN
constant for double NaN
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.