2#include "include/fun.h"
8 cout <<
"Calibration type: PreT0Calib" << endl;
19 m_fdTrec =
new TFolder(
"mTrec",
"Trec");
22 m_fdTrecZ =
new TFolder(
"mTrecZ",
"TrecZ");
23 hlist->Add(m_fdTrecZ);
25 for(
int lay=0; lay<
NLAYER; lay++){
26 for(
int lr=0; lr<
NLR; lr++){
27 if(0 == lr)
sprintf(hname,
"mTrec%02d_L", lay);
28 else if(1 == lr)
sprintf(hname,
"mTrec%02d_R", lay);
29 else sprintf(hname,
"mTrec%02d_C", lay);
31 if(lay < 8) m_hTrec[lay][lr] =
new TH1F(hname,
"", 100, 0, 400);
32 else m_hTrec[lay][lr] =
new TH1F(hname,
"", 125, 0, 500);
33 m_fdTrec ->
Add(m_hTrec[lay][lr]);
37 for(
int lay=0; lay<
NLAYER; lay++){
38 for(
int iud=0; iud<2; iud++){
39 if(0 == iud)
sprintf(hname,
"mTrecCosm%02d_Up", lay);
40 else sprintf(hname,
"mTrecCosm%02d_Dw", lay);
41 if(lay < 8) m_hTrecCosm[lay][iud] =
new TH1F(hname,
"", 100, 0, 400);
42 else m_hTrecCosm[lay][iud] =
new TH1F(hname,
"", 125, 0, 500);
43 m_fdTrec ->
Add(m_hTrecCosm[lay][iud]);
47 for(
int lay=0; lay<
NLAYER; lay++){
48 for(
int lr=0; lr<
NLR; lr++){
50 if(0 == lr)
sprintf(hname,
"mTrec%02d_z%02d_L", lay,
bin);
51 else if(1 == lr)
sprintf(hname,
"mTrec%02d_z%02d_R", lay,
bin);
52 else sprintf(hname,
"mTrec%02d_z%02d_C", lay,
bin);
54 if(lay < 8) m_hTrecZ[lay][lr][
bin] =
new TH1F(hname,
"", 100, 0, 400);
55 else m_hTrecZ[lay][lr][
bin] =
new TH1F(hname,
"", 125, 0, 500);
56 m_fdTrecZ ->
Add(m_hTrecZ[lay][lr][
bin]);
65 TFolder* fdTrec = (TFolder*)fhist->Get(
"Trec");
66 TFolder* fdTrecZ = (TFolder*)fhist->Get(
"TrecZ");
69 for(
int lay=0; lay<
NLAYER; lay++){
70 for(
int lr=0; lr<
NLR; lr++){
71 if(0 == lr)
sprintf(hname,
"Trec%02d_L", lay);
72 else if(1 == lr)
sprintf(hname,
"Trec%02d_R", lay);
73 else sprintf(hname,
"Trec%02d_C", lay);
74 hist = (TH1F*)fdTrec->FindObjectAny(hname);
75 m_hTrec[lay][lr]->Add(hist);
79 for(
int lay=0; lay<
NLAYER; lay++){
80 for(
int iud=0; iud<2; iud++){
81 if(0 == iud)
sprintf(hname,
"TrecCosm%02d_Up", lay);
82 else sprintf(hname,
"TrecCosm%02d_Dw", lay);
83 hist = (TH1F*)fdTrec->FindObjectAny(hname);
84 m_hTrecCosm[lay][iud]->Add(hist);
88 for(
int lay=0; lay<
NLAYER; lay++){
89 for(
int lr=0; lr<
NLR; lr++){
91 if(0 == lr)
sprintf(hname,
"Trec%02d_z%02d_L", lay,
bin);
92 else if(1 == lr)
sprintf(hname,
"Trec%02d_z%02d_R", lay,
bin);
93 else sprintf(hname,
"Trec%02d_z%02d_C", lay,
bin);
94 hist = (TH1F*)fdTrecZ->FindObjectAny(hname);
95 m_hTrecZ[lay][lr][
bin]->Add(hist);
118 TF1* ftminCosm[
NLAYER][2];
119 double t0FitCosm[
NLAYER][2];
121 bool fgT0Ini =
false;
123 ifstream fparIni(
"fitT0_inival.txt");
124 if(fparIni.is_open()){
126 for(
int lay=0; lay<
NLAYER; lay++){
127 fparIni >> strtmp >> strtmp;
128 for(
int i=0; i<6; i++) fparIni >> t0ParIni[lay][2][i];
132 cout <<
"read initial values of T0 fit from fitT0_inival.txt" << endl;
134 if(!fgT0Ini) cout <<
"set initial values of T0 fit to default values" << endl;
137 for(
int lay=0; lay<
NLAYER; lay++){
138 for(
int lr=0; lr<
NLR; lr++){
139 fitTminFg[lay][lr] = 0;
140 chindfTmin[lay][lr] = -1;
141 sprintf(funname,
"ftmin%02d_%d", lay, lr);
142 ftmin[lay][lr] =
new TF1(funname, funTmin, 0, 150, 6);
152 double c1Ini = (m_hTrec[lay][lr]->GetMaximum());
155 for(
int i=0; i<6; i++){
156 if(fabs(t0ParIni[lay][2][i] + 9999)<0.01)
continue;
157 ftmin[lay][lr] -> SetParameter(i, t0ParIni[lay][2][i]);
160 ftmin[lay][lr] -> SetParameter(0, 0);
161 ftmin[lay][lr] -> SetParameter(1, c1Ini);
162 ftmin[lay][lr] -> SetParameter(2, 0);
163 ftmin[lay][lr] -> SetParameter(4, initT0);
164 if(lay<4) ftmin[lay][lr] -> SetParameter(5, 4);
165 else ftmin[lay][lr] -> SetParameter(5, 1.5);
168 if(lay<4) m_hTrec[lay][lr] ->
Fit(funname,
"Q",
"", 0, 140);
170 gStyle -> SetOptFit(11);
171 chisq = ftmin[lay][lr]->GetChisquare();
172 ndf = ftmin[lay][lr]->GetNDF();
173 chindfTmin[lay][lr] = chisq / ndf;
184 fitTminFg[lay][lr] = 1;
185 t0Fit[lay][lr] = ftmin[lay][lr]->GetParameter(4);
188 for(
int i=0; i<6; i++) t0FitPar[lay][lr][i] = ftmin[lay][lr]->GetParameter(i);
192 if(0 == fitTminFg[lay][lr]){
194 t0Cal[lay][lr] = calconst->
getT0(wir);
199 for(
int iud=0; iud<2; iud++){
200 sprintf(funname,
"ftminCosm_%02d_%d", lay, iud);
201 ftminCosm[lay][iud] =
new TF1(funname, funTmin, 0, 150, 6);
202 ftminCosm[lay][iud] -> SetParameter(0, 0);
203 ftminCosm[lay][iud] -> SetParameter(4, initT0);
204 ftminCosm[lay][iud] -> SetParameter(5, 1);
206 gStyle -> SetOptFit(11);
208 t0FitCosm[lay][iud] = ftminCosm[lay][iud]->GetParameter(4);
214 for(
int lay=0; lay<
NLAYER; lay++){
215 for(
int lr=0; lr<
NLR; lr++){
216 fitTmaxFg[lay][lr] = 0;
217 chindfTmax[lay][lr] = -1;
218 sprintf(funname,
"ftmax%02d_%d", lay, lr);
219 ftmax[lay][lr] =
new TF1(funname, funTmax, 250, 500, 4);
222 ftmax[lay][lr] -> SetParameter(2,
gInitTm[lay]);
223 ftmax[lay][lr] -> SetParameter(3, 10);
225 gStyle -> SetOptFit(11);
226 chisq = ftmax[lay][lr]->GetChisquare();
227 ndf = ftmax[lay][lr]->GetNDF();
228 chindfTmax[lay][lr] = chisq / ndf;
230 fitTmaxFg[lay][lr] = 1;
231 tmax[lay][lr] = ftmax[lay][lr]->GetParameter(2);
235 if(0 == fitTmaxFg[lay][lr]){
236 tmax[lay][lr] = (calconst->
getXtpar(lay, 0, lr, 6)) + t0Fit[lay][2];
242 ofstream ft0(
"preT0.dat");
243 for(
int lay=0; lay<
NLAYER; lay++){
244 ft0 << setw(5) << lay << setw(3) << fitTminFg[lay][2]
245 << setw(15) << t0Cal[lay][2] << setw(15) << t0Fit[lay][2]
246 << setw(15) << chindfTmin[lay][2] << endl;
249 for(
int lay=0; lay<
NLAYER; lay++){
250 ft0 << setw(5) << lay
251 << setw(3) << fitTmaxFg[lay][0] << setw(10) << tmax[lay][0]
252 << setw(10) << chindfTmax[lay][0]
253 << setw(3) << fitTmaxFg[lay][1] << setw(10) << tmax[lay][1]
254 << setw(10) << chindfTmax[lay][1]
255 << setw(3) << fitTmaxFg[lay][2] << setw(10) << tmax[lay][2]
256 << setw(10) << chindfTmax[lay][2]
257 << setw(10) << tmax[lay][0] - t0Fit[lay][2]
258 << setw(10) << tmax[lay][1] - t0Fit[lay][2]
259 << setw(10) << tmax[lay][2] - t0Fit[lay][2]
263 for(
int lay=0; lay<
NLAYER; lay++){
264 ft0 << setw(5) << lay << setw(15) << chindfTmin[lay][2];
265 for(
int i=0; i<6; i++) ft0 << setw(15) << t0FitPar[lay][2][i];
269 cout <<
"preT0.dat was written." << endl;
272 ofstream ft0cosm(
"cosmicT0.dat");
273 for(
int lay=0; lay<
NLAYER; lay++){
274 ft0cosm << setw(5) << lay << setw(15) << t0Fit[lay][2]
275 << setw(15) << t0FitCosm[lay][0] << setw(15) << t0FitCosm[lay][1] << endl;
280 for(
int i=0; i<
NWIRE; i++){
281 int lay = m_pGeom -> getWire(i) -> getLayerId();
283 calconst -> resetT0(i, t0Cal[lay][2]);
284 calconst -> resetDelT0(i, 0.0);
291 for(
int lay=0; lay<
NLAYER; lay++){
294 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
295 for(
int lr=0; lr<
NLR; lr++){
296 tm = tmax[lay][lr] - t0Fit[lay][2];
299 calconst -> resetXtpar(lay, iEntr, lr, 6, tm);
307 for(
int lay=0; lay<
NLAYER; lay++){
308 for(
int lr=0; lr<
NLR; lr++){
309 delete ftmin[lay][lr];
310 delete ftmax[lay][lr];
315void PreT0Calib::renameHist(){
317 for(
int lay=0; lay<
NLAYER; lay++){
318 for(
int lr=0; lr<
NLR; lr++){
319 if(0 == lr)
sprintf(hname,
"Trec%02d_L", lay);
320 else if(1 == lr)
sprintf(hname,
"Trec%02d_R", lay);
321 else sprintf(hname,
"Trec%02d_C", lay);
322 m_hTrec[lay][lr]->SetName(hname);
325 for(
int lay=0; lay<
NLAYER; lay++){
326 for(
int iud=0; iud<2; iud++){
327 if(0 == iud)
sprintf(hname,
"TrecCosm%02d_Up", lay);
328 else sprintf(hname,
"TrecCosm%02d_Dw", lay);
329 m_hTrecCosm[lay][iud]->SetName(hname);
332 for(
int lay=0; lay<
NLAYER; lay++){
333 for(
int lr=0; lr<
NLR; lr++){
335 if(0 == lr)
sprintf(hname,
"Trec%02d_z%02d_L", lay,
bin);
336 else if(1 == lr)
sprintf(hname,
"Trec%02d_z%02d_R", lay,
bin);
337 else sprintf(hname,
"Trec%02d_z%02d_C", lay,
bin);
338 m_hTrecZ[lay][lr][
bin]->SetName(hname);
344Double_t PreT0Calib::funTmin(Double_t* x, Double_t* par){
346 fitval = par[0] + par[1]*
exp( -par[2]*(x[0]-par[3]) ) /
347 ( 1 +
exp( -(x[0]-par[4])/par[5] ));
351Double_t PreT0Calib::funTmax(Double_t* x, Double_t* par){
353 fitval = par[0] + par[1] / (1 +
exp((x[0]-par[2])/par[3]));
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
double gTminFitRange[NLAYER][2]
double gTmaxFitRange[NLAYER][2]
EvtComplex exp(const EvtComplex &c)
double getT0(int wireid) const
double getXtpar(int lay, int entr, int lr, int order)
const MdcCosWire * getWire(int iwire) const
void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
void mergeHist(TFile *fhist)
void init(TObjArray *hlist, MdcCosGeom *pGeom)