CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
InductionGar2 Class Reference

#include <InductionGar2.h>

+ Inheritance diagram for InductionGar2:

Classes

struct  PVectorXYZT
 

Public Member Functions

 InductionGar2 ()
 
 ~InductionGar2 ()
 
void init (ICgemGeomSvc *geomSvc, double magConfig)
 
void setDebugOutput (bool debugOutput)
 
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)
 
void setMultiElectrons (int layer, const HitHistMap &hitmap, const PVectorXYZT *debug_ref_electrons=0)
 
int getNXstrips () const
 
int getNVstrips () const
 
int getXstripSheet (int n) const
 
int getXstripID (int n) const
 
int getVstripSheet (int n) const
 
int getVstripID (int n) const
 
double getXstripQ (int n) const
 
double getVstripQ (int n) const
 
double getXstripT (int n) const
 
double getVstripT (int n) const
 
double getXstripT_Branch (int n) const
 
double getVstripT_Branch (int n) const
 
double getXstripQ_Branch (int n) const
 
double getVstripQ_Branch (int n) const
 
double getXfirstT (int n) const
 
double getVfirstT (int n) const
 
void setLUTFilePath (std::string path)
 
void setV2EfineFile (std::string path)
 
void setVsampleDelay (double delay)
 
void setStoreFlag (bool flag)
 
void setSaturation (bool flag)
 
void setScaleSignalX (double ScaleSignalX)
 
void setQinGausSigma (vector< double > sigma)
 
- Public Member Functions inherited from Induction
 Induction ()
 
virtual ~Induction ()
 

Detailed Description

Definition at line 43 of file InductionGar2.h.

Constructor & Destructor Documentation

◆ InductionGar2()

InductionGar2::InductionGar2 ( )

Definition at line 536 of file InductionGar2.cxx.

536 {
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}

◆ ~InductionGar2()

InductionGar2::~InductionGar2 ( )

Definition at line 549 of file InductionGar2.cxx.

549 {
550}

Member Function Documentation

◆ getNVstrips()

int InductionGar2::getNVstrips ( ) const
inlinevirtual

Implements Induction.

Definition at line 59 of file InductionGar2.h.

59{ return m_nVstrips; }

◆ getNXstrips()

int InductionGar2::getNXstrips ( ) const
inlinevirtual

Implements Induction.

Definition at line 58 of file InductionGar2.h.

58{ return m_nXstrips; }

◆ getVfirstT()

double InductionGar2::getVfirstT ( int n) const
inlinevirtual

Implements Induction.

Definition at line 73 of file InductionGar2.h.

73{ return m_vTfirst[n]; }
const Int_t n

◆ getVstripID()

int InductionGar2::getVstripID ( int n) const
inlinevirtual

Implements Induction.

Definition at line 63 of file InductionGar2.h.

63{ return m_vstripID[n]; }

◆ getVstripQ()

double InductionGar2::getVstripQ ( int n) const
inlinevirtual

Implements Induction.

Definition at line 65 of file InductionGar2.h.

65{ return m_vstripQ[n]; }

◆ getVstripQ_Branch()

double InductionGar2::getVstripQ_Branch ( int n) const
inlinevirtual

Implements Induction.

Definition at line 71 of file InductionGar2.h.

71{ return m_vstripQ_Branch[n]; }

◆ getVstripSheet()

int InductionGar2::getVstripSheet ( int n) const
inlinevirtual

Implements Induction.

Definition at line 62 of file InductionGar2.h.

62{ return m_vstripSheet[n]; }

◆ getVstripT()

double InductionGar2::getVstripT ( int n) const
inlinevirtual

Implements Induction.

Definition at line 67 of file InductionGar2.h.

67{ return m_vstripT_Branch[n]; }

◆ getVstripT_Branch()

double InductionGar2::getVstripT_Branch ( int n) const
inlinevirtual

Implements Induction.

Definition at line 69 of file InductionGar2.h.

69{ return m_vstripT_Branch[n]; }

◆ getXfirstT()

double InductionGar2::getXfirstT ( int n) const
inlinevirtual

Implements Induction.

Definition at line 72 of file InductionGar2.h.

72{ return m_xTfirst[n]; }

◆ getXstripID()

int InductionGar2::getXstripID ( int n) const
inlinevirtual

Implements Induction.

Definition at line 61 of file InductionGar2.h.

61{ return m_xstripID[n]; }

◆ getXstripQ()

double InductionGar2::getXstripQ ( int n) const
inlinevirtual

Implements Induction.

Definition at line 64 of file InductionGar2.h.

64{ return m_xstripQ[n]; }

◆ getXstripQ_Branch()

double InductionGar2::getXstripQ_Branch ( int n) const
inlinevirtual

Implements Induction.

Definition at line 70 of file InductionGar2.h.

70{ return m_xstripQ_Branch[n]; }

◆ getXstripSheet()

int InductionGar2::getXstripSheet ( int n) const
inlinevirtual

Implements Induction.

Definition at line 60 of file InductionGar2.h.

60{ return m_xstripSheet[n]; }

◆ getXstripT()

double InductionGar2::getXstripT ( int n) const
inlinevirtual

Implements Induction.

Definition at line 66 of file InductionGar2.h.

66{ return m_xstripT_Branch[n]; }

◆ getXstripT_Branch()

double InductionGar2::getXstripT_Branch ( int n) const
inlinevirtual

Implements Induction.

Definition at line 68 of file InductionGar2.h.

68{ return m_xstripT_Branch[n]; }

◆ init()

void InductionGar2::init ( ICgemGeomSvc * geomSvc,
double magConfig )
virtual

Implements Induction.

Definition at line 552 of file InductionGar2.cxx.

552 {
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}
float Float_t
void init(const double *ConstArray, const int ConstArrayLength, const int Blength, TransformOptimOpt opt=opt_EX, TransformLengthOpt optL=opt_AsShortAsPsb)
void init(ICgemGeomSvc *geomSvc, double magConfig)

Referenced by init(), and setMultiElectrons().

◆ setDebugOutput()

void InductionGar2::setDebugOutput ( bool debugOutput)
inlinevirtual

Implements Induction.

Definition at line 50 of file InductionGar2.h.

50{ m_debugOutput = debugOutput; }

◆ setLUTFilePath()

void InductionGar2::setLUTFilePath ( std::string path)
inlinevirtual

Implements Induction.

Definition at line 75 of file InductionGar2.h.

75{ m_LUTFilePath = path; }

◆ setMultiElectrons() [1/2]

void InductionGar2::setMultiElectrons ( int layer,
const HitHistMap & hitmap,
const PVectorXYZT * debug_ref_electrons = 0 )

Definition at line 810 of file InductionGar2.cxx.

810 {
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}
Double_t x[10]
std::vector< int > Vint
Definition Gam4pikp.cxx:52
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 ...
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 ...
int getNumberOfSheet() const
double getDist2ClosestXStripCenter(double phi, int &id)
bool OnThePlane(double phi, double z) const
double getDist2ClosestVStripCenter(G4ThreeVector pos, int &id)
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const =0
virtual CgemGeoLayer * getCgemLayer(int i) const =0
int num[96]
Definition ranlxd.c:373
int t()
Definition t.c:1

◆ setMultiElectrons() [2/2]

void InductionGar2::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 )
inlinevirtual

Implements Induction.

Definition at line 54 of file InductionGar2.h.

54{};

Referenced by CgemDigitizerSvc::setTrack().

◆ setQinGausSigma()

void InductionGar2::setQinGausSigma ( vector< double > sigma)
inline

Definition at line 82 of file InductionGar2.h.

83 {
84 m_QinGausSigma[0]=sigma[0];
85 m_QinGausSigma[1]=sigma[1];
86 }

Referenced by CgemDigitizerSvc::initialize().

◆ setSaturation()

void InductionGar2::setSaturation ( bool flag)
inlinevirtual

Implements Induction.

Definition at line 79 of file InductionGar2.h.

79{ m_saturation = flag; }

◆ setScaleSignalX()

void InductionGar2::setScaleSignalX ( double ScaleSignalX)
inline

Definition at line 81 of file InductionGar2.h.

81{m_ScaleSignalX = ScaleSignalX;}

Referenced by CgemDigitizerSvc::initialize().

◆ setStoreFlag()

void InductionGar2::setStoreFlag ( bool flag)
inlinevirtual

Implements Induction.

Definition at line 78 of file InductionGar2.h.

78{ storeFlag = flag; }

◆ setV2EfineFile()

void InductionGar2::setV2EfineFile ( std::string path)
inline

Definition at line 76 of file InductionGar2.h.

76{ m_V2EfineFile = path; }

◆ setVsampleDelay()

void InductionGar2::setVsampleDelay ( double delay)
inlinevirtual

Implements Induction.

Definition at line 77 of file InductionGar2.h.

77{ sample_delay = delay; }

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