00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PMT_FULL_MODEL_H
00012 #define PMT_FULL_MODEL_H
00013
00014 #include <fstream>
00015 #include <iomanip>
00016 #include <string.h>
00017 #include <math.h>
00018 #include <iostream>
00019 #include <TMath.h>
00020
00021
00022
00023 Double_t Poisson(Int_t n,Double_t mu);
00024
00025 Double_t Ser_n(Int_t n,Double_t Q0,Double_t Delta0,Double_t Q1,Double_t Delta1,Double_t *x);
00026 Double_t Noise_n(Int_t n,Double_t Q0,Double_t Delta0,Double_t Q1,Double_t Delta1,Double_t A,Double_t *x);
00027 Double_t SER_n(Int_t n,Double_t *x,Double_t *par);
00028
00029
00030
00031 Int_t NON_ZERO_MAX_NUM;
00032 Double_t EVENT_TOTLE_NUM=0;
00033 Double_t Pi2=TMath::Sqrt(2*TMath::Pi());
00034 Double_t N;
00035
00036 Double_t xlow;
00037 Double_t xhigh;
00038
00039 long NNN;
00040
00041
00042
00043
00044
00045 Double_t Poisson(Int_t n,Double_t mu)
00046 {
00047 Double_t RESULT=1;
00048 Double_t temp=TMath::Exp(-1*mu);
00049 if(n==0)
00050 {
00051 RESULT=temp;
00052 return RESULT;
00053 }
00054 RESULT=TMath::Power(mu,n)*temp/TMath::Gamma(n+1);
00055 return RESULT;
00056 }
00057
00058
00059
00060
00061
00062
00063 Double_t Ser_n(Int_t n,Double_t Q0,Double_t Delta0,Double_t Q1,Double_t Delta1,Double_t *x)
00064 {
00065 Double_t RESULT=1;
00066 if(n==0&&Delta0!=0)
00067 {
00068 RESULT=TMath::Exp(-0.5*(x[0]-Q0)*(x[0]-Q0)/TMath::Power(Delta0,2))/(Pi2*Delta0);
00069 }
00070 else if(Delta1!=0)
00071 RESULT=TMath::Exp(-0.5*(x[0]-Q0-n*Q1)*(x[0]-Q0-n*Q1)/(n*TMath::Power(Delta1,2)+TMath::Power(Delta0,2)))/(Pi2*TMath::Sqrt(n*TMath::Power(Delta1,2)+TMath::Power(Delta0,2)));
00072 else
00073 return 0;
00074 return RESULT;
00075 }
00076
00077
00078
00079
00080
00081
00082 Double_t Noise_n(Int_t n,Double_t Q0,Double_t Delta0,Double_t Q1,Double_t Delta1,Double_t A,Double_t *x)
00083 {
00084 Double_t Qn=Q0+n*Q1;
00085 Double_t Deltan=TMath::Sqrt(TMath::Power(Delta0,2)+n*TMath::Power(Delta1,2));
00086 Double_t temp1=x[0]-Qn-0.5*A*TMath::Power(Deltan,2);
00087 Double_t temp2=Q0-Qn-A*TMath::Power(Deltan,2);
00088 Double_t temp3=TMath::Sqrt(2.)*Deltan;
00089 Double_t RESULT=0;
00090 Double_t t1=TMath::Abs(temp1)/temp3;
00091 Double_t t2=TMath::Abs(temp2)/temp3;
00092
00093 Double_t sign1=-1;
00094 if(temp1>=0) sign1=1;
00095
00096 if(x[0]>=Q0)
00097 RESULT=0.5*A*TMath::Exp(-1*A*temp1)*(TMath::Erf(t2)+sign1*TMath::Erf(t1));
00098
00099 return RESULT;
00100 }
00101
00102
00103
00104
00105
00106
00107 Double_t SER_n(Int_t n,Double_t *x,Double_t *par)
00108 {
00109 Double_t RESULT;
00110 Double_t mu=par[0];
00111 Double_t Q0=par[1];
00112 Double_t Delta0=par[2];
00113 Double_t Q1=par[3];
00114 Double_t Delta1=par[4];
00115 Double_t w=par[5];
00116 Double_t A=par[6];
00117
00118 RESULT=Poisson(n,mu)*((1-w)*Ser_n(n,Q0,Delta0,Q1,Delta1,x)+w*Noise_n(n,Q0,Delta0,Q1,Delta1,A,x));
00119 return RESULT;
00120 }
00121
00122
00123 #endif //over of PMT_FULL_MODEL_H