48 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc );
49 MsgStream log(
msgSvc,
"PreXtMdcCalib" );
50 log << MSG::INFO <<
"PreXtMdcCalib::initialize()" << endmsg;
53 m_mdcGeomSvc = mdcGeomSvc;
54 m_mdcFunSvc = mdcFunSvc;
55 m_mdcUtilitySvc = mdcUtilitySvc;
59 m_nWire = m_mdcGeomSvc->getWireSize();
60 m_nLayer = m_mdcGeomSvc->getLayerSize();
62 m_fdPreXt =
new TFolder(
"PreXt",
"PreXt" );
63 m_hlist->Add( m_fdPreXt );
65 m_fdNhit =
new TFolder(
"XtNhit",
"XtNhit" );
66 m_hlist->Add( m_fdNhit );
68 m_haxis =
new TH2F(
"axis",
"", 50, 0, 300, 50, 0, 9 );
69 m_haxis->SetStats( 0 );
70 m_fdPreXt->Add( m_haxis );
75 sprintf( hname,
"trec%02d", lay );
76 m_htrec[lay] =
new TH1F( hname,
"", 310, -20, 600 );
77 m_fdPreXt->Add( m_htrec[lay] );
80 m_nhitTot =
new TH1F(
"nhitTot",
"", 43, -0.5, 42.5 );
81 m_fdNhit->Add( m_nhitTot );
85 sprintf( hname,
"nhitBin%02d", lay );
86 m_nhitBin[lay] =
new TH1F( hname,
"", 40, 5.0, 405.0 );
87 m_fdNhit->Add( m_nhitBin[lay] );
94 for (
bin = 0;
bin < m_nXtBin;
bin++ ) m_tbin[
bin] = (
double)(
bin + 1 ) * twid;
99 for (
bin = 0;
bin < m_nXtBin;
bin++ ) { m_nEntries[lay][
bin] = 0; }
105 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc );
106 MsgStream log(
msgSvc,
"PreXtMdcCalib" );
107 log << MSG::DEBUG <<
"PreXtMdcCalib::fillHist()" << endmsg;
119 IDataProviderSvc* eventSvc = NULL;
120 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc );
127 m_t0[lay] = m_mdcFunSvc->getT0( lay, 0 );
128 m_mdcFunSvc->getXtpar( lay, 0, 0, xtpar );
129 m_tm[lay] = xtpar[6];
135 double tes = -9999.0;
137 SmartDataPtr<RecEsTimeCol> aevtimeCol( eventSvc,
"/Event/Recon/RecEsTimeCol" );
138 if ( ( !aevtimeCol ) || ( aevtimeCol->size() == 0 ) )
145 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
146 for ( ; iter_evt != aevtimeCol->end(); iter_evt++ )
148 tes = ( *iter_evt )->getTest();
149 esTimeflag = ( *iter_evt )->getStat();
152 bool flagTes =
false;
153 for (
int iEs = 0; iEs < m_param.nEsFlag; iEs++ )
155 if ( esTimeflag == m_param.esFlag[iEs] )
161 if ( -1 == esTimeflag )
return -1;
163 if ( ( m_param.esCut ) &&
164 ( ( !flagTes ) || ( tes < m_param.tesMin ) || ( tes > m_param.tesMax ) ) )
168 SmartDataPtr<MdcDigiCol> mdcDigiCol( eventSvc,
"/Event/Digi/MdcDigiCol" );
169 if ( !mdcDigiCol ) { log << MSG::FATAL <<
"Could not find event" << endmsg; }
171 MdcDigiCol::iterator
iter = mdcDigiCol->begin();
173 for ( ;
iter != mdcDigiCol->end();
iter++, digiId++ )
176 id = ( aDigi )->identify();
180 tdc = ( aDigi )->getTimeChannel();
181 adc = ( aDigi )->getChargeChannel();
182 fgOverFlow = ( aDigi )->getOverflow();
184 trec = traw - tes - m_t0[lay];
189 if ( ( ( fgOverFlow & 1 ) != 0 ) || ( ( fgOverFlow & 12 ) != 0 ) ||
197 if ( trec < m_tm[lay] )
200 m_htrec[lay]->Fill( trec );
201 m_nhitTot->Fill( lay );
205 if ( trec < m_tbin[
bin] )
207 m_nEntries[lay][
bin]++;
208 m_nhitBin[lay]->Fill( m_tbin[
bin] );
220 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc );
221 MsgStream log(
msgSvc,
"PreXtMdcCalib" );
222 log << MSG::DEBUG <<
"PreXtMdcCalib::updateConst()" << endmsg;
232 double pi = 3.141592653;
239 TF1* funXt =
new TF1(
"funXt", xtfun, 0, 300, 6 );
240 funXt->FixParameter( 0, 0.0 );
241 funXt->SetParameter( 1, 0.03 );
242 funXt->SetParameter( 2, 0.0 );
243 funXt->SetParameter( 3, 0.0 );
244 funXt->SetParameter( 4, 0.0 );
245 funXt->SetParameter( 5, 0.0 );
247 ofstream fxtlog(
"preXtpar.dat" );
250 sprintf( hname,
"grPreXt%02d", lay );
251 m_grXt[lay] =
new TGraph();
252 m_grXt[lay]->SetName( hname );
253 m_grXt[lay]->SetMarkerStyle( 20 );
254 m_fdPreXt->Add( m_grXt[lay] );
256 layRad = m_mdcGeomSvc->Layer( lay )->Radius();
257 ncel = m_mdcGeomSvc->Layer( lay )->NCell();
258 dm =
pi * layRad / ncel;
260 fxtlog <<
"layer " << lay << endl;
263 dist[
bin] = dm * m_nEntries[lay][
bin] / m_nTot[lay];
264 m_grXt[lay]->SetPoint(
bin, m_tbin[
bin], dist[
bin] );
265 fxtlog << setw( 4 ) <<
bin << setw( 15 ) << m_tbin[
bin] << setw( 15 ) << dist[
bin]
266 << setw( 15 ) << dm << setw( 10 ) << m_nEntries[lay][
bin] << setw( 10 )
267 << m_nTot[lay] << endl;
269 if ( m_tbin[
bin] >= m_tm[lay] )
break;
272 if ( 1 == m_param.fgCalib[lay] )
274 m_grXt[lay]->Fit( funXt,
"Q",
"", 0.0, m_tm[lay] );
275 for ( ord = 0; ord < 6; ord++ ) { xtpar[ord] = funXt->GetParameter( ord ); }
279 for ( iLR = 0; iLR <
MdcCalLR; iLR++ )
281 for ( ord = 0; ord < 6; ord++ )
282 { calconst->
resetXtpar( lay, iEntr, iLR, ord, xtpar[ord] ); }
288 for ( ord = 0; ord < 6; ord++ ) xtpar[ord] = calconst->
getXtpar( lay, 0, 0, ord );
291 for ( ord = 0; ord < 6; ord++ ) fxtlog << setw( 14 ) << xtpar[ord];
292 fxtlog << setw( 10 ) << m_tm[lay] <<
" 0" << endl;
295 cout <<
"preXt.dat was written." << endl;
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)