70 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
71 MsgStream log(
msgSvc,
"XtMdcCalib");
72 log << MSG::INFO <<
"XtMdcCalib::initialize()" << endreq;
75 m_mdcGeomSvc = mdcGeomSvc;
76 m_mdcFunSvc = mdcFunSvc;
77 m_mdcUtilitySvc = mdcUtilitySvc;
90 m_fdXt =
new TFolder(
"fdXt",
"fdXt");
91 m_hlist -> Add(m_fdXt);
93 m_nlayer = m_mdcGeomSvc -> getLayerSize();
96 for(lay=0; lay<m_nlayer; lay++){
97 for(iEntr=0; iEntr<m_nEntr[lay]; iEntr++){
98 for(iLR=0; iLR<m_nLR; iLR++){
100 sprintf(hname,
"Hxt%02d_E%02d_LR%01d_B%02d", lay, iEntr, iLR,
bin);
101 hist =
new TH1D(hname,
"", 300, -1.5, 1.5);
102 m_hxt.push_back( hist );
103 m_fdXt -> Add( hist );
116 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
117 MsgStream log(
msgSvc,
"XtMdcCalib");
118 log << MSG::DEBUG <<
"XtMdcCalib::fillHist()" << endreq;
123 bool esCutFg =
event->getEsCutFlag();
124 if( ! esCutFg )
return -1;
154 for(iEntr=0; iEntr<m_nEntr[lay]; iEntr++){
157 if(0 == iEntr) m_mdcFunSvc -> getXtpar(lay, 8, iLR, xtpar);
158 else if(1 == iEntr) m_mdcFunSvc -> getXtpar(lay, 9, iLR, xtpar);
159 m_tm[lay][iEntr][iLR] = xtpar[6];
170 int ntrk =
event -> getNTrk();
171 if((ntrk < m_param.
nTrkCut[0]) || (ntrk > m_param.
nTrkCut[1]))
return -1;
172 for(i=0; i<ntrk; i++){
173 rectrk =
event->getRecTrk(i);
174 nhit = rectrk -> getNHits();
177 dr = rectrk->
getDr();
178 if(fabs(dr) > m_param.
drCut)
continue;
181 dz = rectrk->
getDz();
182 if(fabs(dz) > m_param.
dzCut)
continue;
185 fgHitLay[lay] =
false;
188 for(k=0; k<nhit; k++){
189 rechit = rectrk -> getRecHit(k);
190 lay = rechit -> getLayid();
191 fgHitLay[lay] =
true;
196 if(fgHitLay[lay]) nhitlay++;
203 for(k=0; k<nhit; k++){
204 rechit = rectrk -> getRecHit(k);
205 lay = rechit -> getLayid();
206 doca = rechit -> getDocaInc();
207 iLR = rechit -> getLR();
208 entrance = rechit -> getEntra();
209 resi = rechit -> getResiInc();
210 tdr = rechit -> getTdrift();
211 stat = rechit -> getStat();
213 if(1 != stat)
continue;
215 if( (fabs(doca) > m_docaMax[lay]) ||
216 (fabs(resi) > m_param.
resiCut[lay]) ){
221 if( ! fgHitLay[1] )
continue;
222 }
else if(42 == lay){
223 if( ! fgHitLay[41] )
continue;
225 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) )
continue;
228 iEntr = m_mdcFunSvc -> getXtEntrIndex(entrance);
229 if(1 == m_nEntr[lay]){
231 }
else if(2 == m_nEntr[lay]){
232 if(entrance > 0.0) iEntr = 1;
236 bin = (int)(tdr / m_tbinw);
240 if((
bin < m_nbin) && (1 == m_hxtmap.count(
key))){
242 m_hxt[hid] -> Fill( resi );
247 if((
bin < m_nbin) && (1 == m_hxtmap.count(
key))){
249 m_hxt[hid] -> Fill( resi );
252 if(fabs(tdr - m_tm[lay][iEntr][iLR]) < 5){
254 if( 1 == m_hxtmap.count(
key) ){
256 m_hxt[hid] -> Fill( resi );
260 if( 1 == m_hxtmap.count(
key) ){
262 m_hxt[hid] -> Fill( resi );
273 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
274 MsgStream log(
msgSvc,
"XtMdcCalib");
275 log << MSG::INFO <<
"XtMdcCalib::updateConst()" << endreq;
305 Double_t arglist[10];
307 TMinuit* gmxt =
new TMinuit(6);
308 gmxt -> SetPrintLevel(-1);
309 gmxt -> SetFCN(
fcnXT);
310 gmxt -> SetErrorDef(1.0);
311 gmxt -> mnparm(0,
"xtpar0", 0, 0.1, 0, 0, ierflg);
312 gmxt -> mnparm(1,
"xtpar1", 0, 0.1, 0, 0, ierflg);
313 gmxt -> mnparm(2,
"xtpar2", 0, 0.1, 0, 0, ierflg);
314 gmxt -> mnparm(3,
"xtpar3", 0, 0.1, 0, 0, ierflg);
315 gmxt -> mnparm(4,
"xtpar4", 0, 0.1, 0, 0, ierflg);
316 gmxt -> mnparm(5,
"xtpar5", 0, 0.1, 0, 0, ierflg);
318 gmxt -> mnexcm(
"SET NOW", arglist, 0, ierflg);
320 TMinuit* gmxtEd =
new TMinuit(1);
321 gmxtEd -> SetPrintLevel(-1);
323 gmxtEd -> SetErrorDef(1.0);
324 gmxtEd -> mnparm(0,
"xtpar0", 0, 0.1, 0, 0, ierflg);
326 gmxtEd -> mnexcm(
"SET NOW", arglist, 0, ierflg);
328 ofstream fxtlog(
"xtlog");
329 for(lay=0; lay<m_nlayer; lay++){
330 if(0 == m_param.
fgCalib[lay])
continue;
332 for(iEntr=0; iEntr<m_nEntr[lay]; iEntr++){
333 for(iLR=0; iLR<m_nLR; iLR++){
335 fxtlog <<
"Layer " << setw(3) << lay << setw(3) << iEntr
336 << setw(3) << iLR << endl;
338 for(ord=0; ord<m_nxtpar; ord++){
340 if(0 == iEntr) xtpar = calconst -> getXtpar(lay, 8, iLR, ord);
341 else if(1 == iEntr) xtpar = calconst -> getXtpar(lay, 9, iLR, ord);
353 entry = m_hxt[hid] -> GetEntries();
355 deltx = m_hxt[hid] -> GetMean();
356 xerr = m_hxt[hid]->GetRMS();
362 tbcen = ( (double)
bin + 0.5 ) * m_tbinw;
363 else tbcen = m_tm[lay][iEntr][iLR];
364 xcor =
xtFun(tbcen, xtini) - deltx;
366 if((tbcen <=
Tmax) || (
bin == m_nbin)){
368 XMEAS.push_back( xcor );
369 ERR.push_back( xerr );
373 ERRED.push_back( xerr );
375 fxtlog << setw(3) <<
bin
383 if(
XMEAS.size() < 12 ){
395 for(ord=0; ord<=5; ord++){
396 arglist[0] = ord + 1;
397 arglist[1] = xtini[ord];
398 gmxt -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
405 gmxt -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
406 gmxt -> mnexcm(
"FIX", arglist, 1, ierflg);
411 gmxt -> mnexcm(
"MIGRAD", arglist, 2, ierflg);
412 gmxt -> mnstat(fmin, edm, errdef, nvpar, nparx, istat);
414 fxtlog <<
"Xtpar: " << endl;
415 if( (0 == ierflg) && (istat >= 2) ){
416 for(ord=0; ord<=5; ord++){
417 gmxt -> GetParameter(ord, xtpar, xterr);
421 if(1 == m_nEntr[lay]){
423 calconst -> resetXtpar(lay, i, iLR, ord, xtpar);
424 }
else if(2 == m_nEntr[lay]){
427 calconst->
resetXtpar(lay, i, iLR, ord, xtpar);
430 calconst->
resetXtpar(lay, i, iLR, ord, xtpar);
433 fxtlog << setw(15) << xtpar << setw(15) << xterr << endl;
436 for(ord=0; ord<=5; ord++){
437 fxtlog << setw(15) << xtini[ord] << setw(15) <<
"0" << endl;
440 fxtlog << setw(15) <<
Tmax << setw(15) <<
"0" << endl;
445 gmxt -> mnexcm(
"REL", arglist, 1, ierflg);
453 arglist[1] = xtini[7];
454 gmxtEd -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
458 gmxtEd -> mnexcm(
"MIGRAD", arglist, 2, ierflg);
459 gmxtEd -> mnstat(fmin, edm, errdef, nvpar, nparx, istat);
461 if( (0 == ierflg) && (istat >=2) ){
462 gmxtEd -> GetParameter(0, xtpar, xterr);
463 if(xtpar < 0.0) xtpar = 0.0;
467 if(1 == m_nEntr[lay]){
469 calconst -> resetXtpar(lay, i, iLR, 7, xtpar);
470 }
else if(2 == m_nEntr[lay]){
479 fxtlog << setw(15) << xtpar << setw(15) << xterr << endl;
481 fxtlog << setw(15) << xtini[7] << setw(15) <<
"0" << endl;
484 fxtlog << setw(15) << xtini[7] << setw(15) <<
"0" << endl;
486 fxtlog <<
"Tm " << setw(15) <<
Tmax
487 <<
" Dmax " << setw(15) <<
Dmax << endl;
502 cout <<
"Xt update finished" << endl;