3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/IMessageSvc.h"
5#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/Bootstrap.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
11#include "GaudiKernel/INTupleSvc.h"
12#include "GaudiKernel/IService.h"
20#include "CLHEP/Vector/ThreeVector.h"
34typedef std::vector<HepLorentzVector>
Vp4;
48 fgReadWireEff =
false;
51 for(lay=0; lay<43; lay++){
52 if(lay < 15) m_nEntr[lay] = 1;
53 else m_nEntr[lay] = 2;
59 m_phiWid =
PI2 / (double)NPhiBin;
60 m_theWid = 2.0 / (double)NThetaBin;
65 if(lay < 8) m_nBin[lay] = 12;
66 else m_nBin[lay] = 16;
71 if((0==lay) || (7==lay) || (8==lay) || (19==lay) || (20==lay) ||
72 (35==lay) || (36==lay) || (42==lay) ) m_layBound[lay] =
true;
73 else m_layBound[lay] =
false;
82 for(lay=0; lay<m_nlayer; lay++){
85 delete m_hresInc[lay];
86 delete m_hresExc[lay];
87 delete m_hresAve[lay];
89 for (
int lr=0; lr<2; lr++){
90 delete m_htdrlr[lay][lr];
91 delete m_hreslrInc[lay][lr];
92 delete m_hreslrExc[lay][lr];
93 delete m_hreslrAve[lay][lr];
98 delete m_effNtrkRecHit;
102 for(
int i=0; i<14; i++){
103 delete m_hresAveAllQ[i];
104 delete m_hresAveOutQ[i];
106 for(lay=0; lay<43; lay++){
107 for(
int i=0; i<14; i++)
delete m_hresAveLayQ[lay][i];
115 delete m_hresAllExcUp;
116 delete m_hresAllExcDw;
117 delete m_hresInnExcUp;
118 delete m_hresInnExcDw;
119 delete m_hresStpExcUp;
120 delete m_hresStpExcDw;
121 delete m_hresOutExcUp;
122 delete m_hresOutExcDw;
123 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++)
delete m_hTes[iEs];
127 delete m_hTesAllFlag;
129 delete m_hTesCalFlag;
148 delete m_hnhitsRecInn;
149 delete m_hnhitsRecStp;
150 delete m_hnhitsRecOut;
152 delete m_hnhitsCalInn;
153 delete m_hnhitsCalStp;
154 delete m_hnhitsCalOut;
156 delete m_layerhitmap;
159 delete m_hnoisenhits;
181 delete m_ppPhiCms[
bin];
182 delete m_pnPhiCms[
bin];
183 for(thbin=0; thbin<NThetaBin; thbin++){
184 delete m_ppThePhi[thbin][
bin];
185 delete m_pnThePhi[thbin][
bin];
186 delete m_ppThePhiCms[thbin][
bin];
187 delete m_pnThePhiCms[thbin][
bin];
190 for(thbin=0; thbin<NThetaBin; thbin++){
191 delete m_ppThe[thbin];
192 delete m_pnThe[thbin];
193 delete m_ppTheCms[thbin];
194 delete m_pnTheCms[thbin];
197 for(
unsigned i=0; i<m_hr2dInc.size(); i++){
217 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
218 MsgStream log(
msgSvc,
"MdcCalib");
219 log << MSG::INFO <<
"MdcCalib::initialize()" << endreq;
222 m_mdcGeomSvc = mdcGeomSvc;
223 m_mdcFunSvc = mdcFunSvc;
224 m_mdcUtilitySvc = mdcUtilitySvc;
234 m_nlayer = m_mdcGeomSvc -> getLayerSize();
236 for(lay=0; lay<m_nlayer; lay++){
239 ofstream fwpc(
"wirelog.txt");
244 m_xw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().x();
245 m_yw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().y();
246 m_zw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().z();
247 fwpc << setw(6) << wir << setw(15) << m_xe[wir] << setw(15) << m_ye[wir]
248 << setw(15) << m_ze[wir] << setw(15) << m_xw[wir]
249 << setw(15) << m_yw[wir] << setw(15) << m_zw[wir] << endl;
253 m_fdcom =
new TFolder(
"common",
"common");
254 m_hlist ->
Add(m_fdcom);
256 m_effNtrk =
new TH1F(
"effNtrk",
"", 43, -0.5, 42.5);
257 m_fdcom->Add(m_effNtrk);
259 m_effNtrkRecHit =
new TH1F(
"effNtrkRecHit",
"", 43, -0.5, 42.5);
260 m_fdcom->Add(m_effNtrkRecHit);
262 m_hresAllInc =
new TH1F(
"HResAllInc",
"", 200, -1.0, 1.0);
263 m_fdcom ->
Add(m_hresAllInc);
265 m_hresAllExc =
new TH1F(
"HResAllExc",
"", 200, -1.0, 1.0);
266 m_fdcom ->
Add(m_hresAllExc);
268 m_hresAllAve =
new TH1F(
"HResAllAve",
"", 200, -1.0, 1.0);
269 m_fdcom ->
Add(m_hresAllAve);
271 m_hresInnInc =
new TH1F(
"HResInnInc",
"", 200, -1.0, 1.0);
272 m_fdcom ->
Add(m_hresInnInc);
274 m_hresInnExc =
new TH1F(
"HResInnExc",
"", 200, -1.0, 1.0);
275 m_fdcom ->
Add(m_hresInnExc);
277 m_hresStpInc =
new TH1F(
"HResStpInc",
"", 200, -1.0, 1.0);
278 m_fdcom ->
Add(m_hresStpInc);
280 m_hresStpExc =
new TH1F(
"HResStpExc",
"", 200, -1.0, 1.0);
281 m_fdcom ->
Add(m_hresStpExc);
283 m_hresOutInc =
new TH1F(
"HResOutInc",
"", 200, -1.0, 1.0);
284 m_fdcom ->
Add(m_hresOutInc);
286 m_hresOutExc =
new TH1F(
"HResOutExc",
"", 200, -1.0, 1.0);
287 m_fdcom ->
Add(m_hresOutExc);
289 m_hresAllExcUp =
new TH1F(
"HResAllExcUp",
"", 200, -1.0, 1.0);
290 m_fdcom ->
Add(m_hresAllExcUp);
292 m_hresAllExcDw =
new TH1F(
"HResAllExcDw",
"", 200, -1.0, 1.0);
293 m_fdcom ->
Add(m_hresAllExcDw);
295 m_hresInnExcUp =
new TH1F(
"HResInnExcUp",
"", 200, -1.0, 1.0);
296 m_fdcom ->
Add(m_hresInnExcUp);
298 m_hresInnExcDw =
new TH1F(
"HResInnExcDw",
"", 200, -1.0, 1.0);
299 m_fdcom ->
Add(m_hresInnExcDw);
301 m_hresStpExcUp =
new TH1F(
"HResStpExcUp",
"", 200, -1.0, 1.0);
302 m_fdcom ->
Add(m_hresStpExcUp);
304 m_hresStpExcDw =
new TH1F(
"HResStpExcDw",
"", 200, -1.0, 1.0);
305 m_fdcom ->
Add(m_hresStpExcDw);
307 m_hresOutExcUp =
new TH1F(
"HResOutExcUp",
"", 200, -1.0, 1.0);
308 m_fdcom ->
Add(m_hresOutExcUp);
310 m_hresOutExcDw =
new TH1F(
"HResOutExcDw",
"", 200, -1.0, 1.0);
311 m_fdcom ->
Add(m_hresOutExcDw);
313 m_fdResQ =
new TFolder(
"ResQ",
"ResQ");
314 m_hlist->Add(m_fdResQ);
315 for(
int i=0; i<14; i++){
316 sprintf(hname,
"resoAll_qbin%02d", i);
317 m_hresAveAllQ[i] =
new TH1F(hname,
"", 200, -1, 1);
318 m_fdResQ->Add(m_hresAveAllQ[i]);
320 sprintf(hname,
"resoOut_qbin%02d", i);
321 m_hresAveOutQ[i] =
new TH1F(hname,
"", 200, -1, 1);
322 m_fdResQ->Add(m_hresAveOutQ[i]);
324 for(lay=0; lay<43; lay++){
325 for(
int i=0; i<14; i++){
326 sprintf(hname,
"resoLay%02d_qbin%02d", lay, i);
327 m_hresAveLayQ[lay][i] =
new TH1F(hname,
"", 200, -1, 1);
328 m_fdResQ->Add(m_hresAveLayQ[lay][i]);
332 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++){
334 m_hTes[iEs] =
new TH1F(hname,
"", 750, 0, 1500);
335 m_fdcom->Add(m_hTes[iEs]);
338 m_hbbTrkFlg =
new TH1F(
"BbTrkFlg",
"", 100, 0, 6);
339 m_fdcom ->
Add(m_hbbTrkFlg);
341 m_hTesAll =
new TH1F(
"TesAll",
"", 2000, 0, 2000);
342 m_fdcom ->
Add(m_hTesAll);
344 m_hTesGood =
new TH1F(
"TesGood",
"", 2000, 0, 2000);
345 m_fdcom ->
Add(m_hTesGood);
347 m_hTesAllFlag =
new TH1F(
"TesAllFlag",
"", 300, -0.5, 299.5);
348 m_fdcom ->
Add(m_hTesAllFlag);
350 m_hTesRec =
new TH1F(
"TesRec",
"", 2000, 0, 2000);
351 m_fdcom ->
Add(m_hTesRec);
353 m_hTesCalFlag =
new TH1F(
"TesCalFlag",
"", 2000, 0, 2000);
354 m_fdcom ->
Add(m_hTesCalFlag);
356 m_hTesCalUse =
new TH1F(
"TesCalUse",
"", 2000, 0, 2000);
357 m_fdcom ->
Add(m_hTesCalUse);
359 m_hnRawHit =
new TH1F(
"nRawHit",
"", 6797, -0.5, 6796.5);
360 m_fdcom ->
Add(m_hnRawHit);
362 m_hpt =
new TH1F(
"HPt",
"", nbinMom, 0, 3);
363 m_fdcom ->
Add(m_hpt);
365 m_hptPos =
new TH1F(
"HPtPos",
"", nbinMom, 0, 3);
366 m_fdcom ->
Add(m_hptPos);
368 m_hptNeg =
new TH1F(
"HPtNeg",
"", nbinMom, 0, 3);
369 m_fdcom ->
Add(m_hptNeg);
371 m_hp =
new TH1F(
"HP",
"", nbinMom, 0, 3);
372 m_fdcom ->
Add(m_hp);
374 m_hp_cms =
new TH1F(
"HPCMS",
"", nbinMom, 0, 3);
375 m_fdcom ->
Add(m_hp_cms);
377 m_hpMax =
new TH1F(
"HPMax",
"", nbinMom, 0, 3);
378 m_fdcom ->
Add(m_hpMax);
380 m_hpMaxCms =
new TH1F(
"HPMax_Cms",
"", nbinMom, 0, 3);
381 m_fdcom ->
Add(m_hpMaxCms);
383 m_hpPos =
new TH1F(
"HP_Pos",
"", nbinMom, 0, 3);
384 m_fdcom ->
Add(m_hpPos);
386 m_hpNeg =
new TH1F(
"HP_Neg",
"", nbinMom, 0, 3);
387 m_fdcom ->
Add(m_hpNeg);
389 m_hpPoscms =
new TH1F(
"HP_Pos_cms",
"", nbinMom, 0, 3);
390 m_fdcom ->
Add(m_hpPoscms);
392 m_hpNegcms =
new TH1F(
"HP_Neg_cms",
"", nbinMom, 0, 3);
393 m_fdcom ->
Add(m_hpNegcms);
395 m_hp_cut =
new TH1F(
"HPCut",
"", nbinMom, 0, 3);
396 m_fdcom ->
Add(m_hp_cut);
398 m_hchisq =
new TH1F(
"Chisq",
"", 10, 0, 100);
399 m_fdcom ->
Add(m_hchisq);
401 m_hnTrk =
new TH1F(
"HNtrack",
"HNtrack", 10, -0.5, 9.5);
402 m_fdcom ->
Add(m_hnTrk);
404 m_hnTrkCal =
new TH1F(
"HNtrackCal",
"HNtrackCal", 10, -0.5, 9.5);
405 m_fdcom ->
Add(m_hnTrkCal);
407 m_hnhitsRec =
new TH1F(
"HNhitsRec",
"", 100, -0.5, 99.5);
408 m_fdcom ->
Add(m_hnhitsRec);
410 m_hnhitsRecInn =
new TH1F(
"HNhitsInnRec",
"", 60, 0.5, 60.5);
411 m_fdcom ->
Add(m_hnhitsRecInn);
413 m_hnhitsRecStp =
new TH1F(
"HNhitsStpRec",
"", 60, 0.5, 60.5);
414 m_fdcom ->
Add(m_hnhitsRecStp);
416 m_hnhitsRecOut =
new TH1F(
"HNhitsOutRec",
"", 60, 0.5, 60.5);
417 m_fdcom ->
Add(m_hnhitsRecOut);
419 m_hnhitsCal =
new TH1F(
"HNhitsCal",
"", 100, -0.5, 99.5);
420 m_fdcom ->
Add(m_hnhitsCal);
422 m_hnhitsCalInn =
new TH1F(
"HNhitsCalInn",
"", 60, 0.5, 60.5);
423 m_fdcom ->
Add(m_hnhitsCalInn);
425 m_hnhitsCalStp =
new TH1F(
"HNhitsCalStp",
"", 60, 0.5, 60.5);
426 m_fdcom ->
Add(m_hnhitsCalStp);
428 m_hnhitsCalOut =
new TH1F(
"HNhitsCalOut",
"", 60, 0.5, 60.5);
429 m_fdcom ->
Add(m_hnhitsCalOut);
431 m_wirehitmap =
new TH1F(
"Wire_HitMap",
"Wire_HitMap", 6796, -0.5, 6795.5);
432 m_fdcom ->
Add(m_wirehitmap);
434 m_layerhitmap =
new TH1F(
"Layer_HitMap",
"Layer_HitMap", 43, -0.5, 42.5);
435 m_fdcom ->
Add(m_layerhitmap);
437 m_hnoisephi =
new TH1F(
"phi_noise",
"", 100, 0, 6.284);
438 m_fdcom ->
Add(m_hnoisephi);
440 m_hnoiselay =
new TH1F(
"Layer_noise",
"Layer_noise", 43, -0.5, 42.5);
441 m_fdcom ->
Add(m_hnoiselay);
443 m_hnoisenhits =
new TH1F(
"nhits_noise",
"nhits_noise", 6796, -0.5, 6795.5);
444 m_fdcom ->
Add(m_hnoisenhits);
446 m_hratio =
new TH1F(
"ratio",
"", 100, 0, 1);
447 m_fdcom ->
Add(m_hratio);
449 m_hdr =
new TH1F(
"dr",
"", 2000, -100, 100);
450 m_fdcom ->
Add(m_hdr);
452 m_hphi0 =
new TH1F(
"phi0",
"", 100, 0, 6.284);
453 m_fdcom ->
Add(m_hphi0);
455 m_hkap =
new TH1F(
"kappa",
"", 400, -50, 50);
456 m_fdcom ->
Add(m_hkap);
458 m_hdz =
new TH1F(
"dz",
"", 2000, -500, 500);
459 m_fdcom ->
Add(m_hdz);
461 m_htanl =
new TH1F(
"tanl",
"", 200, -5, 5);
462 m_fdcom ->
Add(m_htanl);
464 m_hcosthe =
new TH1F(
"costheta",
"", 200, -1, 1);
465 m_fdcom ->
Add(m_hcosthe);
467 m_hcostheNeg =
new TH1F(
"costhetaNeg",
"", 200, -1, 1);
468 m_fdcom ->
Add(m_hcostheNeg);
470 m_hcosthePos =
new TH1F(
"costhetaPos",
"", 200, -1, 1);
471 m_fdcom ->
Add(m_hcosthePos);
473 m_hx0 =
new TH1F(
"x0",
"", 100, -10, 10);
474 m_fdcom ->
Add(m_hx0);
476 m_hy0 =
new TH1F(
"y0",
"", 100, -10, 10);
477 m_fdcom ->
Add(m_hy0);
479 m_hdelZ0 =
new TH1F(
"delta_z0",
"", 100, -50, 50);
480 m_fdcom ->
Add(m_hdelZ0);
482 m_grX0Y0 =
new TGraph();
483 m_grX0Y0->SetName(
"x0y0");
484 m_fdcom ->
Add(m_grX0Y0);
486 m_hitEffAll =
new TH1F(
"hitEffAll",
"", 6800, -0.5, 6799.5);
487 m_fdcom ->
Add(m_hitEffAll);
489 m_hitEffRaw =
new TH1F(
"hitEffRaw",
"", 6800, -0.5, 6799.5);
490 m_fdcom ->
Add(m_hitEffRaw);
492 m_hitEffRec =
new TH1F(
"hitEffRec",
"", 6800, -0.5, 6799.5);
493 m_fdcom ->
Add(m_hitEffRec);
496 m_fdTime =
new TFolder(
"time",
"time");
497 m_hlist ->
Add(m_fdTime);
499 for(lay=0; lay<m_nlayer; lay++){
500 sprintf(hname,
"Traw%02d", lay);
501 m_htraw[lay] =
new TH1F(hname,
"", 1000, 0, 2000);
502 m_fdTime ->
Add(m_htraw[lay]);
504 sprintf(hname,
"Tdr%02d", lay);
505 m_htdr[lay] =
new TH1F(hname,
"", 510, -10, 500);
506 m_fdTime ->
Add(m_htdr[lay]);
508 for (lr=0; lr<2; lr++){
509 sprintf(hname,
"Tdr%02d_lr%01d", lay, lr);
510 m_htdrlr[lay][lr] =
new TH1F(hname,
"", 510, -10, 500);
511 m_fdTime ->
Add(m_htdrlr[lay][lr]);
516 m_fdAdc =
new TFolder(
"adc",
"adc");
517 m_hlist ->
Add(m_fdAdc);
519 for(lay=0; lay<m_nlayer; lay++){
520 sprintf(hname,
"adc%02d", lay);
521 m_hadc[lay] =
new TH1F(hname,
"", 1500, 0, 3000);
522 m_fdAdc ->
Add(m_hadc[lay]);
525 m_fdres =
new TFolder(
"resolution",
"resolution");
526 m_hlist ->
Add(m_fdres);
528 m_fdresAve =
new TFolder(
"resAve",
"resAve");
529 m_hlist ->
Add(m_fdresAve);
531 for(lay=0; lay<m_nlayer; lay++){
532 sprintf(hname,
"Reso%02dInc", lay);
533 m_hresInc[lay] =
new TH1F(hname,
"", 1000, -5, 5);
534 m_fdres ->
Add(m_hresInc[lay]);
536 sprintf(hname,
"Reso%02dExc", lay);
537 m_hresExc[lay] =
new TH1F(hname,
"", 1000, -5, 5);
538 m_fdres ->
Add(m_hresExc[lay]);
540 sprintf(hname,
"Reso%02d", lay);
541 m_hresAve[lay] =
new TH1F(hname,
"", 1000, -5, 5);
542 m_fdresAve ->
Add(m_hresAve[lay]);
544 for (lr=0; lr<2; lr++){
545 sprintf(hname,
"Reso%02dInc_lr%01d", lay, lr);
547 m_hreslrInc[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
548 m_fdres->Add(m_hreslrInc[lay][lr]);
550 sprintf(hname,
"Reso%02dExc_lr%01d", lay, lr);
552 m_hreslrExc[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
553 m_fdres->Add(m_hreslrExc[lay][lr]);
555 sprintf(hname,
"Reso%02d_lr%01d", lay, lr);
557 m_hreslrAve[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
558 m_fdresAve->Add(m_hreslrAve[lay][lr]);
560 for(
int phi=0; phi<20; phi++){
561 sprintf(hname,
"ResoPhi%02d_phi%02d", lay, phi);
562 m_hresphi[lay][phi] =
new TH1F(hname,
"", 200, -1, 1);
563 m_fdres->Add(m_hresphi[lay][phi]);
568 m_fdmomPhi =
new TFolder(
"momPhi",
"momPhi");
569 m_hlist ->
Add(m_fdmomPhi);
574 m_ppPhi[
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
575 m_fdmomPhi->Add(m_ppPhi[
bin]);
578 m_pnPhi[
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
579 m_fdmomPhi->Add(m_pnPhi[
bin]);
582 m_ppPhiCms[
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
583 m_fdmomPhi->Add(m_ppPhiCms[
bin]);
586 m_pnPhiCms[
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
587 m_fdmomPhi->Add(m_pnPhiCms[
bin]);
589 for(thbin=0; thbin<NThetaBin; thbin++){
590 sprintf(hname,
"hPpos_theta%02d_phi%02d", thbin,
bin);
591 m_ppThePhi[thbin][
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
592 m_fdmomPhi->Add(m_ppThePhi[thbin][
bin]);
594 sprintf(hname,
"hPneg_theta%02d_phi%02d", thbin,
bin);
595 m_pnThePhi[thbin][
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
596 m_fdmomPhi->Add(m_pnThePhi[thbin][
bin]);
598 sprintf(hname,
"hPposCms_theta%02d_phi%02d", thbin,
bin);
599 m_ppThePhiCms[thbin][
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
600 m_fdmomPhi->Add(m_ppThePhiCms[thbin][
bin]);
602 sprintf(hname,
"hPnegCms_theta%02d_phi%02d", thbin,
bin);
603 m_pnThePhiCms[thbin][
bin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
604 m_fdmomPhi->Add(m_pnThePhiCms[thbin][
bin]);
607 for(thbin=0; thbin<NThetaBin; thbin++){
608 sprintf(hname,
"hPpos_the%02d", thbin);
609 m_ppThe[thbin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
610 m_fdmomPhi->Add(m_ppThe[thbin]);
612 sprintf(hname,
"hPneg_the%02d", thbin);
613 m_pnThe[thbin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
614 m_fdmomPhi->Add(m_pnThe[thbin]);
616 sprintf(hname,
"hPposCms_the%02d", thbin);
617 m_ppTheCms[thbin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
618 m_fdmomPhi->Add(m_ppTheCms[thbin]);
620 sprintf(hname,
"hPnegCms_the%02d", thbin);
621 m_pnTheCms[thbin] =
new TH1F(hname,
"", nbinMom, 0.0, 3.0);
622 m_fdmomPhi->Add(m_pnTheCms[thbin]);
626 m_fdres2d =
new TFolder(
"res2d",
"res2d");
627 m_hlist ->
Add(m_fdres2d);
632 for(lay=0; lay<m_nlayer; lay++){
634 for(lr=0; lr<2; lr++){
636 sprintf(hname,
"r2d%02d_%02d_%01d_%02dInc", lay, iEntr, lr,
bin);
637 hist =
new TH1F(hname,
"", 200, -1, 1);
638 m_hr2dInc.push_back(hist);
639 m_fdres2d ->
Add(hist);
641 sprintf(hname,
"r2d%02d_%02d_%01d_%02dExc", lay, iEntr, lr,
bin);
642 hist =
new TH1F(hname,
"", 200, -1, 1);
643 m_hr2dExc.push_back(hist);
644 m_fdres2d ->
Add(hist);
646 key = getHresId(lay, iEntr, lr,
bin);
654 m_fdres2t =
new TFolder(
"res2t",
"res2t");
657 for(lay=0; lay<m_nlayer; lay++){
659 for(lr=0; lr<2; lr++){
661 sprintf(hname,
"r2t%02d_%02d_%01d_%02d", lay, iEntr, lr,
bin);
662 m_hr2t[lay][iEntr][lr][
bin] =
new TH1F(hname,
"", 600, -3, 3);
663 m_fdres2t ->
Add(m_hr2t[lay][iEntr][lr][
bin]);
670 Gaudi::svcLocator() -> service(
"NTupleSvc",
ntupleSvc);
671 for(lay=0; lay<m_nlayer; lay++){
672 sprintf(hname,
"FILE136/xt%02d", lay);
674 if ( nt ) m_xtTuple[lay] = nt;
676 m_xtTuple[lay] =
ntupleSvc->book(hname, CLID_ColumnWiseTuple,
"MdcXtNtuple");
677 if( m_xtTuple[lay] ){
678 m_xtTuple[lay]->addItem(
"cel", m_cel[lay]);
679 m_xtTuple[lay]->addItem(
"lr", m_lr[lay]);
680 m_xtTuple[lay]->addItem(
"run", m_run[lay]);
681 m_xtTuple[lay]->addItem(
"evt", m_evt[lay]);
682 m_xtTuple[lay]->addItem(
"doca", m_doca[lay]);
683 m_xtTuple[lay]->addItem(
"dm", m_dm[lay]);
684 m_xtTuple[lay]->addItem(
"tdr", m_tdr[lay]);
685 m_xtTuple[lay]->addItem(
"tdc", m_tdc[lay]);
686 m_xtTuple[lay]->addItem(
"entr", m_entr[lay]);
687 m_xtTuple[lay]->addItem(
"zhit", m_zhit[lay]);
688 m_xtTuple[lay]->addItem(
"qhit", m_qhit[lay]);
689 m_xtTuple[lay]->addItem(
"p", m_p[lay]);
690 m_xtTuple[lay]->addItem(
"pt", m_pt[lay]);
691 m_xtTuple[lay]->addItem(
"phi0", m_phi0[lay]);
692 m_xtTuple[lay]->addItem(
"tanl", m_tanl[lay]);
693 m_xtTuple[lay]->addItem(
"hitphi", m_hitphi[lay]);
695 log << MSG::FATAL <<
"Cannot book Xt N-tuple:"
696 << long(m_xtTuple[lay]) << endreq;
702 sprintf(hname,
"FILE136/cosmic");
704 if ( nt ) m_cosmic = nt;
706 m_cosmic =
ntupleSvc->book(hname, CLID_ColumnWiseTuple,
"MdcXtNtuple");
708 m_cosmic->addItem(
"pUp", m_pUpcos);
709 m_cosmic->addItem(
"pDw", m_pDwcos);
710 m_cosmic->addItem(
"ptUp", m_ptUpcos);
711 m_cosmic->addItem(
"ptDw", m_ptDwcos);
712 m_cosmic->addItem(
"phiUp", m_phiUpcos);
713 m_cosmic->addItem(
"phiDw", m_phiDwcos);
714 m_cosmic->addItem(
"drUp", m_drUpcos);
715 m_cosmic->addItem(
"drDw", m_drDwcos);
716 m_cosmic->addItem(
"dzUp", m_dzUpcos);
717 m_cosmic->addItem(
"dzDw", m_dzDwcos);
718 m_cosmic->addItem(
"ctheUp", m_ctheUpcos);
719 m_cosmic->addItem(
"ctheDw", m_ctheDwcos);
720 m_cosmic->addItem(
"nhitUp", m_nhitUpcos);
721 m_cosmic->addItem(
"nhitDw", m_nhitDwcos);
722 m_cosmic->addItem(
"char", m_chargecos);
723 m_cosmic->addItem(
"tesfg", m_tesFlagcos);
724 m_cosmic->addItem(
"tes", m_tescos);
732 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
733 MsgStream log(
msgSvc,
"MdcCalib");
734 log << MSG::DEBUG <<
"MdcCalib::fillHist()" << endreq;
767 double ecm = m_param.
ecm;
768 double xboost = m_param.
boostPar[0] * ecm;
769 double yboost = m_param.
boostPar[1];
770 double zboost = m_param.
boostPar[2];
781 double zminus = 9999.0;
782 double zplus = -9999.0;
800 int ntrk =
event -> getNTrk();
818 for(cel=0; cel<ncel; cel++){
819 double eff = m_mdcFunSvc->
getWireEff(lay, cel);
820 if(eff > 0.5) m_fgGoodWire[lay][cel] =
true;
821 else m_fgGoodWire[lay][cel] =
false;
822 int wireid = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
823 if(eff<0.9) cout <<
"dead channel: " << setw(5) << lay << setw(5) << cel << setw(8) << wireid << endl;
826 fgReadWireEff =
true;
828 ofstream fwpc(
"wirelog_align.txt");
833 m_xw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().x();
834 m_yw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().y();
835 m_zw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().z();
836 fwpc << setw(6) << wir << setw(15) << m_xe[wir] << setw(15) << m_ye[wir]
837 << setw(15) << m_ze[wir] << setw(15) << m_xw[wir]
838 << setw(15) << m_yw[wir] << setw(15) << m_zw[wir] << endl;
843 int nRawHit =
event->getNRawHitTQ();
844 m_hnRawHit->Fill(nRawHit);
846 IDataProviderSvc* eventSvc =
NULL;
847 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
849 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
851 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
852 return( StatusCode::FAILURE);
854 int iRun = eventHeader->runNumber();
855 int iEvt = eventHeader->eventNumber();
857 int esTimeflag =
event->getEsFlag();
858 double tes =
event->getTes();
859 bool esCutFg =
event->getEsCutFlag();
860 int iEs =
event->getNesCutFlag();
862 if (-1 != esTimeflag) {
863 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
865 log << MSG::ERROR <<
"Could not find RecMdcTrackCol" << endreq;
866 return ( StatusCode::FAILURE );
872 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
873 for(; it_trk != newtrkCol->end(); it_trk++){
874 double mass = 0.000511;
875 HepLorentzVector
p4 = (*it_trk)->p4(
mass);
876 icharge = (*it_trk)->charge();
877 if (icharge > 0) p4p.push_back(
p4);
878 else p4m.push_back(
p4);
880 if (1 == p4p.size() * p4m.size()){
881 double dang = p4p[0].vect().angle(p4m[0].vect());
882 m_hbbTrkFlg->Fill(1);
884 m_hbbTrkFlg->Fill(2);
889 m_hTesAll->Fill(tes);
892 if (-1 == esTimeflag)
return -1;
893 m_hTesGood->Fill(tes);
894 m_hTesAllFlag->Fill(esTimeflag);
895 if(ntrk > 0) m_hTesRec->Fill(tes);
896 if( (iEs >= 0) && (iEs < m_param.
nEsFlag) ) m_hTes[iEs]->Fill(tes);
898 if( esCutFg ) m_hTesCalFlag->Fill(tes);
910 for(i=0; i<200; i++) trkFlag[i] =
false;
915 double hitphiplus = 9999.0;
916 double hitthetaplus = 9999.0;
917 double hitphiminus = -9999.0;
918 double hitthetaminus = -9999.0;
932 for(i=0; i<ntrk; i++){
935 rectrk =
event -> getRecTrk(i);
936 nhitRec = rectrk -> getNHits();
937 m_hnhitsRec ->
Fill( nhitRec );
940 fgHitLay[lay] =
false;
946 for(k=0; k<nhitRec; k++){
947 rechit = rectrk -> getRecHit(k);
948 lay = rechit -> getLayid();
949 doca = rechit -> getDocaExc();
950 resiExc = rechit -> getResiExc();
951 fgHitLay[lay] =
true;
953 if(lay < 8) nhitRecInn++;
954 else if(lay < 20) nhitRecStp++;
957 m_hnhitsRecInn->Fill(nhitRecInn);
958 m_hnhitsRecStp->Fill(nhitRecStp);
959 m_hnhitsRecOut->Fill(nhitRecOut);
962 pt = rectrk -> getPt();
963 p = rectrk -> getP();
967 HepLorentzVector psip(xboost, yboost, zboost, ecm);
968 Hep3Vector boostv = psip.boostVector();
972 if(phicms < 0) phicms +=
PI2;
973 thetacms =
p4.theta();
974 costheCMS =
cos(thetacms);
975 if (pt < 0)
p_cms *= -1.0;
986 dr = rectrk->
getDr();
987 if(fabs(dr) > m_param.
drCut){
993 dz = rectrk->
getDz();
994 if(fabs(dz) > m_param.
dzCut){
1000 if((fabs(p) < m_param.
pCut[0]) || (fabs(p) > m_param.
pCut[1])){
1017 if(fgHitLay[lay]) nhitlay++;
1025 if(nhitRec < m_param.
nHitCut){
1039 int cellTrkPass[43];
1040 bool fgPass = getCellTrkPass(event, i, cellTrkPass);
1041 for(lay=0; lay<m_nlayer; lay++){
1044 if((15==lay) || (16==lay) || (18==lay) || (19==lay) || (40==lay) || (41==lay) || (42==lay)){
1045 int iCell = cellTrkPass[lay];
1046 if(fgPass && (iCell >= 0) && m_fgGoodWire[lay][iCell]) m_effNtrk->Fill(lay);
1047 else fgAdd[lay] = 1;
1049 m_effNtrk->Fill(lay);
1054 chisq = rectrk -> getChisq();
1055 m_hchisq ->
Fill( chisq );
1059 m_hptPos ->
Fill(pt);
1065 m_hpt ->
Fill(-1.0*pt);
1066 m_hptNeg ->
Fill(-1.0*pt);
1067 m_hp ->
Fill(-1.0*p);
1069 m_hpNeg ->
Fill(-1.0*p);
1074 pTrkcms[i] = fabs(
p_cms);
1077 dr = rectrk -> getDr();
1078 phi0 = rectrk -> getPhi0();
1079 kap = rectrk -> getKappa();
1080 dz = rectrk -> getDz();
1081 tanl = rectrk -> getTanLamda();
1083 theta =
HFPI - lamda;
1086 m_hphi0 ->
Fill(phi0);
1087 m_hkap ->
Fill(kap);
1089 m_htanl ->
Fill(tanl);
1090 m_hcosthe ->
Fill(
cos(theta));
1091 if(pt > 0) m_hcosthePos->Fill(
cos(theta));
1092 else m_hcostheNeg->Fill(
cos(theta));
1094 philab = phi0 +
HFPI;
1095 if(philab >
PI2) philab -=
PI2;
1098 phiBin = (int)(philab / m_phiWid);
1099 phiBinCms = (int)(phicms / m_phiWid);
1100 theBin = (int)((
cos(theta) + 1.0) / m_theWid);
1101 theBinCms = (int)((
cos(thetacms) + 1.0) / m_theWid);
1102 if(phiBin < 0) phiBin = 0;
1103 if(phiBin >= NPhiBin) phiBin = NPhiBin-1;
1104 if(phiBinCms < 0) phiBinCms = 0;
1105 if(phiBinCms >= NPhiBin) phiBinCms = NPhiBin-1;
1106 if(theBin < 0) theBin = 0;
1107 if(theBin >= NThetaBin) theBin = NThetaBin-1;
1108 if(theBinCms < 0) theBinCms = 0;
1109 if(theBinCms >= NThetaBin) theBinCms = NThetaBin-1;
1112 m_ppPhi[phiBin]->Fill(p);
1113 m_ppPhiCms[phiBinCms]->Fill(
p_cms);
1114 m_ppThe[theBin]->Fill(p);
1115 m_ppTheCms[theBinCms]->Fill(
p_cms);
1116 m_ppThePhi[theBin][phiBin]->Fill(p);
1117 m_ppThePhiCms[theBinCms][phiBinCms]->Fill(
p_cms);
1119 m_pnPhi[phiBin]->Fill(-1.0*p);
1120 m_pnPhiCms[phiBinCms]->Fill(-1.0*
p_cms);
1121 m_pnThe[theBin]->Fill(-1.0*p);
1122 m_pnTheCms[theBinCms]->Fill(-1.0*
p_cms);
1123 m_pnThePhi[theBin][phiBin]->Fill(-1.0*p);
1124 m_pnThePhiCms[theBinCms][phiBinCms]->Fill(-1.0*
p_cms);
1127 x0 = dr *
cos(phi0);
1128 y0 = dr *
sin(phi0);
1131 if(m_nGrPoint < 10000){
1132 m_grX0Y0->SetPoint(m_nGrPoint, x0, y0);
1139 phibinm = phiBinCms;
1143 phibinp = phiBinCms;
1153 for(k=0; k<nhitRec; k++){
1154 rechit = rectrk -> getRecHit(k);
1156 lay = rechit -> getLayid();
1157 cel = rechit -> getCellid();
1158 lr = rechit -> getLR();
1159 stat = rechit -> getStat();
1160 doca = rechit -> getDocaExc();
1161 resiInc = rechit -> getResiIncLR();
1162 resiExc = rechit -> getResiExcLR();
1163 entr = rechit -> getEntra();
1164 tdr = rechit -> getTdrift();
1166 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1168 m_cel[lay] = (long)cel;
1169 m_lr[lay] = (long)lr;
1173 m_dm[lay] = rechit -> getDmeas();
1176 m_entr[lay] = entr*180.0/3.14;
1177 m_zhit[lay] = rechit -> getZhit();
1178 m_qhit[lay] = rechit -> getQhit();
1183 qhit = rechit -> getQhit();
1186 xx = (m_zhit[lay] - m_zw[wir]) * (m_xe[wir] - m_xw[wir]) /
1187 (m_ze[wir] - m_zw[wir]) + m_xw[wir];
1188 yy = (m_zhit[lay] - m_zw[wir]) * (m_ye[wir] - m_yw[wir]) /
1189 (m_ze[wir] - m_zw[wir]) + m_yw[wir];
1190 rr = sqrt( (xx * xx) + (yy * yy) );
1191 dphi = fabs(doca) / m_radii[lay];
1193 if( yy >= 0 ) wphi = acos(xx / rr);
1194 else wphi =
PI2 - acos(xx / rr);
1195 if(1 == lr) hitphi = wphi + dphi;
1196 else hitphi = wphi - dphi;
1197 if(hitphi < 0) hitphi +=
PI2;
1198 else if(hitphi >
PI2) hitphi -=
PI2;
1200 m_hitphi[lay] = hitphi;
1202 if( (fabs(doca) > m_docaMax[lay]) ||
1203 (fabs(resiExc) > m_param.
resiCut[lay]) ){
1209 if( ! fgHitLay[1] )
continue;
1210 }
else if(42 == lay){
1211 if( ! fgHitLay[41] )
continue;
1213 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) )
continue;
1217 ((!fgHitLay[lay-1]) || (!fgHitLay[lay+1])) )
continue;
1221 if((1 == m_param.
hitStatCut) && (1 != stat))
continue;
1225 m_xtTuple[lay] -> write();
1229 if( (0 == fgAdd[lay]) && (1 == stat) ){
1230 m_effNtrkRecHit->Fill(lay);
1234 if(0 == fgAdd[lay]){
1235 m_effNtrkRecHit->Fill(lay);
1241 if(lay < 8) nhitCalInn++;
1242 else if(lay < 20) nhitCalStp++;
1245 m_wirehitmap ->
Fill(wir);
1246 m_layerhitmap ->
Fill(lay);
1248 m_htraw[lay] ->
Fill(traw);
1249 m_htdr[lay] ->
Fill(tdr);
1250 m_htdrlr[lay][lr]->Fill(tdr);
1251 m_hadc[lay] ->
Fill(qhit);
1253 m_hresAllInc ->
Fill(resiInc);
1254 m_hresAllExc ->
Fill(resiExc);
1255 double resiAve = 0.5 * (resiInc + resiExc);
1256 m_hresAllAve ->
Fill(resiAve);
1257 if(yy > 0) m_hresAllExcUp->Fill(resiExc);
1258 else m_hresAllExcDw->Fill(resiExc);
1261 m_hresInnInc ->
Fill(resiInc);
1262 m_hresInnExc ->
Fill(resiExc);
1263 if(yy > 0) m_hresInnExcUp->Fill(resiExc);
1264 else m_hresInnExcDw->Fill(resiExc);
1265 }
else if(lay < 20){
1266 m_hresStpInc ->
Fill(resiInc);
1267 m_hresStpExc ->
Fill(resiExc);
1268 if(yy > 0) m_hresStpExcUp->Fill(resiExc);
1269 else m_hresStpExcDw->Fill(resiExc);
1271 m_hresOutInc ->
Fill(resiInc);
1272 m_hresOutExc ->
Fill(resiExc);
1273 if(yy > 0) m_hresOutExcUp->Fill(resiExc);
1274 else m_hresOutExcDw->Fill(resiExc);
1277 int qbin = (int)((qhit-100.0)/100.0);
1278 if(qbin>=0 && qbin<14){
1279 m_hresAveAllQ[qbin]->Fill(resiAve);
1280 m_hresAveLayQ[lay][qbin]->Fill(resiAve);
1281 if(lay > 7) m_hresAveOutQ[qbin]->Fill(resiAve);
1285 m_hresInc[lay] ->
Fill(resiInc);
1286 m_hreslrInc[lay][lr]->Fill(resiInc);
1287 m_hresExc[lay] ->
Fill(resiExc);
1288 m_hreslrExc[lay][lr]->Fill(resiExc);
1289 m_hresAve[lay] ->
Fill(resiAve);
1290 m_hreslrAve[lay][lr]->Fill(resiAve);
1293 int iPhi = (int)(hitphi*20.0/
PI2);
1294 if(iPhi>=20) iPhi = 19;
1295 m_hresphi[lay][iPhi]->Fill((resiInc+resiExc)*0.5);
1299 iEntr = m_mdcFunSvc -> getSdEntrIndex(entr);
1300 if(1 == m_nEntr[lay]){
1302 }
else if(2 == m_nEntr[lay]){
1303 if(entr > 0.0) iEntr = 1;
1305 }
else if(3 == m_nEntr[lay]){
1306 double entrBinWid = 0.174532925;
1307 iEntr = (int)(fabs(entr)/entrBinWid);
1308 if(iEntr > 2) iEntr = 2;
1311 key = getHresId(lay, iEntr, lr,
bin);
1312 if( 1 == m_mapr2d.count(
key) ){
1313 hid = m_mapr2d[
key];
1314 m_hr2dInc[hid] ->
Fill(resiInc);
1315 m_hr2dExc[hid] ->
Fill(resiExc);
1319 if((tdr>0) && (tdr<750)){
1320 if(tdr<300)
bin = (int)(tdr/10.0);
1321 else bin = (int)((tdr-300.0)/30.0) + 29;
1322 m_hr2t[lay][iEntr][lr][
bin]->Fill(resiExc);
1326 m_hnhitsCal->Fill(nhitCal);
1327 m_hnhitsCalInn->Fill(nhitCalInn);
1328 m_hnhitsCalStp->Fill(nhitCalStp);
1329 m_hnhitsCalOut->Fill(nhitCalOut);
1331 m_hnTrkCal->Fill(ntrkCal);
1333 if(pTrk[0] > pTrk[1]) m_hpMax->Fill(pTrk[0]);
1334 else m_hpMax->Fill(pTrk[1]);
1336 if(pTrkcms[0] > pTrkcms[1]) m_hpMaxCms->Fill(pTrkcms[0]);
1337 else m_hpMaxCms->Fill(pTrkcms[1]);
1339 if(ntrkCal > 0) m_hTesCalUse->Fill(tes);
1342 if((fabs(zminus) < 9000.0) && (fabs(zplus) < 9000.0)) delZ0 = zplus - zminus;
1343 m_hdelZ0 ->
Fill(delZ0);
1345 if (1 == pp.size() * pm.size()){
1346 HepLorentzVector ptot = pp[0] + pm[0];
1347 bool fourmomcut =
false;
1350 fourmomcut = (fabs(ptot.x()-0.04)<0.026) && (fabs(ptot.y()) < 0.026)
1351 && (fabs(ptot.z()-0.005)<0.036) && (fabs(ptot.e()-ecm)<0.058);
1354 HepLorentzVector psip(xboost, yboost, zboost, ecm);
1355 Hep3Vector boostv = psip.boostVector();
1356 pp[0].boost(- boostv);
1357 pm[0].boost(- boostv);
1358 m_hp_cut->Fill(pp[0].rho());
1359 m_hp_cut->Fill(pm[0].rho());
1363 if(2==ntrk)
for(i=0; i<ntrk; i++) pTrk[i] = (event -> getRecTrk(i)) -> getP();
1364 if((5==m_param.
particle) && (2==ntrk) && (fabs(pTrk[0])<5) && (fabs(pTrk[1])<5)){
1368 m_tesFlagcos = esTimeflag;
1369 for(i=0; i<ntrk; i++){
1370 rectrk =
event -> getRecTrk(i);
1371 phi0 = rectrk -> getPhi0();
1374 tanl = rectrk -> getTanLamda();
1376 theta =
HFPI - lamda;
1378 if(phi0 < (2.0*
HFPI)){
1379 m_nhitUpcos = rectrk -> getNHits();
1380 m_pUpcos = rectrk -> getP();
1381 m_ptUpcos = rectrk -> getPt();
1383 m_drUpcos = rectrk->
getDr();
1384 m_dzUpcos = rectrk->
getDz();
1385 m_ctheUpcos =
cos(theta);
1387 m_nhitDwcos = rectrk -> getNHits();
1388 m_pDwcos = rectrk -> getP();
1389 m_ptDwcos = rectrk -> getPt();
1391 m_drDwcos = rectrk->
getDr();
1392 m_dzDwcos = rectrk->
getDz();
1393 m_ctheDwcos =
cos(theta);
1395 if(m_pDwcos > 0) m_chargecos = 1;
1396 else m_chargecos = 0;
1408 cout <<
"Events " << m_hTesAll->GetEntries() <<
", Tes cut " << m_hTesCalFlag->GetEntries()
1409 <<
", nTrkCut " << m_cut1 << endl;
1410 cout <<
"Tot Tracks " << m_nTrkAfTrkCut
1411 <<
", cos(theta)_cut " << m_cut2 <<
", drCut " << m_cut3
1412 <<
", dzCut " << m_cut4 <<
", momCut" << m_cut5
1413 <<
", nHitLayer_cut " << m_cut6 <<
", nHit_cut " << m_cut7 << endl;
1414 cout <<
"nTrack after all cuts: " << m_nTrkCal << endl;
1419 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
1420 MsgStream log(
msgSvc,
"MdcCalib");
1421 log << MSG::DEBUG <<
"MdcCalib::updateConst()" << endreq;
1435 ofstream feffi(
"MdcLayerEffi.dat");
1436 for(lay=0; lay<m_nlayer; lay++){
1437 double effNtrk = m_effNtrk->GetBinContent(lay+1);
1438 double effGoodHit = m_effNtrkRecHit->GetBinContent(lay+1);
1439 nGoodAll += effGoodHit;
1440 if(lay < 8) nGoodInn += effGoodHit;
1441 else if (lay < 20) nGoodStp += effGoodHit;
1442 else nGoodOut += effGoodHit;
1445 if(lay < 8) nTotInn += effNtrk;
1446 else if (lay < 20) nTotStp += effNtrk;
1447 else nTotOut += effNtrk;
1449 effi = (double)effGoodHit / (
double)effNtrk;
1450 effErr = sqrt(effi * (1-effi) / (
double)effNtrk);
1451 feffi << setw(5) << lay << setw(15) << effi << setw(15) << effErr
1452 << setw(15) << effGoodHit << setw(15) << effNtrk << endl;
1454 double effiAll = (double)nGoodAll / (
double)(nTotAll);
1455 double errAll = sqrt(effiAll * (1-effiAll) / (
double)(nTotAll));
1456 double effiInn = (double)nGoodInn / (
double)(nTotInn);
1457 double errInn = sqrt(effiInn * (1-effiInn) / (
double)(nTotInn));
1458 double effiStp = (double)nGoodStp / (
double)(nTotStp);
1459 double errStp = sqrt(effiStp * (1-effiStp) / (
double)(nTotStp));
1460 double effiOut = (double)nGoodOut / (
double)(nTotOut);
1461 double errOut = sqrt(effiOut * (1-effiOut) / (
double)(nTotOut));
1462 feffi << endl <<
"EffiAll: " << setw(15) << effiAll << setw(15) << errAll
1463 << setw(15) << nGoodAll << setw(15) << nTotAll << endl;
1464 feffi << endl <<
"EffiInn: " << setw(15) << effiInn << setw(15) << errInn
1465 << setw(15) << nGoodInn << setw(15) << nTotInn << endl;
1466 feffi << endl <<
"EffiStp: " << setw(15) << effiStp << setw(15) << errStp
1467 << setw(15) << nGoodStp << setw(15) << nTotStp << endl;
1468 feffi << endl <<
"EffiOut: " << setw(15) << effiOut << setw(15) << errOut
1469 << setw(15) << nGoodOut << setw(15) << nTotOut << endl;
1474 int nHitAll[] = {0, 0};
1475 int nHitInn[] = {0, 0};
1476 int nHitStp[] = {0, 0};
1477 int nHitOut[] = {0, 0};
1478 ofstream feff2(
"MdcHitEffi.dat");
1479 for(lay=0; lay<m_nlayer; lay++){
1480 nHitAll[0] += m_hitNum[lay][0];
1481 nHitAll[1] += m_hitNum[lay][1];
1483 nHitInn[0] += m_hitNum[lay][0];
1484 nHitInn[1] += m_hitNum[lay][1];
1485 }
else if (lay < 20){
1486 nHitStp[0] += m_hitNum[lay][0];
1487 nHitStp[1] += m_hitNum[lay][1];
1489 nHitOut[0] += m_hitNum[lay][0];
1490 nHitOut[1] += m_hitNum[lay][1];
1493 effi = (double)m_hitNum[lay][1] / (
double)m_hitNum[lay][0];
1494 effErr = sqrt(effi * (1-effi) / (
double)m_hitNum[lay][0]);
1495 feff2 << setw(5) << lay << setw(15) << effi << setw(15) << effErr
1496 << setw(15) << m_hitNum[lay][1] << setw(15) << m_hitNum[lay][0] << endl;
1498 effiAll = (double)nHitAll[1] / (
double)nHitAll[0];
1499 errAll = sqrt(effiAll * (1-effiAll)) / (double)nHitAll[0];
1500 effiInn = (double)nHitInn[1] / (
double)nHitInn[0];
1501 errInn = sqrt(effiInn * (1-effiInn)) / (double)nHitInn[0];
1502 effiStp = (double)nHitStp[1] / (
double)nHitStp[0];
1503 errStp = sqrt(effiStp * (1-effiStp)) / (double)nHitStp[0];
1504 effiOut = (double)nHitOut[1] / (
double)nHitOut[0];
1505 errOut = sqrt(effiOut * (1-effiOut)) / (double)nHitOut[0];
1506 feff2 << endl <<
"EffiAll: " << setw(15) << effiAll << setw(15) << errAll
1507 << setw(15) << nHitAll[1] << setw(15) << nHitAll[0] << endl;
1508 feff2 << endl <<
"EffiInn: " << setw(15) << effiInn << setw(15) << errInn
1509 << setw(15) << nHitInn[1] << setw(15) << nHitInn[0] << endl;
1510 feff2 << endl <<
"EffiStp: " << setw(15) << effiStp << setw(15) << errStp
1511 << setw(15) << nHitStp[1] << setw(15) << nHitStp[0] << endl;
1512 feff2 << endl <<
"EffiOut: " << setw(15) << effiOut << setw(15) << errOut
1513 << setw(15) << nHitOut[1] << setw(15) << nHitOut[0] << endl;
1528 ofstream fr2d(
"logr2d.dat");
1529 for(lay=0; lay<m_nlayer; lay++){
1530 for(iEntr=0; iEntr<m_nEntr[lay]; iEntr++){
1531 for(lr=0; lr<2; lr++){
1532 fr2d << setw(3) << lay << setw(3) << iEntr << setw(3) << lr << endl;
1534 key = getHresId(lay, iEntr, lr,
bin);
1535 hid = m_mapr2d[
key];
1538 entry = m_hr2dExc[hid] -> GetEntries();
1540 m_hr2dExc[hid] ->
Fit(
"gaus",
"Q");
1541 sigm[
bin] = m_hr2dExc[hid]->GetFunction(
"gaus")->GetParameter(2);
1542 }
else if(entry > 100){
1543 sigm[
bin] = m_hr2dExc[hid]->GetRMS();
1548 entry = m_hr2dInc[hid] -> GetEntries();
1550 m_hr2dInc[hid] ->
Fit(
"gaus",
"Q");
1551 sigm[
bin] = m_hr2dInc[hid]->GetFunction(
"gaus")->GetParameter(2);
1552 }
else if(entry > 100){
1553 sigm[
bin] = m_hr2dInc[hid]->GetRMS();
1558 if(sigm[
bin] < 0.05) sigm[
bin] = 0.05;
1562 sigm[
bin] = sigm[m_nBin[lay]-1];
1566 if(1 == m_param.
fgCalib[lay]){
1568 if(1 == m_nEntr[lay]){
1569 for(i=0; i<6; i++) calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1570 }
else if(2 == m_nEntr[lay]){
1573 calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1577 calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1584 fr2d << setw(5) <<
bin << setw(15) << sigm[
bin] << endl;
1595int MdcCalib::getHresId(
int lay,
int entr,
int lr,
int bin)
const{
1596 int index = ( (lay << HRESLAYER_INDEX) & HRESLAYER_MASK ) |
1597 ( (entr << HRESENTRA_INDEX) & HRESENTRA_MASK ) |
1598 ( (lr << HRESLR_INDEX) & HRESLR_MASK ) |
1599 ( (
bin << HRESBIN_INDEX) & HRESBIN_MASK );
1603int MdcCalib::calDetEffi(){
1605 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
1606 MsgStream log(
msgSvc,
"MdcCalib");
1608 IDataProviderSvc* eventSvc =
NULL;
1609 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
1610 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc,
"/Event/Digi/MdcDigiCol");
1612 log << MSG::FATAL <<
"Could not find event" << endreq;
1617 bool hitCel[43][288];
1618 int hitCel2[43][288];
1619 for(lay=0; lay<43; lay++){
1620 for(cel=0; cel<288; cel++){
1621 hitCel[lay][cel] =
false;
1622 hitCel2[lay][cel] = 0;
1626 MdcDigiCol::iterator
iter = mdcDigiCol->begin();
1627 unsigned fgOverFlow;
1630 for(;
iter != mdcDigiCol->end();
iter++, digiId++) {
1632 id = (aDigi)->identify();
1636 fgOverFlow = (aDigi) -> getOverflow();
1641 if ( ((fgOverFlow & 3) !=0 ) || ((fgOverFlow & 12) != 0) ||
1644 hitCel[lay][cel] =
true;
1645 hitCel2[lay][cel] = 1;
1648 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
1650 log << MSG::ERROR <<
"Could not find RecMdcTrackCol" << endreq;
1657 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
1658 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1659 HitRefVec gothits = (*it_trk) -> getVecHits();
1660 HitRefVec::iterator it_hit = gothits.begin();
1661 for(; it_hit != gothits.end(); it_hit++){
1662 identifier = (*it_hit)->getMdcId();
1663 lay = mdcid.
layer(identifier);
1664 cel = mdcid.
wire(identifier);
1665 hitCel2[lay][cel] = 2;
1668 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1669 HepVector helix = (*it_trk)->helix();
1670 HepSymMatrix helixErr = (*it_trk)->err();
1671 double phi0 = (*it_trk)->helix(1);
1672 double phiTrk = phi0 +
HFPI;
1673 if(phiTrk >
PI2) phiTrk -=
PI2;
1675 for(lay=0; lay<43; lay++){
1676 double docamin = 0.9;
1677 if(lay<8) docamin = 0.6;
1679 int ncel = m_mdcGeomSvc->
Layer(lay)->
NCell();
1680 for(cel=0; cel<ncel; cel++){
1682 const MdcGeoWire* pWire = m_mdcGeomSvc -> Wire(lay, cel);
1685 double rr = sqrt( (xx * xx) + (yy * yy) );
1686 if( yy >= 0 ) wphi = acos(xx / rr);
1687 else wphi = CLHEP::twopi - acos(xx / rr);
1689 if( !( (fabs(wphi-phiTrk) < dphi) || (fabs(wphi+
PI2-phiTrk) < dphi) ||
1690 (fabs(wphi-
PI2-phiTrk) < dphi) ) ){
1694 double doca = m_mdcUtilitySvc->
doca(lay, cel, helix, helixErr);
1696 if(fabs(doca) < fabs(docamin)){
1702 if((celmin > -1) && (m_fgGoodWire[lay][celmin])){
1703 int wir = m_mdcGeomSvc -> Wire(lay, celmin) -> Id();
1704 m_hitEffAll->Fill(wir);
1705 m_hitEffAll->Fill(6799);
1706 if(lay<8) m_hitEffAll->Fill(6796);
1707 else if(lay<20) m_hitEffAll->Fill(6797);
1708 else m_hitEffAll->Fill(6798);
1712 if(hitCel[lay][celmin]){
1713 m_hitEffRaw->Fill(wir);
1714 m_hitEffRaw->Fill(6799);
1715 if(lay<8) m_hitEffRaw->Fill(6796);
1716 else if(lay<20) m_hitEffRaw->Fill(6797);
1717 else m_hitEffRaw->Fill(6798);
1719 if(2==hitCel2[lay][celmin]){
1720 m_hitEffRec->Fill(wir);
1721 m_hitEffRec->Fill(6799);
1722 if(lay<8) m_hitEffRec->Fill(6796);
1723 else if(lay<20) m_hitEffRec->Fill(6797);
1724 else m_hitEffRec->Fill(6798);
1804bool MdcCalib::getCellTrkPass(
MdcCalEvent* event,
int iTrk,
int cellTrkPass[]){
1806 int nHits = rectrk -> getNHits();
1808 for(
int k=0; k<nHits; k++){
1812 int wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1816 IDataProviderSvc* eventSvc =
NULL;
1817 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
1819 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
1827 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
1828 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1829 int nRecHits = (*it_trk)->getNhits();
1830 if(nRecHits < nHits)
continue;
1832 int hitInRecTrk[100];
1834 HitRefVec gothits = (*it_trk) -> getVecHits();
1835 HitRefVec::iterator it_hit = gothits.begin();
1836 for(; it_hit != gothits.end(); it_hit++){
1837 identifier = (*it_hit)->getMdcId();
1838 int lay = mdcid.
layer(identifier);
1839 int cel = mdcid.
wire(identifier);
1840 int wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1841 hitInRecTrk[iRecHit] = wir;
1846 bool matchSuccess =
true;
1847 for(
int i=0; i<nHits; i++){
1848 bool findHit =
false;
1849 for(
int k=0; k<nRecHits; k++){
1850 if(hitInTrk[i] == hitInRecTrk[k]){
1856 matchSuccess =
false;
1860 if(!matchSuccess)
continue;
1862 HepVector helix = (*it_trk)->helix();
1863 HepSymMatrix helixErr = (*it_trk)->err();
1864 double phi0 = (*it_trk)->helix(1);
1865 double phiTrk = phi0 +
HFPI;
1866 if(phiTrk >
PI2) phiTrk -=
PI2;
1868 for(
int lay=0; lay<43; lay++){
1869 double docamin = 0.9;
1870 if(lay<8) docamin = 0.6;
1872 int ncel = m_mdcGeomSvc->
Layer(lay)->
NCell();
1873 for(
int cel=0; cel<ncel; cel++){
1875 const MdcGeoWire* pWire = m_mdcGeomSvc -> Wire(lay, cel);
1878 double rr = sqrt( (xx * xx) + (yy * yy) );
1879 if( yy >= 0 ) wphi = acos(xx / rr);
1880 else wphi = CLHEP::twopi - acos(xx / rr);
1882 if( !( (fabs(wphi-phiTrk) < dphi) || (fabs(wphi+
PI2-phiTrk) < dphi) ||
1883 (fabs(wphi-
PI2-phiTrk) < dphi) ) ){
1887 double doca = m_mdcUtilitySvc->
doca(lay, cel, helix, helixErr);
1889 if(fabs(doca) < fabs(docamin)){
1895 cellTrkPass[lay] = celmin;
1897 cellTrkPass[lay] = -1;
double sin(const BesAngle a)
double cos(const BesAngle a)
const HepLorentzVector p_cms(0.034067, 0.0, 0.0, 3.097)
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)
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
std::vector< HepLorentzVector > Vp4
const double MdcCalTdcCnv
map< int, int >::value_type valType3
std::vector< HepLorentzVector > Vp4
SmartRefVector< RecMdcHit > HitRefVec
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
virtual double getWireEff(int layid, int cellid) const =0
virtual const MdcGeoLayer *const Layer(unsigned id)=0
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual double doca(int layer, int cell, const HepVector helix, const HepSymMatrix errMat, bool passCellRequired=true, bool doSag=true) const =0
int fgCalib[MdcCalNLayer]
double resiCut[MdcCalNLayer]
MdcCalRecHit * getRecHit(int index) const
HepLorentzVector getP4() const
double getSdpar(int lay, int entr, int lr, int bin)
virtual void printCut() const =0
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
virtual int updateConst(MdcCalibConst *calconst)=0
virtual int fillHist(MdcCalEvent *event)=0
double Radius(void) const
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
unsigned int getChargeChannel() const
unsigned int getTimeChannel() const
double double double * p4