82 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
83 MsgStream log(
msgSvc,
"IniMdcCalib");
84 log << MSG::INFO <<
"IniMdcCalib::initialize()" << endreq;
87 m_mdcGeomSvc = mdcGeomSvc;
88 m_mdcFunSvc = mdcFunSvc;
89 m_mdcUtilitySvc = mdcUtilitySvc;
97 m_nWire = m_mdcGeomSvc -> getWireSize();
98 m_nLayer = m_mdcGeomSvc -> getLayerSize();
100 m_fdcom =
new TFolder(
"Common",
"Common");
101 m_hlist->Add(m_fdcom);
103 m_fdTmap =
new TFolder(
"Thitmap",
"Thitmap");
104 m_hlist->Add(m_fdTmap);
106 m_fdTraw =
new TFolder(
"Traw",
"Traw");
107 m_hlist->Add(m_fdTraw);
109 m_fdTrawCel =
new TFolder(
"TrawCell",
"TrawCell");
110 m_hlist->Add(m_fdTrawCel);
112 m_fdTrawTes =
new TFolder(
"TrawTes",
"TrawTes");
113 m_hlist->Add(m_fdTrawTes);
115 m_fdQmap =
new TFolder(
"Qhitmap",
"Qhitmap");
116 m_hlist->Add(m_fdQmap);
118 m_fdQraw =
new TFolder(
"Qraw",
"Qraw");
119 m_hlist->Add(m_fdQraw);
121 m_fdQrawCel =
new TFolder(
"QrawCell",
"QrawCell");
122 m_hlist->Add(m_fdQrawCel);
124 m_hLayerHitmapT =
new TH1F(
"T_Hitmap_Layer",
"", 43, -0.5, 42.5);
125 m_fdcom->Add(m_hLayerHitmapT);
127 m_hWireHitMapT =
new TH1F(
"T_Hitmap_Wire",
"", 6796, -0.5, 6795.5);
128 m_fdcom->Add(m_hWireHitMapT);
130 m_hLayerHitmapQ =
new TH1F(
"Q_Hitmap_Layer",
"", 43, -0.5, 42.5);
131 m_fdcom->Add(m_hLayerHitmapQ);
133 m_hWireHitMapQ =
new TH1F(
"Q_Hitmap_Wire",
"", 6796, -0.5, 6795.5);
134 m_fdcom->Add(m_hWireHitMapQ);
137 for(iEs=0; iEs<m_param.
nEsFlag; iEs++){
139 m_hTes[iEs] =
new TH1F(hname,
"", 2000, 0, 2000);
140 m_fdcom->Add(m_hTes[iEs]);
143 m_hTesAllFlag =
new TH1F(
"TesAllFlag",
"", 300, -0.5, 299.5);
144 m_fdcom ->
Add(m_hTesAllFlag);
146 m_hTesAll =
new TH1F(
"TesAll",
"", 2000, 0, 2000);
147 m_fdcom->Add(m_hTesAll);
149 m_hTesCal =
new TH1F(
"TesCal",
"", 2000, 0, 2000);
150 m_fdcom->Add(m_hTesCal);
152 m_hTesFlag =
new TH1F(
"Tes_Flag",
"", 300, -0.5, 299.5);
153 m_fdcom->Add(m_hTesFlag);
157 double tdcmax = 20000;
161 double trawmax = 2000;
163 for(lay=0; lay<m_nLayer; lay++){
166 sprintf(hname,
"T_hitmap_Lay%02d", lay);
167 m_hlaymapT[lay] =
new TH1F(hname,
"", ncel, -0.5, (
float)ncel-0.5);
168 m_fdTmap ->
Add(m_hlaymapT[lay]);
170 sprintf(hname,
"TDC_Lay%02d", lay);
171 m_htdc[lay] =
new TH1F(hname,
"", tdcNbin, tdcmin, tdcmax);
172 m_fdTraw ->
Add(m_htdc[lay]);
174 sprintf(hname,
"Traw_Lay%02d", lay);
175 m_htraw[lay] =
new TH1F(hname,
"", trawNbin, trawmin, trawmax);
176 m_fdTraw ->
Add(m_htraw[lay]);
178 for(iEs=0; iEs<m_param.
nEsFlag; iEs++){
179 sprintf(hname,
"TDC_Lay%02d_Tes%d", lay, m_param.
esFlag[iEs]);
180 m_htdcTes[lay][iEs] =
new TH1F(hname,
"", tdcNbin, tdcmin, tdcmax);
181 m_fdTrawTes ->
Add(m_htdcTes[lay][iEs]);
183 sprintf(hname,
"Traw_Lay%02d_Tes%d", lay, m_param.
esFlag[iEs]);
184 m_htrawTes[lay][iEs] =
new TH1F(hname,
"", trawNbin, trawmin, trawmax);
185 m_fdTrawTes ->
Add(m_htrawTes[lay][iEs]);
188 sprintf(hname,
"Q_hitmap_Lay%02d", lay);
189 m_hlaymapQ[lay] =
new TH1F(hname,
"", ncel, -0.5, (
float)ncel-0.5);
190 m_fdQmap ->
Add(m_hlaymapQ[lay]);
192 sprintf(hname,
"Qraw_Lay%02d", lay);
193 m_hqraw[lay] =
new TH1F(hname,
"", 2000, 0, 4000);
194 m_fdQraw ->
Add(m_hqraw[lay]);
198 lay = m_mdcGeomSvc -> Wire(wir) -> Layer();
199 cel = m_mdcGeomSvc -> Wire(wir) -> Cell();
201 sprintf(hname,
"Traw_%02d_%03d_%04d", lay, cel, wir);
202 m_htrawCel[wir] =
new TH1F(hname,
"", trawNbin, trawmin, trawmax);
203 m_fdTrawCel ->
Add(m_htrawCel[wir]);
205 sprintf(hname,
"Qraw_%02d_%03d_%04d", lay, cel, wir);
206 m_hqrawCel[wir] =
new TH1F(hname,
"", 2000, 0, 4000);
207 m_fdQrawCel ->
Add(m_hqrawCel[wir]);
213 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
214 MsgStream log(
msgSvc,
"IniMdcCalib");
215 log << MSG::DEBUG <<
"IniMdcCalib::fillHist()" << endreq;
228 IDataProviderSvc* eventSvc =
NULL;
229 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
231 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
233 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
234 return( StatusCode::FAILURE);
236 int iRun = eventHeader->runNumber();
237 int iEvt = eventHeader->eventNumber();
240 double tes = -9999.0;
242 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc,
"/Event/Recon/RecEsTimeCol");
243 if( (!aevtimeCol) || (aevtimeCol->size()==0) ){
247 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
248 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
249 tes = (*iter_evt)->getTest();
250 esTimeflag = (*iter_evt)->getStat();
254 m_hTesAllFlag->Fill(esTimeflag);
255 m_hTesAll->Fill(tes);
256 m_hTesFlag->Fill(esTimeflag);
258 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++){
259 if(esTimeflag == m_param.
esFlag[iEs]){
260 m_hTes[iEs]->Fill(tes);
265 bool fgFillTes =
false;
268 }
else if( (nTesFlag > -1) && (tes > m_param.
tesMin) && (tes < m_param.
tesMax) ){
272 if(fgFillTes) m_hTesCal->Fill(tes);
277 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc,
"/Event/Digi/MdcDigiCol");
279 log << MSG::FATAL <<
"Could not find event" << endreq;
282 MdcDigiCol::iterator
iter = mdcDigiCol->begin();
284 for(;
iter != mdcDigiCol->end();
iter++, digiId++) {
286 id = (aDigi)->identify();
290 wir = m_mdcGeomSvc->
Wire(lay, cel)->
Id();
292 tdc = (aDigi) -> getTimeChannel();
293 adc = (aDigi) -> getChargeChannel();
294 fgOverFlow = (aDigi) -> getOverflow();
296 if ( ((fgOverFlow & 1) !=0 ) || ((fgOverFlow & 12) != 0) ||
303 m_hLayerHitmapT ->
Fill(lay);
304 m_hWireHitMapT ->
Fill(wir);
305 m_hlaymapT[lay] ->
Fill(cel);
307 m_hLayerHitmapQ ->
Fill(lay);
308 m_hWireHitMapQ ->
Fill(wir);
309 m_hlaymapQ[lay] ->
Fill(cel);
315 m_htdc[lay] ->
Fill(tdc);
316 m_htraw[lay] ->
Fill(traw);
317 m_hqraw[lay] ->
Fill(qraw);
320 m_htdcTes[lay][nTesFlag] ->
Fill(tdc);
321 m_htrawTes[lay][nTesFlag] ->
Fill(traw);
324 m_htrawCel[wir] ->
Fill(traw);
325 m_hqrawCel[wir] ->
Fill(qraw);
336 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
337 MsgStream log(
msgSvc,
"IniMdcCalib");
338 log << MSG::DEBUG <<
"IniMdcCalib::updateConst()" << endreq;
345 double initT0 = m_param.
initT0;
359 for(lay=0; lay<m_nLayer; lay++){
361 chindfTmin[lay] = -1;
362 sprintf(funname,
"ftmin%02d", lay);
363 ftmin[lay] =
new TF1(funname, funTmin, 0, 150, 6);
366 Stat_t nEntryTot = 0;
367 for(
int ibin=1; ibin<=25; ibin++){
368 Stat_t entry = m_htraw[lay]->GetBinContent(ibin);
371 double c0Ini = (double)nEntryTot / 25.0;
372 double c1Ini = (m_htraw[lay]->GetMaximum()) - c0Ini;
374 ftmin[lay] -> SetParameter(0, c0Ini);
375 ftmin[lay] -> SetParameter(1, c1Ini);
376 ftmin[lay] -> SetParameter(2, 0);
377 ftmin[lay] -> SetParameter(4, initT0);
378 ftmin[lay] -> SetParameter(5, 2);
380 m_htraw[lay] ->
Fit(funname,
"Q",
"",
383 chisq = ftmin[lay]->GetChisquare();
384 gStyle -> SetOptFit(11);
385 ndf = ftmin[lay]->GetNDF();
386 chindfTmin[lay] = chisq / ndf;
389 t0Fit[lay] = ftmin[lay]->GetParameter(4);
391 t0Cal[lay] = t0Fit[lay] - m_param.
timeShift;
395 if(0 == fitTminFg[lay]){
396 wir = m_mdcGeomSvc->
Wire(lay, 0)->
Id();
397 t0Cal[lay] = calconst->
getT0(wir);
398 t0Fit[lay] = t0Cal[lay] + m_param.
timeShift;
404 for(lay=0; lay<m_nLayer; lay++){
406 chindfTmax[lay] = -1;
407 sprintf(funname,
"ftmax%02d", lay);
408 ftmax[lay] =
new TF1(funname, funTmax, 250, 500, 4);
411 ftmax[lay] -> SetParameter(2, m_param.
initTm[lay]);
412 ftmax[lay] -> SetParameter(3, 10);
414 m_htraw[lay] ->
Fit(funname,
"Q+",
"",
417 gStyle -> SetOptFit(11);
418 chisq = ftmax[lay]->GetChisquare();
419 ndf = ftmax[lay]->GetNDF();
420 chindfTmax[lay] = chisq / ndf;
423 tmax[lay] = ftmax[lay]->GetParameter(2);
427 if(0 == fitTmaxFg[lay]){
428 tmax[lay] = (calconst->
getXtpar(lay, 0, 0, 6)) + t0Fit[lay];
433 ofstream ft0(
"iniT0.dat");
434 for(lay=0; lay<m_nLayer; lay++){
435 ft0 << setw(5) << lay << setw(3) << fitTminFg[lay]
436 << setw(12) << t0Cal[lay] << setw(12) << t0Fit[lay]
437 << setw(12) << chindfTmin[lay] << setw(5) << fitTmaxFg[lay]
438 << setw(12) << tmax[lay] << setw(12) << tmax[lay] - t0Fit[lay]
439 << setw(12) << chindfTmax[lay] << endl;
442 cout <<
"iniT0.dat was written." << endl;
446 int nwire = m_mdcGeomSvc -> getWireSize();
447 for(i=0; i<nwire; i++){
448 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
450 calconst -> resetT0(i, t0Cal[lay]);
451 calconst -> resetDelT0(i, 0.0);
461 double xtini[8] = {0, 0.03, 0, 0, 0, 0, 999.9, 0};
462 for(lay=0; lay<m_nLayer; lay++){
463 if(1 != m_param.
fgCalib[lay])
continue;
469 xtpar = tmax[lay] - t0Fit[lay];
473 calconst -> resetXtpar(lay, iEntr, lr, ord, xtpar);
480 for(lay=0; lay<m_nLayer; lay++){
481 calconst -> resetQtpar0(lay, 0.0);
482 calconst -> resetQtpar1(lay, 0.0);
488 for(lay=0; lay<m_nLayer; lay++){
490 for(lr=0; lr<2; lr++){
492 calconst -> resetSdpar(lay, iEntr, lr,
bin, sdpar);
501 for(lay=0; lay<m_nLayer; lay++){
504 xtpar = tmax[lay] - t0Fit[lay];
505 calconst -> resetXtpar(lay, iEntr, lr, 6, xtpar);