1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
20 // 1. The laser track is associated with the mirror
21 // see function FindMirror
23 // 2. The laser track is accepted for the analysis under certain condition
24 // (see function Accpet laser)
26 // 3. The drift velocity and jitter is calculated event by event
27 // (see function drift velocity)
31 // To make laser scan the user interaction neccessary
34 gSystem->Load("libANALYSIS");
35 gSystem->Load("libTPCcalib");
36 TFile fcalib("CalibObjects.root");
37 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
38 AliTPCcalibLaser * laser = ( AliTPCcalibLaser *)array->FindObject("laserTPC");
39 laser->DumpMeanInfo(-0.4)
40 TFile fmean("laserMean.root")
42 // laser track clasification;
44 TCut cutT("cutT","abs(Tr.fP[3])<0.06");
45 TCut cutPt("cutPt","abs(Tr.fP[4])<0.1");
46 TCut cutN("cutN","fTPCncls>70");
47 TCut cutP("cutP","abs(atan2(x1,x0)-atan2(lx1,lx0))<0.03")
48 TCut cutA = cutT+cutPt+cutP;
49 TFile f("laserTPCDebug.root");
50 TTree * treeT = (TTree*)f.Get("Track");
55 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
56 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
57 AliXRDPROOFtoolkit tool;
58 TChain * chain = tool.MakeChain("laserScan.txt","Mean",0,10200);
60 AliTPCcalibLaser::DumpScanInfo(chain)
61 TFile fscan("laserScan.root")
62 TTree * treeT = (TTree*)fscan.Get("Mean")
66 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
67 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
68 AliXRDPROOFtoolkit tool;
69 TChain * chain = tool.MakeChain("laser.txt","Residuals",0,10200);
76 #include "TLinearFitter.h"
77 #include "AliTPCcalibLaser.h"
78 #include "AliExternalTrackParam.h"
79 #include "AliESDEvent.h"
80 #include "AliESDfriend.h"
81 #include "AliESDtrack.h"
82 #include "AliTPCTracklet.h"
87 #include "TTreeStream.h"
90 #include "TGraphErrors.h"
91 #include "AliTPCclusterMI.h"
92 #include "AliTPCseed.h"
93 #include "AliTracker.h"
95 #include "TClonesArray.h"
99 #include "TTreeStream.h"
102 #include "AliTPCLaserTrack.h"
106 ClassImp(AliTPCcalibLaser)
108 AliTPCcalibLaser::AliTPCcalibLaser():
114 fTracksEsdParam(336),
130 fFitAside(new TVectorD(3)),
131 fFitCside(new TVectorD(3)),
142 fTracksEsdParam.SetOwner(kTRUE);
145 AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title):
151 fTracksEsdParam(336),
153 fDeltaZ(336), // array of histograms of delta z for each track
154 fDeltaPhi(336), // array of histograms of delta z for each track
155 fDeltaPhiP(336), // array of histograms of delta z for each track
156 fSignals(336), // array of dedx signals
167 fFitAside(new TVectorD(3)), // drift fit - A side
168 fFitCside(new TVectorD(3)), // drift fit - C- side
169 fEdgeXcuts(5), // cuts in local x direction; used in the refit of the laser tracks
170 fEdgeYcuts(5), // cuts in local y direction; used in the refit of the laser tracks
171 fNClCuts(5), // cuts on the number of clusters per tracklet; used in the refit of the laser tracks
172 fNcuts(0), // number of cuts
181 fTracksEsdParam.SetOwner(kTRUE);
184 AliTPCcalibLaser::~AliTPCcalibLaser() {
192 void AliTPCcalibLaser::Process(AliESDEvent * event) {
195 // Loop over tracks and call Process function
201 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
205 AliDebug(4,Form("Event number in current file: %d",event->GetEventNumberInFile()));
208 fTracksEsdParam.Delete();
210 Int_t n=fESD->GetNumberOfTracks();
211 Int_t run = fESD->GetRunNumber();
213 for (Int_t i=0;i<n;++i) {
214 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
215 AliESDtrack *track=fESD->GetTrack(i);
216 TObject *calibObject=0;
218 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
219 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
221 if (track&&seed) FindMirror(track,seed);
228 for (Int_t id=0; id<336; id++){
231 if (!fTracksEsdParam.At(id)) continue;
240 void AliTPCcalibLaser::MakeDistHisto(){
244 for (Int_t id=0; id<336; id++){
247 if (!fTracksEsdParam.At(id)) continue;
248 if (!AcceptLaser(id)) continue;
251 TH1F * hisdz = (TH1F*)fDeltaZ.At(id);
252 TH1F * hisdphi = (TH1F*)fDeltaPhi.At(id);
253 TH1F * hisdphiP = (TH1F*)fDeltaPhiP.At(id);
254 TH1F * hisSignal = (TH1F*)fSignals.At(id);
257 hisdz = new TH1F(Form("hisdz%d",id),Form("hisdz%d",id),1000,-10,10);
258 hisdz->SetDirectory(0);
259 fDeltaZ.AddAt(hisdz,id);
261 hisdphi = new TH1F(Form("hisdphi%d",id),Form("hisdphi%d",id),1000,-1,1);
262 hisdphi->SetDirectory(0);
263 fDeltaPhi.AddAt(hisdphi,id);
265 hisdphiP = new TH1F(Form("hisdphiP%d",id),Form("hisdphiP%d",id),1000,-0.01,0.01);
266 hisdphiP->SetDirectory(0);
267 fDeltaPhiP.AddAt(hisdphiP,id);
268 hisSignal = new TH1F(Form("hisSignal%d",id),Form("hisSignal%d",id),1000,0,1000);
269 hisSignal->SetDirectory(0);
270 fSignals.AddAt(hisSignal,id);
273 AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
274 AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
275 AliESDtrack *track = (AliESDtrack*)fTracksEsd.At(id);
284 param->GetPxPyPz(pxyz);
286 ltrp->GetPxPyPz(lpxyz);
288 Float_t dz = param->GetZ()-ltrp->GetZ();
289 Float_t dphi = (TMath::ATan2(xyz[1],xyz[0])- TMath::ATan2(lxyz[1],lxyz[0]))*254.;
290 Float_t dphiP = param->GetParameter()[2]-ltrp->GetParameter()[2];
291 if (hisdz) hisdz->Fill(dz);
292 if (hisdphi) hisdphi->Fill(dphi);
293 if (hisdphiP) hisdphiP->Fill(dphiP);
294 if (hisSignal) hisSignal->Fill(track->GetTPCsignal());
298 void AliTPCcalibLaser::FitDriftV(){
300 // Fit drift velocity - linear approximation in the z and global y
302 static TLinearFitter fdriftA(3,"hyp2");
303 static TLinearFitter fdriftC(3,"hyp2");
304 fdriftA.ClearPoints();
305 fdriftC.ClearPoints();
307 for (Int_t id=0; id<336; id++){
308 if (!fTracksEsdParam.At(id)) continue;
309 if (!AcceptLaser(id)) continue;
310 AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
311 AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
317 param->GetPxPyPz(pxyz);
319 ltrp->GetPxPyPz(lpxyz);
320 Double_t xxx[2] = {lxyz[2],lxyz[1]};
321 if (ltrp->GetSide()==0){
322 fdriftA.AddPoint(xxx,xyz[2],1);
324 fdriftC.AddPoint(xxx,xyz[2],1);
332 if (fdriftA.GetNpoints()>10){
334 fdriftA.EvalRobust(0.8);
335 fdriftA.GetParameters(*fFitAside);
336 npointsA= fdriftA.GetNpoints();
337 chi2A = fdriftA.GetChisquare()/fdriftA.GetNpoints();
339 if (fdriftC.GetNpoints()>10){
341 fdriftC.EvalRobust(0.8);
342 fdriftC.GetParameters(*fFitCside);
343 npointsC= fdriftC.GetNpoints();
344 chi2C = fdriftC.GetChisquare()/fdriftC.GetNpoints();
348 TTreeSRedirector *cstream = GetDebugStreamer();
349 Int_t time = fESD->GetTimeStamp();
351 (*cstream)<<"driftv"<<
352 "driftA.="<<fFitAside<<
353 "driftC.="<<fFitCside<<
366 Bool_t AliTPCcalibLaser::AcceptLaser(Int_t id){
371 TCut cutT("cutT","abs(Tr.fP[3])<0.06");
372 TCut cutPt("cutPt","abs(Tr.fP[4])<0.1");
373 TCut cutN("cutN","fTPCncls>70");
374 TCut cutP("cutP","abs(atan2(x1,x0)-atan2(lx1,lx0))<0.03")
375 TCut cutA = cutT+cutPt+cutP;
377 AliExternalTrackParam *param =(AliExternalTrackParam*)fTracksEsdParam.At(id);
378 AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
379 AliESDtrack *track = (AliESDtrack*)fTracksEsd.At(id);
381 if (TMath::Abs(param->GetParameter()[4])>0.03) return kFALSE;
382 if (TMath::Abs(param->GetParameter()[3])>0.06) return kFALSE;
383 if (TMath::Abs(param->GetParameter()[2]-ltrp->GetParameter()[2])>0.06) return kFALSE;
384 if (TMath::Abs(param->GetParameter()[1]-ltrp->GetParameter()[1])>10) return kFALSE;
388 if (TMath::Abs(track->GetTPCsignal())<20) return kFALSE;
389 if (TMath::Abs(track->GetTPCsignal())>800) return kFALSE;
394 Int_t AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
396 // Find corresponding mirror
397 // add the corresponding tracks
399 Float_t kRadius0 = 252;
400 Float_t kRadius = 253.4;
401 if (!track->GetOuterParam()) return -1;
402 AliExternalTrackParam param(*(track->GetOuterParam()));
403 AliTracker::PropagateTrackTo(¶m,kRadius0,0.10566,3,kTRUE);
404 AliTracker::PropagateTrackTo(¶m,kRadius,0.10566,0.1,kTRUE);
405 AliTPCLaserTrack ltr;
406 AliTPCLaserTrack *ltrp=0x0;
407 AliTPCLaserTrack *ltrpjw=0x0;
409 Int_t id = AliTPCLaserTrack::IdentifyTrack(¶m);
410 // Int_t idjw = AliTPCLaserTrack::IdentifyTrackJW(¶m);
411 //AliDebug(4,Form("Identified Track: %03d (%03d)",id,idjw));
413 if (id!=-1 && (AliTPCLaserTrack::GetTracks()->UncheckedAt(id)))
414 ltrp=(AliTPCLaserTrack*)AliTPCLaserTrack::GetTracks()->UncheckedAt(id);
418 if (idjw!=-1 && (AliTPCLaserTrack::GetTracks()->UncheckedAt(idjw)))
419 ltrpjw=(AliTPCLaserTrack*)AliTPCLaserTrack::GetTracks()->UncheckedAt(idjw);
425 TTreeSRedirector *cstream = GetDebugStreamer();
427 (*cstream)<<"idcmp"<<
444 Float_t radius=TMath::Abs(ltrp->GetX());
445 AliTracker::PropagateTrackTo(¶m,radius,0.10566,0.01,kTRUE);
447 if (!fTracksMirror.At(id)) fTracksMirror.AddAt(ltrp,id);
448 fTracksEsdParam.AddAt(param.Clone(),id);
449 fTracksEsd.AddAt(track,id);
450 fTracksTPC.AddAt(seed,id);
459 void AliTPCcalibLaser::DumpLaser(Int_t id) {
461 // Dump Laser info to the tree
463 AliESDtrack *track = (AliESDtrack*)fTracksEsd.At(id);
464 AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
465 AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
474 param->GetPxPyPz(pxyz);
476 ltrp->GetPxPyPz(lpxyz);
479 TTreeSRedirector *cstream = GetDebugStreamer();
480 Int_t time = fESD->GetTimeStamp();
481 Bool_t accept = AcceptLaser(id);
483 (*cstream)<<"Track"<<
487 "driftA.="<<fFitAside<<
488 "driftC.="<<fFitCside<<
512 void AliTPCcalibLaser::RefitLaserJW(Int_t id){
514 // Refit the track with different tracklet models:
515 // 1. Per ROC using the kalman filter, different edge cuts
516 // 2. Per ROC linear in y and z
517 // 3. Per ROC quadratic in y and z
518 // 4. Per track offset for each sector, linear for each sector, common quadratic
519 // store x, y, z information for all models and the cluster to calculate the residuals
521 AliTPCseed *track = (AliTPCseed*)fTracksTPC.At(id);
522 AliExternalTrackParam *extparam=(AliExternalTrackParam*)fTracksEsdParam.At(id);
523 AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
525 AliTPCclusterMI dummyCl;
528 Int_t kMaxTracklets=2;
529 //=============================================//
530 // Linear Fitters for the Different Approaches //
531 //=============================================//
532 //linear fit model in y and z; inner - outer sector
533 static TLinearFitter fy1I(2,"hyp1");
534 static TLinearFitter fy1O(2,"hyp1");
535 static TLinearFitter fz1I(2,"hyp1");
536 static TLinearFitter fz1O(2,"hyp1");
537 //quadratic fit model in y and z; inner - sector
538 static TLinearFitter fy2I(3,"hyp2");
539 static TLinearFitter fy2O(3,"hyp2");
540 static TLinearFitter fz2I(3,"hyp2");
541 static TLinearFitter fz2O(3,"hyp2");
542 //common quadratic fit for IROC and OROC in y and z
543 static TLinearFitter fy4(5,"hyp4");
544 static TLinearFitter fz4(5,"hyp4");
554 //=============================//
555 // Loop over all Tracklet Cuts //
556 //=============================//
557 for (Int_t icut=0; icut<fNcuts; icut++){
558 AliDebug(4,Form("Processing cut %d for track with ID %d",icut,id));
560 Double_t edgeCutX = fEdgeXcuts[icut];
561 Double_t edgeCutY = fEdgeYcuts[icut];
562 Int_t nclCut = fNClCuts[icut];
563 //=========================//
564 // Parameters to calculate //
565 //=========================//
566 //fit parameter inner, outer tracklet and combined fit
567 TVectorD vecy1resInner(2),vecz1resInner(2); //pol1 fit parameters inner
568 TVectorD vecy2resInner(3),vecz2resInner(3); //pol2 fit parameters inner
570 TVectorD vecy1resOuter(2),vecz1resOuter(2); //pol1 fit parameters outer
571 TVectorD vecy2resOuter(3),vecz2resOuter(3); //pol2 fit parameters outer
572 TVectorD vecy4res(5),vecz4res(5);
573 // cluster and track positions for each row - used for residuals
574 TVectorD vecX(159); // x is the same for all (row center)
575 TVectorD vecYkalman(159); // y from kalman fit
576 TVectorD vecZkalman(159); // z from kalman fit
577 TVectorD vecY1(159); // y from pol1 fit per ROC
578 TVectorD vecZ1(159); // z from pol1 fit per ROC
579 TVectorD vecY2(159); // y from pol2 fit per ROC
580 TVectorD vecZ2(159); // z from pol2 fit per ROC
581 TVectorD vecY4(159); // y from sector fit
582 TVectorD vecZ4(159); // z from sector fit
583 TVectorD vecClY(159); // y cluster position
584 TVectorD vecClZ(159); // z cluster position
585 TVectorD vecSec(159); // sector for each row
587 Double_t chi2I1z=-1; // chi2 of pol1 fit in z (inner)
588 Double_t chi2I1y=-1; // chi2 of pol1 fit in y (inner)
589 Double_t chi2O1z=-1; // chi2 of pol1 fit in z (outer)
590 Double_t chi2O1y=-1; // chi2 of pol1 fit in y (outer)
591 Double_t chi2I2z=-1; // chi2 of pol2 fit in z (inner)
592 Double_t chi2I2y=-1; // chi2 of pol2 fit in y (inner)
593 Double_t chi2O2z=-1; // chi2 of pol2 fit in z (outer)
594 Double_t chi2O2y=-1; // chi2 of pol2 fit in y (outer)
595 Double_t chi2IOz=-1; // chi2 of hyp4 fit in z (inner+outer)
596 Double_t chi2IOy=-1; // chi2 of hyp4 fit in y (inner+outer)
598 Int_t innerSector = -1; // number of inner sector
599 Int_t outerSector = -1; // number of outer sector
600 Int_t nclI=0; // number of clusters (inner)
601 Int_t nclO=0; // number of clusters (outer)
602 //=================================================//
603 // Perform the Kalman Fit using the Tracklet Class //
604 //=================================================//
605 AliTPCTracklet::SetEdgeCut(edgeCutX,edgeCutY);
607 AliTPCTracklet::CreateTracklets(track,AliTPCTracklet::kKalman,
608 kFALSE,nclCut,kMaxTracklets);
610 AliTPCTracklet *trInner = (AliTPCTracklet*)tracklets.At(0);
611 AliTPCTracklet *trOuter = (AliTPCTracklet*)tracklets.At(1);
612 AliTPCTracklet *tr=0x0;
613 AliTPCTracklet dummy;
614 //continue if we didn't find a tracklet
615 if ( !trInner && !trOuter ) continue;
616 //================================================================================//
617 // Swap Inner and Outer if necessary (inner sector is definde by smaller local x) //
618 //================================================================================//
619 if ( trInner && trOuter ){
620 if ( !trInner->GetInner() || !trOuter->GetInner() ) continue;
621 if ( trInner->GetInner()->GetX() > trOuter->GetInner()->GetX() ){
625 AliDebug(5,Form("Swapped Sectors: %02d (%f) <-> %02d (%f)", trOuter->GetSector(), trOuter->GetInner()->GetX(), trInner->GetSector(), trInner->GetInner()->GetX()));
629 if ( !trInner->GetInner() ) continue;
631 if ( trInner->GetSector()>35 ){
636 if ( !trOuter->GetInner() ) continue;
638 if ( trOuter->GetSector()<36 ){
644 innerSector = trInner->GetSector();
645 if ( innerSector>=0 ) AliDebug(5,Form("Found inner Sector %02d at X %.2f", innerSector, trInner->GetInner()->GetX()));
646 outerSector = trOuter->GetSector();
647 if ( outerSector>=0 ) AliDebug(5,Form("Found outer Sector %02d at X %.2f", outerSector, trOuter->GetInner()->GetX()));
650 TClonesArray arrCl("AliTPCclusterMI",159);
651 arrCl.ExpandCreateFast(159);
652 //=======================================//
653 // fill fitters with cluster information //
654 //=======================================//
655 AliDebug(3,"Filing Cluster Information");
656 for (Int_t irow=158;irow>-1;--irow) {
657 AliTPCclusterMI *c=track->GetClusterPointer(irow);
658 AliTPCclusterMI &cl = (AliTPCclusterMI&) (*arrCl[irow]);
664 Int_t roc = static_cast<Int_t>(c->GetDetector());
665 if ( roc!=innerSector && roc!=outerSector ) continue;
667 //store clusters in clones array
670 vecX[irow] = c->GetX();
671 vecClY[irow] = c->GetY();
672 vecClZ[irow] = c->GetZ();
674 Double_t x = vecX[irow]-133.4; //reference is between IROC and OROC
675 Double_t y = vecClY[irow];
676 Double_t z = vecClZ[irow];
678 Double_t x2[2]={x,x*x}; //linear and parabolic parameters
679 Double_t x4[4]={0,0,0,0}; //hyp4 parameters
680 if ( roc == innerSector ) {
681 x4[0]=1; //offset inner - outer sector
682 x4[1]=x; //slope parameter inner sector
684 x4[2]=x; //slope parameter outer sector
686 x4[3]=x*x; //common parabolic shape
688 if ( roc==innerSector ){
695 if ( roc==outerSector ){
705 //======================================//
706 // Evaluate and retrieve fit parameters //
707 //======================================//
708 AliDebug(5,Form("Evaluating fits with inner (outer) Sec: %02d (%02d)",innerSector,outerSector));
710 if ( (innerSector>-1) && (fy1I.GetNpoints()>0) ){
715 fy1I.GetParameters(vecy1resInner);
716 fz1I.GetParameters(vecz1resInner);
717 fy2I.GetParameters(vecy2resInner);
718 fz2I.GetParameters(vecz2resInner);
719 chi2I1y=fy1I.GetChisquare()/(fy1I.GetNpoints()-2);
720 chi2I1z=fz1I.GetChisquare()/(fz1I.GetNpoints()-2);
721 chi2I2y=fy2I.GetChisquare()/(fy2I.GetNpoints()-3);
722 chi2I2z=fz2I.GetChisquare()/(fz2I.GetNpoints()-3);
725 if ( (outerSector>-1) && (fy1O.GetNpoints()>0) ){
730 fy1O.GetParameters(vecy1resOuter);
731 fz1O.GetParameters(vecz1resOuter);
732 fy2O.GetParameters(vecy2resOuter);
733 fz2O.GetParameters(vecz2resOuter);
734 chi2O1y=fy1O.GetChisquare()/(fy1O.GetNpoints()-2);
735 chi2O1z=fz1O.GetChisquare()/(fz1O.GetNpoints()-2);
736 chi2O2y=fy2O.GetChisquare()/(fy2O.GetNpoints()-3);
737 chi2O2z=fz2O.GetChisquare()/(fz2O.GetNpoints()-3);
740 if ( innerSector>0 && outerSector>0 ){
741 if (fy4.GetNpoints()>0) {
743 fy4.GetParameters(vecy4res);
744 chi2IOy=fy4.GetChisquare()/(fy4.GetNpoints()-5);
746 if (fz4.GetNpoints()>0) {
748 fz4.GetParameters(vecz4res);
749 chi2IOz=fz4.GetChisquare()/(fz4.GetNpoints()-5);
753 fy4.ClearPoints(); fz4.ClearPoints();
754 fy1I.ClearPoints(); fy1O.ClearPoints();
755 fz1I.ClearPoints(); fz1O.ClearPoints();
756 fy2I.ClearPoints(); fy2O.ClearPoints();
757 fz2I.ClearPoints(); fz2O.ClearPoints();
758 //==============================//
759 // calculate tracklet positions //
760 //==============================//
761 AliDebug(4,"Calculate tracklet positions");
762 for (Int_t irow=158;irow>-1;--irow) {
763 if ( vecSec[irow]==-1 ) continue; //no cluster info
764 if ( vecSec[irow]!=innerSector && vecSec[irow]!=outerSector ) continue;
766 Double_t x=vecX[irow];
767 Double_t xref=x-133.4;
769 Double_t yoffInner=0;
770 Double_t zoffInner=0;
771 Double_t yslopeInner=0;
772 Double_t yslopeOuter=0;
773 Double_t zslopeInner=0;
774 Double_t zslopeOuter=0;
775 //positions of hyperplane fits
776 if ( vecSec[irow] == outerSector ) {
778 vecY1[irow]=vecy1resOuter[0]+vecy1resOuter[1]*xref;
779 vecZ1[irow]=vecz1resOuter[0]+vecz1resOuter[1]*xref;
780 vecY2[irow]=vecy2resOuter[0]+vecy2resOuter[1]*xref+vecy2resOuter[2]*xref*xref;
781 vecZ2[irow]=vecz2resOuter[0]+vecz2resOuter[1]*xref+vecz2resOuter[2]*xref*xref;
782 yslopeOuter=vecy4res[3];
783 zslopeOuter=vecz4res[3];
786 vecY1[irow]=vecy1resInner[0]+vecy1resInner[1]*xref;
787 vecZ1[irow]=vecz1resInner[0]+vecz1resInner[1]*xref;
788 vecY2[irow]=vecy2resInner[0]+vecy2resInner[1]*xref+vecy2resInner[2]*xref*xref;
789 vecZ2[irow]=vecz2resInner[0]+vecz2resInner[1]*xref+vecz2resInner[2]*xref*xref;
790 yoffInner=vecy4res[1];
791 zoffInner=vecz4res[1];
792 yslopeInner=vecy4res[2];
793 zslopeInner=vecz4res[2];
795 vecY4[irow]=vecy4res[0]+yoffInner+yslopeInner*xref+yslopeOuter*xref+vecy4res[4]*xref*xref;
796 vecZ4[irow]=vecz4res[0]+zoffInner+zslopeInner*xref+zslopeOuter*xref+vecz4res[4]*xref*xref;
797 //positions of kalman fits
798 Double_t gxyz[3],xyz[3];
799 AliExternalTrackParam *param = 0x0;
801 param=tr->GetInner();
804 Float_t bz = AliTracker::GetBz(gxyz);
805 param->GetYAt(x, bz, xyz[1]);
806 param->GetZAt(x, bz, xyz[2]);
807 vecYkalman[irow]=xyz[1];
808 vecZkalman[irow]=xyz[2];
811 //=====================================================================//
812 // write results from the different tracklet fits with debug streamers //
813 //=====================================================================//
815 TTreeSRedirector *cstream = GetDebugStreamer();
817 Float_t dedx = track->GetdEdx();
818 (*cstream)<<"FitModels"<<
820 "edgeCutX=" << edgeCutX <<
821 "edgeCutY=" << edgeCutY <<
822 "nclCut=" << nclCut <<
823 "innerSector="<< innerSector <<
824 "outerSector="<< outerSector <<
827 "Tr.=" << extparam <<
828 "yPol1In.=" << &vecy1resInner <<
829 "zPol1In.=" << &vecz1resInner <<
830 "yPol2In.=" << &vecy2resInner <<
831 "zPol2In.=" << &vecz2resInner <<
832 "yPol1Out.=" << &vecy1resOuter <<
833 "zPol1Out.=" << &vecz1resOuter <<
834 "yPol2Out.=" << &vecy2resOuter <<
835 "zPol2Out.=" << &vecz2resOuter <<
836 "yInOut.=" << &vecy4res <<
837 "zInOut.=" << &vecz4res <<
838 "chi2y1In=" << chi2I1y <<
839 "chi2z1In=" << chi2I1z <<
840 "chi2y1Out=" << chi2O1y <<
841 "chi2z1Out=" << chi2O1z <<
842 "chi2y2In=" << chi2I2y <<
843 "chi2z2In=" << chi2I2z <<
844 "chi2y2Out=" << chi2O2y <<
845 "chi2z2Out=" << chi2O2z <<
846 "chi2yInOut=" << chi2IOy <<
847 "chi2zInOut=" << chi2IOz <<
848 "trletIn.=" << trInner <<
849 "trletOut.=" << trOuter <<
856 // wirte residuals information
858 TTreeSRedirector *cstream = GetDebugStreamer();
860 Float_t dedx = track->GetdEdx();
861 (*cstream)<<"Residuals"<<
863 "edgeCutX=" << edgeCutX <<
864 "edgeCutY=" << edgeCutY <<
865 "nclCut=" << nclCut <<
871 "TrYpol1.=" << &vecY1 <<
872 "TrZpol1.=" << &vecZ1 <<
873 "TrYpol2.=" << &vecY2 <<
874 "TrZpol2.=" << &vecZ2 <<
875 "TrYInOut.=" << &vecY4 <<
876 "TrZInOut.=" << &vecZ4 <<
877 "ClY.=" << &vecClY <<
878 "ClZ.=" << &vecClZ <<
879 "sec.=" << &vecSec <<
882 "yInOut.=" << &vecy4res <<
883 "zInOut.=" << &vecz4res <<
884 "chi2y1In=" << chi2I1y <<
885 "chi2z1In=" << chi2I1z <<
886 "chi2y1Out=" << chi2O1y <<
887 "chi2z1Out=" << chi2O1z <<
888 "chi2y2In=" << chi2I2y <<
889 "chi2z2In=" << chi2I2z <<
890 "chi2y2Out=" << chi2O2y <<
891 "chi2z2Out=" << chi2O2z <<
892 "chi2yInOut=" << chi2IOy <<
893 "chi2zInOut=" << chi2IOz <<
898 //==========================//
899 // Fill Residual Histograms //
900 //==========================//
901 TProfile *profy = (TProfile*)fDeltaYres.UncheckedAt(id);
902 TProfile *profz = (TProfile*)fDeltaZres.UncheckedAt(id);
904 profy=new TProfile(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d",id),115,80,250);
905 fDeltaYres.AddAt(profy,id);
908 profz=new TProfile(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d",id),115,80,250);
909 fDeltaZres.AddAt(profz,id);
911 for (Int_t irow=158;irow>-1;--irow) {
912 if (vecSec[irow]==-1)continue; //no cluster info
913 Double_t x = vecX[irow];
914 Double_t ycl = vecClY[irow];
915 Double_t yfit = vecY1[irow];
916 Double_t zcl = vecClZ[irow];
917 Double_t zfit = vecZ1[irow];
918 profy->Fill(x,yfit-ycl);
919 profz->Fill(x,zfit-zcl);
921 //===============================//
922 // Fill Fit Parameter Histograms //
923 //===============================//
924 TH1F *pol2InnerY =(TH1F*)fPol2Par2InY.UncheckedAt(id);
925 TH1F *diff1InnerY=(TH1F*)fDiffPar1InY.UncheckedAt(id);
926 TH1F *pol2OuterY =(TH1F*)fPol2Par2OutY.UncheckedAt(id);
927 TH1F *diff1OuterY=(TH1F*)fDiffPar1OutY.UncheckedAt(id);
928 TH1F *pol2InnerZ =(TH1F*)fPol2Par2InZ.UncheckedAt(id);
929 TH1F *diff1InnerZ=(TH1F*)fDiffPar1InZ.UncheckedAt(id);
930 TH1F *pol2OuterZ =(TH1F*)fPol2Par2OutZ.UncheckedAt(id);
931 TH1F *diff1OuterZ=(TH1F*)fDiffPar1OutZ.UncheckedAt(id);
932 //create histograms if the do not already exist
934 pol2InnerY =new TH1F(Form("pol2par2inY%03d",id),
935 Form("2nd derivative from pol2 fit in Y for Laser beam %03d (inner sector)",id),
937 pol2OuterY =new TH1F(Form("pol2par2outY%03d",id),
938 Form("2nd derivative from pol2 fit in Y for Laser beam %03d (outer sector)",id),
940 diff1InnerY=new TH1F(Form("diff1inY%03d",id),
941 Form("diff of 1st derivative from pol1 and pol2 in Y fit for Laser beam %03d (inner sector)",id),
943 diff1OuterY=new TH1F(Form("diff1outY%03d",id),
944 Form("diff of 1st derivative from pol1 and pol2 in Yfit for Laser beam %03d (outer sector)",id),
946 pol2InnerZ =new TH1F(Form("pol2par2inZ%03d",id),
947 Form("2nd derivative from pol2 fit in Z for Laser beam %03d (inner sector)",id),
949 pol2OuterZ =new TH1F(Form("pol2par2outZ%03d",id),
950 Form("2nd derivative from pol2 fit in Z for Laser beam %03d (outer sector)",id),
952 diff1InnerZ=new TH1F(Form("diff1inZ%03d",id),
953 Form("diff of 1st derivative from pol1 and pol2 in Z fit for Laser beam %03d (inner sector)",id),
955 diff1OuterZ=new TH1F(Form("diff1outZ%03d",id),
956 Form("diff of 1st derivative from pol1 and pol2 in Zfit for Laser beam %03d (outer sector)",id),
959 fPol2Par2InY.AddAt(pol2InnerY,id);
960 fDiffPar1InY.AddAt(diff1InnerY,id);
961 fPol2Par2OutY.AddAt(pol2OuterY,id);
962 fDiffPar1OutY.AddAt(diff1OuterY,id);
963 fPol2Par2InZ.AddAt(pol2InnerZ,id);
964 fDiffPar1InZ.AddAt(diff1InnerZ,id);
965 fPol2Par2OutZ.AddAt(pol2OuterZ,id);
966 fDiffPar1OutZ.AddAt(diff1OuterZ,id);
969 pol2InnerY ->Fill(vecy2resInner[2]);
970 pol2OuterY ->Fill(vecy2resOuter[2]);
971 diff1InnerY->Fill(vecy2resInner[1]-vecy1resInner[1]);
972 diff1OuterY->Fill(vecy2resOuter[1]-vecy1resOuter[1]);
973 pol2InnerZ ->Fill(vecz2resInner[2]);
974 pol2OuterZ ->Fill(vecz2resOuter[2]);
975 diff1InnerZ->Fill(vecz2resInner[1]-vecz1resInner[1]);
976 diff1OuterZ->Fill(vecz2resOuter[1]-vecz1resOuter[1]);
984 void AliTPCcalibLaser::RefitLaser(Int_t id){
986 // Refit the track store residuals
989 AliTPCseed *track = (AliTPCseed*)fTracksTPC.At(id);
990 AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
991 AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
993 //linear fit model in y and z per sector
994 static TLinearFitter fy1(2,"hyp1");
995 static TLinearFitter fz1(2,"hyp1");
996 //quadratic fit model in y and z per sector
997 static TLinearFitter fy2(3,"hyp2");
998 static TLinearFitter fz2(3,"hyp2");
999 static TVectorD vecy2,vecz2,vecy1,vecz1;
1001 const Int_t kMinClusters=20;
1002 Int_t nclusters[72];
1004 for (Int_t i=0;i<72;++i) nclusters[i]=0;
1006 for (Int_t i=0;i<160;++i) {
1007 AliTPCclusterMI *c=track->GetClusterPointer(i);
1008 if (c) nclusters[c->GetDetector()]++;
1011 for (Int_t isec=0; isec<72;isec++){
1012 if (nclusters[isec]<kMinClusters) continue;
1018 for (Int_t irow=0;irow<160;++irow) {
1019 AliTPCclusterMI *c=track->GetClusterPointer(irow);
1020 //if (c && RejectCluster(c)) continue;
1021 Double_t xd = c->GetX()-133.4; // reference x is beteen iroc and oroc
1022 if (c&&c->GetDetector()==isec) {
1023 Double_t x[2]={xd,xd*xd};
1024 fy2.AddPoint(x,c->GetY());
1025 fz2.AddPoint(x,c->GetZ());
1027 fy1.AddPoint(x,c->GetY());
1028 fz1.AddPoint(x,c->GetZ());
1035 fy1.GetParameters(vecy1);
1036 fy2.GetParameters(vecy2);
1037 fz1.GetParameters(vecz1);
1038 fz2.GetParameters(vecz2);
1040 if (fStreamLevel>0){
1041 TTreeSRedirector *cstream = GetDebugStreamer();
1043 Float_t dedx = track->GetdEdx();
1044 (*cstream)<<"Tracklet"<<
1048 "ncl="<<nclusters[isec]<<
1062 // for (Int_t irow=0;irow<160;++irow) {
1063 // AliTPCclusterMI *c=track->GetClusterPointer(irow);
1064 // if (c && RejectCluster(c)) continue;
1065 // if (c&&c->GetDetector()==isec) {
1066 // Double_t x[2]={c->GetX(),c->GetX()*c->GetX()};
1067 // fy2.AddPoint(&x,c->GetY());
1068 // fz2.AddPoint(&x,c->GetZ());
1070 // fy1.AddPoint(&x,c->GetY());
1071 // fz1.AddPoint(&x,c->GetZ());
1078 void AliTPCcalibLaser::DumpMeanInfo(Float_t bfield,Int_t minEntries){
1080 // Dump information about laser beams
1081 // isOK variable indicates usability of the beam
1082 // Beam is not usable if:
1083 // a. No entries in range (krmsCut0)
1084 // b. Big sperad (krmscut1)
1085 // c. RMSto fit sigma bigger then (kmultiCut)
1086 // d. Too big angular spread
1089 const Float_t krmsCut0=0.001;
1090 const Float_t krmsCut1=0.16;
1091 const Float_t kmultiCut=2;
1092 const Float_t kcutP0=0.002;
1094 AliTPCcalibLaser *laser = this;
1095 TTreeSRedirector *pcstream = new TTreeSRedirector("laserMean.root");
1096 TF1 fg("fg","gaus");
1099 for (Int_t id=0; id<336; id++){
1101 TH1F * hisphi = (TH1F*)laser->fDeltaPhi.At(id);
1102 TH1F * hisphiP = (TH1F*)laser->fDeltaPhiP.At(id);
1103 TH1F * hisZ = (TH1F*)laser->fDeltaZ.At(id);
1104 TH1F * hisS = (TH1F*)laser->fSignals.At(id);
1105 if (!hisphi) continue;;
1106 Double_t entries = hisphi->GetEntries();
1107 if (entries<minEntries) continue;
1109 AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
1111 AliTPCLaserTrack::LoadTracks();
1112 ltrp =(AliTPCLaserTrack*)AliTPCLaserTrack::GetTracks()->UncheckedAt(id);
1114 Float_t meanphi = hisphi->GetMean();
1115 Float_t rmsphi = hisphi->GetRMS();
1117 Float_t meanphiP = hisphiP->GetMean();
1118 Float_t rmsphiP = hisphiP->GetRMS();
1119 Float_t meanZ = hisZ->GetMean();
1120 Float_t rmsZ = hisZ->GetRMS();
1121 hisphi->Fit(&fg,"","",hisphi->GetMean()-4*hisphi->GetRMS(),hisphi->GetMean()+4*hisphi->GetRMS());
1122 Double_t gphi1 = fg.GetParameter(1);
1123 Double_t gphi2 = fg.GetParameter(2);
1124 hisphiP->Fit(&fg,"","",hisphiP->GetMean()-4*hisphiP->GetRMS(),hisphiP->GetMean()+4*hisphiP->GetRMS());
1125 Double_t gphiP1 = fg.GetParameter(1);
1126 Double_t gphiP2 = fg.GetParameter(2);
1127 hisZ->Fit(&fg,"","",hisZ->GetMean()-4*hisZ->GetRMS(),hisZ->GetMean()+4*hisZ->GetRMS());
1128 Double_t gz1 = fg.GetParameter(1);
1129 Double_t gz2 = fg.GetParameter(2);
1131 Float_t meanS=hisS->GetMean();
1136 ltrp->GetPxPyPz(lpxyz);
1138 if (rmsphi<krmsCut0) isOK=kFALSE; // empty in range - not entries inside
1139 if (rmsphi>krmsCut1) isOK=kFALSE; // empty in range - not entries inside
1140 if (rmsphi>krmsCut0) if (gphi2/rmsphi>kmultiCut) isOK=kFALSE; // multi peak structure
1141 if (gphiP2>kcutP0) isOK=kFALSE;
1143 (*pcstream)<<"Mean"<<
1145 "entries="<<entries<< // number of entries
1146 "bz="<<bfield<< // bfield
1147 "LTr.="<<ltrp<< // refernece track
1149 "lx0="<<lxyz[0]<< // reference x
1150 "lx1="<<lxyz[1]<< // reference y
1151 "lx2="<<lxyz[2]<< // refernece z
1152 "lpx0="<<lpxyz[0]<< // reference x
1153 "lpx1="<<lpxyz[1]<< // reference y
1154 "lpx2="<<lpxyz[2]<< // refernece z
1158 "mphi="<<meanphi<< //
1159 "rmsphi="<<rmsphi<< //
1163 "mphiP="<<meanphiP<< //
1164 "rmsphiP="<<rmsphiP<< //
1180 void AliTPCcalibLaser::DumpScanInfo(TTree * chain){
1184 TTreeSRedirector *pcstream = new TTreeSRedirector("laserScan.root");
1185 TFile * f = pcstream->GetFile();
1187 f->mkdir("dirphiP");
1189 TF1 fp("p1","pol1");
1194 char grnamefull[1000];
1197 Double_t mphiP[100];
1198 Double_t smphi[100];
1199 Double_t smphiP[100];
1209 for (Int_t id=0; id<336; id++){
1211 sprintf(cut,"isOK&&fId==%d",id);
1212 Int_t entries = chain->Draw("bz",cut,"goff");
1213 if (entries<3) continue;
1214 AliTPCLaserTrack *ltrp = 0;;
1215 if (!AliTPCLaserTrack::GetTracks()) AliTPCLaserTrack::LoadTracks();
1216 ltrp =(AliTPCLaserTrack*)AliTPCLaserTrack::GetTracks()->UncheckedAt(id);
1220 ltrp->GetPxPyPz(lpxyz);
1222 chain->Draw("bz",cut,"goff");
1223 memcpy(bz, chain->GetV1(), entries*sizeof(Double_t));
1224 chain->Draw("0.01*abs(bz)+0.02",cut,"goff");
1225 memcpy(sbz, chain->GetV1(), entries*sizeof(Double_t));
1227 chain->Draw("gphi1",cut,"goff");
1228 memcpy(mphi, chain->GetV1(), entries*sizeof(Double_t));
1229 chain->Draw("0.05*abs(mphi)+gphi2",cut,"goff");
1230 memcpy(smphi, chain->GetV1(), entries*sizeof(Double_t));
1232 chain->Draw("gphiP1",cut,"goff");
1233 memcpy(mphiP, chain->GetV1(), entries*sizeof(Double_t));
1234 chain->Draw("0.05*abs(mphiP)+gphiP2",cut,"goff");
1235 memcpy(smphiP, chain->GetV1(), entries*sizeof(Double_t));
1237 chain->Draw("gz1",cut,"goff");
1238 memcpy(mZ, chain->GetV1(), entries*sizeof(Double_t));
1239 chain->Draw("0.01*abs(meanZ)+gz2",cut,"goff");
1240 memcpy(smZ, chain->GetV1(), entries*sizeof(Double_t));
1243 sprintf(grnamefull,"Side_%d_Bundle_%d_Rod_%d_Beam_%d",
1244 ltrp->GetSide(), ltrp->GetBundle(), ltrp->GetRod(), ltrp->GetBeam());
1248 TGraphErrors *grphi = new TGraphErrors(entries,bz,mphi,sbz,smphi);
1251 pphi[0] = fp.GetParameter(0); // offset
1252 pphi[1] = fp.GetParameter(1); // slope
1253 pphi[2] = TMath::Sqrt(fp.GetChisquare()/(entries-2.)); // normalized chi2
1254 sprintf(grname,"phi_id%d",id);
1255 grphi->SetName(grname); grphi->SetTitle(grnamefull);
1256 grphi->GetXaxis()->SetTitle("b_{z} (T)");
1257 grphi->GetYaxis()->SetTitle("#Delta r#phi (cm)");
1258 grphi->SetMaximum(1.2);
1259 grphi->SetMinimum(-1.2);
1263 gPad->SaveAs(Form("pic/phi/phi_%s.gif",grnamefull));
1266 TGraphErrors *grphiP = new TGraphErrors(entries,bz,mphiP,sbz,smphiP);
1269 pphiP[0] = fp.GetParameter(0); // offset
1270 pphiP[1] = fp.GetParameter(1); // slope
1271 pphiP[2] = TMath::Sqrt(fp.GetChisquare()/(entries-2.)); // normalized chi2
1272 sprintf(grname,"phiP_id%d",id);
1273 grphiP->SetName(grname); grphiP->SetTitle(grnamefull);
1274 grphiP->GetXaxis()->SetTitle("b_{z} (T)");
1275 grphiP->GetYaxis()->SetTitle("#Delta #phi (rad)");
1276 grphiP->SetMaximum(pphiP[0]+0.005);
1277 grphiP->SetMinimum(pphiP[0]-0.005);
1279 gPad->SaveAs(Form("pic/phiP/phiP_%s.gif",grnamefull));
1284 TGraphErrors *grmZ = new TGraphErrors(entries,bz,mZ,sbz,smZ);
1287 pmZ[0] = fp.GetParameter(0); // offset
1288 pmZ[1] = fp.GetParameter(1); // slope
1289 pmZ[2] = TMath::Sqrt(fp.GetChisquare()/(entries-2.)); // normalized chi2
1290 sprintf(grname,"mZ_id%d",id);
1291 grmZ->SetName(grname); grmZ->SetTitle(grnamefull);
1292 grmZ->GetXaxis()->SetTitle("b_{z} (T)");
1293 grmZ->GetYaxis()->SetTitle("#Delta z (cm)");
1295 gPad->SaveAs(Form("pic/z/z_%s.gif",grnamefull));
1299 for (Int_t ientry=0; ientry<entries; ientry++){
1300 (*pcstream)<<"Mean"<<
1303 "entries="<<entries<<
1305 "lx0="<<lxyz[0]<< // reference x
1306 "lx1="<<lxyz[1]<< // reference y
1307 "lx2="<<lxyz[2]<< // refernece z
1308 "lpx0="<<lpxyz[0]<< // reference x
1309 "lpx1="<<lpxyz[1]<< // reference y
1310 "lpx2="<<lpxyz[2]<< // refernece z
1312 "gphi1="<<mphi[ientry]<< // mean - from gaus fit
1313 "pphi0="<<pphi[0]<< // offset
1314 "pphi1="<<pphi[1]<< // mean
1315 "pphi2="<<pphi[2]<< // norm chi2
1317 "gphiP1="<<mphiP[ientry]<< // mean - from gaus fit
1318 "pphiP0="<<pphiP[0]<< // offset
1319 "pphiP1="<<pphiP[1]<< // mean
1320 "pphiP2="<<pphiP[2]<< // norm chi2
1322 "gz1="<<mZ[ientry]<<
1323 "pmZ0="<<pmZ[0]<< // offset
1324 "pmZ1="<<pmZ[1]<< // mean
1325 "pmZ2="<<pmZ[2]<< // norm chi2
1335 void AliTPCcalibLaser::Analyze(){
1342 Long64_t AliTPCcalibLaser::Merge(TCollection *li) {
1344 TIterator* iter = li->MakeIterator();
1345 AliTPCcalibLaser* cal = 0;
1347 while ((cal = (AliTPCcalibLaser*)iter->Next())) {
1348 if (!cal->InheritsFrom(AliTPCcalibLaser::Class())) {
1349 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
1353 // fHistNTracks->Add(cal->fHistNTracks);
1354 // fClusters->Add(cal->fClusters);
1355 // fModules->Add(cal->fModules);
1356 // fHistPt->Add(cal->fHistPt);
1357 // fPtResolution->Add(cal->fPtResolution);
1358 // fDeDx->Add(cal->fDeDx);
1366 for (Int_t id=0; id<336; id++){
1367 // merge fDeltaZ histograms
1368 hm = (TH1F*)cal->fDeltaZ.At(id);
1369 h = (TH1F*)fDeltaZ.At(id);
1371 h=new TH1F(Form("hisdz%d",id),Form("hisdz%d",id),1000,-10,10);
1372 fDeltaZ.AddAt(h,id);
1375 // merge fDeltaPhi histograms
1376 hm = (TH1F*)cal->fDeltaPhi.At(id);
1377 h = (TH1F*)fDeltaPhi.At(id);
1379 h= new TH1F(Form("hisdphi%d",id),Form("hisdphi%d",id),1000,-1,1);
1380 fDeltaPhi.AddAt(h,id);
1383 // merge fDeltaPhiP histograms
1384 hm = (TH1F*)cal->fDeltaPhiP.At(id);
1385 h = (TH1F*)fDeltaPhiP.At(id);
1387 h=new TH1F(Form("hisdphiP%d",id),Form("hisdphiP%d",id),1000,-0.01,0.01);
1388 fDeltaPhiP.AddAt(h,id);
1391 // merge fSignals histograms
1392 hm = (TH1F*)cal->fSignals.At(id);
1393 h = (TH1F*)fSignals.At(id);
1395 h=new TH1F(Form("hisSignal%d",id),Form("hisSignal%d",id),1000,0,1000);
1396 fSignals.AddAt(h,id);
1401 // merge ProfileY histograms
1402 hpm = (TProfile*)cal->fDeltaYres.At(id);
1403 hp = (TProfile*)fDeltaYres.At(id);
1405 hp=new TProfile(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d",id),115,80,250);;
1406 fDeltaYres.AddAt(hp,id);
1408 if (hpm) hp->Add(hpm);
1410 hpm = (TProfile*)cal->fDeltaZres.At(id);
1411 hp = (TProfile*)fDeltaZres.At(id);
1413 hp=new TProfile(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d",id),115,80,250);;
1414 fDeltaZres.AddAt(hp,id);
1416 if (hpm) hp->Add(hpm);
1419 //merge fit param histograms
1421 TH1F *pol2InnerY =(TH1F*)fPol2Par2InY.UncheckedAt(id);
1422 TH1F *diff1InnerY=(TH1F*)fDiffPar1InY.UncheckedAt(id);
1423 TH1F *pol2OuterY =(TH1F*)fPol2Par2OutY.UncheckedAt(id);
1424 TH1F *diff1OuterY=(TH1F*)fDiffPar1OutY.UncheckedAt(id);
1425 TH1F *pol2InnerZ =(TH1F*)fPol2Par2InZ.UncheckedAt(id);
1426 TH1F *diff1InnerZ=(TH1F*)fDiffPar1InZ.UncheckedAt(id);
1427 TH1F *pol2OuterZ =(TH1F*)fPol2Par2OutZ.UncheckedAt(id);
1428 TH1F *diff1OuterZ=(TH1F*)fDiffPar1OutZ.UncheckedAt(id);
1430 TH1F *pol2InnerYm =(TH1F*)cal->fPol2Par2InY.UncheckedAt(id);
1431 TH1F *diff1InnerYm=(TH1F*)cal->fDiffPar1InY.UncheckedAt(id);
1432 TH1F *pol2OuterYm =(TH1F*)cal->fPol2Par2OutY.UncheckedAt(id);
1433 TH1F *diff1OuterYm=(TH1F*)cal->fDiffPar1OutY.UncheckedAt(id);
1434 TH1F *pol2InnerZm =(TH1F*)cal->fPol2Par2InZ.UncheckedAt(id);
1435 TH1F *diff1InnerZm=(TH1F*)cal->fDiffPar1InZ.UncheckedAt(id);
1436 TH1F *pol2OuterZm =(TH1F*)cal->fPol2Par2OutZ.UncheckedAt(id);
1437 TH1F *diff1OuterZm=(TH1F*)cal->fDiffPar1OutZ.UncheckedAt(id);
1438 //create histos if they do not exist
1440 pol2InnerY =new TH1F(Form("pol2par2inY%03d",id),
1441 Form("2nd derivative from pol2 fit in Y for Laser beam %03d (inner sector)",id),
1443 pol2OuterY =new TH1F(Form("pol2par2outY%03d",id),
1444 Form("2nd derivative from pol2 fit in Y for Laser beam %03d (outer sector)",id),
1446 diff1InnerY=new TH1F(Form("diff1inY%03d",id),
1447 Form("diff of 1st derivative from pol1 and pol2 in Y fit for Laser beam %03d (inner sector)",id),
1449 diff1OuterY=new TH1F(Form("diff1outY%03d",id),
1450 Form("diff of 1st derivative from pol1 and pol2 in Yfit for Laser beam %03d (outer sector)",id),
1452 pol2InnerZ =new TH1F(Form("pol2par2inZ%03d",id),
1453 Form("2nd derivative from pol2 fit in Z for Laser beam %03d (inner sector)",id),
1455 pol2OuterZ =new TH1F(Form("pol2par2outZ%03d",id),
1456 Form("2nd derivative from pol2 fit in Z for Laser beam %03d (outer sector)",id),
1458 diff1InnerZ=new TH1F(Form("diff1inZ%03d",id),
1459 Form("diff of 1st derivative from pol1 and pol2 in Z fit for Laser beam %03d (inner sector)",id),
1461 diff1OuterZ=new TH1F(Form("diff1outZ%03d",id),
1462 Form("diff of 1st derivative from pol1 and pol2 in Zfit for Laser beam %03d (outer sector)",id),
1465 pol2InnerYm =(TH1F*)cal->fPol2Par2InY.UncheckedAt(id);
1466 diff1InnerYm=(TH1F*)cal->fDiffPar1InY.UncheckedAt(id);
1467 pol2OuterYm =(TH1F*)cal->fPol2Par2OutY.UncheckedAt(id);
1468 diff1OuterYm=(TH1F*)cal->fDiffPar1OutY.UncheckedAt(id);
1469 pol2InnerZm =(TH1F*)cal->fPol2Par2InZ.UncheckedAt(id);
1470 diff1InnerZm=(TH1F*)cal->fDiffPar1InZ.UncheckedAt(id);
1471 pol2OuterZm =(TH1F*)cal->fPol2Par2OutZ.UncheckedAt(id);
1472 diff1OuterZm=(TH1F*)cal->fDiffPar1OutZ.UncheckedAt(id);
1482 gSystem->Load("libSTAT.so")
1483 TStatToolkit toolkit;
1488 TCut cutA("entries>2&&pphi2<3&&abs(gphiP1-pphiP0)<0.003&&abs(gz1)<6");
1493 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz++"; //1
1494 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz*LTr.fP[2]++"; //2
1495 fstring+="(abs(LTr.fP[1]/250)^1-1)*bz++"; //3
1496 fstring+="(abs(LTr.fP[1]/250)-1)*bz*LTr.fP[2]++"; //4
1498 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz*sin(atan2(lx1,lx0))++" //5
1499 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz*sin(atan2(lx1,lx0))*LTr.fP[2]++" //6
1500 fstring+="(abs(LTr.fP[1]/250)-1)*bz*sin(atan2(lx1,lx0))++" //7
1501 fstring+="(abs(LTr.fP[1]/250)-1)*bz*sin(atan2(lx1,lx0))*LTr.fP[2]++" //8
1503 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz*cos(atan2(lx1,lx0))++" //9
1504 fstring+="(abs(LTr.fP[1]/250)^3-1)*bz*cos(atan2(lx1,lx0))*LTr.fP[2]++" //10
1505 fstring+="(abs(LTr.fP[1]/250)-1)*bz*cos(atan2(lx1,lx0))++" //11
1506 fstring+="(abs(LTr.fP[1]/250)-1)*bz*cos(atan2(lx1,lx0))*LTr.fP[2]++" //12
1511 TString *strq0 = toolkit.FitPlane(treeT,"gphi1-pphi0",fstring->Data(), "fSide==1"+cutA, chi2,npoints,fitParam,covMatrix);
1513 treeT->SetAlias("fit",strq0->Data());
1516 TString *strqP = toolkit.FitPlane(treeT,"1000*(gphiP1-pphiP0)",fstring->Data(), "fSide==1"+cutA, chi2,npoints,fitParam,covMatrix);
1518 treeT->SetAlias("fitP",strqP->Data());
1521 TString *strqDrift = toolkit.FitPlane(treeT,"gz1","LTr.fP[1]++(1-2*(fSide==1))++lx1", cutA, chi2,npoints,fitParam,covMatrix);
1522 treeT->SetAlias("fitD",strqDrift->Data());
1525 treeT->Draw("fit:LTr.fP[1]","abs(bz+0.4)<0.05"+cutA,"");
1527 for (Int_t i=0; i<6;i++){
1528 treeT->SetLineColor(i+2);
1529 treeT->SetMarkerSize(1);
1530 treeT->SetMarkerStyle(22+i);
1531 treeT->SetMarkerColor(i+2);
1533 treeT->Draw("fit:LTr.fP[1]",Form("abs(bz+0.4)<0.05&fRod==%d",i)+cutA,"same");
1541 TTree * tree = (TTree*)f.Get("FitModels");
1543 TEventList listLFit0("listLFit0","listLFit0");
1544 TEventList listLFit1("listLFit1","listLFit1");
1545 tree->Draw(">>listLFit0","seed.fdEdx<200&&seed.fdEdx>40");
1546 tree->SetEventList(&listLFit0);
1551 gSystem->Load("libSTAT.so")
1552 TStatToolkit toolkit;
1558 chain->SetAlias("dp","((Cl.fPad-int(Cl.fPad))*pi)");
1559 chain->SetAlias("dt","((Cl.fTimeBin-int(Cl.fTimeBin))*pi)");
1563 fstring+="cos(dp)++";
1564 fstring+="sin(dp)++";
1565 fstring+="cos(dt)++";
1566 fstring+="sin(dt)++";
1568 TString *str = toolkit.FitPlane(chain,"Cl.fZ-TrZInOut.fElements",fstring->Data(), "Cl.fDetector>35", chi2,npoints,fitParam,covMatrix,-1,0,200);