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];