Belle II Software development
TrgEclDigitizer Class Reference

FAM module. More...

#include <TrgEclDigitizer.h>

Public Member Functions

 TrgEclDigitizer ()
 Constructor.
 
virtual ~TrgEclDigitizer ()
 Destructor.
 
void setup (int)
 setup fam module
 
void getTCHit ()
 get TC Hits from Xtal hits Set TC data m_sourceOfTC => 1=ECLHit, 2=ECLSimHit, 3=ECLHit+TRGECLBGTCHit ("1:=ECLHit" is used for signal w/o bkg, and real time background monitor)
 
void digitization01 (std::vector< std::vector< double > > &, std::vector< std::vector< double > > &)
 fit method, digi with 125ns interval
 
void digitization02 (std::vector< std::vector< double > > &, std::vector< std::vector< double > > &)
 original no fit method, digi with 12ns interval
 
void save (int)
 save fitting result into tables
 
void setWaveform (int wave)
 Set flag of waveform table.
 
void setFADC (int fadc)
 Set flag of waveform table.
 
void setSourceOfTC (int SourceOfTC)
 Set flag of waveform table.
 
void clear ()
 Clear all the data fields.
 
void initialize ()
 Initialize the class.
 
double FADC (int, double)
 FADC.
 
double SimplifiedFADC (int, double)
 FADC.
 
double interFADC (double)
 Faster FADC using interpolation.
 
double ShapeF (double, double, double, double, double, double, double)
 return shape using FADC function
 
double ShapeF (double, double)
 Return shape using Simplified FADC.
 
double u_max (double, double)
 Find max value between 2 vals;.
 

Private Attributes

double m_TimeRange = 4000
 time range(default : -4000 ~ 4000 ns )
 
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCEnergy
 TC Energy converted from Xtarl Energy [GeV].
 
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCTiming
 TC Timing converted from Xtarl Timing [GeV].
 
std::array< double, c_NTC > m_TCEnergy_tot
 TC Energy converted from Xtarl Energy [GeV].
 
std::array< double, c_NTC > m_TCTiming_tot
 TC Timing converted from Xtarl Timing [GeV].
 
std::array< std::array< double, 60 >, c_NTC > m_TCRawEnergy
 Input TC energy[GeV].
 
std::array< std::array< double, 60 >, c_NTC > m_TCRawTiming
 Input TC timing[ns].
 
std::array< std::array< double, 60 >, c_NTC > m_TCRawBkgTag
 Input Beambackground tag.
 
TrgEclMapping * m_TCMap
 Object of TC Mapping.
 
TrgEclDataBase * m_DataBase
 Object of DataBase.
 
std::array< std::array< double, 64 >, 64 > m_MatrixParallel
 Noise Matrix of Parallel and Serial Noise.
 
std::array< std::array< double, 64 >, 64 > m_MatrixSerial
 Noise Low triangle Matrix of Serial noise.
 
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCBkgContribution
 Beambackground contribution.
 
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCSigContribution
 Signal contribution.
 
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCBeambkgTag
 Beambackground tag.
 
int m_SaveTCWaveForm = 0
 Flag of waveform table.
 
double m_WaveForm [c_NTC][c_NSamplingDigi01] = {{0.}}
 TC Energy converted from Xtarl Energy [GeV].
 
int m_FADC = 1
 Flag of choosing the method of waveform generation function 0: use simplifiedFADC, 1: use interFADC(interpolation)
 
int m_BeambkgTag = 0
 Flag of saving beam background tag or not.
 
int m_sourceOfTC = 0
 Which TC source to use.
 
std::array< float, c_NSamplingDigi01 > m_noisePileup = {0.}
 Noise from pileup.
 
std::array< float, c_NSamplingDigi01 > m_noiseParallel = {0.}
 Noise from parallel.
 
std::array< float, c_NSamplingDigi01 > m_noiseSerial = {0.}
 Noise from serial.
 
std::array< float, c_NSamplingDigi01 > m_Xpr = {0.}
 Random parallel noise.
 
std::array< float, c_NSamplingDigi01 > m_Xsr = {0.}
 Random serial noise.
 

Static Private Attributes

static constexpr int c_NTC = 576
 Number of ECL TriggerCells (TC)
 
static constexpr int c_NSamplingDigi01 = 64
 Numer of sampling points for digitizer01.
 
static constexpr int c_NSamplingDigi02 = 666
 Numer of sampling points for digitizer02.
 
static constexpr int c_nTimeBins = 80
 Numer of time bins.
 
static constexpr int c_nECLCrystals = 8736
 Numer of time bins.
 
static constexpr std::array< double, 245 > m_SignalAmp
 Normalised FADC signal shape, sampled every 12 ns from 0 to 2928 ns.
 

Detailed Description

FAM module.

Definition at line 26 of file TrgEclDigitizer.h.

Constructor & Destructor Documentation

◆ TrgEclDigitizer()

Constructor.

Definition at line 32 of file TrgEclDigitizer.cc.

33{
34 initialize();
35}
void initialize()
Initialize the class.

◆ ~TrgEclDigitizer()

~TrgEclDigitizer ( )
virtual

Destructor.

Definition at line 39 of file TrgEclDigitizer.cc.

40{
41 delete m_TCMap;
42 delete m_DataBase;
43}
TrgEclDataBase * m_DataBase
Object of DataBase.
TrgEclMapping * m_TCMap
Object of TC Mapping.

Member Function Documentation

◆ clear()

void clear ( )

Clear all the data fields.

Definition at line 63 of file TrgEclDigitizer.cc.

64{
65 m_TCEnergy_tot.fill(0.);
66 m_TCTiming_tot.fill(0.);
67 for (uint i = 0; i < c_NTC; i++) {
68 m_TCEnergy[i].fill(0.);
69 m_TCTiming[i].fill(0.);
70 m_TCBkgContribution[i].fill(0.);
71 m_TCSigContribution[i].fill(0.);
72 m_TCBeambkgTag[i].fill(0.);
73 m_TCRawEnergy[i].fill(0.);
74 m_TCRawTiming[i].fill(0.);
75 m_TCRawBkgTag[i].fill(0.);
76 for (uint j = 0; j < 64; j++) {
77 m_WaveForm[i][j] = 0.;
78 }
79 }
80}
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCEnergy
TC Energy converted from Xtarl Energy [GeV].
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCBkgContribution
Beambackground contribution.
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCTiming
TC Timing converted from Xtarl Timing [GeV].
static constexpr int c_NTC
Number of ECL TriggerCells (TC)
double m_WaveForm[c_NTC][c_NSamplingDigi01]
TC Energy converted from Xtarl Energy [GeV].
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCSigContribution
Signal contribution.
std::array< std::array< double, c_nTimeBins >, c_NTC > m_TCBeambkgTag
Beambackground tag.
std::array< std::array< double, 60 >, c_NTC > m_TCRawBkgTag
Input Beambackground tag.
std::array< double, c_NTC > m_TCEnergy_tot
TC Energy converted from Xtarl Energy [GeV].
std::array< std::array< double, 60 >, c_NTC > m_TCRawTiming
Input TC timing[ns].
std::array< std::array< double, 60 >, c_NTC > m_TCRawEnergy
Input TC energy[GeV].
std::array< double, c_NTC > m_TCTiming_tot
TC Timing converted from Xtarl Timing [GeV].

◆ digitization01()

void digitization01 ( std::vector< std::vector< double > > & TCDigiE,
std::vector< std::vector< double > > & TCDigiT )

fit method, digi with 125ns interval

Definition at line 313 of file TrgEclDigitizer.cc.

315{
316 for (uint i = 0; i < c_NTC; i++) {
317 TCDigiE[i].assign(c_NSamplingDigi01, 0);
318 TCDigiT[i].assign(c_NSamplingDigi01, 0);
319 }
320
321 //
322 static constexpr double cut_energy_tot = 0.03; // [GeV]
323 static constexpr int nbin_pedestal = 4; // = nbin_pedestal*fam_sampling_interval [ns] in total
324 static constexpr double fam_sampling_interval = 125; // [ns]
325
326
327 // (Make sampling time random between FAM sampling intervals)
328 const double random_sampling_correction = gRandom->Rndm() * fam_sampling_interval; // [ns]
329 //==================
330 // (01)Signal digitization
331 //==================
332
333 // This is for the noise embedding step below, but can already be filled here to save time
334 std::bitset<c_NTC> hasEnergy;
335 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
336 for (int iTimeBin = 0; iTimeBin < c_nTimeBins; iTimeBin++) {
337
338 if (m_TCEnergy[iTCIdm][iTimeBin] >= 1e-9) {
339 hasEnergy[iTCIdm] = true;
340 }
341 if (m_TCEnergy[iTCIdm][iTimeBin] < 0.0001) {
342 continue;
343 } // 0.1MeV cut on TC bin_energy
344 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
345 // inputTiming is in [us] <-- Be careful, here is NOT [ns]
346 double inputTiming
347 = (-m_TCTiming[iTCIdm][iTimeBin] - m_TimeRange + (-nbin_pedestal + iSampling) * fam_sampling_interval) * 0.001;
348 inputTiming += random_sampling_correction * 0.001;
349 if (inputTiming < 0 || inputTiming > 2.0) {continue;} // Shaping in t0 ~t0+ 2.0 us
350 if (m_FADC == 1) {
351
352 TCDigiE[iTCIdm][iSampling] += interFADC(inputTiming) * m_TCEnergy[iTCIdm][iTimeBin];
353 } else {
354 TCDigiE[iTCIdm][iSampling] += SimplifiedFADC(0, inputTiming) * m_TCEnergy[iTCIdm][iTimeBin];
355 }
356 }
357
358 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
359 TCDigiT[iTCIdm][iSampling] = (-nbin_pedestal + iSampling - m_TimeRange / fam_sampling_interval) * fam_sampling_interval +
360 random_sampling_correction;
361 }
362 }
363 }
364
365
366 if (0) {
367 FILE* f_out_dat = fopen("ztsim.no_noise.dat", "w");
368 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
369 if (m_TCEnergy_tot[iTCIdm] < cut_energy_tot) { continue; } // TC energy_tot cut
370 fprintf(f_out_dat, "%5i %8.5f %8.5f %8.1f ",
371 iTCIdm + 1, m_TCEnergy_tot[iTCIdm], m_TCEnergy[iTCIdm][0], TCDigiT[iTCIdm][0]);
372 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
373 fprintf(f_out_dat, "%7.4f ", TCDigiE[iTCIdm][iSampling]);
374 }
375 fprintf(f_out_dat, "\n");
376 }
377 fclose(f_out_dat);
378 }
379 //==================
380 // (01)noise embedding
381 //==================
382 static constexpr double tmin_noise = -4; // original
383 static constexpr double tgen = 10.3; // original
384 static constexpr int bkg_level = 1030;
385 double ttt0 = 0; // [us]
386 /* cppcheck-suppress variableScope */
387 double ttt1 = 0; // [us]
388 /* cppcheck-suppress variableScope */
389 double ttt2 = 0; // [us]
390 //
391 static constexpr double frac_pileup = 0.035; // pileup noise fraction?
392 static constexpr double frac_parallel = 0.023; // parallel noise fraction?
393 static constexpr double frac_serial = 0.055; // serial noise fraction?
394 static constexpr double times_pileup = 1; // noise scale based on Belle noise.
395 static constexpr double times_parallel = 3.15; // noise scale
396 static constexpr double times_serial = 3.15; // noise scale
397
398 const double sqrTerm = std::sqrt(fam_sampling_interval * 0.001);
399 const double corr_pileup = times_pileup * frac_pileup * sqrTerm;
400 const double corr_parallel = times_parallel * frac_parallel * sqrTerm;
401 const double corr_serial = times_serial * frac_serial * sqrTerm;
402 const double parallelNoiseCorrection = 10 * corr_parallel;
403 const double serialNoiseCorrection = 10 * corr_serial;
404
405
406 if (0) {
407 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
408 if (m_TCEnergy_tot[iTCIdm] < cut_energy_tot) { continue; } // TC energy_tot cut
409 for (int jjj = 0; jjj < bkg_level; jjj++) {
410 ttt0 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
411 ttt1 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
412 ttt2 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
413 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
414 // (pile-up noise)
415 if (ttt0 > 0) { TCDigiE[iTCIdm][iSampling] += SimplifiedFADC(0, ttt0) * corr_pileup * 0.001; }
416 // (parallel noise)
417 if (ttt1 > 0) { TCDigiE[iTCIdm][iSampling] += SimplifiedFADC(1, ttt1) * corr_parallel; }
418 // (serial noise)
419 if (ttt2 > 0) { TCDigiE[iTCIdm][iSampling] += SimplifiedFADC(2, ttt2) * corr_serial; }
420 ttt0 += fam_sampling_interval * 0.001;
421 ttt1 += fam_sampling_interval * 0.001;
422 ttt2 += fam_sampling_interval * 0.001;
423 }
424 }
425 }
426 }
427 if (1) { //use L Matrix
428 // A TC with no deposited energy in any time bin receives no signal
429 // contribution at all, so noise alone cannot bring it over the fit
430 // threshold. Note m_TCEnergy_tot covers only bins 40-49 and so must NOT
431 // be used here: a real signal arriving just before t=0 falls in bin 39.
432 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
433
434 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
435 m_Xpr[iSampling] = gRandom ->Gaus(0, 1);
436 m_Xsr[iSampling] = gRandom ->Gaus(0, 1);
437 }
438
439 // drawn for every TC above, so the random sequence is left untouched
440 if (!hasEnergy[iTCIdm]) { continue; }
441
442 m_noisePileup.fill(0.);
443 m_noiseParallel.fill(0.);
444 m_noiseSerial.fill(0.);
445 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
446 double parallelNoiseTerm = 0., serialNoiseTerm = 0.;
447 for (int jSampling = 0; jSampling < c_NSamplingDigi01; jSampling++) {
448 parallelNoiseTerm += parallelNoiseCorrection * m_MatrixParallel[iSampling][jSampling] * m_Xpr[jSampling];
449 serialNoiseTerm += serialNoiseCorrection * m_MatrixSerial[iSampling][jSampling] * m_Xsr[jSampling];
450 }
451 m_noiseParallel[iSampling] += parallelNoiseTerm;
452 m_noiseSerial[iSampling] += serialNoiseTerm;
453 }
454
455 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
456 TCDigiE[iTCIdm][iSampling] += m_noisePileup[iSampling] + m_noiseParallel[iSampling] + m_noiseSerial[iSampling];
457 }
458 }
459 if (0) {
460 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) { //Only Pile-up noise use old method.
461 if (m_TCEnergy_tot[iTCIdm] < cut_energy_tot) { continue; } // TC energy_tot cut
462 for (int jjj = 0; jjj < bkg_level; jjj++) {
463 ttt0 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
464 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
465 // (pile-up noise)
466 if (ttt0 > 0) { TCDigiE[iTCIdm][iSampling] += SimplifiedFADC(0, ttt0) * corr_pileup * 0.001; }
467 ttt0 += fam_sampling_interval * 0.001;
468 }
469 }
470 }
471 }
472 }
473
474 if (m_SaveTCWaveForm == 1) {
475
476 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
477 for (int iSampling = 0; iSampling < c_NSamplingDigi01; iSampling++) {
478 m_WaveForm[iTCIdm][iSampling] = TCDigiE[iTCIdm][iSampling];
479 }
480
481 }
482 }
483
484}
std::array< float, c_NSamplingDigi01 > m_Xpr
Random parallel noise.
std::array< std::array< double, 64 >, 64 > m_MatrixParallel
Noise Matrix of Parallel and Serial Noise.
static constexpr int c_nTimeBins
Numer of time bins.
std::array< float, c_NSamplingDigi01 > m_noiseParallel
Noise from parallel.
std::array< float, c_NSamplingDigi01 > m_Xsr
Random serial noise.
int m_SaveTCWaveForm
Flag of waveform table.
std::array< std::array< double, 64 >, 64 > m_MatrixSerial
Noise Low triangle Matrix of Serial noise.
double interFADC(double)
Faster FADC using interpolation.
std::array< float, c_NSamplingDigi01 > m_noiseSerial
Noise from serial.
double SimplifiedFADC(int, double)
FADC.
std::array< float, c_NSamplingDigi01 > m_noisePileup
Noise from pileup.
int m_FADC
Flag of choosing the method of waveform generation function 0: use simplifiedFADC,...
double m_TimeRange
time range(default : -4000 ~ 4000 ns )
static constexpr int c_NSamplingDigi01
Numer of sampling points for digitizer01.

◆ digitization02()

void digitization02 ( std::vector< std::vector< double > > & TCDigiE,
std::vector< std::vector< double > > & TCDigiT )

original no fit method, digi with 12ns interval

Definition at line 486 of file TrgEclDigitizer.cc.

487{
488 //===============
489 // (03)Signal digitization (w/ 12ns interval for method-0)
490 //===============
491 for (uint i = 0; i < c_NTC; i++) {
492 TCDigiE[i].assign(c_NSamplingDigi02, 0);
493 TCDigiT[i].assign(c_NSamplingDigi02, 0);
494 }
495 double cut_energy_tot = 0.03; // [GeV]
496 int nbin_pedestal = 100;
497 float fam_sampling_interval = 12; // [ns]
498
499 std::vector< std::vector<float> > TCDigiEnergy(c_NTC, std::vector<float>(c_NSamplingDigi02, 0.0)); // [GeV]
500 std::vector< std::vector<float> > TCDigiTiming(c_NTC, std::vector<float>(c_NSamplingDigi02, 0.0)); // [ns]
501
502 // Make sampling time random between FAM sampling intervals
503 float random_sampling_correction = 0; // [ns]
504 random_sampling_correction = gRandom->Rndm() * fam_sampling_interval;
505 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
506 if (m_TCEnergy_tot[iTCIdm] < cut_energy_tot) {continue;} // TC energy_tot cut
507 for (int iTimeBin = 0; iTimeBin < c_nTimeBins; iTimeBin++) {
508 if (m_TCEnergy[iTCIdm][iTimeBin] < 0.0001) { continue; } // 0.1 MeV cut on TC bin_energy
509 for (int iSampling = 0; iSampling < c_NSamplingDigi02; iSampling++) {
510 // inputTiming is in [us] <-- Be careful, here is NOT [ns]
511 float inputTiming
512 = (-m_TCTiming[iTCIdm][iTimeBin] - m_TimeRange + (-nbin_pedestal + iSampling) * fam_sampling_interval) * 0.001;
513
514 inputTiming += random_sampling_correction * 0.001;
515 if (inputTiming < 0 || inputTiming > 2.0) {continue;} // Shaping in t0 ~t0+ 2.0 us
516
517 TCDigiEnergy[iTCIdm][iSampling] += FADC(0, inputTiming) * m_TCEnergy[iTCIdm][iTimeBin];
518 }
519 }
520 for (int iSampling = 0; iSampling < c_NSamplingDigi02; iSampling++) {
521 TCDigiTiming[iTCIdm][iSampling] = (-nbin_pedestal + iSampling - m_TimeRange / fam_sampling_interval) * fam_sampling_interval;
522 TCDigiTiming[iTCIdm][iSampling] += random_sampling_correction;
523 }
524 }
525 //==================
526 // (03)noise embedding
527 //==================
528
529 double tmin_noise = -4; // original
530 double tgen = 10.3; //
531 int bkg_level = 1030;
532 double ttt0 = 0; // [us]
533 double ttt1 = 0; // [us]
534 double ttt2 = 0; // [us]
535 //double frac_pileup = 0.035; // pileup noise fraction?
536 //double frac_parallel = 0.023; // parallel noise fraction?
537 //double frac_serial = 0.055; // serial noise fraction?
538 //double times_pileup = 1; // noise scale based on Belle noise.
539 //double times_parallel = 1; // noise scale
540 //double times_serial = 1; // noise scale
541 //double corr_pileup = times_pileup * frac_pileup * sqrt(fam_sampling_interval * 0.001);
542 //double corr_parallel = times_parallel * frac_parallel * sqrt(fam_sampling_interval * 0.001);
543 //double corr_serial = times_serial * frac_serial * sqrt(fam_sampling_interval * 0.001);
544 double corr_pileup = 0.011068;
545 double corr_parallel = 0.00727324;
546 double corr_serial = 0.0173925;
547
548
549 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
550 if (m_TCEnergy_tot[iTCIdm] < cut_energy_tot) { continue; } // 1 MeV TC energy cut
551 for (int jjj = 0; jjj < bkg_level; jjj++) {
552 ttt0 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
553 ttt1 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
554 ttt2 = -(tmin_noise + tgen * gRandom->Rndm()); // [us]
555 for (int iSampling = 0; iSampling < c_NSamplingDigi02; iSampling++) {
556 // (pile-up noise)
557 if (ttt0 > 0) { TCDigiEnergy[iTCIdm][iSampling] += FADC(0, ttt0) * corr_pileup * 0.001; }
558 // (parallel noise)
559 if (ttt1 > 0) { TCDigiEnergy[iTCIdm][iSampling] += FADC(1, ttt1) * corr_parallel; }
560 // (serial noise)
561 if (ttt2 > 0) { TCDigiEnergy[iTCIdm][iSampling] += FADC(2, ttt2) * corr_serial; }
562 ttt0 += fam_sampling_interval * 0.001;
563 ttt1 += fam_sampling_interval * 0.001;
564 ttt2 += fam_sampling_interval * 0.001;
565 }
566 }
567 }
568
569}
static constexpr int c_NSamplingDigi02
Numer of sampling points for digitizer02.
double FADC(int, double)
FADC.

◆ FADC()

double FADC ( int flag_gen,
double timing )

FADC.

Definition at line 644 of file TrgEclDigitizer.cc.

646{
647
648 //--------------------------------------
649 //
650 // o "timing" unit is [us]
651 // o flag_gen = 0(=signal), 1(=parallel), 2(=serial)
652 // o return value(PDF) is [GeV]
653 //
654 //--------------------------------------
655 double tsh, dd;
656 static double tc, tc2, tsc, tris, b1, b2;
657 static double amp, dft, as;
658 static double td, t1, t2;
659
660 static int ifir = 0;
661
662 if (ifir == 0) {
663
664 td = 0.10; // diff time ( 0.10)
665 t1 = 0.10; // integ1 real ( 0.10)
666 b1 = 30.90; // integ1 imag ( 30.90)
667 t2 = 0.01; // integ2 real ( 0.01)
668 b2 = 30.01; // integ2 imag ( 30.01)
669 double ts = 1.00; // scint decay ( 1.00)
670 dft = 0.600; // diff delay ( 0.600)
671 as = 0.548; // diff frac ( 0.548)
672 //
673 amp = 1.0;
674 tris = 0.01;
675 tsc = ts;
676 //
677 int im = 0;
678 int ij = 0;
679 int fm = 0;
680 tc = 0;
681 double tt = u_max(u_max(td, t1), u_max(t2, ts)) * 2;
682 int flag_once = 0;
683 while (flag_once == 0) {
684 double dt = tt / 1000;
685 double tm = 0;
686 for (int j = 1; j <= 1000; j++) {
687 tc2 = tc - dft;
688 double fff =
689 (ShapeF(tc, t1, b1, t2, b2, td, tsc) -
690 ShapeF(tc, t1, b1, t2, b2, td, tris) * 0.01) -
691 (ShapeF(tc2, t1, b1, t2, b2, td, tsc) -
692 ShapeF(tc2, t1, b1, t2, b2, td, tris) * 0.01) * as;
693 if (fff > fm) {
694 fm = fff;
695 tm = tc;
696 im = j;
697 }
698 tc = tc + dt;
699 }
700 if (im >= 1000) {
701 tt = 2 * tt;
702 flag_once = 0;
703 continue;
704 }
705 if (ij == 0) {
706 ij = 1;
707 tc = 0.99 * tm;
708 dt = tm * 0.02 / 1000;
709 flag_once = 0;
710 continue;
711 }
712 flag_once = 1;
713 }
714 amp = 1.0 / fm;
715 ifir = 1;
716 }
717 //
718 //
719 double pdf = 0;
720 if (flag_gen == 0) {
721 //-----<signal>
722 tc2 = timing - dft;
723 pdf = amp * (
724 (ShapeF(timing, t1, b1, t2, b2, td, tsc) -
725 ShapeF(timing, t1, b1, t2, b2, td, tris) * 0.01) -
726 (ShapeF(tc2, t1, b1, t2, b2, td, tsc) -
727 ShapeF(tc2, t1, b1, t2, b2, td, tris) * 0.01) * as);
728 } else if (flag_gen == 1) {
729 //-----<parallel>
730 tc2 = timing - dft;
731 tsh = 0.001;
732 pdf = amp * (
733 ShapeF(timing, t1, b1, t2, b2, td, tsh) -
734 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as);
735 pdf = pdf * 0.001; // GeV
736 } else {
737 //-----<serial>
738 tc2 = timing - dft;
739 tsh = 0.001;
740 pdf = amp * (
741 ShapeF(timing, t1, b1, t2, b2, td, tsh) -
742 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as);
743 //
744 tc = timing - 0.01;
745 if (tc < 0) { tc = 0; }
746 dd = timing - tc;
747 tc2 = tc - dft;
748 pdf = (amp * (
749 ShapeF(tc, t1, b1, t2, b2, td, tsh) -
750 ShapeF(tc2, t1, b1, t2, b2, td, tsh) * as) - pdf) / dd;
751 pdf = pdf * 0.001; // GeV
752 }
753
754 return pdf;
755}
double u_max(double, double)
Find max value between 2 vals;.
double ShapeF(double, double, double, double, double, double, double)
return shape using FADC function

◆ getTCHit()

void getTCHit ( )

get TC Hits from Xtal hits Set TC data m_sourceOfTC => 1=ECLHit, 2=ECLSimHit, 3=ECLHit+TRGECLBGTCHit ("1:=ECLHit" is used for signal w/o bkg, and real time background monitor)

Definition at line 86 of file TrgEclDigitizer.cc.

87{
88
89 //-------------------------------------------------------------------
90 // read Xtal data
91 //---------------------------------------------------------------------
92 if (m_sourceOfTC == 1) { // read ECLHit table
93
94 // only needed to resolve the dominant background tag below
95 std::vector< std::vector<float> > E_cell(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
96 std::vector< std::vector<float> > beambkg_tag(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
97
98 StoreArray<ECLHit> eclHitArray("ECLHits");
99
100 int nHits_hit = eclHitArray.getEntries();
101 //
102 for (int iHits = 0; iHits < nHits_hit; iHits++) {
103 // Get a hit
104 ECLHit* aECLHit = eclHitArray[iHits];
105 int beambkg = aECLHit->getBackgroundTag();
106
107 // Hit geom. info
108 int hitCellId = aECLHit->getCellId() - 1;
109 float hitE = aECLHit->getEnergyDep() / Unit::GeV;
110 float aveT = aECLHit->getTimeAve(); // ns :time from IP to PD
111 if (aveT < - m_TimeRange || aveT > m_TimeRange) {continue;} //Choose - TimeRange ~ TimeTange
112 int TimeIndex = (int)((aveT + m_TimeRange) / 100); //Binning : -4000 = 1st bin ~ 4000 c_nTimeBinsth bin.
113
114 int iTCIdm = m_TCMap->getTCIdFromXtalId(hitCellId + 1) - 1;
115 m_TCEnergy[iTCIdm][TimeIndex] += hitE;
116 m_TCTiming[iTCIdm][TimeIndex] += hitE * aveT;
117 if (beambkg > 0) {m_TCBkgContribution[iTCIdm][TimeIndex] += hitE ;}
118 else if (beambkg == 0) {m_TCSigContribution[iTCIdm][TimeIndex] += hitE;}
119
120 }
121 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
122 for (int iTime = 0; iTime < c_nTimeBins; iTime++) {
123
124 if (m_TCEnergy[iTCIdm][iTime] < 1e-9) {continue;}// 0.01MeV cut
125 /* cppcheck-suppress variableScope */
126 double maxbkgE = 0;
127 /* cppcheck-suppress variableScope */
128 int maxbkgtag = 0;
129 m_TCTiming[iTCIdm][iTime] /= m_TCEnergy[iTCIdm][iTime];
130 if (m_BeambkgTag == 1) {
131 if (m_TCBkgContribution[iTCIdm][iTime] < m_TCSigContribution[iTCIdm][iTime]) {
132 m_TCBeambkgTag[iTCIdm][iTime] = 0; //signal Tag : 0
133 } else {
134 for (int iXtalIdm = 0; iXtalIdm < c_nECLCrystals; iXtalIdm++) {
135 int iTCId = m_TCMap->getTCIdFromXtalId(iXtalIdm + 1) - 1;
136 if (iTCIdm != iTCId) {continue;}
137 if (maxbkgE < E_cell[iXtalIdm][iTime]) {
138 maxbkgE = E_cell[iXtalIdm][iTime];
139 maxbkgtag = beambkg_tag[iXtalIdm][iTime];
140 }
141 }
142 m_TCBeambkgTag[iTCIdm][iTime] = maxbkgtag;
143 }
144 }
145 }
146 }
147 }
148
149
150 if (m_sourceOfTC == 2) { // read ECLSimHit
151 std::vector< std::vector<float> > E_cell(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
152 std::vector< std::vector<float> > T_ave(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
153 std::vector< std::vector<float> > Tof_ave(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
154 std::vector< std::vector<float> > beambkg_tag(c_nECLCrystals, std::vector<float>(c_nTimeBins, 0.0));
155
156 ECL::ECLGeometryPar* eclp = ECL::ECLGeometryPar::Instance();
157 //=====================
158 // Loop over all hits of steps
159 //=====================
160 StoreArray<ECLSimHit> eclArray("ECLSimHits");
161 int nHits = eclArray.getEntries();
162 //
163 for (int iHits = 0; iHits < nHits; iHits++) {
164 // Get a hit
165 ECLSimHit* aECLSimHit = eclArray[iHits];
166
167 int hitCellId = aECLSimHit->getCellId() - 1;
168 float hitE = aECLSimHit->getEnergyDep() / Unit::GeV;
169 float hitTOF = aECLSimHit->getFlightTime() / Unit::ns;
170
171 G4ThreeVector t = aECLSimHit->getPosIn(); // [cm], Hit position in Xtal (based on from IP)
172 ROOT::Math::XYZVector HitInPos(t.x(), t.y(), t.z()); // = aECLSimHit->getPosIn(); // [cm], Hit position in Xtal (based on from IP)
173 ROOT::Math::XYZVector PosCell = eclp->GetCrystalPos(hitCellId);// [cm], Xtal position (based on from IP)
174 ROOT::Math::XYZVector VecCell = eclp->GetCrystalVec(hitCellId);
175 float local_pos_r = 15.0 - (HitInPos - PosCell).Dot(VecCell);
176 if (hitTOF < - m_TimeRange || hitTOF > m_TimeRange) {continue;}
177 int TimeIndex = (int)((hitTOF + m_TimeRange) / 100);
178 E_cell[hitCellId][TimeIndex] = E_cell[hitCellId][TimeIndex] + hitE;
179 T_ave[hitCellId][TimeIndex] = T_ave[hitCellId][TimeIndex] + hitE * local_pos_r;
180 Tof_ave[hitCellId][TimeIndex] = Tof_ave[hitCellId][TimeIndex] + hitE * hitTOF;
181 }
182 //
183 //
184 //
185 //===============
186 // Xtal energy and timing (0-8us, 0.2us interval, 40 bins)
187 //===============
188 for (int iECLCell = 0; iECLCell < c_nECLCrystals; iECLCell++) {
189 for (int TimeIndex = 0; TimeIndex < c_nTimeBins; TimeIndex++) {
190
191 if (E_cell[iECLCell][TimeIndex] < 1e-9) {continue;} // 0.01MeV cut
192
193 T_ave[iECLCell][TimeIndex] = T_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex];
194 T_ave[iECLCell][TimeIndex] =
195 6.05 +
196 0.0749 * T_ave[iECLCell][TimeIndex] -
197 0.00112 * T_ave[iECLCell][TimeIndex] * T_ave[iECLCell][TimeIndex];
198 Tof_ave[iECLCell][TimeIndex] = Tof_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex];
199
200 } // 40bins, Time interval = 200ns
201 }
202 //
203 //
204 //
205 for (int iXtalIdm = 0; iXtalIdm < c_nECLCrystals; iXtalIdm++) {
206 int iTCIdm = m_TCMap->getTCIdFromXtalId(iXtalIdm + 1) - 1;
207 for (int iTime = 0; iTime < c_nTimeBins; iTime++) {
208
209 if (E_cell[iXtalIdm][iTime] < 1e-9) {continue;} // 0.01MeV cut
210 m_TCEnergy[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];
211 m_TCTiming[iTCIdm][iTime] += E_cell[iXtalIdm][iTime] * (T_ave[iXtalIdm][iTime]);
212 if (beambkg_tag[iXtalIdm][iTime] > 0) {m_TCBkgContribution[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];}
213 if (beambkg_tag[iXtalIdm][iTime] == 0) {m_TCSigContribution[iTCIdm][iTime] += E_cell[iXtalIdm][iTime];}
214
215 }
216 }
217 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
218 for (int iTime = 0; iTime < c_nTimeBins; iTime++) {
219 /* cppcheck-suppress variableScope */
220 double maxbkgE = 0;
221 /* cppcheck-suppress variableScope */
222 int maxbkgtag = 0;
223
224 if (m_TCEnergy[iTCIdm][iTime] < 1e-9) {continue;} // 0.01MeV cut
225 m_TCTiming[iTCIdm][iTime] /= m_TCEnergy[iTCIdm][iTime];
226 if (m_BeambkgTag == 1) {
227 if (m_TCBkgContribution[iTCIdm][iTime] < m_TCSigContribution[iTCIdm][iTime]) {
228 m_TCBeambkgTag[iTCIdm][iTime] = 0; //signal Tag : 0
229 } else {
230 for (int iXtalIdm = 0; iXtalIdm < c_nECLCrystals; iXtalIdm++) {
231 int iTCId = m_TCMap->getTCIdFromXtalId(iXtalIdm + 1) - 1;
232 if (iTCIdm != iTCId) {continue;}
233 if (maxbkgE < E_cell[iXtalIdm][iTime]) {
234 maxbkgE = E_cell[iXtalIdm][iTime];
235 maxbkgtag = beambkg_tag[iXtalIdm][iTime];
236 }
237 }
238 m_TCBeambkgTag[iTCIdm][iTime] = maxbkgtag;
239 }
240 }
241 }
242
243 }
244
245 }
246 //--------------------------------------------------------
247 //
248 //--------------------------------------------------------
249 if (m_sourceOfTC == 3) {
250
251 StoreArray<ECLHit> eclHitArray("ECLHits");
252
253 int nHits_hit = eclHitArray.getEntries();
254 // signal hit
255 for (int iHits = 0; iHits < nHits_hit; iHits++) {
256 // Get a hit
257 ECLHit* aECLHit = eclHitArray[iHits];
258 // Hit geom. info
259 int hitCellId = aECLHit->getCellId() - 1;
260 float hitE = aECLHit->getEnergyDep() / Unit::GeV;
261 float aveT = aECLHit->getTimeAve(); // ns :time from IP to PD
262 // Choose - TimeRange ~ TimeTange
263 if (aveT < - m_TimeRange || aveT > m_TimeRange) {continue;}
264 // Binning : -4000 = 1st bin ~ 4000 c_nTimeBinsth bin.
265 int TimeIndex = (int)((aveT + m_TimeRange) / 100);
266
267 int iTCIdm = m_TCMap->getTCIdFromXtalId(hitCellId + 1) - 1;
268 m_TCEnergy[iTCIdm][TimeIndex] += hitE;
269 m_TCTiming[iTCIdm][TimeIndex] += hitE * aveT;
270 }
271 // background hit
272 StoreArray<TRGECLBGTCHit> m_trgeclBGTCHits("TRGECLBGTCHits_beamBG");
273 for (const TRGECLBGTCHit& ttt : m_trgeclBGTCHits) {
274 // TC timing
275 double tcbg_t = ttt.getTimeAve();
276 // Timing cut
277 if (abs(tcbg_t) > m_TimeRange) continue;
278 //Binning : -4000 = 1st bin ~ 4000 c_nTimeBinsth bin.
279 int TimeIndex = (int)((tcbg_t + m_TimeRange) / 100);
280 // TC energy
281 double tcbg_e = ttt.getEnergyDep();
282 // TC ID index
283 int iTCIdm = ttt.getTCId() - 1;
284 // TC energy and timing
285 double tc_e = m_TCEnergy[iTCIdm][TimeIndex];
286 double tc_t = m_TCTiming[iTCIdm][TimeIndex];
287 m_TCEnergy[iTCIdm][TimeIndex] += tcbg_e;
288 m_TCTiming[iTCIdm][TimeIndex] += (tcbg_e * tcbg_t + tc_e * tc_t);
289 }
290 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
291 for (int iTime = 0; iTime < c_nTimeBins; iTime++) {
292 m_TCTiming[iTCIdm][iTime] /= m_TCEnergy[iTCIdm][iTime];
293 }
294 }
295 }
296 //--------------------------
297 // TC energy and timing in t=0-1us as true values.
298 //--------------------------
299 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
300 for (int iTime = 40; iTime < 50; iTime++) {
301 m_TCEnergy_tot[iTCIdm] += m_TCEnergy[iTCIdm][iTime];
302 m_TCTiming_tot[iTCIdm] += m_TCTiming[iTCIdm][iTime] * m_TCEnergy[iTCIdm][iTime];
303 }
304 m_TCTiming_tot[iTCIdm] /= m_TCEnergy_tot[iTCIdm];
305 }
306
307 return;
308}
double getTimeAve() const
Get average time.
Definition ECLHit.h:75
int getCellId() const
Get Cell ID.
Definition ECLHit.h:65
double getEnergyDep() const
Get deposit energy.
Definition ECLHit.h:70
int getCellId() const
Get Cell ID.
Definition ECLSimHit.h:86
double getFlightTime() const
Get Flight time from IP.
Definition ECLSimHit.h:101
double getEnergyDep() const
Get Deposit energy.
Definition ECLSimHit.h:106
G4ThreeVector getPosIn() const
Get Position.
Definition ECLSimHit.h:121
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.
Definition SimHitBase.h:46
static constexpr int c_nECLCrystals
Numer of time bins.
int m_BeambkgTag
Flag of saving beam background tag or not.
int m_sourceOfTC
Which TC source to use.
static const double ns
Standard of [time].
Definition Unit.h:48
static const double GeV
Standard of [energy, momentum, mass].
Definition Unit.h:51

◆ initialize()

void initialize ( )

Initialize the class.

Definition at line 49 of file TrgEclDigitizer.cc.

50{
51 clear();
52
53 delete m_TCMap;
54 delete m_DataBase;
55 m_TCMap = new TrgEclMapping();
56 m_DataBase = new TrgEclDataBase();
57
58 // prepare Matrix for Noise generation
59 m_DataBase->readNoiseLMatrix(m_MatrixParallel, m_MatrixSerial);
60}
void clear()
Clear all the data fields.

◆ interFADC()

double interFADC ( double timing)

Faster FADC using interpolation.

Definition at line 616 of file TrgEclDigitizer.cc.

617{
618 timing = timing * 1000;
619
620 double E_out = 0;
621
622 // m_SignalAmp is sampled every 12 ns up to 2928 ns; nothing to interpolate
623 // outside that range. Excluding the upper edge also keeps endbin in range.
624 if (timing < 0 || timing >= 12.0 * (m_SignalAmp.size() - 1)) {return E_out;}
625
626 const int startbin = (int)(timing) / 12;
627 const int endbin = startbin + 1;
628 // the sampling times are exactly 12 ns * index, so no lookup table is needed
629 const double starttime = 12.0 * startbin;
630 const double endtime = 12.0 * endbin;
631
632 if (timing > starttime) {
633 E_out = ((m_SignalAmp[endbin] - m_SignalAmp[startbin]) / (endtime - starttime)) *
634 (timing - starttime) + m_SignalAmp[startbin];
635 }
636
637 return E_out;
638
639}
static constexpr std::array< double, 245 > m_SignalAmp
Normalised FADC signal shape, sampled every 12 ns from 0 to 2928 ns.

◆ save()

void save ( int m_nEvent)

save fitting result into tables

Definition at line 574 of file TrgEclDigitizer.cc.

575{
576 //---------------
577 // Root Output
578 //---------------
579 int m_hitNum = 0;
580 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
581 for (int iBinTime = 0; iBinTime < c_nTimeBins; iBinTime++) {
582 if (m_TCEnergy[iTCIdm][iBinTime] < 0.001) {continue;}
583 StoreArray<TRGECLDigi0> TCDigiArray;
584 TCDigiArray.appendNew();
585 m_hitNum = TCDigiArray.getEntries() - 1;
586
587 TCDigiArray[m_hitNum]->setEventId(m_nEvent);
588 TCDigiArray[m_hitNum]->setTCId(iTCIdm + 1);
589 TCDigiArray[m_hitNum]->setiBinTime(iBinTime);
590 TCDigiArray[m_hitNum]->setRawEnergy(m_TCEnergy[iTCIdm][iBinTime]);
591 TCDigiArray[m_hitNum]->setRawTiming(m_TCTiming[iTCIdm][iBinTime]);
592 TCDigiArray[m_hitNum]->setBeamBkgTag(m_TCBeambkgTag[iTCIdm][iBinTime]);
593 }
594 }
595
596 if (m_SaveTCWaveForm == 1) {
597 StoreArray<TRGECLWaveform> TCWaveformArray;
598 for (int iTCIdm = 0; iTCIdm < c_NTC; iTCIdm++) {
599 if (iTCIdm == c_nTimeBins) iTCIdm = 512; // skip barrel
600 int tc_phi_id = m_TCMap->getTCPhiIdFromTCId(iTCIdm + 1);
601 int tc_theta_id = m_TCMap->getTCThetaIdFromTCId(iTCIdm + 1);
602 TRGECLWaveform* newWf =
603 TCWaveformArray.appendNew(iTCIdm + 1, m_WaveForm[iTCIdm]);
604 newWf->setThetaPhiIDs(tc_theta_id, tc_phi_id);
605 }
606
607 }
608
609
610 return;
611}
T * appendNew()
Construct a new T object at the end of the array.
Definition StoreArray.h:247
int getEntries() const
Get the number of objects in the array.
Definition StoreArray.h:216
void setThetaPhiIDs(int thid, int phid)
Set Theta and Phi Id of TC.

◆ setFADC()

void setFADC ( int fadc)
inline

Set flag of waveform table.

Definition at line 54 of file TrgEclDigitizer.h.

54{ m_FADC = fadc;}

◆ setSourceOfTC()

void setSourceOfTC ( int SourceOfTC)
inline

Set flag of waveform table.

Definition at line 56 of file TrgEclDigitizer.h.

56{ m_sourceOfTC = SourceOfTC;}

◆ setWaveform()

void setWaveform ( int wave)
inline

Set flag of waveform table.

Definition at line 52 of file TrgEclDigitizer.h.

52{ m_SaveTCWaveForm = wave;}

◆ ShapeF() [1/2]

double ShapeF ( double t00,
double ts1 )

Return shape using Simplified FADC.

Definition at line 956 of file TrgEclDigitizer.cc.

957{
958 static const double realNaN = std::numeric_limits<double>::quiet_NaN();
959
960 double dzna;
961 // double das1,das0,dac0;
962 double dcs0s = realNaN, dsn0s = realNaN, dcs0d, dsn0d;
963 double dcs1s = realNaN, dsn1s = realNaN, dcs1d, dsn1d;
964 double a1, a2, b1, b2, c1, c2 = realNaN;
965 double sv123 = 0.0;
966
967 if (t00 <= 0.0) return 0;
968
969
970
971 a1 = 10 ;
972 a2 = 0.0323625 ;
973 b1 = 100;
974 b2 = 0.0333222;
975 c1 = 10;
976
977 if (ts1 == 1) {
978 c2 = 1;
979 dsn0s = -29.9897;
980 dcs0s = -0.08627;
981
982 dsn1s = -2.64784;
983 dcs1s = -0.00285194;
984 }
985 if (ts1 == 0.01) {
986 c2 = 100;
987 dsn0s = 2.999 ;
988 dcs0s = -0.00323517;
989
990 dsn1s = 5.82524;
991 dcs1s = -7866.7;
992 }
993 if (ts1 == 0.001) {
994 c2 = 1000;
995 dsn0s = 0.272636;
996 dcs0s = -0.000204983;
997
998 dsn1s = 0.291262;
999 dcs1s = 0.000204894;
1000 }
1001
1002 dsn0d = -5.998;
1003 dcs0d = -8340.22;
1004
1005 dsn1d = -2.91262;
1006 dcs1d = -0.00323517;
1007 //
1008 //
1009 //
1010 dzna = 6.561e+07;
1011
1012 sv123 = (
1013 (dcs0s + dcs1s) * exp(-c2 * t00) * (-1) +
1014 (dcs0d + dcs1d) * exp(-c1 * t00) +
1015 ((dsn0s - dsn0d) * sin(a2 * t00) + (dcs0s - dcs0d) * cos(a2 * t00)) * exp(-a1 * t00) +
1016 ((dsn1s - dsn1d) * sin(b2 * t00) + (dcs1s - dcs1d) * cos(b2 * t00)) * exp(-b1 * t00)
1017 )
1018 / dzna / (1 / c2 - 1 / c1);
1019
1020 return sv123;
1021}
static const double realNaN
This collects the B-meson properties in the hadronic B-decays It is used for the Ecms calibration in ...

◆ ShapeF() [2/2]

double ShapeF ( double t00,
double t01,
double tb1,
double t02,
double tb2,
double td1,
double ts1 )

return shape using FADC function

Definition at line 760 of file TrgEclDigitizer.cc.

767{
768 double dr;
769 double dzna;
770 double das1, das0, dac0;
771 double dcs0s, dsn0s, dcs0d, dsn0d;
772 double dcs1s, dsn1s, dcs1d, dsn1d;
773
774 double sv123 = 0.0;
775 if (t00 < 0) return 0;
776
777 dr = (ts1 - td1) / td1;
778 if (fabs(dr) <= 1.0e-5) {
779 if (ts1 > td1) { ts1 = td1 * 1.00001; }
780 else { ts1 = td1 * 0.99999; }
781 }
782 //
783 dr = (pow((t01 - t02), 2) + pow((tb1 - tb2), 2)) / (pow((t01), 2) + pow((tb1), 2));
784 if (dr <= 1.e-10) {
785 if (t01 < t02) { t01 = t02 / 1.00001; }
786 else { t01 = t02 / 0.99999; }
787 }
788 if (t00 <= 0.0) return 0;
789 //
790 //
791 //
792 double a1 = 1 / t01;
793 double a2 = 1 / tb1;
794 double b1 = 1 / t02;
795 double b2 = 1 / tb2;
796 double c1 = 1 / td1;
797 double c2 = 1 / ts1;
798
799 das0 = b2 * (pow((b1 - a1), 2) + (b2 + a2) * (b2 - a2));
800 dac0 = -2 * (b1 - a1) * a2 * b2;
801 das1 = a2 * (pow((b1 - a1), 2) - (b2 + a2) * (b2 - a2));
802
803 dsn0s = ((c2 - a1) * das0 - (-a2) * dac0) / (pow(a2, 2) + pow((c2 - a1), 2));
804 dcs0s = ((-a2) * das0 + (c2 - a1) * dac0) / (pow(a2, 2) + pow((c2 - a1), 2));
805
806 dsn1s = ((c2 - b1) * das1 - (-b2) * (-dac0)) / (pow(b2, 2) + pow((c2 - b1), 2));
807 dcs1s = ((-b2) * das1 + (c2 - b1) * (-dac0)) / (pow(b2, 2) + pow((c2 - b1), 2));
808
809 dsn0d = ((c1 - a1) * das0 - (-a2) * dac0) / (pow(a2, 2) + pow((c1 - a1), 2));
810 dcs0d = ((-a2) * das0 + (c1 - a1) * dac0) / (pow(a2, 2) + pow((c1 - a1), 2));
811
812 dsn1d = ((c1 - b1) * das1 - (-b2) * (-dac0)) / (pow(b2, 2) + pow((c1 - b1), 2));
813 dcs1d = ((-b2) * das1 + (c1 - b1) * (-dac0)) / (pow(b2, 2) + pow((c1 - b1), 2));
814 //
815 //
816 //
817 dzna = (pow((b1 - a1), 2) + pow((b2 - a2), 2)) * (pow((b1 - a1), 2) + pow((a2 + b2), 2));
818
819 sv123 = (
820 (dcs0s + dcs1s) * exp(-c2 * t00) * (-1) +
821 (dcs0d + dcs1d) * exp(-c1 * t00) +
822 ((dsn0s - dsn0d) * sin(a2 * t00) + (dcs0s - dcs0d) * cos(a2 * t00)) * exp(-a1 * t00) +
823 ((dsn1s - dsn1d) * sin(b2 * t00) + (dcs1s - dcs1d) * cos(b2 * t00)) * exp(-b1 * t00)
824 )
825 / dzna / (1 / c2 - 1 / c1);
826
827 return sv123;
828}

◆ SimplifiedFADC()

double SimplifiedFADC ( int flag_gen,
double timing )

FADC.

Faster FADC

Definition at line 836 of file TrgEclDigitizer.cc.

838{
839
840 //--------------------------------------
841 //
842 // o "timing" unit is [us]
843 // o flag_gen = 0(=signal), 1(=parallel), 2(=serial)
844 // o return value(PDF) is [GeV]
845 // o Generate signal shape using a simplified function.
846 //
847 //
848 //--------------------------------------
849 double tsh, dd;
850 static double tc, tc2, tsc, tris;
851 static double amp, dft, as;
852
853
854 // int im, ij;
855
856 static int ifir = 0;
857
858 if (ifir == 0) {
859
860 const double td = 0.10; // diff time ( 0.10)
861 const double t1 = 0.10; // integ1 real ( 0.10)
862 // b1 = 30.90; // integ1 imag ( 30.90)
863 const double t2 = 0.01; // integ2 real ( 0.01)
864 // b2 = 30.01; // integ2 imag ( 30.01)
865 double ts = 1.00; // scint decay ( 1.00)
866 dft = 0.600; // diff delay ( 0.600)
867 as = 0.548; // diff frac ( 0.548)
868 //
869 amp = 1.0;
870 tris = 0.01;
871 // ts0 = 0.0;
872 tsc = ts;
873 double fm = 0;
874 //
875 int im = 0;
876 int ij = 0;
877 tc = 0;
878 double tt = u_max(u_max(td, t1), u_max(t2, ts)) * 2;
879 int flag_once = 0;
880 while (flag_once == 0) {
881 double dt = tt / 1000;
882
883 double tm = 0;
884 for (int j = 1; j <= 1000; j++) {
885 tc2 = tc - dft;
886 double fff =
887 (ShapeF(tc, tsc) -
888 ShapeF(tc, tris) * 0.01) -
889 (ShapeF(tc2, tsc) -
890 ShapeF(tc2, tris) * 0.01) * as;
891 if (fff > fm) {
892 fm = fff;
893 tm = tc;
894 im = j;
895 }
896 tc = tc + dt;
897 }
898 if (im >= 1000) {
899 tt = 2 * tt;
900 flag_once = 0;
901 continue;
902 }
903 if (ij == 0) {
904 ij = 1;
905 tc = 0.99 * tm;
906 dt = tm * 0.02 / 1000;
907 flag_once = 0;
908 continue;
909 }
910 flag_once = 1;
911 }
912 amp = 1.0 / fm;
913 ifir = 1;
914 }
915 //
916 //
917 double pdf = 0;
918 if (flag_gen == 0) {
919 //-----<signal>
920 tc2 = timing - dft;
921 pdf = amp * (
922 (ShapeF(timing, tsc) -
923 ShapeF(timing, tris) * 0.01) -
924 (ShapeF(tc2, tsc) -
925 ShapeF(tc2, tris) * 0.01) * as);
926 } else if (flag_gen == 1) {
927 //-----<parallel>
928 tc2 = timing - dft;
929 tsh = 0.001;
930 pdf = amp * (
931 ShapeF(timing, tsh) -
932 ShapeF(tc2, tsh) * as);
933 pdf = pdf * 0.001; // GeV
934 } else {
935 //-----<serial>
936 tc2 = timing - dft;
937 tsh = 0.001;
938 pdf = amp * (
939 ShapeF(timing, tsh) -
940 ShapeF(tc2, tsh) * as);
941 //
942 tc = timing - 0.01;
943 if (tc < 0) { tc = 0; }
944 dd = timing - tc;
945 tc2 = tc - dft;
946 pdf = (amp * (
947 ShapeF(tc, tsh) -
948 ShapeF(tc2, tsh) * as) - pdf) / dd;
949 pdf = pdf * 0.001; // GeV
950 }
951
952 return pdf;
953}

◆ u_max()

double u_max ( double aaa,
double bbb )

Find max value between 2 vals;.

Definition at line 1026 of file TrgEclDigitizer.cc.

1027{
1028 if (aaa > bbb) { return aaa; }
1029 else { return bbb; }
1030}

Member Data Documentation

◆ c_nECLCrystals

int c_nECLCrystals = 8736
staticconstexprprivate

Numer of time bins.

Definition at line 87 of file TrgEclDigitizer.h.

◆ c_NSamplingDigi01

int c_NSamplingDigi01 = 64
staticconstexprprivate

Numer of sampling points for digitizer01.

Definition at line 81 of file TrgEclDigitizer.h.

◆ c_NSamplingDigi02

int c_NSamplingDigi02 = 666
staticconstexprprivate

Numer of sampling points for digitizer02.

Definition at line 83 of file TrgEclDigitizer.h.

◆ c_NTC

int c_NTC = 576
staticconstexprprivate

Number of ECL TriggerCells (TC)

Definition at line 79 of file TrgEclDigitizer.h.

◆ c_nTimeBins

int c_nTimeBins = 80
staticconstexprprivate

Numer of time bins.

Definition at line 85 of file TrgEclDigitizer.h.

◆ m_BeambkgTag

int m_BeambkgTag = 0
private

Flag of saving beam background tag or not.

Definition at line 137 of file TrgEclDigitizer.h.

◆ m_DataBase

TrgEclDataBase* m_DataBase
private

Object of DataBase.

Definition at line 117 of file TrgEclDigitizer.h.

◆ m_FADC

int m_FADC = 1
private

Flag of choosing the method of waveform generation function 0: use simplifiedFADC, 1: use interFADC(interpolation)

Definition at line 135 of file TrgEclDigitizer.h.

◆ m_MatrixParallel

std::array<std::array<double, 64>, 64> m_MatrixParallel
private

Noise Matrix of Parallel and Serial Noise.

Noise Low triangle Matrix of Parallel noise

Definition at line 121 of file TrgEclDigitizer.h.

◆ m_MatrixSerial

std::array<std::array<double, 64>, 64> m_MatrixSerial
private

Noise Low triangle Matrix of Serial noise.

Definition at line 123 of file TrgEclDigitizer.h.

◆ m_noiseParallel

std::array<float, c_NSamplingDigi01> m_noiseParallel = {0.}
private

Noise from parallel.

Definition at line 144 of file TrgEclDigitizer.h.

144{0.};

◆ m_noisePileup

std::array<float, c_NSamplingDigi01> m_noisePileup = {0.}
private

Noise from pileup.

Definition at line 142 of file TrgEclDigitizer.h.

142{0.};

◆ m_noiseSerial

std::array<float, c_NSamplingDigi01> m_noiseSerial = {0.}
private

Noise from serial.

Definition at line 146 of file TrgEclDigitizer.h.

146{0.};

◆ m_SaveTCWaveForm

int m_SaveTCWaveForm = 0
private

Flag of waveform table.

Definition at line 131 of file TrgEclDigitizer.h.

◆ m_SignalAmp

std::array<double, 245> m_SignalAmp
staticconstexprprivate

Normalised FADC signal shape, sampled every 12 ns from 0 to 2928 ns.

Used by interFADC() to interpolate the waveform; the corresponding sampling times are simply 12 ns * index and so are not tabulated.

Definition at line 156 of file TrgEclDigitizer.h.

156 {
157 0, 3.47505e-06, 0.000133173, 0.000939532, 0.00337321, 0.00845977, 0.0170396, 0.0296601,
158 0.0465713, 0.0677693, 0.0930545, 0.122086, 0.154429, 0.189595, 0.227068, 0.266331,
159 0.306882, 0.348243, 0.389971, 0.431664, 0.472959, 0.513539, 0.553127, 0.59149,
160 0.628431, 0.663791, 0.697445, 0.729297, 0.759281, 0.787354, 0.813494, 0.837698,
161 0.859982, 0.880372, 0.898908, 0.915639, 0.930622, 0.943919, 0.955598, 0.965731,
162 0.97439, 0.98165, 0.987587, 0.992275, 0.995788, 0.9982, 0.999581, 1,
163 0.999525, 0.998219, 0.996143, 0.993356, 0.989846, 0.985364, 0.979439, 0.971558,
164 0.961304, 0.948421, 0.932809, 0.914509, 0.893664, 0.870494, 0.845267, 0.818279,
165 0.789837, 0.76025, 0.729815, 0.698815, 0.667511, 0.636141, 0.604919, 0.574035,
166 0.543654, 0.513915, 0.484939, 0.456822, 0.429643, 0.403462, 0.378324, 0.354259,
167 0.331286, 0.309412, 0.288633, 0.26894, 0.250316, 0.232736, 0.216174, 0.200597,
168 0.185972, 0.172262, 0.159428, 0.147431, 0.136232, 0.12579, 0.116067, 0.107022,
169 0.0986191, 0.0908193, 0.0835871, 0.0768874, 0.0706867, 0.0649528, 0.0596551, 0.0547641,
170 0.0502523, 0.0460932, 0.042262, 0.0387353, 0.0354909, 0.0325082, 0.0297677, 0.0272511,
171 0.0249416, 0.0228232, 0.020881, 0.0191014, 0.0174714, 0.0159792, 0.0146138, 0.0133649,
172 0.012223, 0.0111793, 0.0102258, 0.00935504, 0.00856, 0.00783438, 0.00717232, 0.00656842,
173 0.00601773, 0.00551567, 0.00505807, 0.00464106, 0.00426114, 0.00391506, 0.00359985, 0.0033128,
174 0.00305143, 0.00281346, 0.00259681, 0.00239957, 0.00222002, 0.00205655, 0.00190773, 0.00177223,
175 0.00164885, 0.00153648, 0.00143413, 0.00134087, 0.00125589, 0.00117842, 0.00110777, 0.00104332,
176 0.000984488, 0.000930766, 0.000881678, 0.000836798, 0.000795734, 0.000758134, 0.000723677, 0.00069207,
177 0.000663051, 0.000636377, 0.000611832, 0.000589219, 0.000568358, 0.000549086, 0.000531258, 0.000514738,
178 0.000499407, 0.000485156, 0.000471884, 0.000459502, 0.00044793, 0.000437092, 0.000426923, 0.000417363,
179 0.000408356, 0.000399853, 0.000391811, 0.000384187, 0.000376946, 0.000370055, 0.000363483, 0.000357203,
180 0.000351192, 0.000345426, 0.000339886, 0.000334554, 0.000329413, 0.000324448, 0.000319645, 0.000314993,
181 0.000310481, 0.000306098, 0.000301836, 0.000297686, 0.00029364, 0.000289693, 0.000285837, 0.000282068,
182 0.00027838, 0.000274768, 0.000271229, 0.000267759, 0.000264354, 0.000261011, 0.000257727, 0.000254499,
183 0.000251326, 0.000248204, 0.000245132, 0.000242108, 0.000239131, 0.000236198, 0.000233308, 0.00023046,
184 0.000227653, 0.000224885, 0.000222155, 0.000219463, 0.000216807, 0.000214187, 0.000211602, 0.00020905,
185 0.000206532, 0.000204046, 0.000201593, 0.00019917, 0.000196779, 0.000194417, 0.000192085, 0.000189782,
186 0.000187508, 0.000185262, 0.000183044, 0.000180853, 0.000178689, 0.000176552, 0.000174441, 0.000172355,
187 0.000170295, 0.00016826, 0.000166249, 0.000164263, 0.000162301,
188 };

◆ m_sourceOfTC

int m_sourceOfTC = 0
private

Which TC source to use.

Definition at line 139 of file TrgEclDigitizer.h.

◆ m_TCBeambkgTag

std::array<std::array<double, c_nTimeBins>, c_NTC> m_TCBeambkgTag
private

Beambackground tag.

Definition at line 129 of file TrgEclDigitizer.h.

◆ m_TCBkgContribution

std::array<std::array<double, c_nTimeBins>, c_NTC> m_TCBkgContribution
private

Beambackground contribution.

Definition at line 125 of file TrgEclDigitizer.h.

◆ m_TCEnergy

std::array<std::array<double, c_nTimeBins>, c_NTC> m_TCEnergy
private

TC Energy converted from Xtarl Energy [GeV].

Definition at line 92 of file TrgEclDigitizer.h.

◆ m_TCEnergy_tot

std::array<double, c_NTC> m_TCEnergy_tot
private

TC Energy converted from Xtarl Energy [GeV].

Definition at line 96 of file TrgEclDigitizer.h.

◆ m_TCMap

TrgEclMapping* m_TCMap
private

Object of TC Mapping.

Definition at line 115 of file TrgEclDigitizer.h.

◆ m_TCRawBkgTag

std::array<std::array<double, 60>, c_NTC> m_TCRawBkgTag
private

Input Beambackground tag.

Definition at line 112 of file TrgEclDigitizer.h.

◆ m_TCRawEnergy

std::array<std::array<double, 60>, c_NTC> m_TCRawEnergy
private

Input TC energy[GeV].

Definition at line 108 of file TrgEclDigitizer.h.

◆ m_TCRawTiming

std::array<std::array<double, 60>, c_NTC> m_TCRawTiming
private

Input TC timing[ns].

Definition at line 110 of file TrgEclDigitizer.h.

◆ m_TCSigContribution

std::array<std::array<double, c_nTimeBins>, c_NTC> m_TCSigContribution
private

Signal contribution.

Definition at line 127 of file TrgEclDigitizer.h.

◆ m_TCTiming

std::array<std::array<double, c_nTimeBins>, c_NTC> m_TCTiming
private

TC Timing converted from Xtarl Timing [GeV].

Definition at line 94 of file TrgEclDigitizer.h.

◆ m_TCTiming_tot

std::array<double, c_NTC> m_TCTiming_tot
private

TC Timing converted from Xtarl Timing [GeV].

Definition at line 98 of file TrgEclDigitizer.h.

◆ m_TimeRange

double m_TimeRange = 4000
private

time range(default : -4000 ~ 4000 ns )

Definition at line 90 of file TrgEclDigitizer.h.

◆ m_WaveForm

double m_WaveForm[c_NTC][c_NSamplingDigi01] = {{0.}}
private

TC Energy converted from Xtarl Energy [GeV].

Definition at line 133 of file TrgEclDigitizer.h.

133{{0.}};

◆ m_Xpr

std::array<float, c_NSamplingDigi01> m_Xpr = {0.}
private

Random parallel noise.

Definition at line 148 of file TrgEclDigitizer.h.

148{0.};

◆ m_Xsr

std::array<float, c_NSamplingDigi01> m_Xsr = {0.}
private

Random serial noise.

Definition at line 150 of file TrgEclDigitizer.h.

150{0.};

The documentation for this class was generated from the following files: