9 #include "TRSymMatrix.h"
11 #include "Riostream.h"
19 const Int_t NoLayers = 7;
30 const Int_t BL[4] = {8, 12, 16, 20};
38 Double_t STcheb(Int_t N, Double_t *par, Double_t x) {
39 if (N < 0 || N > 12)
return 0;
41 Double_t T1 = 2*x - 1;
43 Double_t Sum = par[0]*T0;
47 for (
int n = 2; n <= N; n++) {
48 T2 = 2*(2*x - 1)*T1 - T0;
58 Double_t DriftCorHack(Int_t barrel, Int_t ladder, Int_t wafer, Double_t u) {
60 Int_t barrel, layer, ladder, wafer, hybrid, Npar;
66 static data_t *pointers[3][16][7][2];
68 N =
sizeof(Data)/
sizeof(
data_t);
69 memset (pointers,0, 3*16*7*2*
sizeof(
data_t *));
73 assert(barrel >= 1 && barrel <= 3);
74 assert(ladder >= 1 && ladder <= 16);
75 assert(wafer >= 1 && wafer <= 7);
76 data_t *p = pointers[barrel-1][ladder-1][wafer-1][h-1];
78 for (Int_t i = 0; i < N; i++) {
79 if (Data[i].barrel == barrel &&
80 Data[i].ladder == ladder &&
81 Data[i].wafer == wafer &&
82 Data[i].hybrid == h) {
84 pointers[barrel-1][ladder-1][wafer-1][h-1] = p;
90 return p ? STcheb(p->Npar, p->param, TMath::Abs(u/3.)) : 0;
94 void TT::Loop(Int_t Nevents) {
258 if (fChain == 0)
return;
267 static Double_t Du[2] = {3.000, 3.65};
268 static Double_t Sv[2] = {6.305, 4.35};
269 const PlotName_t plotNameD[10] = {
270 {
"dutuP",
"<u - uP> versus tuP => dw for Drift", { 0.5, 0.5}},
271 {
"dvtvP",
"<v - vP> versus tvP => dw for Drift", { 2.5, 2.5}},
272 {
"duvP",
"<u - uP> versus v => gamma for Drift", { -2, -2}},
273 {
"dvuP",
"<v - vP> versus u => -gamma for Drift", { -1, -1}},
274 {
"duOvertuPvP",
"<(u - uP)/tuP> versus v => alpha for Drift", { -2, -2}},
275 {
"dvOvertvPvP",
"<(v - vP)/tvP> versus v => alpha for Drift", { -2, -2}},
276 {
"duOvertuPuP",
"<(u - uP)/tuP> versus u => -beta for Drift", { -1, -1}},
277 {
"dvOvertvPuP",
"<(v - vP)/tvP> versus u => -beta for Drift", { -1, -1}},
278 {
"duuH" ,
"<u - uP> versus uHat for Drift", {1.2, -1}},
279 {
"duvH" ,
"<u - uP> versus vHat for Drift", {1.2, -2}}
281 const PlotName_t plotName[37] = {
282 {
"dutuP",
"<u - uP> versus tuP => dw", { 0.5, 0.5}},
283 {
"dvtvP",
"<v - vP> versus tvP => dw", { 2.5, 2.5}},
284 {
"duvP",
"<u - uP> versus vP => gamma", { -2, -2}},
285 {
"dvuP",
"<v - vP> versus -uP => gamma", { -1, -1}},
286 {
"duOvertuPvP",
"<(u - uP)/tuP> versus vP => alpha", { -2, -2}},
287 {
"dvOvertvPvP",
"<(v - vP)/tvP> versus vP => alpha", { -2, -2}},
288 {
"duOvertuPuP",
"<(u - uP)/tuP> versus -uP => beta", { -1, -1}},
289 {
"dvOvertvPuP",
"<(v - vP)/tvP> versus -uP => beta", { -1, -1}},
290 {
"duuP",
"<u - uP> versus -uP", { -1, -1}},
291 {
"dvvP",
"<v - vP> versus vP", { -2, -2}},
292 {
"dXvsX",
"dX versus x" , { 16, 24}},
293 {
"dXvsY",
"dX versus y => gamma", { 16, 24}},
294 {
"dXvsZ",
"dX versus -z => beta", { 24.,36}},
295 {
"dYvsX",
"dY versus -x => gamma", { 16, 24}},
296 {
"dYvsY",
"dY versus y" , { 16, 24}},
297 {
"dYvsZ",
"dY versus z => alpha", { 24.,36}},
298 {
"dZvsX",
"dZ versus x => beta", { 16, 24}},
299 {
"dZvsY",
"dZ versus -y => alpha", { 16, 24}},
300 {
"dZvsZ",
"dZ versus z", { 24.,36}},
302 {
"dX4dx",
"dX vs -1+jx*vx => dx", {2.2,2.2}},
303 {
"dX4dy",
"dX vs jx*vy => dy", { 1, 1}},
304 {
"dX4dz",
"dX vs jx*vz => dz", {.01,.01}},
305 {
"dX4da",
"dX vs jx*(-vy*z+vz*y)=> alpha", {20,20}},
306 {
"dX4db",
"dX vs -z+jx*(vx*z-vz*x)=> beta ", {40,40}},
307 {
"dX4dg",
"dX vs y+jx*(-vx*y+vy*x)=> alpha", {25,25}},
309 {
"dY4dx",
"dY vs jy*vx => dx", { 1, 1}},
310 {
"dY4dy",
"dY vs -1+jy*vy => dy", {2.2,2.2}},
311 {
"dY4dz",
"dY vs jy*vz => dz", {.01,.01}},
312 {
"dY4da",
"dY vs z+jy*(-vy*z+vz*y)=> alpha", {35,35}},
313 {
"dY4db",
"dY vs jy*(vx*z-vz*x)=> beta ", {20,20}},
314 {
"dY4dg",
"dY vs -x+jy*(-vx*y+vy*x)=> gamma", {25,25}},
316 {
"dZ4dx",
"dZ vs jz*vx => dx", {2.2,2.2}},
317 {
"dZ4dy",
"dZ vs jz*vy => dy", {2.2,2.2}},
318 {
"dZ4dz",
"dZ vs -1+jz*vz => dz", {2.2,2.2}},
319 {
"dZ4da",
"dZ vs -y+jz*(-vy*z+vz*y)=> alpha", {80,80}},
320 {
"dZ4db",
"dZ vs x+jz*( vx*z-vy*x)=> beta ", {80,80}},
321 {
"dZ4dg",
"dZ vs jz*(-vx*y+vy*x)=> gamma", {10,10}},
325 const Int_t ssdSector[20] = {
327 203, 204, 205, 206, 207, 208, 209,
329 413, 414, 415, 416, 417, 418, 419,
332 TFile *fOut =
new TFile(fOutFileName,
"recreate");
334 TH1D *LSF =
new TH1D(
"LSF",
"Matrix and right part for Least Squred Fit",6*28,0,6*28);
336 for (Int_t barrel = 1; barrel <= 4; barrel++)
337 LSFB[barrel-1] =
new TH1D(Form(
"LSFB%i",barrel),
338 Form(
"Matrix and right part for Least Squred Fit for barrel %i",barrel),
339 BL[barrel-1]*28,0,BL[barrel-1]*28);
341 TH2F *LocPlots[10][4][20][17];
342 memset(LocPlots,0,10*4*20*17*
sizeof(TH2F *));
345 for (Int_t L = 0; L < NoLayers; L++) {
346 Int_t barrel = SvtSsdConfig[L].Barrel;
347 Int_t layer = SvtSsdConfig[L].Layer;
348 Int_t NoLadders = SvtSsdConfig[L].NoLadders;
349 Int_t NoWafers = SvtSsdConfig[L].NoWafers;
351 for (Int_t ladder = 1; ladder <= NoLadders; ladder++) {
352 if (barrel <= 3 && (ladder-1)%2 != layer%2)
continue;
353 for (Int_t wafer = 0; wafer <= NoWafers; wafer++) {
354 Int_t Id = ladder + 100*(wafer + 10*layer);
355 for (Int_t t = 0; t < 10; t++) {
356 if (NoWafers > 2 && wafer != 0) {
357 Name = Form(
"%s%04i",plotNameD[t].Name,Id);
358 Title = Form(
"%s for barrel %i, layer %i ladder %i, ",plotNameD[t].Title,barrel,layer,ladder);
360 Name = Form(
"%s%04i",plotNameD[t].Name,Id);
361 Title = Form(
"%s for barrel %i, layer %i ladder %i, ",plotNameD[t].Title,barrel,layer,ladder);
364 if (wafer == 0) Title +=
"all wafers";
365 else Title += Form(
"wafer %i",wafer);
367 Title +=
"all wafers";
368 if (wafer == 1) Title +=
" Positive";
369 if (wafer == 2) Title +=
" Negative";
373 if (barrel > 3) k = 1;
374 Double_t xmax = plotNameD[t].xmax[k];
376 cout << plotNameD[t].Name <<
"/" << plotNameD[t].Title
377 <<
"\txmax " << plotNameD[t].xmax[0] <<
"\t" << plotNameD[t].xmax[1]
378 <<
"\txmax = " << xmax << endl;
380 if (xmax > 0 && t >= 8 && ! (NoWafers > 2 && wafer != 0)) xmax = -1;
382 Int_t m = - (Int_t) xmax;
383 if (m == 1) xmax = Du[k];
384 else xmax = Sv[k]/2.;
386 if ((wafer == 0 || ! AllWafers) && (t == 2 || t == 4 || t == 5 || t == 9)) {
388 case 1: xmax = 12;
break;
389 case 2: xmax = 18;
break;
390 case 3: xmax = 21;
break;
392 case 4: xmax = 35;
break;
393 default: xmax = 40;
break;
396 n = (Int_t) (4*xmax);
398 Double_t ymax = rCut/2;
400 Double_t dy = ymax/ny;
402 LocPlots[t][barrel-1][ladder-1][wafer] =
new TH2F(Name,Title,n,-xmax,xmax,ny+1,-ymax-dy,ymax+dy);
408 TH2F *GloPlots[27][6];
409 memset(GloPlots,0,27*6*
sizeof(TH2F *));
410 for (Int_t s = 0; s < 6; s++) {
411 for (Int_t i = 0; i < 27; i++) {
413 Name = Form(
"%s%i",plotName[t].Name,s);
415 Title = Form(
"%s for SVT Clam shell %i",plotName[t].Title,s);
417 Title = Form(
"%s for SSD Sector %i",plotName[t].Title,s-1);
420 Double_t xmax = plotName[t].xmax[m];
421 Int_t n = (Int_t) (4.*xmax);
422 if (n < 100) n = 100;
423 Double_t ymax = rCut;
424 GloPlots[i][s] =
new TH2F(Name,Title, n,-xmax,xmax,500,-ymax,ymax);
428 TH2F *GloBLPlots[27][4][20];
429 memset(GloBLPlots,0,27*4*20*
sizeof(TH2F *));
430 if (LaddersInGlobal) {
431 for (Int_t barrel = 0; barrel < 4; barrel++) {
432 for (Int_t ladder = 0; ladder < BL[barrel]; ladder++) {
433 for (Int_t i = 0; i < 27; i++) {
435 Name = Form(
"%sB%iL%02i",plotName[t].Name,barrel+1,ladder+1);
436 Title = Form(
"%s for barrel %i ladder %02i",plotName[t].Title,barrel+1,ladder+1);
438 if (barrel > 3) m = 1;
439 Double_t xmax = plotName[t].xmax[m];
440 Int_t n = (Int_t) (4.*xmax);
441 if (n < 100) n = 100;
442 Double_t ymax = 2.50;
443 GloBLPlots[i][barrel][ladder] =
new TH2F(Name,Title, n,-xmax,xmax,500,-ymax,ymax);
448 Long64_t nentries = fChain->GetEntriesFast();
449 if (Nevents > 0 && nentries > Nevents) nentries = Nevents;
450 Long64_t nbytes = 0, nb = 0;
452 TString currentFile(
"");
453 for (Long64_t jentry=0; jentry<nentries;jentry++) {
454 Long64_t ientry = LoadTree(jentry);
455 if (ientry < 0)
break;
456 nb = fChain->GetEntry(jentry); nbytes += nb;
457 if (! jentry%1000 || TreeNo != fChain->GetTreeNumber()) {
458 if (jentry > 0) fOut->Flush();
459 cout <<
"Read event \t" << jentry
460 <<
" so far. switch to file " << fChain->GetCurrentFile()->GetName() << endl;
461 TreeNo = fChain->GetTreeNumber();
463 if (VertexZCut > 0 && TMath::Abs(fVertex[2]) > VertexZCut)
continue;
464 UInt_t Ntrack = fNPTracks;
465 Int_t run = fEvtHdr_fRun;
466 for (UInt_t trk = 0; trk < Ntrack; trk++) {
467 Int_t Npoints = fTracks_fNpoint[trk];
468 if (minNoFitPoints > 0 && Npoints%100 < minNoFitPoints)
continue;
469 if (UseSsd && Npoints < 1000)
continue;
470 if (UseSvt && Npoints < 100)
continue;
471 if (TpcLengthCut > 0 && fTracks_fLength[trk] < TpcLengthCut)
continue;
472 if (dEdxCut > 0 && (fTracks_fdEdx[trk] <= 1e-7 || fTracks_fdEdx[trk] > dEdxCut))
continue;
474 if (TMath::Abs(fTracks_fTanL[trk]) > 3)
continue;
476 Double_t zTPC = fVertex[2] + 60*fTracks_fTanL[trk];
478 if (EastWest > 2) zCut = 60.*TMath::SinH(0.5);
479 if (EastWest%2 == 1 && ! (zTPC < -zCut || fTracks_fTanL[trk] < 0))
continue;
480 if (EastWest%2 == 0 && ! (zTPC > zCut || fTracks_fTanL[trk] > 0))
continue;
482 Int_t Nsp = fTracks_fNsp[trk];
485 Int_t k = fTracks_fIdHitT[trk][
hit]-1;
487 Int_t barrel = fHits_barrel[k];
488 Int_t layer = fHits_layer[k];
489 Int_t ladder = fHits_ladder[k];
490 Int_t wafer = fHits_wafer[k];
491 Int_t hybrid = fHits_hybrid[k];
492 Double32_t anode = fHits_anode[k];
494 if (fHits_isTrack[k])
continue;
495 if (layer < 7 && fHits_hitFlag[k] > 3)
continue;
498 if (layer < 7 && IsNotValidHybrid(barrel,ladder,wafer,hybrid,run,anode))
continue;
501 if (ladder > SvtSsdConfig[layer-1].NoLadders/2) sector = 1;
502 }
else {sector = ssdSector[ladder-1]/100 + 1; barrel = 4;}
503 if (sector < 0 || sector > 5) {
504 cout <<
"Sector " << sector;
505 cout <<
" for barrel " << barrel
506 <<
", ladder " << ladder
507 <<
",wafer " << wafer <<
"\t";
508 cout <<
"is not been defined" << endl;
511 if (! GloPlots[0][sector]) {
512 cout <<
"GloPlots[0][" << sector <<
"]";
513 cout <<
" for barrel " << barrel
514 <<
", ladder " << ladder
515 <<
",wafer " << wafer <<
"\t";
516 cout <<
"is not been defined" << endl;
519 if (LaddersInGlobal && ! GloBLPlots[0][barrel-1][ladder-1]) {
520 cout <<
"GloBLPlots[0][" << sector <<
"]";
521 cout <<
" for barrel " << barrel
522 <<
", ladder " << ladder
523 <<
",wafer " << wafer <<
"\t";
524 cout <<
"is not been defined" << endl;
528 if (! LocPlots[0][barrel-1][ladder-1][wafer]) {
530 cout <<
" for barrel " << barrel
531 <<
", ladder " << ladder
532 <<
",wafer " << wafer <<
"\t";
533 cout <<
"is not been defined" << endl;
537 if (DipCut > 0 && TMath::Abs(fHits_pT[k]) < DipCut*fHits_pMom[k])
continue;
539 Double32_t xPG = fHits_xPG[k];
540 Double32_t zPG = fHits_zPG[k];
541 Double32_t yPG = fHits_yPG[k];
542 Double32_t uP = fHits_uP[k];
543 Double32_t vP = fHits_vP[k];
544 Double32_t tuP = fHits_tuP[k];
545 Double32_t tvP = fHits_tvP[k];
546 Double32_t xPL = fHits_xPL[k];
547 Double32_t zPL = fHits_zPL[k];
548 Double_t dxP = fHits_cxPG[k];
549 Double_t dyP = fHits_cyPG[k];
550 Double_t dzP = fHits_czPG[k];
551 #ifdef __USE_GLOBAL__
553 xPG = fHits_xPGlG[k];
554 zPG = fHits_zPGlG[k];
555 yPG = fHits_yPGlG[k];
558 tuP = fHits_tuPGl[k];
559 tvP = fHits_tvPGl[k];
560 xPL = fHits_xPGlL[k];
561 zPL = fHits_zPGlL[k];
562 dxP = fHits_cxPGlG[k];
563 dyP = fHits_cyPGlG[k];
564 dzP = fHits_czPGlG[k];
567 Double32_t xG = fHits_xG[k];
568 Double32_t yG = fHits_yG[k];
569 Double32_t zG = fHits_zG[k];
570 Double32_t dX = xG - xPG;
571 Double32_t dY = yG - yPG;
572 Double32_t dZ = zG - zPG;
573 Double32_t u = fHits_u[k];
574 Double32_t v = fHits_v[k];
575 Double32_t uHat = fHits_uHat[k];
576 if (hybrid == 1) uHat -= 0.1;
577 if (hybrid == 2) uHat += 0.1;
579 Double32_t vHat = 1. - anode/240.;
580 if (hybrid == 1) vHat = - vHat;
581 if (hybrid == 1) vHat -= 0.1;
582 if (hybrid == 2) vHat += 0.1;
583 Double32_t zL = fHits_zL[k];
584 if (barrel <= 3) {zPL -= 23.5250; zL -= 23.5250;}
585 Double32_t xL = fHits_xL[k];
586 Double_t DxL = xL - xPL;
588 Double32_t yL = fHits_yL[k];
589 Double32_t yPL = fHits_yPL[k];
590 Double_t DyL = yL - yPL;
592 Double_t DzL = zL - zPL;
593 Double32_t du = u - uP;
595 if (barrel <= 3) du -= DriftCorHack(barrel, ladder, wafer, u);
597 Double32_t dv = v - vP;
598 if (TMath::Abs(fHits_pT[k]) < 0.2)
continue;
600 if (TMath::Abs(du) > rCut || TMath::Abs(dv) > rCut)
continue;
602 if (barrel > 3) m = 1;
603 if (TMath::Abs(xPG) > plotName[10].xmax[m] ||
604 TMath::Abs(yPG) > plotName[11].xmax[m] ||
605 TMath::Abs(zPG) > plotName[12].xmax[m])
continue;
606 if (TMath::Abs(uP) > Du[m] || TMath::Abs(vP) > Sv[m]/2)
continue;
607 Double_t uA = TMath::Abs(u);
608 Double_t vA = TMath::Abs(v);
610 if (uMax > 0 && uA > uMax)
continue;
611 if (uMin > 0 && uA < uMin)
continue;
612 if (vMax > 0 && vA > vMax)
continue;
613 if (vMin > 0 && vA < vMin)
continue;
618 Double_t jL2 = TMath::Sqrt(1. + tuP*tuP + tvP*tvP);
619 Double_t wG[3] = {fHits_wGu[k],fHits_wGv[k], fHits_wGw[k]};
620 Double_t vx = fHits_wGu[k]*jL2;
621 Double_t vy = fHits_wGv[k]*jL2;
622 Double_t vz = fHits_wGw[k]*jL2;
623 Double_t vars[27][2] = {
636 {dX, ( dxP*(-vy*z+vz*y))},
637 {dX, (-z+dxP*( vx*z-vz*x))},
638 {dX, ( y+dxP*(-vx*y+vy*x))},
642 {dY, ( z+dyP*(-vy*z+vz*y))},
643 {dY, ( dyP*( vx*z-vz*x))},
644 {dY, (-x+dyP*(-vx*y+vy*x))},
648 {dZ, (-y+dzP*(-vy*z+vz*y))},
649 {dZ, ( x+dzP*( vx*z-vz*x))},
650 {dZ, ( dzP*(-vx*y+vy*x))}
652 for (Int_t l = 0; l < 9; l++) {
653 GloPlots[l][sector]->Fill(vars[l][1],vars[l][0]);
655 GloBLPlots[l][barrel-1][ladder-1]->Fill(vars[l][1],vars[l][0]);
657 Double_t vxyz[3] = {vx, vy, vz};
659 Double_t dxyzP[3] = {dxP, dyP, dzP};
661 static TRMatrix UR(TRArray::kUnit,3);
665 1. , 0., 0., 0., z,-y,
666 0., 1., 0., -z, 0., x,
667 0., 0., 1., y, -x, 0.);
669 Double_t dxyz[3] = {dX, dY, dZ};
672 for (UInt_t l = 0; l < 3; l++) {
673 if (l == 0 && TMath::Abs(wG[0]) >= 0.999 ||
674 l == 1 && TMath::Abs(wG[1]) >= 0.999)
continue;
676 A.AddRow(ABR.GetRow(l));
677 for (UInt_t k = 0; k < 6; k++) {
678 UInt_t lk = k + 6*l + 9;
679 GloPlots[lk][sector]->Fill(ABR(l,k),dxyz[l]);
681 GloBLPlots[lk][barrel-1][ladder-1]->Fill(ABR(l,k),dxyz[l]);
683 if (TMath::Abs(vars[l][0]) < 1.e-3 || TMath::Abs(vars[l][1]) < 1.e-3) {
684 cout <<
"l\t" << l <<
"\tdX/dY/dZ = " << dX <<
"\t" << dY <<
"\t" << dZ << endl;
685 cout <<
"x/y/z(PG) = " << x <<
"\t" << y <<
"\t" << z << endl;
686 cout <<
"x/y/z( G) = " << xG <<
"\t" << yG <<
"\t" << zG << endl;
687 cout <<
"dirXYZ = " << dxP <<
"\t" << dyP <<
"\t" << dzP << endl;
688 cout <<
"v xyz = " << vx <<
"\t" << vy <<
"\t" << vz << endl;
695 Double_t *array = LSF->GetArray();
696 Double_t *amX = AmX.GetArray();
697 Double_t *sX = SX.GetArray();
698 Int_t im = 1 + 28*sector;
700 TCL::vadd(amX,array+im,array+im,6);
701 TCL::vadd(sX,array+is,array+is,21);
705 -1., 0., tuP, tuP*vP, -tuP*uP, vP,
706 0., -1., tvP, tvP*vP, -tvP*uP, -uP);
709 array = LSFB[barrel-1]->GetArray();
712 im = 1 + 28*(ladder-1);
714 TCL::vadd(amX,array+im,array+im,6);
715 TCL::vadd(sX,array+is,array+is,21);
718 Double32_t duOvertuP = du/tuP;
719 Double32_t dvOvertvP = dv/tvP;
723 LocPlots[0][barrel-1][ladder-1][wafer]->Fill(tuP,du);
724 LocPlots[1][barrel-1][ladder-1][wafer]->Fill(tvP,dv);
725 LocPlots[2][barrel-1][ladder-1][wafer]->Fill( vP,du);
726 LocPlots[3][barrel-1][ladder-1][wafer]->Fill(-uP,dv);
727 LocPlots[4][barrel-1][ladder-1][wafer]->Fill( vP,duOvertuP);
728 LocPlots[5][barrel-1][ladder-1][wafer]->Fill( vP,dvOvertvP);
729 LocPlots[6][barrel-1][ladder-1][wafer]->Fill(-uP,duOvertuP);
730 LocPlots[7][barrel-1][ladder-1][wafer]->Fill(-uP,dvOvertvP);
731 LocPlots[8][barrel-1][ladder-1][wafer]->Fill(-uP,du);
732 LocPlots[9][barrel-1][ladder-1][wafer]->Fill( vP,dv);
734 LocPlots[0][barrel-1][ladder-1][wafer]->Fill(tuP,du);
735 LocPlots[1][barrel-1][ladder-1][wafer]->Fill(tvP,dv);
736 LocPlots[2][barrel-1][ladder-1][wafer]->Fill( v ,du);
737 LocPlots[3][barrel-1][ladder-1][wafer]->Fill( u ,dv);
738 LocPlots[4][barrel-1][ladder-1][wafer]->Fill( v ,duOvertuP);
739 LocPlots[5][barrel-1][ladder-1][wafer]->Fill( v ,dvOvertvP);
740 LocPlots[6][barrel-1][ladder-1][wafer]->Fill( u ,duOvertuP);
741 LocPlots[7][barrel-1][ladder-1][wafer]->Fill( u ,dvOvertvP);
742 LocPlots[8][barrel-1][ladder-1][wafer]->Fill( uHat ,du);
743 LocPlots[9][barrel-1][ladder-1][wafer]->Fill( vHat ,du);
747 if (fHits_pT[k] < 0) wafer = 2;
748 LocPlots[0][barrel-1][ladder-1][wafer]->Fill(tuP,du);
749 LocPlots[1][barrel-1][ladder-1][wafer]->Fill(tvP,dv);
750 LocPlots[2][barrel-1][ladder-1][wafer]->Fill( zPL,du);
751 LocPlots[3][barrel-1][ladder-1][wafer]->Fill(-uP,dv);
752 LocPlots[4][barrel-1][ladder-1][wafer]->Fill( zPL,duOvertuP);
753 LocPlots[5][barrel-1][ladder-1][wafer]->Fill( zPL,dvOvertvP);
754 LocPlots[6][barrel-1][ladder-1][wafer]->Fill(-uP,duOvertuP);
755 LocPlots[7][barrel-1][ladder-1][wafer]->Fill(-uP,dvOvertvP);
756 LocPlots[8][barrel-1][ladder-1][wafer]->Fill(-uP,du);
757 LocPlots[9][barrel-1][ladder-1][wafer]->Fill( zPL,dv);
762 Double32_t DxLOvertuP = DxL/tuP;
763 Double32_t DzLOvertvP = DzL/tvP;
764 LocPlots[0][barrel-1][ladder-1][wafer]->Fill(tuP,DxL);
765 LocPlots[1][barrel-1][ladder-1][wafer]->Fill(tvP,DzL);
766 LocPlots[2][barrel-1][ladder-1][wafer]->Fill( zPL,DxL);
767 LocPlots[3][barrel-1][ladder-1][wafer]->Fill(-xPL,DzL);
768 LocPlots[4][barrel-1][ladder-1][wafer]->Fill( zPL,DxLOvertuP);
769 LocPlots[5][barrel-1][ladder-1][wafer]->Fill( zPL,DzLOvertvP);
770 LocPlots[6][barrel-1][ladder-1][wafer]->Fill(-xPL,DxLOvertuP);
771 LocPlots[7][barrel-1][ladder-1][wafer]->Fill(-xPL,DzLOvertvP);
772 LocPlots[8][barrel-1][ladder-1][wafer]->Fill(-xPL,DxL);
773 LocPlots[9][barrel-1][ladder-1][wafer]->Fill( zPL,DzL);
779 for (Int_t s = 0; s < 6; s++) {
780 Double_t *array = LSF->GetArray();
783 cout <<
"sector " << s <<
"================================" << endl;
784 TRVector AmX(6,array+im); cout <<
"AmX " << AmX << endl;
785 TRSymMatrix S(6,array+is); cout <<
"S " << S << endl;
786 TRSymMatrix SInv(S,TRArray::kInverted); cout <<
"SInv " << SInv << endl;
787 TRVector X(SInv,TRArray::kSxA,AmX); cout <<
"X " << X << endl;
797 for (Int_t barrel = 1; barrel <= 4; barrel++) {
798 for (Int_t ladder = 1; ladder <= 20; ladder++) {
799 for (Int_t wafer = 1; wafer <= 16; wafer++) {
800 for (Int_t hybrid = 1; hybrid <= 2; hybrid++) {
801 HybridFit_t *fit = HFit[barrel-1][ladder-1][wafer-1][hybrid-1];
803 if (fit->noentries < 100)
continue;
804 cout <<
"B/L/W/H\t" << barrel <<
"/" << ladder <<
"/" << wafer <<
"/" << hybrid << endl;
805 cout <<
"AmX " << fit->AmX << endl;
806 cout <<
"S " << fit->S << endl;
807 TRSymMatrix SInv(fit->S,TRArray::kInverted); cout <<
"SInv " << SInv << endl;
808 TRVector X(SInv,TRArray::kSxA,fit->AmX); cout <<
"X " << X << endl;
809 for (Int_t i = 0; i < 6; i++) {
810 cout << X(i) <<
" +/- " << TMath::Sqrt(SInv(i,i)) << endl;
819 if (fChain == 0)
return;
821 Long64_t nentries = fChain->GetEntriesFast();
822 Long64_t nbytes = 0, nb = 0;
824 TString currentFile(
"");
828 for (Long64_t jentry=0; jentry<nentries;jentry++) {
829 Long64_t ientry = LoadTree(jentry);
830 if (ientry < 0)
break;
831 nb = fChain->GetEntry(jentry); nbytes += nb;
832 if (! jentry%1000 || TreeNo != fChain->GetTreeNumber()) {
833 cout <<
"Read event \t" << jentry
834 <<
" so far. switch to file " << fChain->GetCurrentFile()->GetName() << endl;
835 if (TreeNo > -1) FillNt(HFit);
836 TreeNo = fChain->GetTreeNumber();
838 if (VertexZCut > 0 && TMath::Abs(fVertex[2]) > VertexZCut)
continue;
839 UInt_t Ntrack = fNPTracks;
840 for (UInt_t trk = 0; trk < Ntrack; trk++) {
841 Int_t Npoints = fTracks_fNpoint[trk];
842 if (minNoFitPoints > 0 && Npoints%100 < minNoFitPoints)
continue;
843 if (UseSsd && Npoints < 1000)
continue;
844 if (UseSvt && Npoints < 100)
continue;
845 Int_t Nsp = fTracks_fNsp[trk];
848 Int_t k = fTracks_fIdHitT[trk][
hit];
850 Int_t barrel = fHits_barrel[k];
851 Int_t layer = fHits_layer[k];
852 if (layer < 7 && fHits_hitFlag[k] > 3)
continue;
853 Int_t ladder = fHits_ladder[k];
854 Int_t wafer = fHits_wafer[k];
855 Int_t hybrid = fHits_hybrid[k];
856 Double32_t u = fHits_u[k];
857 Double32_t v = fHits_v[k];
858 Double32_t uP = fHits_uP[k];
859 Double32_t vP = fHits_vP[k];
860 Double32_t du = u - uP;
861 Double32_t dv = v - vP;
862 if (TMath::Abs(fHits_pT[k]) < 0.2)
continue;
864 if (TMath::Abs(du) > rCut || TMath::Abs(dv) > rCut)
continue;
865 Double_t uA = TMath::Abs(u);
866 Double_t vA = TMath::Abs(v);
868 if (uMax > 0 && uA > uMax)
continue;
869 if (uMin > 0 && uA < uMin)
continue;
870 if (vMax > 0 && vA > vMax)
continue;
871 if (vMin > 0 && vA < vMin)
continue;
873 HybridFit_t *fit = HFit[barrel-1][ladder-1][wafer-1][hybrid-1];
875 HFit[barrel-1][ladder-1][wafer-1][hybrid-1] = fit =
new HybridFit_t();
886 fit->AmX +=
TRVector(A,TRArray::kATxB,duv);
898 void TT::Loop4BadAnodes(Int_t Nevents) {
904 TFile *fOut =
new TFile(fOutFileName,
"recreate");
905 TH1F *hists[B][L][W][H];
906 memset(hists, 0, B*L*W*H*
sizeof(TH1F *));
907 for (Int_t barrel = 1; barrel <= B; barrel++) {
908 Int_t nl = SvtSsdConfig[2*barrel-1].NoLadders;
909 Int_t nw = SvtSsdConfig[2*barrel-1].NoWafers;
910 for (Int_t ladder = 1; ladder <= nl; ladder++)
911 for (Int_t wafer = 1; wafer <= nw; wafer++)
912 for (Int_t hybrid = 1; hybrid <= H; hybrid++) {
913 hists[barrel-1][ladder-1][wafer-1][hybrid-1] =
914 new TH1F(Form(
"B%iL%02iW%iH%i",barrel,ladder,wafer,hybrid),
915 Form(
"Anode for Barrel %i Ladder %i, Wafer %i Hybrid %i",
916 barrel,ladder,wafer,hybrid),
920 Long64_t nentries = fChain->GetEntriesFast();
921 if (Nevents > 0 && nentries > Nevents) nentries = Nevents;
922 Long64_t nbytes = 0, nb = 0;
924 TString currentFile(
"");
925 for (Long64_t jentry=0; jentry<nentries;jentry++) {
926 Long64_t ientry = LoadTree(jentry);
927 if (ientry < 0)
break;
928 nb = fChain->GetEntry(jentry); nbytes += nb;
929 if (! jentry%1000 || TreeNo != fChain->GetTreeNumber()) {
930 if (jentry > 0) fOut->Flush();
931 cout <<
"Read event \t" << jentry
932 <<
" so far. switch to file " << fChain->GetCurrentFile()->GetName() << endl;
933 TreeNo = fChain->GetTreeNumber();
935 for (UInt_t k = 0; k < fNhit; k++) {
936 Int_t barrel = fHits_barrel[k];
937 if (barrel < 1 || barrel > 3)
continue;
938 Int_t ladder = fHits_ladder[k];
939 Int_t wafer = fHits_wafer[k];
940 Int_t hybrid = fHits_hybrid[k];
941 TH1F *hist = hists[barrel-1][ladder-1][wafer-1][hybrid-1];
942 if (! hist)
continue;
943 Double32_t anode = fHits_anode[k];
951 void T::LoopTB(Int_t Nevents) {
964 const PlotName_t plotNameTB =
965 {
"timeB",
"time for 80 anodes", 128, 3, 0,128, 0,3, 0,0 };
967 TFile *fOut =
new TFile(fOutFileName,
"recreate");
976 TH1F *LocPlots[NB][NL][NW][NH][NA];
977 TH1F * LocAll =
new TH1F(
"All",
"all", plotNameTB.nx, plotNameTB.xmin, plotNameTB.xmax);
978 TH1F * uAll =
new TH1F(
"Uall",
"ua", 200, -5., 5.);
979 TH1F * uCut =
new TH1F(
"Ucut",
"uc", 200, -3., 3.);
980 TH1F * vCut =
new TH1F(
"Vcut",
"vc", 200, -3., 3.);
981 memset(LocPlots,0,NB*NL*NW*NH*
sizeof(TH2F *));
982 for (Int_t L = 0; L < 6; L++) {
983 Int_t barrel = SvtSsdConfig[L].Barrel;
984 Int_t layer = SvtSsdConfig[L].Layer;
985 Int_t NoLadders = SvtSsdConfig[L].NoLadders;
986 Int_t NoWafers = SvtSsdConfig[L].NoWafers;
987 for (Int_t ladder = 1; ladder <= NoLadders; ladder++) {
988 if (barrel <= 3 && (ladder-1)%2 != layer%2)
continue;
989 for (Int_t wafer = 1; wafer <= NoWafers; wafer++) {
990 for (Int_t hybrid = 1; hybrid <= 2; hybrid++) {
991 for (Int_t anode =1; anode <=3; anode++) {
992 Name = plotNameTB.Name;
993 Name += Form(
"L%02iB%iW%02iH%iA%i", ladder, barrel, wafer, hybrid, anode);
994 Title = Form(
"%s for layer %i B %i L %i W %i H %i G %i",
995 plotNameTB.Title, layer, barrel, ladder, wafer, hybrid, anode);
996 LocPlots[barrel-1][ladder-1][wafer-1][hybrid-1][anode-1] =
997 new TH1F(Name, Title, plotNameTB.nx, plotNameTB.xmin, plotNameTB.xmax );
1003 Long64_t nentries = fChain->GetEntriesFast();
1004 if (Nevents > 0 && nentries > Nevents) nentries = Nevents;
1005 Long64_t nbytes = 0, nb = 0;
1007 TString currentFile(
"");
1009 for (Long64_t jentry=0; jentry<nentries;jentry++) {
1010 Long64_t ientry = LoadTree(jentry);
1011 if (ientry < 0)
break;
1012 nb = fChain->GetEntry(jentry); nbytes += nb;
1013 if (! jentry%1000 || TreeNo != fChain->GetTreeNumber()) {
1014 cout <<
"Read event \t" << jentry
1015 <<
" so far, switch to file " << fChain->GetCurrentFile()->GetName() << endl;
1016 TreeNo = fChain->GetTreeNumber();
1019 UInt_t Ntrack = fNPTracks;
1020 for (UInt_t trk = 0; trk < Ntrack; trk++) {
1021 Int_t Npoints = fTracks_fNpoint[trk];
1022 if (minNoFitPoints > 0 && Npoints%100 < minNoFitPoints)
continue;
1023 if (UseSsd && Npoints < 1000)
continue;
1024 if (UseSvt && Npoints < 100)
continue;
1025 Int_t Nsp = fTracks_fNsp[trk];
1027 Int_t k = fTracks_fIdHitT[trk][
hit] - 1;
1029 Int_t barrel = fHits_barrel[k];
1030 Int_t layer = fHits_layer[k];
1031 Int_t ladder = fHits_ladder[k];
1032 Int_t wafer = fHits_wafer[k];
1033 Int_t hybrid = fHits_hybrid[k];
1036 Double32_t u = fHits_u[k];
1037 Double32_t v = fHits_v[k];
1038 Double32_t uP = fHits_uP[k];
1039 Double32_t vP = fHits_vP[k];
1040 Double32_t du = u - uP;
1041 Double32_t dv = v - vP;
1042 if (TMath::Abs(fHits_pT[k]) < 0.2)
continue;
1044 if (TMath::Abs(du) > rCut )
continue;
1046 if (TMath::Abs(dv) > rCut)
continue;
1047 Double32_t anode = fHits_anode[k];
1048 Double32_t timeb = fHits_timeb[k];
1049 Int_t group = ((Int_t)anode)/80;
1050 if (group >= 3) group = 2;
1051 if (group < 0) group = 0;
1052 LocPlots[barrel-1][ladder-1][wafer-1][hybrid-1][group]->Fill( timeb );
1053 LocAll->Fill( timeb );
1064 Int_t TT::IsNotValidHybrid(Int_t barrel, Int_t ladder, Int_t wafer, Int_t hybrid, Int_t run, Double_t anode) {
1066 if (anode <= 10 || anode >= 230) {iok = 1;
goto ENDL;}
1068 #if !defined(__CINT__)
1073 Double_t mu0, sigma0;
1074 Double_t mu1, sigma1;
1075 Double_t mu2, sigma2;
1076 Double_t mu3, sigma3;
1077 Double_t mu4, sigma4;
1078 Double_t mu5, sigma5;
1079 Double_t mu6, sigma6;
1080 Double_t mu7, sigma7;
1081 Double_t mu8, sigma8;
1082 Double_t mu9, sigma9;
1084 static const Hybrids_t Hybrids[] = {
1086 static const UInt_t NoHybrids =
sizeof(Hybrids)/
sizeof(Hybrids_t);
1087 static TString oldHybrid(
"");
1088 static TString oldRun(
"");
1089 static Bool_t InitDone = kFALSE;
1090 static const Int_t NB = 3;
1091 static const Int_t NL =12;
1092 static const Int_t NW = 7;
1093 static const Int_t NH = 2;
1094 static const Int_t ND = 3;
1095 static Hybrids_t *ptr[NB][NL][NW][NH][ND];
1098 memset(ptr, 0, NB*NL*NW*NH*ND*
sizeof(Hybrids_t *));
1099 Int_t b, l, w, h, d, day;
1100 for (UInt_t k = 0; k < NoHybrids; k++) {
1101 sscanf(&Hybrids[k].hybrid[0],
"B%iL%02iW%iH%i",&b,&l,&w,&h);
1102 if (b > 0 && b <= NB && l > 0 && l <= NL && w > 0 && w <= NW && h > 0 && h <= NH) {
1103 sscanf(&Hybrids[k].run[0],
"0%2iD",&day);
1105 if (day == 49) d = 1;
1106 if (day == 69) d = 2;
1107 ptr[b-1][l-1][w-1][h-1][d-1] = (Hybrids_t *) &Hybrids[k];
1111 Int_t day = (run/1000)%1000;
1115 Double_t *peaks = 0;
1116 if (day == 49) d = 1;
1117 if (day == 69) d = 2;
1118 if (barrel > 0 && barrel <= NB && ladder > 0 && ladder <= NL && wafer > 0 && wafer <= NW && hybrid > 0 && hybrid <= NH && d < ND) {
1119 p = ptr[barrel-1][ladder-1][wafer-1][hybrid-1][d-1];
1120 if (! p) {iok = 4;
goto ENDL;}
1121 if (p->npeaks < 0) {iok = 2;
goto ENDL;}
1122 peaks = (Double_t *) &p->mu0;
1123 for (k = 0; k < p->npeaks; k++) {
1124 if (TMath::Abs(anode-peaks[2*k]) < 3*peaks[2*k+1]) {iok = 3;
goto ENDL;}