CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
APV25GTS.cxx
Go to the documentation of this file.
1// implementation:
2// R. Farinelli (University of Ferrara & INFN of Ferrara)
3// L. Lavezzi (IHEP & INFN of Torino)
5
6#include "TRandom.h"
7#include "TStyle.h"
8#include "TF1.h"
9#include "TMath.h"
10
11#define ele_to_fC 1.6e-4 // CHECK
12#define tstep 25 // CHECK
13
14APV25GTS::APV25GTS() : histo_q_vs_t(NULL) {
15 histo_q_vs_t = new TH1F("histo_q_vs_t", "", 27, 0, 675); // 25 ns x 27 time bins
16}
17
19 delete histo_q_vs_t;
20}
21
22void APV25GTS::add_charge(double q, double t) {
23 histo_q_vs_t->Fill(t, q);
24}
25
26
27double APV25GTS::compute_charge() { // in fC
28 double qmax = histo_q_vs_t->GetMaximum();
29 double qmax_fC = qmax/ele_to_fC;
30 return qmax_fC;
31}
32
34
35 // TIME from FERMI DIRAC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 // start parameters
37 double maxbin = histo_q_vs_t->GetMaximumBin();
38 double QMaxHisto = compute_charge();
39
40 // double startBin = maxbin - 5;
41 // double endBin = maxbin + 10;
42 //find the lower edge of the rising @ 10% of the maximum
43 double minbin = 0;
44 for(int ibin = maxbin; ibin > 1; ibin--){
45 if(histo_q_vs_t->GetBinContent(ibin) < 0.1 * QMaxHisto) {
46 minbin = ibin;
47 break;
48 }
49 }
50 double startvalues[5] = {0};
51 double fitlimup[5] = {0};
52 double fitlimlow[5] = {0};
53 // media dei tre bin prima del minbin
54 double meanfirstbin = (histo_q_vs_t->GetBinContent(minbin-1) + histo_q_vs_t->GetBinContent(minbin-2) + histo_q_vs_t->GetBinContent(minbin-3))/3.;
55 double sigma_MFB = TMath::Sqrt( ( pow(histo_q_vs_t->GetBinContent(minbin-1) - meanfirstbin, 2) + pow(histo_q_vs_t->GetBinContent(minbin-2) - meanfirstbin,2) + pow(histo_q_vs_t->GetBinContent(minbin-3)- meanfirstbin,2)) / 3.);
56 if(sigma_MFB < TMath::Abs(meanfirstbin)) sigma_MFB = TMath::Abs(meanfirstbin);
57
58 startvalues[0] = meanfirstbin;
59 startvalues[1] = QMaxHisto;
60 startvalues[2] = 0.5* (minbin + maxbin) * tstep;
61 startvalues[3] = 0.5*tstep;
62
63 // put liimits
64 fitlimlow[0] = startvalues[0] - 2 * sigma_MFB;
65 fitlimlow[1] = startvalues[1] - 0.3 * startvalues[1];
66 fitlimlow[2] = minbin * tstep;
67 fitlimlow[3] = 0.1*tstep;
68
69 fitlimup[0] = startvalues[0] + 2 * sigma_MFB;
70 fitlimup[1] = startvalues[1] + 0.3 * startvalues[1];
71 fitlimup[2] = maxbin * tstep;
72 fitlimup[3] = 0.9*tstep;
73 // ...................
74 // the real Fermi Dirac
75 // 1
76 // FD(t) = K ----------------------------- + B
77 // 1 + exp( -(t - tFD)/sigFD )
78 // [0] = B
79 // [1] = K
80 // [2] = tFD
81 // [3] = sigFD
82 double minFD = minbin - 4;
83 double maxFD = maxbin + 0;
84
85 TF1 f_FD("f_FD", "[0] + [1]/(1+TMath::Exp(-(x - [2])/[3]))", minFD*tstep, maxFD*tstep);
86 f_FD.SetParameters(startvalues[0], startvalues[1], startvalues[2], startvalues[3]);
87 f_FD.SetParLimits(0, fitlimlow[0], fitlimup[0]);
88 f_FD.SetParLimits(1, fitlimlow[1], fitlimup[1]);
89 f_FD.SetParLimits(2, fitlimlow[2], fitlimup[2]);
90 f_FD.SetParLimits(3, fitlimlow[3], fitlimup[3]);
91
92 gStyle->SetOptFit(1111);
93 histo_q_vs_t->Fit("f_FD","WQRB"); // quiet/range/params
94
95 double tFD = 0;
96 tFD = gRandom->Gaus(f_FD.GetParameter(2), 8);
97 double dtFD = 0.;
98 dtFD = f_FD.GetParError(2);
99 set_dtFD(dtFD);
100
101 // save parameters
102 set_FD_par(0, f_FD.GetParameter(0));
103 set_FD_par(1, f_FD.GetParameter(1));
104 set_FD_par(2, f_FD.GetParameter(2));
105 set_FD_par(3, f_FD.GetParameter(3));
106
107
108 // CHECK
109 /**
110 double zzz = (tFD-strip_t0-Get_Track_T0())*drift_velocity; // chech --> // This Z assign Z=0.5 to the cathode and Z=0 to G1 CHECK
111 set_APV25_Z(zzz);
112
113 if(Get_APV25_Q(iS)>qcut && Get_APV25_T(iS)!=0){
114 Set_APV25_X(iS,iS*pitch+0.5*pitch+x_min);
115 }
116 **/
117
118 return tFD;
119}
#define tstep
Definition: APV25GTS.cxx:12
#define ele_to_fC
Definition: APV25GTS.cxx:11
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition: KKsem.h:33
APV25GTS()
Definition: APV25GTS.cxx:14
void set_dtFD(double t)
Definition: APV25GTS.h:15
void add_charge(double q, double t)
Definition: APV25GTS.cxx:22
void set_FD_par(int i, double p)
Definition: APV25GTS.h:16
~APV25GTS()
Definition: APV25GTS.cxx:18
double compute_tFD()
Definition: APV25GTS.cxx:33
double compute_charge()
Definition: APV25GTS.cxx:27
int t()
Definition: t.c:1