2#include "include/fun.h"
9 cout <<
"Calibration type: IniCalib" << endl;
18 m_fdcom =
new TFolder(
"mCommon",
"mCommon");
21 m_fdTmap =
new TFolder(
"mThitmap",
"mThitmap");
24 m_fdTraw =
new TFolder(
"mTraw",
"mTraw");
27 m_fdTrawCel =
new TFolder(
"mTrawCell",
"mTrawCell");
28 hlist->Add(m_fdTrawCel);
30 m_fdQmap =
new TFolder(
"mQhitmap",
"mQhitmap");
33 m_fdQraw =
new TFolder(
"mQraw",
"mQraw");
36 m_fdQrawCel =
new TFolder(
"mQrawCell",
"mQrawCell");
37 hlist->Add(m_fdQrawCel);
39 m_hLayerHitmapT =
new TH1F(
"mT_Hitmap_Layer",
"", 43, -0.5, 42.5);
40 m_fdcom->Add(m_hLayerHitmapT);
42 m_hWireHitMapT =
new TH1F(
"mT_Hitmap_Wire",
"", 6796, -0.5, 6795.5);
43 m_fdcom->Add(m_hWireHitMapT);
45 m_hLayerHitmapQ =
new TH1F(
"mQ_Hitmap_Layer",
"", 43, -0.5, 42.5);
46 m_fdcom->Add(m_hLayerHitmapQ);
48 m_hWireHitMapQ =
new TH1F(
"mQ_Hitmap_Wire",
"", 6796, -0.5, 6795.5);
49 m_fdcom->Add(m_hWireHitMapQ);
51 m_hTesAll =
new TH1F(
"mTesAll",
"", 750, 0, 1500);
52 m_fdcom->Add(m_hTesAll);
54 m_hTesCal =
new TH1F(
"mTesCal",
"", 750, 0, 1500);
55 m_fdcom->Add(m_hTesCal);
57 m_hTesFlag =
new TH1F(
"mTes_Flag",
"", 300, -0.5, 299.5);
58 m_fdcom->Add(m_hTesFlag);
60 for(
int lay=0; lay<
NLAYER; lay++){
63 sprintf(hname,
"mT_hitmap_Lay%02d", lay);
64 m_hlaymapT[lay] =
new TH1F(hname,
"", ncel, -0.5, (
float)ncel-0.5);
65 m_fdTmap -> Add(m_hlaymapT[lay]);
67 sprintf(hname,
"mTDC_Lay%02d", lay);
68 m_htdc[lay] =
new TH1F(hname,
"", 800, 0, 20000);
69 m_fdTraw -> Add(m_htdc[lay]);
71 sprintf(hname,
"mTraw_Lay%02d", lay);
72 m_htraw[lay] =
new TH1F(hname,
"", 500, 0, 1000);
73 m_fdTraw -> Add(m_htraw[lay]);
75 sprintf(hname,
"mQ_hitmap_Lay%02d", lay);
76 m_hlaymapQ[lay] =
new TH1F(hname,
"", ncel, -0.5, (
float)ncel-0.5);
77 m_fdQmap -> Add(m_hlaymapQ[lay]);
79 sprintf(hname,
"mQraw_Lay%02d", lay);
80 m_hqraw[lay] =
new TH1F(hname,
"", 2000, 0, 4000);
81 m_fdQraw -> Add(m_hqraw[lay]);
84 for(
int wir=0; wir<
NWIRE; wir++){
85 int lay = m_pGeom -> getWire(wir) -> getLayerId();
86 int cel = m_pGeom -> getWire(wir) -> getCellId();
88 sprintf(hname,
"mTraw_%02d_%03d_%04d", lay, cel, wir);
89 m_htrawCel[wir] =
new TH1F(hname,
"", 300, 0, 600);
90 m_fdTrawCel -> Add(m_htrawCel[wir]);
92 sprintf(hname,
"mQraw_%02d_%03d_%04d", lay, cel, wir);
93 m_hqrawCel[wir] =
new TH1F(hname,
"", 2000, 0, 4000);
94 m_fdQrawCel -> Add(m_hqrawCel[wir]);
99 TFolder* fdcom = (TFolder*)fhist->Get(
"Common");
100 TFolder* fdTmap = (TFolder*)fhist->Get(
"Thitmap");
101 TFolder* fdTraw = (TFolder*)fhist->Get(
"Traw");
102 TFolder* fdTrawCel = (TFolder*)fhist->Get(
"TrawCell");
103 TFolder* fdQmap = (TFolder*)fhist->Get(
"Qhitmap");
104 TFolder* fdQraw = (TFolder*)fhist->Get(
"Qraw");
105 TFolder* fdQrawCel = (TFolder*)fhist->Get(
"QrawCell");
109 hist = (TH1F*)fdcom->FindObjectAny(
"T_Hitmap_Layer");
110 m_hLayerHitmapT->Add(hist);
112 hist = (TH1F*)fdcom->FindObjectAny(
"T_Hitmap_Wire");
113 m_hWireHitMapT->Add(hist);
115 hist = (TH1F*)fdcom->FindObjectAny(
"Q_Hitmap_Layer");
116 m_hLayerHitmapQ->Add(hist);
118 hist = (TH1F*)fdcom->FindObjectAny(
"Q_Hitmap_Wire");
119 m_hWireHitMapQ->Add(hist);
121 hist = (TH1F*)fdcom->FindObjectAny(
"TesAll");
122 m_hTesAll->Add(hist);
124 hist = (TH1F*)fdcom->FindObjectAny(
"TesCal");
125 m_hTesCal->Add(hist);
127 hist = (TH1F*)fdcom->FindObjectAny(
"Tes_Flag");
128 m_hTesFlag->Add(hist);
130 for(
int lay=0; lay<
NLAYER; lay++){
131 sprintf(hname,
"T_hitmap_Lay%02d", lay);
132 hist = (TH1F*)fdTmap->FindObjectAny(hname);
133 m_hlaymapT[lay]->Add(hist);
135 sprintf(hname,
"TDC_Lay%02d", lay);
136 hist = (TH1F*)fdTraw->FindObjectAny(hname);
137 m_htdc[lay]->Add(hist);
139 sprintf(hname,
"Traw_Lay%02d", lay);
140 hist = (TH1F*)fdTraw->FindObjectAny(hname);
141 m_htraw[lay]->Add(hist);
143 sprintf(hname,
"Q_hitmap_Lay%02d", lay);
144 hist = (TH1F*)fdQmap->FindObjectAny(hname);
145 m_hlaymapQ[lay]->Add(hist);
147 sprintf(hname,
"Qraw_Lay%02d", lay);
148 hist = (TH1F*)fdQraw->FindObjectAny(hname);
149 m_hqraw[lay]->Add(hist);
152 for(
int wir=0; wir<
NWIRE; wir++){
153 int lay = m_pGeom -> getWire(wir) -> getLayerId();
154 int cel = m_pGeom -> getWire(wir) -> getCellId();
156 sprintf(hname,
"Traw_%02d_%03d_%04d", lay, cel, wir);
157 hist = (TH1F*)fdTrawCel->FindObjectAny(hname);
158 m_htrawCel[wir]->Add(hist);
160 sprintf(hname,
"Qraw_%02d_%03d_%04d", lay, cel, wir);
161 hist = (TH1F*)fdQrawCel->FindObjectAny(hname);
162 m_hqrawCel[wir]->Add(hist);
178 double chindfTmin[
NLAYER];
179 double chindfTmax[
NLAYER];
184 for(lay=0; lay<
NLAYER; lay++){
186 chindfTmin[lay] = -1;
187 sprintf(funname,
"ftmin%02d", lay);
188 ftmin[lay] =
new TF1(funname, funTmin, 0, 150, 6);
191 Stat_t nEntryTot = 0;
192 for(
int ibin=1; ibin<=25; ibin++){
193 Stat_t entry = m_htraw[lay]->GetBinContent(ibin);
196 double c0Ini = (double)nEntryTot / 25.0;
197 double c1Ini = (m_htraw[lay]->GetMaximum()) - c0Ini;
199 ftmin[lay] -> SetParameter(0, c0Ini);
200 ftmin[lay] -> SetParameter(1, c1Ini);
201 ftmin[lay] -> SetParameter(2, 0);
202 ftmin[lay] -> SetParameter(4, initT0);
203 ftmin[lay] -> SetParameter(5, 1);
206 gStyle -> SetOptFit(11);
207 chisq = ftmin[lay]->GetChisquare();
208 ndf = ftmin[lay]->GetNDF();
209 chindfTmin[lay] = chisq / ndf;
212 t0Fit[lay] = ftmin[lay]->GetParameter(4);
218 if(0 == fitTminFg[lay]){
220 t0Cal[lay] = calconst->
getT0(wir);
227 for(lay=0; lay<
NLAYER; lay++){
229 chindfTmax[lay] = -1;
230 sprintf(funname,
"ftmax%02d", lay);
231 ftmax[lay] =
new TF1(funname, funTmax, 250, 500, 4);
234 ftmax[lay] -> SetParameter(2,
gInitTm[lay]);
235 ftmax[lay] -> SetParameter(3, 10);
238 gStyle -> SetOptFit(11);
239 chisq = ftmax[lay]->GetChisquare();
240 ndf = ftmax[lay]->GetNDF();
241 chindfTmax[lay] = chisq / ndf;
244 tmax[lay] = ftmax[lay]->GetParameter(2);
248 if(0 == fitTmaxFg[lay]){
249 tmax[lay] = (calconst->
getXtpar(lay, 0, 0, 6)) + t0Fit[lay];
254 ofstream ft0(
"iniT0.dat");
255 for(lay=0; lay<
NLAYER; lay++){
256 ft0 << setw(5) << lay << setw(3) << fitTminFg[lay]
257 << setw(12) << t0Cal[lay] << setw(12) << t0Fit[lay]
258 << setw(12) << chindfTmin[lay] << setw(5) << fitTmaxFg[lay]
259 << setw(12) << tmax[lay] << setw(12) << tmax[lay] - t0Fit[lay]
260 << setw(12) << chindfTmax[lay] << endl;
263 cout <<
"iniT0.dat was written." << endl;
267 int nwire = m_pGeom -> getWireSize();
268 for(i=0; i<nwire; i++){
269 lay = m_pGeom -> getWire(i) -> getLayerId();
271 calconst -> resetT0(i, t0Cal[lay]);
272 calconst -> resetDelT0(i, 0.0);
282 double xtini[8] = {0, 0.03, 0, 0, 0, 0, 999.9, 0};
283 for(lay=0; lay<
NLAYER; lay++){
286 for(iEntr=0; iEntr<
NENTRXT; iEntr++){
287 for(lr=0; lr<
NLR; lr++){
288 for(ord=0; ord<
NXTPAR; ord++){
290 xtpar = tmax[lay] - t0Fit[lay];
294 calconst -> resetXtpar(lay, iEntr, lr, ord, xtpar);
301 for(lay=0; lay<
NLAYER; lay++){
302 calconst -> resetQtpar0(lay, 0.0);
303 calconst -> resetQtpar1(lay, 0.0);
309 for(lay=0; lay<
NLAYER; lay++){
310 for(iEntr=0; iEntr<
NENTRSD; iEntr++){
311 for(lr=0; lr<2; lr++){
313 calconst -> resetSdpar(lay, iEntr, lr,
bin, sdpar);
322 for(lay=0; lay<
NLAYER; lay++){
323 for(iEntr=0; iEntr<
NENTRXT; iEntr++){
324 for(lr=0; lr<
NLR; lr++){
325 xtpar = tmax[lay] - t0Fit[lay];
326 calconst -> resetXtpar(lay, iEntr, lr, 6, xtpar);
333 for(lay=0; lay<
NLAYER; lay++){
339Double_t IniCalib::funTmin(Double_t* x, Double_t* par){
341 fitval = par[0] + par[1]*
exp( -par[2]*(x[0]-par[3]) ) /
342 ( 1 +
exp( -(x[0]-par[4])/par[5] ));
346Double_t IniCalib::funTmax(Double_t* x, Double_t* par){
348 fitval = par[0] + par[1] / (1 +
exp((x[0]-par[2])/par[3]));
352void IniCalib::renameHist(){
354 m_fdcom->SetName(
"Common");
355 m_fdTmap->SetName(
"Thitmap");
356 m_fdTraw->SetName(
"Traw");
357 m_fdTrawCel->SetName(
"TrawCell");
358 m_fdQmap->SetName(
"Qhitmap");
359 m_fdQraw->SetName(
"Qraw");
360 m_fdQrawCel->SetName(
"QrawCell");
362 m_hLayerHitmapT->SetName(
"T_Hitmap_Layer");
363 m_hWireHitMapT->SetName(
"T_Hitmap_Wire");
364 m_hLayerHitmapQ->SetName(
"Q_Hitmap_Layer");
365 m_hWireHitMapQ->SetName(
"Q_Hitmap_Wire");
366 m_hTesAll->SetName(
"TesAll");
367 m_hTesCal->SetName(
"TesCal");
368 m_hTesFlag->SetName(
"Tes_Flag");
370 for(
int lay=0; lay<
NLAYER; lay++){
371 sprintf(hname,
"T_hitmap_Lay%02d", lay);
372 m_hlaymapT[lay]->SetName(hname);
374 sprintf(hname,
"TDC_Lay%02d", lay);
375 m_htdc[lay]->SetName(hname);
377 sprintf(hname,
"Traw_Lay%02d", lay);
378 m_htraw[lay]->SetName(hname);
380 sprintf(hname,
"Q_hitmap_Lay%02d", lay);
381 m_hlaymapQ[lay]->SetName(hname);
383 sprintf(hname,
"Qraw_Lay%02d", lay);
384 m_hqraw[lay]->SetName(hname);
386 for(
int wir=0; wir<
NWIRE; wir++){
387 int lay = m_pGeom -> getWire(wir) -> getLayerId();
388 int cel = m_pGeom -> getWire(wir) -> getCellId();
390 sprintf(hname,
"Traw_%02d_%03d_%04d", lay, cel, wir);
391 m_htrawCel[wir]->SetName(hname);
393 sprintf(hname,
"Qraw_%02d_%03d_%04d", lay, cel, wir);
394 m_hqrawCel[wir]->SetName(hname);
EvtComplex exp(const EvtComplex &c)
*******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]
void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
void mergeHist(TFile *fhist)
void init(TObjArray *hlist, MdcCosGeom *pGeom)
double getT0(int wireid) const
double getXtpar(int lay, int entr, int lr, int order)
const MdcCosLayer * getLayer(int ilay) const
const MdcCosWire * getWire(int iwire) const