1#include "MdcCalibAlg/MdcCalib.h"
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"
14#include "EventModel/Event.h"
15#include "MdcRawEvent/MdcDigi.h"
16#include "McTruth/MdcMcHit.h"
17#include "Identifier/Identifier.h"
18#include "Identifier/MdcID.h"
19#include "EventModel/EventHeader.h"
20#include "CLHEP/Vector/ThreeVector.h"
34typedef std::vector<HepLorentzVector>
Vp4;
45 fgReadWireEff =
false;
48 for(lay=0; lay<43; lay++){
49 if(lay < 15) m_nEntr[lay] = 1;
50 else m_nEntr[lay] = 2;
55 m_phiWid =
PI2 / (double)NPhiBin;
56 m_theWid = 2.0 / (double)NThetaBin;
61 if(lay < 8) m_nBin[lay] = 12;
62 else m_nBin[lay] = 16;
67 if((0==lay) || (7==lay) || (8==lay) || (19==lay) || (20==lay) ||
68 (35==lay) || (36==lay) || (42==lay) ) m_layBound[lay] =
true;
69 else m_layBound[lay] =
false;
78 for(lay=0; lay<m_nlayer; lay++){
81 delete m_hresInc[lay];
82 delete m_hresExc[lay];
83 delete m_hresAve[lay];
85 for (
int lr=0; lr<2; lr++){
86 delete m_htdrlr[lay][lr];
87 delete m_hreslrInc[lay][lr];
88 delete m_hreslrExc[lay][lr];
89 delete m_hreslrAve[lay][lr];
94 delete m_effNtrkRecHit;
98 for(
int i=0; i<14; i++){
99 delete m_hresAveAllQ[i];
100 delete m_hresAveOutQ[i];
102 for(lay=0; lay<43; lay++){
103 for(
int i=0; i<14; i++)
delete m_hresAveLayQ[lay][i];
111 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++)
delete m_hTes[iEs];
115 delete m_hTesAllFlag;
117 delete m_hTesCalFlag;
136 delete m_hnhitsRecInn;
137 delete m_hnhitsRecStp;
138 delete m_hnhitsRecOut;
140 delete m_hnhitsCalInn;
141 delete m_hnhitsCalStp;
142 delete m_hnhitsCalOut;
144 delete m_layerhitmap;
147 delete m_hnoisenhits;
169 delete m_ppPhiCms[
bin];
170 delete m_pnPhiCms[
bin];
171 for(thbin=0; thbin<NThetaBin; thbin++){
172 delete m_ppThePhi[thbin][
bin];
173 delete m_pnThePhi[thbin][
bin];
174 delete m_ppThePhiCms[thbin][
bin];
175 delete m_pnThePhiCms[thbin][
bin];
178 for(thbin=0; thbin<NThetaBin; thbin++){
179 delete m_ppThe[thbin];
180 delete m_pnThe[thbin];
181 delete m_ppTheCms[thbin];
182 delete m_pnTheCms[thbin];
185 for(
unsigned i=0; i<m_hr2dInc.size(); i++){
205 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
206 MsgStream log(
msgSvc,
"MdcCalib");
207 log << MSG::INFO <<
"MdcCalib::initialize()" << endreq;
210 m_mdcGeomSvc = mdcGeomSvc;
211 m_mdcFunSvc = mdcFunSvc;
212 m_mdcUtilitySvc = mdcUtilitySvc;
220 m_nlayer = m_mdcGeomSvc -> getLayerSize();
222 for(lay=0; lay<m_nlayer; lay++){
225 ofstream fwpc(
"wirelog.txt");
230 m_xw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().x();
231 m_yw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().y();
232 m_zw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().z();
233 fwpc << setw(6) << wir << setw(15) << m_xe[wir] << setw(15) << m_ye[wir]
234 << setw(15) << m_ze[wir] << setw(15) << m_xw[wir]
235 << setw(15) << m_yw[wir] << setw(15) << m_zw[wir] << endl;
239 m_fdcom =
new TFolder(
"common",
"common");
240 m_hlist ->
Add(m_fdcom);
242 m_effNtrk =
new TH1F(
"effNtrk",
"", 43, -0.5, 42.5);
243 m_fdcom->Add(m_effNtrk);
245 m_effNtrkRecHit =
new TH1F(
"effNtrkRecHit",
"", 43, -0.5, 42.5);
246 m_fdcom->Add(m_effNtrkRecHit);
248 m_hresAllInc =
new TH1F(
"HResAllInc",
"", 200, -1.0, 1.0);
249 m_fdcom ->
Add(m_hresAllInc);
251 m_hresAllExc =
new TH1F(
"HResAllExc",
"", 200, -1.0, 1.0);
252 m_fdcom ->
Add(m_hresAllExc);
254 m_hresAllAve =
new TH1F(
"HResAllAve",
"", 200, -1.0, 1.0);
255 m_fdcom ->
Add(m_hresAllAve);
257 m_hresInnInc =
new TH1F(
"HResInnInc",
"", 200, -1.0, 1.0);
258 m_fdcom ->
Add(m_hresInnInc);
260 m_hresInnExc =
new TH1F(
"HResInnExc",
"", 200, -1.0, 1.0);
261 m_fdcom ->
Add(m_hresInnExc);
263 m_hresStpInc =
new TH1F(
"HResStpInc",
"", 200, -1.0, 1.0);
264 m_fdcom ->
Add(m_hresStpInc);
266 m_hresStpExc =
new TH1F(
"HResStpExc",
"", 200, -1.0, 1.0);
267 m_fdcom ->
Add(m_hresStpExc);
269 m_hresOutInc =
new TH1F(
"HResOutInc",
"", 200, -1.0, 1.0);
270 m_fdcom ->
Add(m_hresOutInc);
272 m_hresOutExc =
new TH1F(
"HResOutExc",
"", 200, -1.0, 1.0);
273 m_fdcom ->
Add(m_hresOutExc);
275 m_fdResQ =
new TFolder(
"ResQ",
"ResQ");
276 m_hlist->Add(m_fdResQ);
277 for(
int i=0; i<14; i++){
278 sprintf(hname,
"resoAll_qbin%02d", i);
279 m_hresAveAllQ[i] =
new TH1F(hname,
"", 200, -1, 1);
280 m_fdResQ->Add(m_hresAveAllQ[i]);
282 sprintf(hname,
"resoOut_qbin%02d", i);
283 m_hresAveOutQ[i] =
new TH1F(hname,
"", 200, -1, 1);
284 m_fdResQ->Add(m_hresAveOutQ[i]);
286 for(lay=0; lay<43; lay++){
287 for(
int i=0; i<14; i++){
288 sprintf(hname,
"resoLay%02d_qbin%02d", lay, i);
289 m_hresAveLayQ[lay][i] =
new TH1F(hname,
"", 200, -1, 1);
290 m_fdResQ->Add(m_hresAveLayQ[lay][i]);
294 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++){
296 m_hTes[iEs] =
new TH1F(hname,
"", 750, 0, 1500);
297 m_fdcom->Add(m_hTes[iEs]);
300 m_hbbTrkFlg =
new TH1F(
"BbTrkFlg",
"", 100, 0, 6);
301 m_fdcom ->
Add(m_hbbTrkFlg);
303 m_hTesAll =
new TH1F(
"TesAll",
"", 1000, 0, 2000);
304 m_fdcom ->
Add(m_hTesAll);
306 m_hTesGood =
new TH1F(
"TesGood",
"", 1000, 0, 2000);
307 m_fdcom ->
Add(m_hTesGood);
309 m_hTesAllFlag =
new TH1F(
"TesAllFlag",
"", 300, -0.5, 299.5);
310 m_fdcom ->
Add(m_hTesAllFlag);
312 m_hTesRec =
new TH1F(
"TesRec",
"", 1000, 0, 2000);
313 m_fdcom ->
Add(m_hTesRec);
315 m_hTesCalFlag =
new TH1F(
"TesCalFlag",
"", 1000, 0, 2000);
316 m_fdcom ->
Add(m_hTesCalFlag);
318 m_hTesCalUse =
new TH1F(
"TesCalUse",
"", 1000, 0, 2000);
319 m_fdcom ->
Add(m_hTesCalUse);
321 m_hnRawHit =
new TH1F(
"nRawHit",
"", 6797, -0.5, 6796.5);
322 m_fdcom ->
Add(m_hnRawHit);
324 m_hpt =
new TH1F(
"HPt",
"", 800, 0, 3);
325 m_fdcom ->
Add(m_hpt);
327 m_hptPos =
new TH1F(
"HPtPos",
"", 800, 0, 3);
328 m_fdcom ->
Add(m_hptPos);
330 m_hptNeg =
new TH1F(
"HPtNeg",
"", 800, 0, 3);
331 m_fdcom ->
Add(m_hptNeg);
333 m_hp =
new TH1F(
"HP",
"", 800, 0, 3);
334 m_fdcom ->
Add(m_hp);
336 m_hp_cms =
new TH1F(
"HPCMS",
"", 800, 0, 3);
337 m_fdcom ->
Add(m_hp_cms);
339 m_hpMax =
new TH1F(
"HPMax",
"", 800, 0, 3);
340 m_fdcom ->
Add(m_hpMax);
342 m_hpMaxCms =
new TH1F(
"HPMax_Cms",
"", 800, 0, 3);
343 m_fdcom ->
Add(m_hpMaxCms);
345 m_hpPos =
new TH1F(
"HP_Pos",
"", 800, 0, 3);
346 m_fdcom ->
Add(m_hpPos);
348 m_hpNeg =
new TH1F(
"HP_Neg",
"", 800, 0, 3);
349 m_fdcom ->
Add(m_hpNeg);
351 m_hpPoscms =
new TH1F(
"HP_Pos_cms",
"", 800, 0, 3);
352 m_fdcom ->
Add(m_hpPoscms);
354 m_hpNegcms =
new TH1F(
"HP_Neg_cms",
"", 800, 0, 3);
355 m_fdcom ->
Add(m_hpNegcms);
357 m_hp_cut =
new TH1F(
"HPCut",
"", 800, 0, 3);
358 m_fdcom ->
Add(m_hp_cut);
360 m_hchisq =
new TH1F(
"Chisq",
"", 10, 0, 100);
361 m_fdcom ->
Add(m_hchisq);
363 m_hnTrk =
new TH1F(
"HNtrack",
"HNtrack", 10, -0.5, 9.5);
364 m_fdcom ->
Add(m_hnTrk);
366 m_hnTrkCal =
new TH1F(
"HNtrackCal",
"HNtrackCal", 10, -0.5, 9.5);
367 m_fdcom ->
Add(m_hnTrkCal);
369 m_hnhitsRec =
new TH1F(
"HNhitsRec",
"", 100, -0.5, 99.5);
370 m_fdcom ->
Add(m_hnhitsRec);
372 m_hnhitsRecInn =
new TH1F(
"HNhitsInnRec",
"", 60, 0.5, 60.5);
373 m_fdcom ->
Add(m_hnhitsRecInn);
375 m_hnhitsRecStp =
new TH1F(
"HNhitsStpRec",
"", 60, 0.5, 60.5);
376 m_fdcom ->
Add(m_hnhitsRecStp);
378 m_hnhitsRecOut =
new TH1F(
"HNhitsOutRec",
"", 60, 0.5, 60.5);
379 m_fdcom ->
Add(m_hnhitsRecOut);
381 m_hnhitsCal =
new TH1F(
"HNhitsCal",
"", 100, -0.5, 99.5);
382 m_fdcom ->
Add(m_hnhitsCal);
384 m_hnhitsCalInn =
new TH1F(
"HNhitsCalInn",
"", 60, 0.5, 60.5);
385 m_fdcom ->
Add(m_hnhitsCalInn);
387 m_hnhitsCalStp =
new TH1F(
"HNhitsCalStp",
"", 60, 0.5, 60.5);
388 m_fdcom ->
Add(m_hnhitsCalStp);
390 m_hnhitsCalOut =
new TH1F(
"HNhitsCalOut",
"", 60, 0.5, 60.5);
391 m_fdcom ->
Add(m_hnhitsCalOut);
393 m_wirehitmap =
new TH1F(
"Wire_HitMap",
"Wire_HitMap", 6796, -0.5, 6795.5);
394 m_fdcom ->
Add(m_wirehitmap);
396 m_layerhitmap =
new TH1F(
"Layer_HitMap",
"Layer_HitMap", 43, -0.5, 42.5);
397 m_fdcom ->
Add(m_layerhitmap);
399 m_hnoisephi =
new TH1F(
"phi_noise",
"", 100, 0, 6.284);
400 m_fdcom ->
Add(m_hnoisephi);
402 m_hnoiselay =
new TH1F(
"Layer_noise",
"Layer_noise", 43, -0.5, 42.5);
403 m_fdcom ->
Add(m_hnoiselay);
405 m_hnoisenhits =
new TH1F(
"nhits_noise",
"nhits_noise", 6796, -0.5, 6795.5);
406 m_fdcom ->
Add(m_hnoisenhits);
408 m_hratio =
new TH1F(
"ratio",
"", 100, 0, 1);
409 m_fdcom ->
Add(m_hratio);
411 m_hdr =
new TH1F(
"dr",
"", 500, -500, 500);
412 m_fdcom ->
Add(m_hdr);
414 m_hphi0 =
new TH1F(
"phi0",
"", 100, 0, 6.284);
415 m_fdcom ->
Add(m_hphi0);
417 m_hkap =
new TH1F(
"kappa",
"", 400, -50, 50);
418 m_fdcom ->
Add(m_hkap);
420 m_hdz =
new TH1F(
"dz",
"", 500, -1000, 1000);
421 m_fdcom ->
Add(m_hdz);
423 m_htanl =
new TH1F(
"tanl",
"", 200, -5, 5);
424 m_fdcom ->
Add(m_htanl);
426 m_hcosthe =
new TH1F(
"costheta",
"", 200, -1, 1);
427 m_fdcom ->
Add(m_hcosthe);
429 m_hcostheNeg =
new TH1F(
"costhetaNeg",
"", 200, -1, 1);
430 m_fdcom ->
Add(m_hcostheNeg);
432 m_hcosthePos =
new TH1F(
"costhetaPos",
"", 200, -1, 1);
433 m_fdcom ->
Add(m_hcosthePos);
435 m_hx0 =
new TH1F(
"x0",
"", 100, -10, 10);
436 m_fdcom ->
Add(m_hx0);
438 m_hy0 =
new TH1F(
"y0",
"", 100, -10, 10);
439 m_fdcom ->
Add(m_hy0);
441 m_hdelZ0 =
new TH1F(
"delta_z0",
"", 100, -50, 50);
442 m_fdcom ->
Add(m_hdelZ0);
444 m_grX0Y0 =
new TGraph();
445 m_grX0Y0->SetName(
"x0y0");
446 m_fdcom ->
Add(m_grX0Y0);
448 m_hitEffAll =
new TH1F(
"hitEffAll",
"", 6800, -0.5, 6799.5);
449 m_fdcom ->
Add(m_hitEffAll);
451 m_hitEffRaw =
new TH1F(
"hitEffRaw",
"", 6800, -0.5, 6799.5);
452 m_fdcom ->
Add(m_hitEffRaw);
454 m_hitEffRec =
new TH1F(
"hitEffRec",
"", 6800, -0.5, 6799.5);
455 m_fdcom ->
Add(m_hitEffRec);
458 m_fdTime =
new TFolder(
"time",
"time");
459 m_hlist ->
Add(m_fdTime);
461 for(lay=0; lay<m_nlayer; lay++){
462 sprintf(hname,
"Traw%02d", lay);
463 m_htraw[lay] =
new TH1F(hname,
"", 1000, 0, 2000);
464 m_fdTime ->
Add(m_htraw[lay]);
466 sprintf(hname,
"Tdr%02d", lay);
467 m_htdr[lay] =
new TH1F(hname,
"", 510, -10, 500);
468 m_fdTime ->
Add(m_htdr[lay]);
470 for (lr=0; lr<2; lr++){
471 sprintf(hname,
"Tdr%02d_lr%01d", lay, lr);
472 m_htdrlr[lay][lr] =
new TH1F(hname,
"", 510, -10, 500);
473 m_fdTime ->
Add(m_htdrlr[lay][lr]);
478 m_fdAdc =
new TFolder(
"adc",
"adc");
479 m_hlist ->
Add(m_fdAdc);
481 for(lay=0; lay<m_nlayer; lay++){
482 sprintf(hname,
"adc%02d", lay);
483 m_hadc[lay] =
new TH1F(hname,
"", 1500, 0, 3000);
484 m_fdAdc ->
Add(m_hadc[lay]);
487 m_fdres =
new TFolder(
"resolution",
"resolution");
488 m_hlist ->
Add(m_fdres);
490 m_fdresAve =
new TFolder(
"resAve",
"resAve");
491 m_hlist ->
Add(m_fdresAve);
493 for(lay=0; lay<m_nlayer; lay++){
494 sprintf(hname,
"Reso%02dInc", lay);
495 m_hresInc[lay] =
new TH1F(hname,
"", 1000, -5, 5);
496 m_fdres ->
Add(m_hresInc[lay]);
498 sprintf(hname,
"Reso%02dExc", lay);
499 m_hresExc[lay] =
new TH1F(hname,
"", 1000, -5, 5);
500 m_fdres ->
Add(m_hresExc[lay]);
502 sprintf(hname,
"Reso%02d", lay);
503 m_hresAve[lay] =
new TH1F(hname,
"", 1000, -5, 5);
504 m_fdresAve ->
Add(m_hresAve[lay]);
506 for (lr=0; lr<2; lr++){
507 sprintf(hname,
"Reso%02dInc_lr%01d", lay, lr);
509 m_hreslrInc[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
510 m_fdres->Add(m_hreslrInc[lay][lr]);
512 sprintf(hname,
"Reso%02dExc_lr%01d", lay, lr);
514 m_hreslrExc[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
515 m_fdres->Add(m_hreslrExc[lay][lr]);
517 sprintf(hname,
"Reso%02d_lr%01d", lay, lr);
519 m_hreslrAve[lay][lr] =
new TH1F(hname,
"", 1000, -5, 5);
520 m_fdresAve->Add(m_hreslrAve[lay][lr]);
522 for(
int phi=0; phi<20; phi++){
523 sprintf(hname,
"ResoPhi%02d_phi%02d", lay, phi);
524 m_hresphi[lay][phi] =
new TH1F(hname,
"", 200, -1, 1);
525 m_fdres->Add(m_hresphi[lay][phi]);
530 m_fdmomPhi =
new TFolder(
"momPhi",
"momPhi");
531 m_hlist ->
Add(m_fdmomPhi);
536 m_ppPhi[
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
537 m_fdmomPhi->Add(m_ppPhi[
bin]);
540 m_pnPhi[
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
541 m_fdmomPhi->Add(m_pnPhi[
bin]);
544 m_ppPhiCms[
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
545 m_fdmomPhi->Add(m_ppPhiCms[
bin]);
548 m_pnPhiCms[
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
549 m_fdmomPhi->Add(m_pnPhiCms[
bin]);
551 for(thbin=0; thbin<NThetaBin; thbin++){
552 sprintf(hname,
"hPpos_theta%02d_phi%02d", thbin,
bin);
553 m_ppThePhi[thbin][
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
554 m_fdmomPhi->Add(m_ppThePhi[thbin][
bin]);
556 sprintf(hname,
"hPneg_theta%02d_phi%02d", thbin,
bin);
557 m_pnThePhi[thbin][
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
558 m_fdmomPhi->Add(m_pnThePhi[thbin][
bin]);
560 sprintf(hname,
"hPposCms_theta%02d_phi%02d", thbin,
bin);
561 m_ppThePhiCms[thbin][
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
562 m_fdmomPhi->Add(m_ppThePhiCms[thbin][
bin]);
564 sprintf(hname,
"hPnegCms_theta%02d_phi%02d", thbin,
bin);
565 m_pnThePhiCms[thbin][
bin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
566 m_fdmomPhi->Add(m_pnThePhiCms[thbin][
bin]);
569 for(thbin=0; thbin<NThetaBin; thbin++){
570 sprintf(hname,
"hPpos_the%02d", thbin);
571 m_ppThe[thbin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
572 m_fdmomPhi->Add(m_ppThe[thbin]);
574 sprintf(hname,
"hPneg_the%02d", thbin);
575 m_pnThe[thbin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
576 m_fdmomPhi->Add(m_pnThe[thbin]);
578 sprintf(hname,
"hPposCms_the%02d", thbin);
579 m_ppTheCms[thbin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
580 m_fdmomPhi->Add(m_ppTheCms[thbin]);
582 sprintf(hname,
"hPnegCms_the%02d", thbin);
583 m_pnTheCms[thbin] =
new TH1F(hname,
"", 400, 1.0, 2.5);
584 m_fdmomPhi->Add(m_pnTheCms[thbin]);
588 m_fdres2d =
new TFolder(
"res2d",
"res2d");
589 m_hlist ->
Add(m_fdres2d);
594 for(lay=0; lay<m_nlayer; lay++){
596 for(lr=0; lr<2; lr++){
598 sprintf(hname,
"r2d%02d_%02d_%01d_%02dInc", lay, iEntr, lr,
bin);
599 hist =
new TH1F(hname,
"", 200, -1, 1);
600 m_hr2dInc.push_back(hist);
601 m_fdres2d ->
Add(hist);
603 sprintf(hname,
"r2d%02d_%02d_%01d_%02dExc", lay, iEntr, lr,
bin);
604 hist =
new TH1F(hname,
"", 200, -1, 1);
605 m_hr2dExc.push_back(hist);
606 m_fdres2d ->
Add(hist);
608 key = getHresId(lay, iEntr, lr,
bin);
616 m_fdres2t =
new TFolder(
"res2t",
"res2t");
619 for(lay=0; lay<m_nlayer; lay++){
621 for(lr=0; lr<2; lr++){
623 sprintf(hname,
"r2t%02d_%02d_%01d_%02d", lay, iEntr, lr,
bin);
624 m_hr2t[lay][iEntr][lr][
bin] =
new TH1F(hname,
"", 600, -3, 3);
625 m_fdres2t ->
Add(m_hr2t[lay][iEntr][lr][
bin]);
632 Gaudi::svcLocator() -> service(
"NTupleSvc",
ntupleSvc);
633 for(lay=0; lay<m_nlayer; lay++){
634 sprintf(hname,
"FILE136/xt%02d", lay);
636 if ( nt ) m_xtTuple[lay] = nt;
638 m_xtTuple[lay] =
ntupleSvc->book(hname, CLID_ColumnWiseTuple,
"MdcXtNtuple");
639 if( m_xtTuple[lay] ){
640 m_xtTuple[lay]->addItem(
"cel", m_cel[lay]);
641 m_xtTuple[lay]->addItem(
"lr", m_lr[lay]);
642 m_xtTuple[lay]->addItem(
"run", m_run[lay]);
643 m_xtTuple[lay]->addItem(
"evt", m_evt[lay]);
644 m_xtTuple[lay]->addItem(
"doca", m_doca[lay]);
645 m_xtTuple[lay]->addItem(
"dm", m_dm[lay]);
646 m_xtTuple[lay]->addItem(
"tdr", m_tdr[lay]);
647 m_xtTuple[lay]->addItem(
"tdc", m_tdc[lay]);
648 m_xtTuple[lay]->addItem(
"entr", m_entr[lay]);
649 m_xtTuple[lay]->addItem(
"zhit", m_zhit[lay]);
650 m_xtTuple[lay]->addItem(
"qhit", m_qhit[lay]);
651 m_xtTuple[lay]->addItem(
"p", m_p[lay]);
652 m_xtTuple[lay]->addItem(
"pt", m_pt[lay]);
653 m_xtTuple[lay]->addItem(
"phi0", m_phi0[lay]);
654 m_xtTuple[lay]->addItem(
"tanl", m_tanl[lay]);
655 m_xtTuple[lay]->addItem(
"hitphi", m_hitphi[lay]);
657 log << MSG::FATAL <<
"Cannot book Xt N-tuple:"
658 << long(m_xtTuple[lay]) << endreq;
664 sprintf(hname,
"FILE136/cosmic");
666 if ( nt ) m_cosmic = nt;
668 m_cosmic =
ntupleSvc->book(hname, CLID_ColumnWiseTuple,
"MdcXtNtuple");
670 m_cosmic->addItem(
"pUp", m_pUpcos);
671 m_cosmic->addItem(
"pDw", m_pDwcos);
672 m_cosmic->addItem(
"ptUp", m_ptUpcos);
673 m_cosmic->addItem(
"ptDw", m_ptDwcos);
674 m_cosmic->addItem(
"phiUp", m_phiUpcos);
675 m_cosmic->addItem(
"phiDw", m_phiDwcos);
676 m_cosmic->addItem(
"drUp", m_drUpcos);
677 m_cosmic->addItem(
"drDw", m_drDwcos);
678 m_cosmic->addItem(
"dzUp", m_dzUpcos);
679 m_cosmic->addItem(
"dzDw", m_dzDwcos);
680 m_cosmic->addItem(
"ctheUp", m_ctheUpcos);
681 m_cosmic->addItem(
"ctheDw", m_ctheDwcos);
682 m_cosmic->addItem(
"nhitUp", m_nhitUpcos);
683 m_cosmic->addItem(
"nhitDw", m_nhitDwcos);
684 m_cosmic->addItem(
"char", m_chargecos);
685 m_cosmic->addItem(
"tesfg", m_tesFlagcos);
686 m_cosmic->addItem(
"tes", m_tescos);
694 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
695 MsgStream log(
msgSvc,
"MdcCalib");
696 log << MSG::DEBUG <<
"MdcCalib::fillHist()" << endreq;
729 double ecm = m_param.
ecm;
730 double xboost = m_param.
boostPar[0] * ecm;
731 double yboost = m_param.
boostPar[1];
732 double zboost = m_param.
boostPar[2];
743 double zminus = 9999.0;
744 double zplus = -9999.0;
762 int ntrk =
event -> getNTrk();
780 for(cel=0; cel<ncel; cel++){
781 double eff = m_mdcFunSvc->
getWireEff(lay, cel);
782 if(eff > 0.5) m_fgGoodWire[lay][cel] =
true;
783 else m_fgGoodWire[lay][cel] =
false;
784 if(eff<0.9) cout <<
"dead channel: " << setw(5) << lay << setw(5) << cel << endl;
787 fgReadWireEff =
true;
790 int nRawHit =
event->getNRawHitTQ();
791 m_hnRawHit->Fill(nRawHit);
793 IDataProviderSvc* eventSvc = NULL;
794 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
796 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
798 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
799 return( StatusCode::FAILURE);
801 int iRun = eventHeader->runNumber();
802 int iEvt = eventHeader->eventNumber();
804 int esTimeflag =
event->getEsFlag();
805 double tes =
event->getTes();
806 bool esCutFg =
event->getEsCutFlag();
807 int iEs =
event->getNesCutFlag();
809 if (-1 != esTimeflag) {
810 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
812 log << MSG::ERROR <<
"Could not find RecMdcTrackCol" << endreq;
813 return ( StatusCode::FAILURE );
819 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
820 for(; it_trk != newtrkCol->end(); it_trk++){
821 double mass = 0.000511;
822 HepLorentzVector p4 = (*it_trk)->p4(
mass);
823 icharge = (*it_trk)->charge();
824 if (icharge > 0) p4p.push_back(p4);
825 else p4m.push_back(p4);
827 if (1 == p4p.size() * p4m.size()){
828 double dang = p4p[0].vect().angle(p4m[0].vect());
829 m_hbbTrkFlg->Fill(1);
831 m_hbbTrkFlg->Fill(2);
836 m_hTesAll->Fill(tes);
838 if (-1 != esTimeflag) m_hTesGood->Fill(tes);
839 m_hTesAllFlag->Fill(esTimeflag);
840 if(ntrk > 0) m_hTesRec->Fill(tes);
841 if( (iEs >= 0) && (iEs < m_param.
nEsFlag) ) m_hTes[iEs]->Fill(tes);
842 if( esCutFg ) m_hTesCalFlag->Fill(tes);
854 for(i=0; i<200; i++) trkFlag[i] =
false;
859 double hitphiplus = 9999.0;
860 double hitthetaplus = 9999.0;
861 double hitphiminus = -9999.0;
862 double hitthetaminus = -9999.0;
876 for(i=0; i<ntrk; i++){
878 rectrk =
event -> getRecTrk(i);
879 nhitRec = rectrk -> getNHits();
880 m_hnhitsRec ->
Fill( nhitRec );
883 fgHitLay[lay] =
false;
889 for(k=0; k<nhitRec; k++){
890 rechit = rectrk -> getRecHit(k);
891 lay = rechit -> getLayid();
892 doca = rechit -> getDocaExc();
893 resiExc = rechit -> getResiExc();
894 fgHitLay[lay] =
true;
896 if(lay < 8) nhitRecInn++;
897 else if(lay < 20) nhitRecStp++;
900 m_hnhitsRecInn->Fill(nhitRecInn);
901 m_hnhitsRecStp->Fill(nhitRecStp);
902 m_hnhitsRecOut->Fill(nhitRecOut);
905 pt = rectrk -> getPt();
906 p = rectrk -> getP();
909 p4 = rectrk->
getP4();
910 HepLorentzVector psip(xboost, yboost, zboost, ecm);
911 Hep3Vector boostv = psip.boostVector();
915 if(phicms < 0) phicms +=
PI2;
916 thetacms = p4.theta();
917 costheCMS =
cos(thetacms);
918 if (pt < 0)
p_cms *= -1.0;
929 dr = rectrk->
getDr();
930 if(fabs(dr) > m_param.
drCut){
936 dz = rectrk->
getDz();
937 if(fabs(dz) > m_param.
dzCut){
947 if(fgHitLay[lay]) nhitlay++;
970 bool fgPass = getCellTrkPass(event, i, cellTrkPass);
971 for(lay=0; lay<m_nlayer; lay++){
974 if((15==lay) || (16==lay) || (18==lay) || (19==lay) || (40==lay) || (41==lay) || (42==lay)){
975 int iCell = cellTrkPass[lay];
976 if(fgPass && (iCell >= 0) && m_fgGoodWire[lay][iCell]) m_effNtrk->Fill(lay);
979 m_effNtrk->Fill(lay);
983 chisq = rectrk -> getChisq();
984 m_hchisq ->
Fill( chisq );
988 m_hptPos ->
Fill(pt);
994 m_hpt ->
Fill(-1.0*pt);
995 m_hptNeg ->
Fill(-1.0*pt);
996 m_hp ->
Fill(-1.0*p);
998 m_hpNeg ->
Fill(-1.0*p);
1003 pTrkcms[i] = fabs(
p_cms);
1006 dr = rectrk -> getDr();
1007 phi0 = rectrk -> getPhi0();
1008 kap = rectrk -> getKappa();
1009 dz = rectrk -> getDz();
1010 tanl = rectrk -> getTanLamda();
1012 theta =
HFPI - lamda;
1015 m_hphi0 ->
Fill(phi0);
1016 m_hkap ->
Fill(kap);
1018 m_htanl ->
Fill(tanl);
1019 m_hcosthe ->
Fill(
cos(theta));
1020 if(pt > 0) m_hcosthePos->Fill(
cos(theta));
1021 else m_hcostheNeg->Fill(
cos(theta));
1023 philab = phi0 +
HFPI;
1024 if(philab >
PI2) philab -=
PI2;
1027 phiBin = (int)(philab / m_phiWid);
1028 phiBinCms = (int)(phicms / m_phiWid);
1029 theBin = (int)((
cos(theta) + 1.0) / m_theWid);
1030 theBinCms = (int)((
cos(thetacms) + 1.0) / m_theWid);
1031 if(phiBin < 0) phiBin = 0;
1032 if(phiBin >= NPhiBin) phiBin = NPhiBin-1;
1033 if(phiBinCms < 0) phiBinCms = 0;
1034 if(phiBinCms >= NPhiBin) phiBinCms = NPhiBin-1;
1035 if(theBin < 0) theBin = 0;
1036 if(theBin >= NThetaBin) theBin = NThetaBin-1;
1037 if(theBinCms < 0) theBinCms = 0;
1038 if(theBinCms >= NThetaBin) theBinCms = NThetaBin-1;
1041 m_ppPhi[phiBin]->Fill(p);
1042 m_ppPhiCms[phiBinCms]->Fill(
p_cms);
1043 m_ppThe[theBin]->Fill(p);
1044 m_ppTheCms[theBinCms]->Fill(
p_cms);
1045 m_ppThePhi[theBin][phiBin]->Fill(p);
1046 m_ppThePhiCms[theBinCms][phiBinCms]->Fill(
p_cms);
1048 m_pnPhi[phiBin]->Fill(-1.0*p);
1049 m_pnPhiCms[phiBinCms]->Fill(-1.0*
p_cms);
1050 m_pnThe[theBin]->Fill(-1.0*p);
1051 m_pnTheCms[theBinCms]->Fill(-1.0*
p_cms);
1052 m_pnThePhi[theBin][phiBin]->Fill(-1.0*p);
1053 m_pnThePhiCms[theBinCms][phiBinCms]->Fill(-1.0*
p_cms);
1056 x0 = dr *
cos(phi0);
1057 y0 = dr *
sin(phi0);
1060 if(m_nGrPoint < 10000){
1061 m_grX0Y0->SetPoint(m_nGrPoint, x0, y0);
1068 phibinm = phiBinCms;
1072 phibinp = phiBinCms;
1082 for(k=0; k<nhitRec; k++){
1083 rechit = rectrk -> getRecHit(k);
1085 lay = rechit -> getLayid();
1086 cel = rechit -> getCellid();
1087 lr = rechit -> getLR();
1088 stat = rechit -> getStat();
1089 doca = rechit -> getDocaExc();
1090 resiInc = rechit -> getResiIncLR();
1091 resiExc = rechit -> getResiExcLR();
1092 entr = rechit -> getEntra();
1093 tdr = rechit -> getTdrift();
1095 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1097 m_cel[lay] = (long)cel;
1098 m_lr[lay] = (long)lr;
1102 m_dm[lay] = rechit -> getDmeas();
1105 m_entr[lay] = entr*180.0/3.14;
1106 m_zhit[lay] = rechit -> getZhit();
1107 m_qhit[lay] = rechit -> getQhit();
1112 qhit = rechit -> getQhit();
1115 xx = (m_zhit[lay] - m_zw[wir]) * (m_xe[wir] - m_xw[wir]) /
1116 (m_ze[wir] - m_zw[wir]) + m_xw[wir];
1117 yy = (m_zhit[lay] - m_zw[wir]) * (m_ye[wir] - m_yw[wir]) /
1118 (m_ze[wir] - m_zw[wir]) + m_yw[wir];
1119 rr = sqrt( (xx * xx) + (yy * yy) );
1120 dphi = fabs(doca) / m_radii[lay];
1122 if( yy >= 0 ) wphi = acos(xx / rr);
1123 else wphi =
PI2 - acos(xx / rr);
1124 if(1 == lr) hitphi = wphi + dphi;
1125 else hitphi = wphi - dphi;
1126 if(hitphi < 0) hitphi +=
PI2;
1127 else if(hitphi >
PI2) hitphi -=
PI2;
1129 m_hitphi[lay] = hitphi;
1131 if( (fabs(doca) > m_docaMax[lay]) ||
1132 (fabs(resiExc) > m_param.
resiCut[lay]) ){
1138 if( ! fgHitLay[1] )
continue;
1139 }
else if(42 == lay){
1140 if( ! fgHitLay[41] )
continue;
1142 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) )
continue;
1146 ((!fgHitLay[lay-1]) || (!fgHitLay[lay+1])) )
continue;
1150 if((1 == m_param.
hitStatCut) && (1 != stat))
continue;
1154 m_xtTuple[lay] -> write();
1158 if( (0 == fgAdd[lay]) && (1 == stat) ){
1159 m_effNtrkRecHit->Fill(lay);
1163 if(0 == fgAdd[lay]){
1164 m_effNtrkRecHit->Fill(lay);
1170 if(lay < 8) nhitCalInn++;
1171 else if(lay < 20) nhitCalStp++;
1174 m_wirehitmap ->
Fill(wir);
1175 m_layerhitmap ->
Fill(lay);
1177 m_htraw[lay] ->
Fill(traw);
1178 m_htdr[lay] ->
Fill(tdr);
1179 m_htdrlr[lay][lr]->Fill(tdr);
1180 m_hadc[lay] ->
Fill(qhit);
1182 m_hresAllInc ->
Fill(resiInc);
1183 m_hresAllExc ->
Fill(resiExc);
1184 double resiAve = 0.5 * (resiInc + resiExc);
1185 m_hresAllAve ->
Fill(resiAve);
1188 m_hresInnInc ->
Fill(resiInc);
1189 m_hresInnExc ->
Fill(resiExc);
1190 }
else if(lay < 20){
1191 m_hresStpInc ->
Fill(resiInc);
1192 m_hresStpExc ->
Fill(resiExc);
1194 m_hresOutInc ->
Fill(resiInc);
1195 m_hresOutExc ->
Fill(resiExc);
1198 int qbin = (int)((qhit-100.0)/100.0);
1199 if(qbin>=0 && qbin<14){
1200 m_hresAveAllQ[qbin]->Fill(resiAve);
1201 m_hresAveLayQ[lay][qbin]->Fill(resiAve);
1202 if(lay > 7) m_hresAveOutQ[qbin]->Fill(resiAve);
1205 m_hresInc[lay] ->
Fill(resiInc);
1206 m_hreslrInc[lay][lr]->Fill(resiInc);
1207 m_hresExc[lay] ->
Fill(resiExc);
1208 m_hreslrExc[lay][lr]->Fill(resiExc);
1209 m_hresAve[lay] ->
Fill(resiAve);
1210 m_hreslrAve[lay][lr]->Fill(resiAve);
1212 int iPhi = (int)(hitphi*20.0/
PI2);
1213 if(iPhi>=20) iPhi = 19;
1214 m_hresphi[lay][iPhi]->Fill((resiInc+resiExc)*0.5);
1218 iEntr = m_mdcFunSvc -> getSdEntrIndex(entr);
1219 if(1 == m_nEntr[lay]){
1221 }
else if(2 == m_nEntr[lay]){
1222 if(entr > 0.0) iEntr = 1;
1226 key = getHresId(lay, iEntr, lr,
bin);
1227 if( 1 == m_mapr2d.count(
key) ){
1228 hid = m_mapr2d[
key];
1229 m_hr2dInc[hid] ->
Fill(resiInc);
1230 m_hr2dExc[hid] ->
Fill(resiExc);
1234 if((tdr>0) && (tdr<750)){
1235 if(tdr<300)
bin = (int)(tdr/10.0);
1236 else bin = (int)((tdr-300.0)/30.0) + 29;
1237 m_hr2t[lay][iEntr][lr][
bin]->Fill(resiExc);
1241 m_hnhitsCal->Fill(nhitCal);
1242 m_hnhitsCalInn->Fill(nhitCalInn);
1243 m_hnhitsCalStp->Fill(nhitCalStp);
1244 m_hnhitsCalOut->Fill(nhitCalOut);
1246 m_hnTrkCal->Fill(ntrkCal);
1248 if(pTrk[0] > pTrk[1]) m_hpMax->Fill(pTrk[0]);
1249 else m_hpMax->Fill(pTrk[1]);
1251 if(pTrkcms[0] > pTrkcms[1]) m_hpMaxCms->Fill(pTrkcms[0]);
1252 else m_hpMaxCms->Fill(pTrkcms[1]);
1254 if(ntrkCal > 0) m_hTesCalUse->Fill(tes);
1257 if((fabs(zminus) < 9000.0) && (fabs(zplus) < 9000.0)) delZ0 = zplus - zminus;
1258 m_hdelZ0 ->
Fill(delZ0);
1260 if (1 == pp.size() * pm.size()){
1261 HepLorentzVector ptot = pp[0] + pm[0];
1262 bool fourmomcut =
false;
1265 fourmomcut = (fabs(ptot.x()-0.04)<0.026) && (fabs(ptot.y()) < 0.026)
1266 && (fabs(ptot.z()-0.005)<0.036) && (fabs(ptot.e()-ecm)<0.058);
1269 HepLorentzVector psip(xboost, yboost, zboost, ecm);
1270 Hep3Vector boostv = psip.boostVector();
1271 pp[0].boost(- boostv);
1272 pm[0].boost(- boostv);
1273 m_hp_cut->Fill(pp[0].rho());
1274 m_hp_cut->Fill(pm[0].rho());
1278 if(2==ntrk)
for(i=0; i<ntrk; i++) pTrk[i] = (event -> getRecTrk(i)) -> getP();
1279 if((5==m_param.
particle) && (2==ntrk) && (fabs(pTrk[0])<5) && (fabs(pTrk[1])<5)){
1283 m_tesFlagcos = esTimeflag;
1284 for(i=0; i<ntrk; i++){
1285 rectrk =
event -> getRecTrk(i);
1286 phi0 = rectrk -> getPhi0();
1289 tanl = rectrk -> getTanLamda();
1291 theta =
HFPI - lamda;
1293 if(phi0 < (2.0*
HFPI)){
1294 m_nhitUpcos = rectrk -> getNHits();
1295 m_pUpcos = rectrk -> getP();
1296 m_ptUpcos = rectrk -> getPt();
1298 m_drUpcos = rectrk->
getDr();
1299 m_dzUpcos = rectrk->
getDz();
1300 m_ctheUpcos =
cos(theta);
1302 m_nhitDwcos = rectrk -> getNHits();
1303 m_pDwcos = rectrk -> getP();
1304 m_ptDwcos = rectrk -> getPt();
1306 m_drDwcos = rectrk->
getDr();
1307 m_dzDwcos = rectrk->
getDz();
1308 m_ctheDwcos =
cos(theta);
1310 if(m_pDwcos > 0) m_chargecos = 1;
1311 else m_chargecos = 0;
1324 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
1325 MsgStream log(
msgSvc,
"MdcCalib");
1326 log << MSG::DEBUG <<
"MdcCalib::updateConst()" << endreq;
1328 cout <<
"Tot " << m_hnTrk->GetEntries()
1329 <<
", nTrkCut " << m_cut1 <<
", cos(theta)_cut " << m_cut2 <<
", drCut " << m_cut3
1330 <<
", dzCut " << m_cut4 <<
", nHitLayer_cut " << m_cut5 <<
", nHit_cut " << m_cut6 << endl;
1344 ofstream feffi(
"MdcLayerEffi.dat");
1345 for(lay=0; lay<m_nlayer; lay++){
1346 double effNtrk = m_effNtrk->GetBinContent(lay+1);
1347 double effGoodHit = m_effNtrkRecHit->GetBinContent(lay+1);
1348 nGoodAll += effGoodHit;
1349 if(lay < 8) nGoodInn += effGoodHit;
1350 else if (lay < 20) nGoodStp += effGoodHit;
1351 else nGoodOut += effGoodHit;
1354 if(lay < 8) nTotInn += effNtrk;
1355 else if (lay < 20) nTotStp += effNtrk;
1356 else nTotOut += effNtrk;
1358 effi = (double)effGoodHit / (
double)effNtrk;
1359 effErr = sqrt(effi * (1-effi) / (
double)effNtrk);
1360 feffi << setw(5) << lay << setw(15) << effi << setw(15) << effErr
1361 << setw(15) << effGoodHit << setw(15) << effNtrk << endl;
1363 double effiAll = (double)nGoodAll / (
double)(nTotAll);
1364 double errAll = sqrt(effiAll * (1-effiAll) / (
double)(nTotAll));
1365 double effiInn = (double)nGoodInn / (
double)(nTotInn);
1366 double errInn = sqrt(effiInn * (1-effiInn) / (
double)(nTotInn));
1367 double effiStp = (double)nGoodStp / (
double)(nTotStp);
1368 double errStp = sqrt(effiStp * (1-effiStp) / (
double)(nTotStp));
1369 double effiOut = (double)nGoodOut / (
double)(nTotOut);
1370 double errOut = sqrt(effiOut * (1-effiOut) / (
double)(nTotOut));
1371 feffi << endl <<
"EffiAll: " << setw(15) << effiAll << setw(15) << errAll
1372 << setw(15) << nGoodAll << setw(15) << nTotAll << endl;
1373 feffi << endl <<
"EffiInn: " << setw(15) << effiInn << setw(15) << errInn
1374 << setw(15) << nGoodInn << setw(15) << nTotInn << endl;
1375 feffi << endl <<
"EffiStp: " << setw(15) << effiStp << setw(15) << errStp
1376 << setw(15) << nGoodStp << setw(15) << nTotStp << endl;
1377 feffi << endl <<
"EffiOut: " << setw(15) << effiOut << setw(15) << errOut
1378 << setw(15) << nGoodOut << setw(15) << nTotOut << endl;
1383 int nHitAll[] = {0, 0};
1384 int nHitInn[] = {0, 0};
1385 int nHitStp[] = {0, 0};
1386 int nHitOut[] = {0, 0};
1387 ofstream feff2(
"MdcHitEffi.dat");
1388 for(lay=0; lay<m_nlayer; lay++){
1389 nHitAll[0] += m_hitNum[lay][0];
1390 nHitAll[1] += m_hitNum[lay][1];
1392 nHitInn[0] += m_hitNum[lay][0];
1393 nHitInn[1] += m_hitNum[lay][1];
1394 }
else if (lay < 20){
1395 nHitStp[0] += m_hitNum[lay][0];
1396 nHitStp[1] += m_hitNum[lay][1];
1398 nHitOut[0] += m_hitNum[lay][0];
1399 nHitOut[1] += m_hitNum[lay][1];
1402 effi = (double)m_hitNum[lay][1] / (
double)m_hitNum[lay][0];
1403 effErr = sqrt(effi * (1-effi) / (
double)m_hitNum[lay][0]);
1404 feff2 << setw(5) << lay << setw(15) << effi << setw(15) << effErr
1405 << setw(15) << m_hitNum[lay][1] << setw(15) << m_hitNum[lay][0] << endl;
1407 effiAll = (double)nHitAll[1] / (
double)nHitAll[0];
1408 errAll = sqrt(effiAll * (1-effiAll)) / (double)nHitAll[0];
1409 effiInn = (double)nHitInn[1] / (
double)nHitInn[0];
1410 errInn = sqrt(effiInn * (1-effiInn)) / (double)nHitInn[0];
1411 effiStp = (double)nHitStp[1] / (
double)nHitStp[0];
1412 errStp = sqrt(effiStp * (1-effiStp)) / (double)nHitStp[0];
1413 effiOut = (double)nHitOut[1] / (
double)nHitOut[0];
1414 errOut = sqrt(effiOut * (1-effiOut)) / (double)nHitOut[0];
1415 feff2 << endl <<
"EffiAll: " << setw(15) << effiAll << setw(15) << errAll
1416 << setw(15) << nHitAll[1] << setw(15) << nHitAll[0] << endl;
1417 feff2 << endl <<
"EffiInn: " << setw(15) << effiInn << setw(15) << errInn
1418 << setw(15) << nHitInn[1] << setw(15) << nHitInn[0] << endl;
1419 feff2 << endl <<
"EffiStp: " << setw(15) << effiStp << setw(15) << errStp
1420 << setw(15) << nHitStp[1] << setw(15) << nHitStp[0] << endl;
1421 feff2 << endl <<
"EffiOut: " << setw(15) << effiOut << setw(15) << errOut
1422 << setw(15) << nHitOut[1] << setw(15) << nHitOut[0] << endl;
1437 ofstream fr2d(
"logr2d.dat");
1438 for(lay=0; lay<m_nlayer; lay++){
1439 for(iEntr=0; iEntr<m_nEntr[lay]; iEntr++){
1440 for(lr=0; lr<2; lr++){
1441 fr2d << setw(3) << lay << setw(3) << iEntr << setw(3) << lr << endl;
1443 key = getHresId(lay, iEntr, lr,
bin);
1444 hid = m_mapr2d[
key];
1447 entry = m_hr2dExc[hid] -> GetEntries();
1449 m_hr2dExc[hid] ->
Fit(
"gaus",
"Q");
1450 sigm[
bin] = m_hr2dExc[hid]->GetFunction(
"gaus")->GetParameter(2);
1451 }
else if(entry > 100){
1452 sigm[
bin] = m_hr2dExc[hid]->GetRMS();
1457 entry = m_hr2dInc[hid] -> GetEntries();
1459 m_hr2dInc[hid] ->
Fit(
"gaus",
"Q");
1460 sigm[
bin] = m_hr2dInc[hid]->GetFunction(
"gaus")->GetParameter(2);
1461 }
else if(entry > 100){
1462 sigm[
bin] = m_hr2dInc[hid]->GetRMS();
1467 if(sigm[
bin] < 0.05) sigm[
bin] = 0.05;
1471 sigm[
bin] = sigm[m_nBin[lay]-1];
1475 if(1 == m_param.
fgCalib[lay]){
1477 if(1 == m_nEntr[lay]){
1478 for(i=0; i<6; i++) calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1479 }
else if(2 == m_nEntr[lay]){
1482 calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1486 calconst -> resetSdpar(lay, i, lr,
bin, sigm[
bin]);
1493 fr2d << setw(5) <<
bin << setw(15) << sigm[
bin] << endl;
1504int MdcCalib::getHresId(
int lay,
int entr,
int lr,
int bin)
const{
1505 int index = ( (lay << HRESLAYER_INDEX) & HRESLAYER_MASK ) |
1506 ( (entr << HRESENTRA_INDEX) & HRESENTRA_MASK ) |
1507 ( (lr << HRESLR_INDEX) & HRESLR_MASK ) |
1508 ( (
bin << HRESBIN_INDEX) & HRESBIN_MASK );
1512int MdcCalib::calDetEffi(){
1514 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
1515 MsgStream log(
msgSvc,
"MdcCalib");
1517 IDataProviderSvc* eventSvc = NULL;
1518 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
1519 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc,
"/Event/Digi/MdcDigiCol");
1521 log << MSG::FATAL <<
"Could not find event" << endreq;
1526 bool hitCel[43][288];
1527 int hitCel2[43][288];
1528 for(lay=0; lay<43; lay++){
1529 for(cel=0; cel<288; cel++){
1530 hitCel[lay][cel] =
false;
1531 hitCel2[lay][cel] = 0;
1535 MdcDigiCol::iterator
iter = mdcDigiCol->begin();
1536 unsigned fgOverFlow;
1539 for(;
iter != mdcDigiCol->end();
iter++, digiId++) {
1541 id = (aDigi)->identify();
1545 fgOverFlow = (aDigi) -> getOverflow();
1550 if ( ((fgOverFlow & 3) !=0 ) || ((fgOverFlow & 12) != 0) ||
1553 hitCel[lay][cel] =
true;
1554 hitCel2[lay][cel] = 1;
1557 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
1559 log << MSG::ERROR <<
"Could not find RecMdcTrackCol" << endreq;
1566 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
1567 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1568 HitRefVec gothits = (*it_trk) -> getVecHits();
1569 HitRefVec::iterator it_hit = gothits.begin();
1570 for(; it_hit != gothits.end(); it_hit++){
1571 identifier = (*it_hit)->getMdcId();
1572 lay = mdcid.
layer(identifier);
1573 cel = mdcid.
wire(identifier);
1574 hitCel2[lay][cel] = 2;
1577 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1578 HepVector helix = (*it_trk)->helix();
1579 HepSymMatrix helixErr = (*it_trk)->err();
1580 double phi0 = (*it_trk)->helix(1);
1581 double phiTrk = phi0 +
HFPI;
1582 if(phiTrk >
PI2) phiTrk -=
PI2;
1584 for(lay=0; lay<43; lay++){
1585 double docamin = 0.9;
1586 if(lay<8) docamin = 0.6;
1588 int ncel = m_mdcGeomSvc->
Layer(lay)->
NCell();
1589 for(cel=0; cel<ncel; cel++){
1591 const MdcGeoWire* pWire = m_mdcGeomSvc -> Wire(lay, cel);
1594 double rr = sqrt( (xx * xx) + (yy * yy) );
1595 if( yy >= 0 ) wphi = acos(xx / rr);
1596 else wphi = CLHEP::twopi - acos(xx / rr);
1598 if( !( (fabs(wphi-phiTrk) < dphi) || (fabs(wphi+
PI2-phiTrk) < dphi) ||
1599 (fabs(wphi-
PI2-phiTrk) < dphi) ) ){
1603 double doca = m_mdcUtilitySvc->
doca(lay, cel, helix, helixErr);
1605 if(fabs(doca) < fabs(docamin)){
1611 int wir = m_mdcGeomSvc -> Wire(lay, celmin) -> Id();
1612 m_hitEffAll->Fill(wir);
1613 m_hitEffAll->Fill(6799);
1614 if(lay<8) m_hitEffAll->Fill(6796);
1615 else if(lay<20) m_hitEffAll->Fill(6797);
1616 else m_hitEffAll->Fill(6798);
1618 if(hitCel[lay][celmin]){
1619 m_hitEffRaw->Fill(wir);
1620 m_hitEffRaw->Fill(6799);
1621 if(lay<8) m_hitEffRaw->Fill(6796);
1622 else if(lay<20) m_hitEffRaw->Fill(6797);
1623 else m_hitEffRaw->Fill(6798);
1625 if(2==hitCel2[lay][celmin]){
1626 m_hitEffRec->Fill(wir);
1627 m_hitEffRec->Fill(6799);
1628 if(lay<8) m_hitEffRec->Fill(6796);
1629 else if(lay<20) m_hitEffRec->Fill(6797);
1630 else m_hitEffRec->Fill(6798);
1710bool MdcCalib::getCellTrkPass(
MdcCalEvent* event,
int iTrk,
int cellTrkPass[]){
1712 int nHits = rectrk -> getNHits();
1714 for(
int k=0; k<nHits; k++){
1718 int wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1722 IDataProviderSvc* eventSvc = NULL;
1723 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
1725 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,
"/Event/Recon/RecMdcTrackCol");
1733 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
1734 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){
1735 int nRecHits = (*it_trk)->getNhits();
1736 if(nRecHits < nHits)
continue;
1738 int hitInRecTrk[100];
1740 HitRefVec gothits = (*it_trk) -> getVecHits();
1741 HitRefVec::iterator it_hit = gothits.begin();
1742 for(; it_hit != gothits.end(); it_hit++){
1743 identifier = (*it_hit)->getMdcId();
1744 int lay = mdcid.
layer(identifier);
1745 int cel = mdcid.
wire(identifier);
1746 int wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
1747 hitInRecTrk[iRecHit] = wir;
1752 bool matchSuccess =
true;
1753 for(
int i=0; i<nHits; i++){
1754 bool findHit =
false;
1755 for(
int k=0; k<nRecHits; k++){
1756 if(hitInTrk[i] == hitInRecTrk[k]){
1762 matchSuccess =
false;
1766 if(!matchSuccess)
continue;
1768 HepVector helix = (*it_trk)->helix();
1769 HepSymMatrix helixErr = (*it_trk)->err();
1770 double phi0 = (*it_trk)->helix(1);
1771 double phiTrk = phi0 +
HFPI;
1772 if(phiTrk >
PI2) phiTrk -=
PI2;
1774 for(
int lay=0; lay<43; lay++){
1775 double docamin = 0.9;
1776 if(lay<8) docamin = 0.6;
1778 int ncel = m_mdcGeomSvc->
Layer(lay)->
NCell();
1779 for(
int cel=0; cel<ncel; cel++){
1781 const MdcGeoWire* pWire = m_mdcGeomSvc -> Wire(lay, cel);
1784 double rr = sqrt( (xx * xx) + (yy * yy) );
1785 if( yy >= 0 ) wphi = acos(xx / rr);
1786 else wphi = CLHEP::twopi - acos(xx / rr);
1788 if( !( (fabs(wphi-phiTrk) < dphi) || (fabs(wphi+
PI2-phiTrk) < dphi) ||
1789 (fabs(wphi-
PI2-phiTrk) < dphi) ) ){
1793 double doca = m_mdcUtilitySvc->
doca(lay, cel, helix, helixErr);
1795 if(fabs(doca) < fabs(docamin)){
1801 cellTrkPass[lay] = celmin;
1803 cellTrkPass[lay] = -1;
const HepLorentzVector p_cms(0.034067, 0.0, 0.0, 3.097)
*******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
double sin(const BesAngle a)
double cos(const BesAngle a)
SmartRefVector< RecMdcHit > HitRefVec
map< int, int >::value_type valType3
std::vector< HepLorentzVector > Vp4
*************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
double resiCut[MdcCalNLayer]
int fgCalib[MdcCalNLayer]
MdcCalRecHit * getRecHit(int index) const
HepLorentzVector getP4() const
double getSdpar(int lay, int entr, int lr, int bin)
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
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)