210 {
212 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
213 MsgStream log(
msgSvc,
"WrMdcCalib");
214 log << MSG::INFO << "WrMdcCalib::updateConst()" << endreq;
215
217
218 int i;
219 int lay;
220 int cel;
221 int nwire = m_mdcGeomSvc -> getWireSize();
222 double dwphi;
223 double resiLrSum;
224 double wpos[6];
225 double xx;
226 double yy;
227 double rr;
228 double dx;
229 double dy;
230 double wphi;
231
232 Stat_t entry_l;
233 double mean_l;
234 Stat_t entry_r;
235 double mean_r;
237
240 string strtmp;
241 ifstream fwpinput(m_param.
wpcFile.c_str());
242 for(i=0; i<7; i++) fwpinput >> strtmp;
243 for(i=0; i<nwire; i++){
244 fwpinput >> strtmp >> dwinput[i][0] >> dwinput[i][1] >> dwinput[i][2]
245 >> dwinput[i][3] >> dwinput[i][4] >> dwinput[i][5];
246 }
247 fwpinput.close();
248
249 std::cout << "totwire: " << nwire << std::endl;
250 for(i=0; i<nwire; i++){
251 pWire = m_mdcGeomSvc -> Wire(i);
252 lay = pWire -> Layer();
253 cel = pWire -> Cell();
254
256 entry_l = m_hleft[i] -> GetEntries();
257 mean_l = m_hleft[i] -> GetMean();
258
259 entry_r = m_hright[i] -> GetEntries();
260 mean_r = m_hright[i] -> GetMean();
261
262 dwphi = 0.5 * (mean_l - mean_r);
263 } else{
264 dwphi = 0.0;
265 }
266 if(0 == m_param.
fgWireCal[i]) dwphi = 0.0;
267
268 resiLrSum = 0.5 * (mean_l + mean_r);
269 m_hLrResiSum->Fill(resiLrSum);
270 m_hLrResiSub->Fill(dwphi);
271
272 wpos[0] = pWire -> Backward().x();
273 wpos[1] = pWire -> Backward().y();
274 wpos[3] = pWire -> Forward().x();
275 wpos[4] = pWire -> Forward().y();
276
277 xx = 0.5 * (wpos[0] + wpos[3]);
278 yy = 0.5 * (wpos[1] + wpos[4]);
279 rr = sqrt( (xx * xx) + (yy * yy) );
280
281 if( yy >= 0 ) wphi = acos(xx / rr);
282 else wphi =
PI2 - acos(xx / rr);
283
284 dx = -1.0 * dwphi *
sin(wphi);
285 dy = dwphi *
cos(wphi);
286
287 ddw[i][0] = dx;
288 ddw[i][1] = dy;
289 ddw[i][2] = 0.0;
290 ddw[i][3] = dx;
291 ddw[i][4] = dy;
292 ddw[i][5] = 0.0;
293 }
294
295 ofstream fwpc("WirePosCalib_new.txt");
296 fwpc << setw(5) << "wireId" << setw(15) << "dx_East(mm)"
297 << setw(15) << "dy_East(mm)" << setw(15) << "dz_East(mm)"
298 << setw(15) << "dx_West(mm)" << setw(15) << "dy_West(mm)"
299 << setw(15) << "dz_West(mm)" << endl;
300
301 ofstream fdw("dw.txt");
302 fdw << setw(5) << "wireId" << setw(15) << "ddx_East(mm)"
303 << setw(15) << "ddy_East(mm)" << setw(15) << "ddz_East(mm)"
304 << setw(15) << "ddx_West(mm)" << setw(15) << "ddy_West(mm)"
305 << setw(15) << "ddz_West(mm)" << endl;
306
307 int k;
308 double dwtot[6];
309 for(i=0; i<nwire; i++){
310 for(k=0; k<6; k++) dwtot[k] = dwinput[i][k] + ddw[i][k];
311 fwpc << setw(5) << i;
312 for(k=0; k<6; k++) fwpc << setw(15) << dwtot[k];
313 fwpc << endl;
314
315 fdw << setw(5) << i;
316 for(k=0; k<6; k++) fdw << setw(15) << ddw[i][k];
317 fdw << endl;
318 m_hdwxtot->Fill(dwtot[0]);
319 m_hddwx->Fill(ddw[i][0]);
320 m_hdwytot->Fill(dwtot[1]);
321 m_hddwy->Fill(ddw[i][1]);
322 }
323 fwpc.close();
324 fdw.close();
325 return 1;
326}
double sin(const BesAngle a)
double cos(const BesAngle a)
int fgCalib[MdcCalNLayer]
int fgWireCal[MdcCalTotCell]
virtual int updateConst(MdcCalibConst *calconst)=0