60 #include "Riostream.h"
65 #include <TTreeStream.h>
68 #include <TTimeStamp.h>
69 #include <AliCDBStorage.h>
71 #include <AliCDBMetaData.h>
78 #include "AliExternalTrackParam.h"
79 #include "AliTrackPointArray.h"
80 #include "TDatabasePDG.h"
81 #include "AliTrackerBase.h"
83 #include "THnSparse.h"
86 #include "AliESDVertex.h"
87 #include "AliVertexerTracks.h"
88 #include "TDatabasePDG.h"
92 #include "TDatabasePDG.h"
99 #include "TLinearFitter.h"
100 #include <AliSysInfo.h>
127 : TNamed("correction_unity","unity"),fILow(0),fJLow(0),fKLow(0), fT1(1), fT2(1), fIsLocal(kFALSE), fIntegrationType(kIntegral)
131 if (!fgVisualCorrection) fgVisualCorrection=
new TObjArray;
133 InitLookUpfulcrums();
138 : TNamed(name,title),fILow(0),fJLow(0),fKLow(0), fT1(1), fT2(1), fIsLocal(kFALSE), fIntegrationType(kIntegral)
160 AliError(
"Zerro pointer - correction");
163 AliError(TString::Format(
"Correction %s not implementend",IsA()->GetName()).Data());
175 for (Int_t j=0;j<3;++j) x[j]+=dx[j];
185 for (Int_t j=0;j<3;++j) xp[j]=x[j]+dx[j];
195 for (Int_t j=0;j<3;++j) x[j]+=dx[j];
203 Float_t gxyz[3]={0,0,0};
204 Double_t alpha = TMath::TwoPi()*(roc%18+0.5)/18;
205 Double_t ca=TMath::Cos(alpha), sa= TMath::Sin(alpha);
206 gxyz[0]= ca*x[0]+sa*x[1];
207 gxyz[1]= -sa*x[0]+ca*x[1];
210 x[0]= ca*gxyz[0]-sa*gxyz[1];
211 x[1]= +sa*gxyz[0]+ca*gxyz[1];
219 Float_t gxyz[3]={0,0,0};
220 Double_t alpha = TMath::TwoPi()*(roc%18+0.5)/18;
221 Double_t ca=TMath::Cos(alpha), sa= TMath::Sin(alpha);
222 gxyz[0]= ca*x[0]+sa*x[1];
223 gxyz[1]= -sa*x[0]+ca*x[1];
226 x[0]= ca*gxyz[0]-sa*gxyz[1];
227 x[1]= sa*gxyz[0]+ca*gxyz[1];
238 for (Int_t j=0;j<3;++j) xp[j]=x[j]+dx[j];
246 for (Int_t j=0;j<3;++j) { dx[j]=0.; }
254 for (Int_t j=0;j<3;++j) dx[j]=-dx[j];
284 static TLinearFitter fitx(2,
"pol1");
285 static TLinearFitter fity(2,
"pol1");
286 static TLinearFitter fitz(2,
"pol1");
295 if ((x[2]+zmin*delta)<0){
307 if ((x[2]+zmax*delta)>0){
317 for (Int_t xdelta=-1; xdelta<=1; xdelta++)
318 for (Int_t ydelta=-1; ydelta<=1; ydelta++){
322 for (Int_t zdelta=zmin; zdelta<=zmax; zdelta++){
325 Float_t xyz[3]={x[0]+xdelta*delta, x[1]+ydelta*delta, x[2]+zdelta*delta};
328 Double_t adelta=zdelta*delta;
329 fitx.AddPoint(&adelta, dxyz[0]);
330 fity.AddPoint(&adelta, dxyz[1]);
331 fitz.AddPoint(&adelta, dxyz[2]);
337 dx[0] = fitx.GetParameter(1);
338 dx[1] = fity.GetParameter(1);
339 dx[2] = fitz.GetParameter(1);
365 static TLinearFitter fitx(2,
"pol1");
366 static TLinearFitter fity(2,
"pol1");
367 static TLinearFitter fitz(2,
"pol1");
377 if ((x[2]+zmin*delta)<0){
383 if ((x[2]+zmax*delta)>0){
391 for (Int_t xdelta=-1; xdelta<=1; xdelta++)
392 for (Int_t ydelta=-1; ydelta<=1; ydelta++){
393 for (Int_t zdelta=zmin; zdelta<=zmax; zdelta++){
397 Float_t xyz[3]={x[0]+xdelta*delta, x[1]+ydelta*delta, x[2]+zdelta*delta};
400 Double_t adelta=zdelta*delta;
401 fitx.AddPoint(&adelta, dxyz[0]);
402 fity.AddPoint(&adelta, dxyz[1]);
403 fitz.AddPoint(&adelta, dxyz[2]);
409 dx[0] = fitx.GetParameter(1);
410 dx[1] = fity.GetParameter(1);
411 dx[2] = fitz.GetParameter(1);
429 Double_t zdrift = TMath::Abs(x[2]-zroc);
430 Int_t nsteps = Int_t(zdrift/delta)+1;
433 Float_t xyz[3]={x[0],x[1],zroc};
434 Float_t dxyz[3]={x[0],x[1],x[2]};
435 Short_t side=(roc/18)%2;
436 Float_t sign=1-2*side;
438 for (Int_t i=0;i<nsteps; i++){
440 Float_t deltaZ=delta*(-sign);
445 if (xyz[2]+deltaZ<0) deltaZ=-xyz[2]+1e-20;
447 if (xyz[2]+deltaZ>0) deltaZ=xyz[2]-+1e-20;
453 Float_t xyz2[3]={xyz[0],xyz[1],
static_cast<Float_t
>(xyz[2]+deltaZ/2.)};
455 xyz[0]+=deltaZ*dxyz[0];
456 xyz[1]+=deltaZ*dxyz[1];
458 sumdz+=deltaZ*dxyz[2];
478 Double_t zdrift = TMath::Abs(x[2]-zroc);
479 Int_t nsteps = Int_t(zdrift/delta)+1;
482 Float_t xyz[3]={x[0],x[1],x[2]};
483 Float_t dxyz[3]={x[0],x[1],x[2]};
484 Float_t sign=((roc%36)<18) ? 1.:-1.;
486 for (Int_t i=0;i<nsteps; i++){
487 Float_t deltaZ=delta;
488 if (xyz[2]+deltaZ>
fgkTPCZ0) deltaZ=TMath::Abs(xyz[2]-zroc);
489 if (xyz[2]-deltaZ<-
fgkTPCZ0) deltaZ=TMath::Abs(xyz[2]-zroc);
495 Float_t xyz2[3]={xyz[0],xyz[1],
static_cast<Float_t
>(xyz[2]+deltaZ/2.)};
497 xyz[0]+=-deltaZ*dxyz[0];
498 xyz[1]+=-deltaZ*dxyz[1];
500 sumdz+=-deltaZ*dxyz[2];
525 printf(
"TPC spacepoint correction: \"%s\"\n",GetTitle());
546 TH2F *h=
CreateTH2F(
"dr_xy", TString::Format(
"%s: DRinXY Z=%2.0f", GetTitle(),z).Data(),
"x [cm]",
"y [cm]",
"dr [cm]",
547 nx,-250.,250.,ny,-250.,250.);
551 for (Int_t iy=1;iy<=ny;++iy) {
552 x[1]=h->GetYaxis()->GetBinCenter(iy);
553 for (Int_t ix=1;ix<=nx;++ix) {
554 x[0]=h->GetXaxis()->GetBinCenter(ix);
556 Float_t r0=TMath::Sqrt((x[0] )*(x[0] )+(x[1] )*(x[1] ));
558 Float_t r1=TMath::Sqrt((x[0]+dx[0])*(x[0]+dx[0])+(x[1]+dx[1])*(x[1]+dx[1]));
559 h->SetBinContent(ix,iy,r1-r0);
562 h->SetBinContent(ix,iy,0.);
577 TH2F *h=
CreateTH2F(
"drphi_xy",TString::Format(
"%s: DRPhiinXY Z=%2.0f", GetTitle(),z).Data(),
"x [cm]",
"y [cm]",
"drphi [cm]",
578 nx,-250.,250.,ny,-250.,250.);
582 for (Int_t iy=1;iy<=ny;++iy) {
583 x[1]=h->GetYaxis()->GetBinCenter(iy);
584 for (Int_t ix=1;ix<=nx;++ix) {
585 x[0]=h->GetXaxis()->GetBinCenter(ix);
587 Float_t r0=TMath::Sqrt((x[0] )*(x[0] )+(x[1] )*(x[1] ));
589 Float_t phi0=TMath::ATan2(x[1] ,x[0] );
590 Float_t phi1=TMath::ATan2(x[1]+dx[1],x[0]+dx[0]);
592 Float_t dphi=phi1-phi0;
593 if (dphi<TMath::Pi()) dphi+=TMath::TwoPi();
594 if (dphi>TMath::Pi()) dphi-=TMath::TwoPi();
596 h->SetBinContent(ix,iy,r0*dphi);
599 h->SetBinContent(ix,iy,0.);
614 TH2F *h=
CreateTH2F(
"dz_xy",TString::Format(
"%s: DZinXY Z=%2.0f", GetTitle(),z).Data(),
"x [cm]",
"y [cm]",
"dz [cm]",
615 nx,-250.,250.,ny,-250.,250.);
619 for (Int_t iy=1;iy<=ny;++iy) {
620 x[1]=h->GetYaxis()->GetBinCenter(iy);
621 for (Int_t ix=1;ix<=nx;++ix) {
622 x[0]=h->GetXaxis()->GetBinCenter(ix);
624 Float_t r0=TMath::Sqrt((x[0] )*(x[0] )+(x[1] )*(x[1] ));
626 h->SetBinContent(ix,iy,dx[2]);
629 h->SetBinContent(ix,iy,0.);
642 TH2F *h=
CreateTH2F(
"dr_zr",TString::Format(
"%s: DRinZR Phi=%2.2f", GetTitle(),phi).Data(),
"z [cm]",
"r [cm]",
"dr [cm]",
643 nz,-250.,250.,nr,85.,250.);
645 for (Int_t ir=1;ir<=nr;++ir) {
646 Float_t radius=h->GetYaxis()->GetBinCenter(ir);
647 x[0]=radius*TMath::Cos(phi);
648 x[1]=radius*TMath::Sin(phi);
649 for (Int_t iz=1;iz<=nz;++iz) {
650 x[2]=h->GetXaxis()->GetBinCenter(iz);
651 Int_t roc=x[2]>0.?0:18;
653 Float_t r0=TMath::Sqrt((x[0] )*(x[0] )+(x[1] )*(x[1] ));
654 Float_t r1=TMath::Sqrt((x[0]+dx[0])*(x[0]+dx[0])+(x[1]+dx[1])*(x[1]+dx[1]));
655 h->SetBinContent(iz,ir,r1-r0);
668 TH2F *h=
CreateTH2F(
"drphi_zr", TString::Format(
"%s: DRPhiinZR R=%2.2f", GetTitle(),phi).Data(),
"z [cm]",
"r [cm]",
"drphi [cm]",
669 nz,-250.,250.,nr,85.,250.);
671 for (Int_t iz=1;iz<=nz;++iz) {
672 x[2]=h->GetXaxis()->GetBinCenter(iz);
673 Int_t roc=x[2]>0.?0:18;
674 for (Int_t ir=1;ir<=nr;++ir) {
675 Float_t radius=h->GetYaxis()->GetBinCenter(ir);
676 x[0]=radius*TMath::Cos(phi);
677 x[1]=radius*TMath::Sin(phi);
679 Float_t r0=TMath::Sqrt((x[0] )*(x[0] )+(x[1] )*(x[1] ));
680 Float_t phi0=TMath::ATan2(x[1] ,x[0] );
681 Float_t phi1=TMath::ATan2(x[1]+dx[1],x[0]+dx[0]);
683 Float_t dphi=phi1-phi0;
684 if (dphi<TMath::Pi()) dphi+=TMath::TwoPi();
685 if (dphi>TMath::Pi()) dphi-=TMath::TwoPi();
687 h->SetBinContent(iz,ir,r0*dphi);
699 TH2F *h=
CreateTH2F(
"dz_zr",TString::Format(
"%s: DZinZR Z=%2.0f", GetTitle(),phi).Data(),
"z [cm]",
"r [cm]",
"dz [cm]",
700 nz,-250.,250.,nr,85.,250.);
702 for (Int_t ir=1;ir<=nr;++ir) {
703 Float_t radius=h->GetYaxis()->GetBinCenter(ir);
704 x[0]=radius*TMath::Cos(phi);
705 x[1]=radius*TMath::Sin(phi);
706 for (Int_t iz=1;iz<=nz;++iz) {
707 x[2]=h->GetXaxis()->GetBinCenter(iz);
708 Int_t roc=x[2]>0.?0:18;
710 h->SetBinContent(iz,ir,dx[2]);
719 const char *xlabel,
const char *ylabel,
const char *zlabel,
720 Int_t nbinsx,Double_t xlow,Double_t xup,
721 Int_t nbinsy,Double_t ylow,Double_t yup) {
727 while (gDirectory->FindObject(hname.Data())) {
734 TH2F *h=
new TH2F(hname.Data(),title,
737 h->GetXaxis()->SetTitle(xlabel);
738 h->GetYaxis()->SetTitle(ylabel);
739 h->GetZaxis()->SetTitle(zlabel);
747 const Double_t er[kNZ][kNR], Double_t &erValue ) {
750 Double_t saveEr[5] = {0,0,0,0,0};
757 if (
fKLow + order >= kNR - 1 )
fKLow = kNR - 1 - order ;
759 for ( Int_t j =
fJLow ; j <
fJLow + order + 1 ; j++ ) {
767 const Double_t er[kNZ][kNPhi][kNR],
const Double_t ephi[kNZ][kNPhi][kNR],
const Double_t ez[kNZ][kNPhi][kNR],
768 Double_t &erValue, Double_t &ephiValue, Double_t &ezValue) {
771 Double_t saveEr[5]= {0,0,0,0,0};
772 Double_t savedEr[5]= {0,0,0,0,0} ;
774 Double_t saveEphi[5]= {0,0,0,0,0};
775 Double_t savedEphi[5]= {0,0,0,0,0} ;
777 Double_t saveEz[5]= {0,0,0,0,0};
778 Double_t savedEz[5]= {0,0,0,0,0} ;
790 if (
fKLow + order >= kNR - 1 )
fKLow = kNR - 1 - order ;
792 for ( Int_t i =
fILow ; i <
fILow + order + 1 ; i++ ) {
793 for ( Int_t j =
fJLow ; j <
fJLow + order + 1 ; j++ ) {
809 Int_t nx, Int_t ny,
const Double_t xv[],
const Double_t yv[],
810 const TMatrixD &
array ) {
813 static Int_t jlow = 0, klow = 0 ;
814 Double_t saveArray[5] = {0,0,0,0,0} ;
816 Search( nx, xv, x, jlow ) ;
817 Search( ny, yv, y, klow ) ;
818 if ( jlow < 0 ) jlow = 0 ;
819 if ( klow < 0 ) klow = 0 ;
820 if ( jlow + order >= nx - 1 ) jlow = nx - 1 - order ;
821 if ( klow + order >= ny - 1 ) klow = ny - 1 - order ;
823 for ( Int_t j = jlow ; j < jlow + order + 1 ; j++ )
825 Double_t *ajkl = &((TMatrixD&)array)(j,klow);
826 saveArray[j-jlow] =
Interpolate( &yv[klow], ajkl , order, y ) ;
829 return(
Interpolate( &xv[jlow], saveArray, order, x ) ) ;
834 Int_t nx, Int_t ny, Int_t nz,
835 const Double_t xv[],
const Double_t yv[],
const Double_t zv[],
836 TMatrixD **arrayofArrays ) {
839 static Int_t ilow = 0, jlow = 0, klow = 0 ;
840 Double_t saveArray[5]= {0,0,0,0,0};
841 Double_t savedArray[5]= {0,0,0,0,0} ;
843 Search( nx, xv, x, ilow ) ;
844 Search( ny, yv, y, jlow ) ;
845 Search( nz, zv, z, klow ) ;
847 if ( ilow < 0 ) ilow = 0 ;
848 if ( jlow < 0 ) jlow = 0 ;
849 if ( klow < 0 ) klow = 0 ;
851 if ( ilow + order >= nx - 1 ) ilow = nx - 1 - order ;
852 if ( jlow + order >= ny - 1 ) jlow = ny - 1 - order ;
853 if ( klow + order >= nz - 1 ) klow = nz - 1 - order ;
855 for ( Int_t k = klow ; k < klow + order + 1 ; k++ )
857 TMatrixD &table = *arrayofArrays[k] ;
858 for ( Int_t i = ilow ; i < ilow + order + 1 ; i++ )
860 saveArray[i-ilow] =
Interpolate( &yv[jlow], &table(i,jlow), order, y ) ;
862 savedArray[k-klow] =
Interpolate( &xv[ilow], saveArray, order, x ) ;
864 return(
Interpolate( &zv[klow], savedArray, order, z ) ) ;
869 Int_t order, Double_t x ) {
874 y = (x-xArray[1]) * (x-xArray[2]) * yArray[0] / ( (xArray[0]-xArray[1]) * (xArray[0]-xArray[2]) ) ;
875 y += (x-xArray[2]) * (x-xArray[0]) * yArray[1] / ( (xArray[1]-xArray[2]) * (xArray[1]-xArray[0]) ) ;
876 y += (x-xArray[0]) * (x-xArray[1]) * yArray[2] / ( (xArray[2]-xArray[0]) * (xArray[2]-xArray[1]) ) ;
878 y = yArray[0] + ( yArray[1]-yArray[0] ) * ( x-xArray[0] ) / ( xArray[1] - xArray[0] ) ;
886 Int_t nx, Int_t ny,
const Double_t xv[],
const Double_t yv[],
887 const TMatrixF &
array ) {
891 static Int_t jlow = 0, klow = 0 ;
892 Float_t saveArray[5] = {0.,0.,0.,0.,0.} ;
894 Search( nx, xv, x, jlow ) ;
895 Search( ny, yv, y, klow ) ;
896 if ( jlow < 0 ) jlow = 0 ;
897 if ( klow < 0 ) klow = 0 ;
898 if ( jlow + order >= nx - 1 ) jlow = nx - 1 - order ;
899 if ( klow + order >= ny - 1 ) klow = ny - 1 - order ;
901 for ( Int_t j = jlow ; j < jlow + order + 1 ; j++ )
903 Float_t *ajkl = &((TMatrixF&)array)(j,klow);
904 saveArray[j-jlow] =
Interpolate( &yv[klow], ajkl , order, y ) ;
907 return(
Interpolate( &xv[jlow], saveArray, order, x ) ) ;
912 Int_t nx, Int_t ny, Int_t nz,
913 const Double_t xv[],
const Double_t yv[],
const Double_t zv[],
914 TMatrixF **arrayofArrays ) {
918 static Int_t ilow = 0, jlow = 0, klow = 0 ;
919 Float_t saveArray[5]= {0.,0.,0.,0.,0.};
920 Float_t savedArray[5]= {0.,0.,0.,0.,0.} ;
922 Search( nx, xv, x, ilow ) ;
923 Search( ny, yv, y, jlow ) ;
924 Search( nz, zv, z, klow ) ;
926 if ( ilow < 0 ) ilow = 0 ;
927 if ( jlow < 0 ) jlow = 0 ;
928 if ( klow < 0 ) klow = 0 ;
930 if ( ilow + order >= nx - 1 ) ilow = nx - 1 - order ;
931 if ( jlow + order >= ny - 1 ) jlow = ny - 1 - order ;
932 if ( klow + order >= nz - 1 ) klow = nz - 1 - order ;
934 for ( Int_t k = klow ; k < klow + order + 1 ; k++ )
936 TMatrixF &table = *arrayofArrays[k] ;
937 for ( Int_t i = ilow ; i < ilow + order + 1 ; i++ )
939 saveArray[i-ilow] =
Interpolate( &yv[jlow], &table(i,jlow), order, y ) ;
941 savedArray[k-klow] =
Interpolate( &xv[ilow], saveArray, order, x ) ;
943 return(
Interpolate( &zv[klow], savedArray, order, z ) ) ;
947 Int_t order, Double_t x ) {
953 y = (x-xArray[1]) * (x-xArray[2]) * yArray[0] / ( (xArray[0]-xArray[1]) * (xArray[0]-xArray[2]) ) ;
954 y += (x-xArray[2]) * (x-xArray[0]) * yArray[1] / ( (xArray[1]-xArray[2]) * (xArray[1]-xArray[0]) ) ;
955 y += (x-xArray[0]) * (x-xArray[1]) * yArray[2] / ( (xArray[2]-xArray[0]) * (xArray[2]-xArray[1]) ) ;
957 y = yArray[0] + ( yArray[1]-yArray[0] ) * ( x-xArray[0] ) / ( xArray[1] - xArray[0] ) ;
969 Long_t middle, high ;
970 Int_t ascend = 0, increment = 1 ;
972 if ( xArray[n-1] >= xArray[0] ) ascend = 1 ;
974 if ( low < 0 || low > n-1 ) {
975 low = -1 ; high = n ;
977 if ( (Int_t)( x >= xArray[low] ) == ascend ) {
978 if ( low == n-1 )
return ;
980 while ( (Int_t)( x >= xArray[high] ) == ascend ) {
983 high = low + increment ;
984 if ( high > n-1 ) { high = n ; break ; }
987 if ( low == 0 ) { low = -1 ;
return ; }
989 while ( (Int_t)( x < xArray[low] ) == ascend ) {
992 if ( increment >= high ) { low = -1 ; break ; }
993 else low = high - increment ;
998 while ( (high-low) != 1 ) {
999 middle = ( high + low ) / 2 ;
1000 if ( (Int_t)( x >= xArray[middle] ) == ascend )
1006 if ( x == xArray[n-1] ) low = n-2 ;
1007 if ( x == xArray[0] ) low = 0 ;
1020 for (Int_t i = 1; i<
kNR; i++) {
1021 fgkRList[i] = fgkRList[i-1] + 3.5;
1022 if (fgkRList[i]<90 ||fgkRList[i]>245)
1023 fgkRList[i] = fgkRList[i-1] + 0.5;
1024 else if (fgkRList[i]<100 || fgkRList[i]>235)
1025 fgkRList[i] = fgkRList[i-1] + 1.5;
1026 else if (fgkRList[i]<120 || fgkRList[i]>225)
1027 fgkRList[i] = fgkRList[i-1] + 2.5;
1033 for (Int_t j = 1; j<
kNZ/2; j++) {
1037 else if(TMath::Abs(
fgkZList[j])< 0.6)
1052 for (Int_t k = 0; k<
kNPhi; k++)
1060 TMatrixD &arrayErOverEz, TMatrixD &arrayDeltaEz,
1061 Int_t rows, Int_t columns, Int_t iterations,
1062 Bool_t rocDisplacement ) {
1088 const Float_t gridSizeZ =
fgkTPCZ0 / (columns-1) ;
1089 const Float_t ratio = gridSizeR*gridSizeR / (gridSizeZ*gridSizeZ) ;
1091 TMatrixD arrayEr(rows,columns) ;
1092 TMatrixD arrayEz(rows,columns) ;
1097 AliError(
"PoissonRelaxation - Error in the number of rows. Must be 2**M - 1");
1101 AliError(
"PoissonRelaxation - Error in the number of columns. Must be 2**N - 1");
1109 Int_t iOne = (rows-1)/4 ;
1110 Int_t jOne = (columns-1)/4 ;
1112 Int_t loops = 1 + (int) ( 0.5 + TMath::Log2( (
double) TMath::Max(iOne,jOne) ) ) ;
1114 for ( Int_t count = 0 ; count < loops ; count++ ) {
1117 Float_t tempGridSizeR = gridSizeR * iOne ;
1118 Float_t tempRatio = ratio * iOne * iOne / ( jOne * jOne ) ;
1119 Float_t tempFourth = 1.0 / (2.0 + 2.0*tempRatio) ;
1122 std::vector<float> coef1(rows) ;
1123 std::vector<float> coef2(rows) ;
1125 for ( Int_t i = iOne ; i < rows-1 ; i+=iOne ) {
1127 coef1[i] = 1.0 + tempGridSizeR/(2*radius);
1128 coef2[i] = 1.0 - tempGridSizeR/(2*radius);
1131 TMatrixD sumChargeDensity(rows,columns) ;
1133 for ( Int_t i = iOne ; i < rows-1 ; i += iOne ) {
1135 for ( Int_t j = jOne ; j < columns-1 ; j += jOne ) {
1136 if ( iOne == 1 && jOne == 1 ) sumChargeDensity(i,j) = chargeDensity(i,j) ;
1139 Float_t weight = 0.0 ;
1141 sumChargeDensity(i,j) = 0.0 ;
1142 for ( Int_t ii = i-iOne/2 ; ii <= i+iOne/2 ; ii++ ) {
1143 for ( Int_t jj = j-jOne/2 ; jj <= j+jOne/2 ; jj++ ) {
1144 if ( ii == i-iOne/2 || ii == i+iOne/2 || jj == j-jOne/2 || jj == j+jOne/2 ) weight = 0.5 ;
1148 sumChargeDensity(i,j) += chargeDensity(ii,jj)*weight*radius ;
1149 sum += weight*radius ;
1152 sumChargeDensity(i,j) /=
sum ;
1154 sumChargeDensity(i,j) *= tempGridSizeR*tempGridSizeR;
1158 for ( Int_t k = 1 ; k <= iterations; k++ ) {
1162 Float_t overRelax = 1.0 + TMath::Sqrt( TMath::Cos( (k*TMath::PiOver2())/iterations ) ) ;
1163 Float_t overRelaxM1 = overRelax - 1.0 ;
1164 Float_t overRelaxtempFourth, overRelaxcoef5 ;
1165 overRelaxtempFourth = overRelax * tempFourth ;
1166 overRelaxcoef5 = overRelaxM1 / overRelaxtempFourth ;
1168 for ( Int_t i = iOne ; i < rows-1 ; i += iOne ) {
1169 for ( Int_t j = jOne ; j < columns-1 ; j += jOne ) {
1171 arrayV(i,j) = ( coef2[i] * arrayV(i-iOne,j)
1172 + tempRatio * ( arrayV(i,j-jOne) + arrayV(i,j+jOne) )
1173 - overRelaxcoef5 * arrayV(i,j)
1174 + coef1[i] * arrayV(i+iOne,j)
1175 + sumChargeDensity(i,j)
1176 ) * overRelaxtempFourth;
1180 if ( k == iterations ) {
1182 for ( Int_t i = iOne ; i < rows-1 ; i += iOne ) {
1183 for ( Int_t j = jOne ; j < columns-1 ; j += jOne ) {
1186 arrayV(i+iOne/2,j) = ( arrayV(i+iOne,j) + arrayV(i,j) ) / 2 ;
1187 if ( i == iOne ) arrayV(i-iOne/2,j) = ( arrayV(0,j) + arrayV(iOne,j) ) / 2 ;
1190 arrayV(i,j+jOne/2) = ( arrayV(i,j+jOne) + arrayV(i,j) ) / 2 ;
1191 if ( j == jOne ) arrayV(i,j-jOne/2) = ( arrayV(i,0) + arrayV(i,jOne) ) / 2 ;
1193 if ( iOne > 1 && jOne > 1 ) {
1194 arrayV(i+iOne/2,j+jOne/2) = ( arrayV(i+iOne,j+jOne) + arrayV(i,j) ) / 2 ;
1195 if ( i == iOne ) arrayV(i-iOne/2,j-jOne/2) = ( arrayV(0,j-jOne) + arrayV(iOne,j) ) / 2 ;
1196 if ( j == jOne ) arrayV(i-iOne/2,j-jOne/2) = ( arrayV(i-iOne,0) + arrayV(i,jOne) ) / 2 ;
1207 iOne = iOne / 2 ;
if ( iOne < 1 ) iOne = 1 ;
1208 jOne = jOne / 2 ;
if ( jOne < 1 ) jOne = 1 ;
1210 sumChargeDensity.Clear();
1214 for ( Int_t j = 0 ; j < columns ; j++ ) {
1215 for ( Int_t i = 1 ; i < rows-1 ; i++ ) arrayEr(i,j) = -1 * ( arrayV(i+1,j) - arrayV(i-1,j) ) / (2*gridSizeR) ;
1216 arrayEr(0,j) = -1 * ( -0.5*arrayV(2,j) + 2.0*arrayV(1,j) - 1.5*arrayV(0,j) ) / gridSizeR ;
1217 arrayEr(rows-1,j) = -1 * ( 1.5*arrayV(rows-1,j) - 2.0*arrayV(rows-2,j) + 0.5*arrayV(rows-3,j) ) / gridSizeR ;
1221 for ( Int_t i = 0 ; i < rows ; i++) {
1222 for ( Int_t j = 1 ; j < columns-1 ; j++ ) arrayEz(i,j) = -1 * ( arrayV(i,j+1) - arrayV(i,j-1) ) / (2*gridSizeZ) ;
1223 arrayEz(i,0) = -1 * ( -0.5*arrayV(i,2) + 2.0*arrayV(i,1) - 1.5*arrayV(i,0) ) / gridSizeZ ;
1224 arrayEz(i,columns-1) = -1 * ( 1.5*arrayV(i,columns-1) - 2.0*arrayV(i,columns-2) + 0.5*arrayV(i,columns-3) ) / gridSizeZ ;
1227 for ( Int_t i = 0 ; i < rows ; i++) {
1230 for ( Int_t j = 0 ; j < columns ; j++ ) {
1231 arrayEz(i,j) += ezField;
1238 for ( Int_t j = 0 ; j < columns ; j++ ) {
1239 for ( Int_t i = 0 ; i < rows ; i++ ) {
1242 arrayErOverEz(i,j) = 0.0 ;
1243 arrayDeltaEz(i,j) = 0.0 ;
1245 for ( Int_t k = j ; k < columns ; k++ ) {
1246 arrayErOverEz(i,j) += index*(gridSizeZ/3.0)*arrayEr(i,k)/arrayEz(i,k) ;
1247 arrayDeltaEz(i,j) += index*(gridSizeZ/3.0)*(arrayEz(i,k)-ezField) ;
1248 if ( index != 4 ) index = 4;
else index = 2 ;
1251 arrayErOverEz(i,j) -= (gridSizeZ/3.0)*arrayEr(i,columns-1)/arrayEz(i,columns-1) ;
1252 arrayDeltaEz(i,j) -= (gridSizeZ/3.0)*(arrayEz(i,columns-1)-ezField) ;
1255 arrayErOverEz(i,j) += (gridSizeZ/3.0) * ( 0.5*arrayEr(i,columns-2)/arrayEz(i,columns-2)
1256 -2.5*arrayEr(i,columns-1)/arrayEz(i,columns-1));
1257 arrayDeltaEz(i,j) += (gridSizeZ/3.0) * ( 0.5*(arrayEz(i,columns-2)-ezField)
1258 -2.5*(arrayEz(i,columns-1)-ezField));
1260 if ( j == columns-2 ) {
1261 arrayErOverEz(i,j) = (gridSizeZ/3.0) * ( 1.5*arrayEr(i,columns-2)/arrayEz(i,columns-2)
1262 +1.5*arrayEr(i,columns-1)/arrayEz(i,columns-1) ) ;
1263 arrayDeltaEz(i,j) = (gridSizeZ/3.0) * ( 1.5*(arrayEz(i,columns-2)-ezField)
1264 +1.5*(arrayEz(i,columns-1)-ezField) ) ;
1266 if ( j == columns-1 ) {
1267 arrayErOverEz(i,j) = 0.0 ;
1268 arrayDeltaEz(i,j) = 0.0 ;
1276 for ( Int_t j = 0 ; j < columns ; j++ ) {
1277 for ( Int_t i = 0 ; i < rows ; i++ ) {
1280 arrayDeltaEz(i,j) = arrayDeltaEz(i,j)*
fgkdvdE;
1283 Double_t dzROCShift = arrayV(i, columns -1)/ezField;
1284 if ( rocDisplacement ) arrayDeltaEz(i,j) = arrayDeltaEz(i,j) + dzROCShift;
1295 TMatrixD**arrayofEroverEz, TMatrixD**arrayofEPhioverEz, TMatrixD**arrayofDeltaEz,
1296 Int_t rows, Int_t columns, Int_t phislices,
1297 Float_t deltaphi, Int_t iterations, Int_t symmetry,
1318 const Float_t gridSizePhi = deltaphi ;
1319 const Float_t gridSizeZ =
fgkTPCZ0 / (columns-1) ;
1320 const Float_t ratioPhi = gridSizeR*gridSizeR / (gridSizePhi*gridSizePhi) ;
1321 const Float_t ratioZ = gridSizeR*gridSizeR / (gridSizeZ*gridSizeZ) ;
1323 TMatrixD arrayE(rows,columns) ;
1330 AliError(
"Poisson3DRelaxation - Error in the number of rows. Must be 2**M - 1");
1333 AliError(
"Poisson3DRelaxation - Error in the number of columns. Must be 2**N - 1");
1335 if ( phislices <= 3 ) {
1336 AliError(
"Poisson3DRelaxation - Error in the number of phislices. Must be larger than 3");
1338 if ( phislices > 1000 ) {
1339 AliError(
"Poisson3D phislices > 1000 is not allowed (nor wise) ");
1346 Int_t loops, mplus, mminus, signplus, signminus ;
1347 Int_t ione = (rows-1)/4 ;
1348 Int_t jone = (columns-1)/4 ;
1349 loops = TMath::Max(ione, jone) ;
1350 loops = 1 + (int) ( 0.5 + TMath::Log2((
double)loops) ) ;
1352 TMatrixD* arrayofSumChargeDensities[1000] ;
1354 for ( Int_t i = 0 ; i < phislices ; i++ ) { arrayofSumChargeDensities[i] =
new TMatrixD(rows,columns) ; }
1355 AliSysInfo::AddStamp(
"3DInit", 10,0,0);
1357 for ( Int_t count = 0 ; count < loops ; count++ ) {
1358 AliSysInfo::AddStamp(
"3Diter", 20,count,0);
1360 Float_t tempgridSizeR = gridSizeR * ione ;
1361 Float_t tempratioPhi = ratioPhi * ione * ione ;
1362 Float_t tempratioZ = ratioZ * ione * ione / ( jone * jone ) ;
1364 std::vector<float> coef1(rows) ;
1365 std::vector<float> coef2(rows) ;
1366 std::vector<float> coef3(rows) ;
1367 std::vector<float> coef4(rows) ;
1369 for ( Int_t i = ione ; i < rows-1 ; i+=ione ) {
1371 coef1[i] = 1.0 + tempgridSizeR/(2*radius);
1372 coef2[i] = 1.0 - tempgridSizeR/(2*radius);
1373 coef3[i] = tempratioPhi/(radius*radius);
1374 coef4[i] = 0.5 / (1.0 + tempratioZ + coef3[i]);
1377 for ( Int_t m = 0 ; m < phislices ; m++ ) {
1378 TMatrixD &chargeDensity = *arrayofChargeDensities[m] ;
1379 TMatrixD &sumChargeDensity = *arrayofSumChargeDensities[m] ;
1380 for ( Int_t i = ione ; i < rows-1 ; i += ione ) {
1382 for ( Int_t j = jone ; j < columns-1 ; j += jone ) {
1383 if ( ione == 1 && jone == 1 ) sumChargeDensity(i,j) = chargeDensity(i,j) ;
1385 Float_t weight = 0.0 ;
1387 sumChargeDensity(i,j) = 0.0 ;
1388 for ( Int_t ii = i-ione/2 ; ii <= i+ione/2 ; ii++ ) {
1389 for ( Int_t jj = j-jone/2 ; jj <= j+jone/2 ; jj++ ) {
1390 if ( ii == i-ione/2 || ii == i+ione/2 || jj == j-jone/2 || jj == j+jone/2 ) weight = 0.5 ;
1393 sumChargeDensity(i,j) += chargeDensity(ii,jj)*weight*radius ;
1394 sum += weight*radius ;
1397 sumChargeDensity(i,j) /=
sum ;
1399 sumChargeDensity(i,j) *= tempgridSizeR*tempgridSizeR;
1404 for ( Int_t k = 1 ; k <= iterations; k++ ) {
1407 Float_t overRelax = 1.0 + TMath::Sqrt( TMath::Cos( (k*TMath::PiOver2())/iterations ) ) ;
1408 Float_t overRelaxM1 = overRelax - 1.0 ;
1410 std::vector<float> overRelaxcoef4(rows) ;
1411 std::vector<float> overRelaxcoef5(rows) ;
1413 for ( Int_t i = ione ; i < rows-1 ; i+=ione ) {
1414 overRelaxcoef4[i] = overRelax * coef4[i] ;
1415 overRelaxcoef5[i] = overRelaxM1 / overRelaxcoef4[i] ;
1418 for ( Int_t m = 0 ; m < phislices ; m++ ) {
1420 mplus = m + 1; signplus = 1 ;
1421 mminus = m - 1 ; signminus = 1 ;
1423 if ( mplus > phislices-1 ) mplus = phislices - 2 ;
1424 if ( mminus < 0 ) mminus = 1 ;
1426 else if (symmetry==-1) {
1427 if ( mplus > phislices-1 ) { mplus = phislices - 2 ; signplus = -1 ; }
1428 if ( mminus < 0 ) { mminus = 1 ; signminus = -1 ; }
1431 if ( mplus > phislices-1 ) mplus = m + 1 - phislices ;
1432 if ( mminus < 0 ) mminus = m - 1 + phislices ;
1434 TMatrixD& arrayV = *arrayofArrayV[m] ;
1435 TMatrixD& arrayVP = *arrayofArrayV[mplus] ;
1436 TMatrixD& arrayVM = *arrayofArrayV[mminus] ;
1437 TMatrixD& sumChargeDensity = *arrayofSumChargeDensities[m] ;
1438 Double_t *arrayVfast = arrayV.GetMatrixArray();
1439 Double_t *arrayVPfast = arrayVP.GetMatrixArray();
1440 Double_t *arrayVMfast = arrayVM.GetMatrixArray();
1441 Double_t *sumChargeDensityFast=sumChargeDensity.GetMatrixArray();
1445 for ( Int_t i = ione ; i < rows-1 ; i+=ione ) {
1446 for ( Int_t j = jone ; j < columns-1 ; j+=jone ) {
1448 arrayV(i,j) = ( coef2[i] * arrayV(i-ione,j)
1449 + tempratioZ * ( arrayV(i,j-jone) + arrayV(i,j+jone) )
1450 - overRelaxcoef5[i] * arrayV(i,j)
1451 + coef1[i] * arrayV(i+ione,j)
1452 + coef3[i] * ( signplus*arrayVP(i,j) + signminus*arrayVM(i,j) )
1453 + sumChargeDensity(i,j)
1454 ) * overRelaxcoef4[i] ;
1459 for ( Int_t i = ione ; i < rows-1 ; i+=ione ) {
1460 Double_t *arrayVfastI = &(arrayVfast[i*columns]);
1461 Double_t *arrayVPfastI = &(arrayVPfast[i*columns]);
1462 Double_t *arrayVMfastI = &(arrayVMfast[i*columns]);
1463 Double_t *sumChargeDensityFastI=&(sumChargeDensityFast[i*columns]);
1464 for ( Int_t j = jone ; j < columns-1 ; j+=jone ) {
1473 resFast = ( coef2[i] * arrayVfastI[j-columns*ione]
1474 + tempratioZ * ( arrayVfastI[j-jone] + arrayVfastI[j+jone] )
1475 - overRelaxcoef5[i] * arrayVfastI[j]
1476 + coef1[i] * arrayVfastI[j+columns*ione]
1477 + coef3[i] * ( signplus* arrayVPfastI[j] + signminus*arrayVMfastI[j])
1478 + sumChargeDensityFastI[j]
1479 ) * overRelaxcoef4[i] ;
1483 arrayVfastI[j]=resFast;
1489 if ( k == iterations ) {
1490 for ( Int_t i = ione ; i < rows-1 ; i+=ione ) {
1491 for ( Int_t j = jone ; j < columns-1 ; j+=jone ) {
1494 arrayV(i+ione/2,j) = ( arrayV(i+ione,j) + arrayV(i,j) ) / 2 ;
1495 if ( i == ione ) arrayV(i-ione/2,j) = ( arrayV(0,j) + arrayV(ione,j) ) / 2 ;
1498 arrayV(i,j+jone/2) = ( arrayV(i,j+jone) + arrayV(i,j) ) / 2 ;
1499 if ( j == jone ) arrayV(i,j-jone/2) = ( arrayV(i,0) + arrayV(i,jone) ) / 2 ;
1501 if ( ione > 1 && jone > 1 ) {
1502 arrayV(i+ione/2,j+jone/2) = ( arrayV(i+ione,j+jone) + arrayV(i,j) ) / 2 ;
1503 if ( i == ione ) arrayV(i-ione/2,j-jone/2) = ( arrayV(0,j-jone) + arrayV(ione,j) ) / 2 ;
1504 if ( j == jone ) arrayV(i-ione/2,j-jone/2) = ( arrayV(i-ione,0) + arrayV(i,jone) ) / 2 ;
1514 ione = ione / 2 ;
if ( ione < 1 ) ione = 1 ;
1515 jone = jone / 2 ;
if ( jone < 1 ) jone = 1 ;
1521 AliSysInfo::AddStamp(
"CalcField", 100,0,0);
1523 for ( Int_t m = 0 ; m < phislices ; m++ ) {
1524 TMatrixD& arrayV = *arrayofArrayV[m] ;
1525 TMatrixD& eroverEz = *arrayofEroverEz[m] ;
1527 for ( Int_t j = columns-1 ; j >= 0 ; j-- ) {
1530 for ( Int_t i = 1 ; i < rows-1 ; i++ ) arrayE(i,j) = -1 * ( arrayV(i+1,j) - arrayV(i-1,j) ) / (2*gridSizeR) ;
1531 arrayE(0,j) = -1 * ( -0.5*arrayV(2,j) + 2.0*arrayV(1,j) - 1.5*arrayV(0,j) ) / gridSizeR ;
1532 arrayE(rows-1,j) = -1 * ( 1.5*arrayV(rows-1,j) - 2.0*arrayV(rows-2,j) + 0.5*arrayV(rows-3,j) ) / gridSizeR ;
1534 for ( Int_t i = 0 ; i < rows ; i++ ) {
1536 eroverEz(i,j) = 0.0 ;
1538 for ( Int_t k = j ; k < columns ; k++ ) {
1540 eroverEz(i,j) += index*(gridSizeZ/3.0)*arrayE(i,k)/(-1*ezField) ;
1541 if ( index != 4 ) index = 4;
else index = 2 ;
1543 if ( index == 4 ) eroverEz(i,j) -= (gridSizeZ/3.0)*arrayE(i,columns-1)/ (-1*ezField) ;
1544 if ( index == 2 ) eroverEz(i,j) +=
1545 (gridSizeZ/3.0)*(0.5*arrayE(i,columns-2)-2.5*arrayE(i,columns-1))/(-1*ezField) ;
1546 if ( j == columns-2 ) eroverEz(i,j) =
1547 (gridSizeZ/3.0)*(1.5*arrayE(i,columns-2)+1.5*arrayE(i,columns-1))/(-1*ezField) ;
1548 if ( j == columns-1 ) eroverEz(i,j) = 0.0 ;
1550 eroverEz(i,j) = arrayE(i,j)/(-1*ezField);
1553 if ( j == columns-2 ) eroverEz(i,j) =
1554 (0.5*arrayE(i,columns-2)+0.5*arrayE(i,columns-1))/(-1*ezField) ;
1555 if ( j == columns-1 ) eroverEz(i,j) = 0.0 ;
1557 if ( j == 2 ) eroverEz(i,j) =
1558 (0.5*arrayE(i,2)+0.5*arrayE(i,1))/(-1*ezField) ;
1559 if ( j == 1 ) eroverEz(i,j) = 0.0 ;
1566 AliSysInfo::AddStamp(
"IntegrateEr", 120,0,0);
1571 for ( Int_t m = 0 ; m < phislices ; m++ ) {
1573 mplus = m + 1; signplus = 1 ;
1574 mminus = m - 1 ; signminus = 1 ;
1576 if ( mplus > phislices-1 ) mplus = phislices - 2 ;
1577 if ( mminus < 0 ) mminus = 1 ;
1579 else if (symmetry==-1) {
1580 if ( mplus > phislices-1 ) { mplus = phislices - 2 ; signplus = -1 ; }
1581 if ( mminus < 0 ) { mminus = 1 ; signminus = -1 ; }
1584 if ( mplus > phislices-1 ) mplus = m + 1 - phislices ;
1585 if ( mminus < 0 ) mminus = m - 1 + phislices ;
1587 TMatrixD &arrayVP = *arrayofArrayV[mplus] ;
1588 TMatrixD &arrayVM = *arrayofArrayV[mminus] ;
1589 TMatrixD &ePhioverEz = *arrayofEPhioverEz[m] ;
1590 for ( Int_t j = columns-1 ; j >= 0 ; j-- ) {
1592 for ( Int_t i = 0 ; i < rows ; i++ ) {
1594 arrayE(i,j) = -1 * (signplus * arrayVP(i,j) - signminus * arrayVM(i,j) ) / (2*radius*gridSizePhi) ;
1597 for ( Int_t i = 0 ; i < rows ; i++ ) {
1599 ePhioverEz(i,j) = 0.0 ;
1601 for ( Int_t k = j ; k < columns ; k++ ) {
1603 ePhioverEz(i,j) += index*(gridSizeZ/3.0)*arrayE(i,k)/(-1*ezField) ;
1604 if ( index != 4 ) index = 4;
else index = 2 ;
1606 if ( index == 4 ) ePhioverEz(i,j) -= (gridSizeZ/3.0)*arrayE(i,columns-1)/ (-1*ezField) ;
1607 if ( index == 2 ) ePhioverEz(i,j) +=
1608 (gridSizeZ/3.0)*(0.5*arrayE(i,columns-2)-2.5*arrayE(i,columns-1))/(-1*ezField) ;
1609 if ( j == columns-2 ) ePhioverEz(i,j) =
1610 (gridSizeZ/3.0)*(1.5*arrayE(i,columns-2)+1.5*arrayE(i,columns-1))/(-1*ezField) ;
1611 if ( j == columns-1 ) ePhioverEz(i,j) = 0.0 ;
1613 ePhioverEz(i,j) = arrayE(i,j)/(-1*ezField);
1614 if ( j == columns-2 ) ePhioverEz(i,j) =
1615 (0.5*arrayE(i,columns-2)+0.5*arrayE(i,columns-1))/(-1*ezField) ;
1616 if ( j == columns-1 ) ePhioverEz(i,j) = 0.0 ;
1618 if ( j == 2 ) ePhioverEz(i,j) =
1619 (0.5*arrayE(i,2)+0.5*arrayE(i,1))/(-1*ezField) ;
1620 if ( j == 1 ) ePhioverEz(i,j) = 0.0 ;
1627 AliSysInfo::AddStamp(
"IntegrateEphi", 130,0,0);
1633 for ( Int_t m = 0 ; m < phislices ; m++ ) {
1634 TMatrixD& arrayV = *arrayofArrayV[m] ;
1635 TMatrixD& deltaEz = *arrayofDeltaEz[m] ;
1638 for ( Int_t i = 0 ; i < rows ; i++) {
1639 for ( Int_t j = 1 ; j < columns-1 ; j++ ) arrayE(i,j) = -1 * ( arrayV(i,j+1) - arrayV(i,j-1) ) / (2*gridSizeZ) ;
1640 arrayE(i,0) = -1 * ( -0.5*arrayV(i,2) + 2.0*arrayV(i,1) - 1.5*arrayV(i,0) ) / gridSizeZ ;
1641 arrayE(i,columns-1) = -1 * ( 1.5*arrayV(i,columns-1) - 2.0*arrayV(i,columns-2) + 0.5*arrayV(i,columns-3) ) / gridSizeZ ;
1644 for ( Int_t j = columns-1 ; j >= 0 ; j-- ) {
1646 for ( Int_t i = 0 ; i < rows ; i++ ) {
1648 deltaEz(i,j) = 0.0 ;
1650 for ( Int_t k = j ; k < columns ; k++ ) {
1651 deltaEz(i,j) += index*(gridSizeZ/3.0)*arrayE(i,k) ;
1652 if ( index != 4 ) index = 4;
else index = 2 ;
1654 if ( index == 4 ) deltaEz(i,j) -= (gridSizeZ/3.0)*arrayE(i,columns-1) ;
1655 if ( index == 2 ) deltaEz(i,j) +=
1656 (gridSizeZ/3.0)*(0.5*arrayE(i,columns-2)-2.5*arrayE(i,columns-1)) ;
1657 if ( j == columns-2 ) deltaEz(i,j) =
1658 (gridSizeZ/3.0)*(1.5*arrayE(i,columns-2)+1.5*arrayE(i,columns-1)) ;
1659 if ( j == columns-1 ) deltaEz(i,j) = 0.0 ;
1661 deltaEz(i,j) = arrayE(i,j) ;
1662 if ( j == columns-2 ) deltaEz(i,j) =
1663 (0.5*arrayE(i,columns-2)+0.5*arrayE(i,columns-1)) ;
1664 if ( j == columns-1 ) deltaEz(i,j) = 0.0 ;
1665 if ( j == 2 ) deltaEz(i,j) =
1666 (0.5*arrayE(i,2)+0.5*arrayE(i,1)) ;
1667 if ( j == 1 ) deltaEz(i,j) = 0.0 ;
1678 for ( Int_t j = 0 ; j < columns ; j++ ) {
1679 for ( Int_t i = 0 ; i < rows ; i++ ) {
1682 deltaEz(i,j) = deltaEz(i,j)*
fgkdvdE;
1685 Double_t dzROCShift = arrayV(i, columns -1)/ezField;
1686 if ( rocDisplacement ) deltaEz(i,j) = deltaEz(i,j) + dzROCShift;
1692 AliSysInfo::AddStamp(
"IntegrateEz", 140,0,0);
1695 for ( Int_t k = 0 ; k < phislices ; k++ )
1697 arrayofSumChargeDensities[k]->Delete() ;
1710 while( i > 0 ) { j += (i&1) ; i = (i>>1) ; }
1711 if ( j == 1 )
return(1) ;
1739 const Double_t kMaxSnp = 0.85;
1740 const Double_t kSigmaY=0.1;
1741 const Double_t kSigmaZ=0.1;
1742 const Double_t kMaxR=500;
1743 const Double_t kMaxZ=500;
1745 const Double_t kMaxZ0=220;
1746 const Double_t kZcut=3;
1747 const Double_t kMass = TDatabasePDG::Instance()->GetParticle(
"pi+")->Mass();
1751 AliExternalTrackParam
track(trackIn);
1753 AliTrackPointArray pointArray0(npoints0);
1754 AliTrackPointArray pointArray1(npoints0);
1756 if (!AliTrackerBase::PropagateTrackTo(&track,kRTPC0,kMass,5,
kTRUE,kMaxSnp))
return 0;
1760 Float_t covPoint[6]={0,0,0,
static_cast<Float_t
>(kSigmaY*kSigmaY),0,static_cast<Float_t>(kSigmaZ*kSigmaZ)};
1761 for (Double_t radius=kRTPC0; radius<kRTPC1; radius++){
1762 if (!AliTrackerBase::PropagateTrackTo(&track,radius,kMass,5,
kTRUE,kMaxSnp))
return 0;
1764 xyz[0]+=gRandom->Gaus(0,0.000005);
1765 xyz[1]+=gRandom->Gaus(0,0.000005);
1766 xyz[2]+=gRandom->Gaus(0,0.000005);
1767 if (TMath::Abs(track.GetZ())>kMaxZ0)
continue;
1768 if (TMath::Abs(track.GetX())<kRTPC0)
continue;
1769 if (TMath::Abs(track.GetX())>kRTPC1)
continue;
1772 Int_t
sector= (xyz[2]>0)? 0:18;
1773 pointArray0.GetPoint(pIn0,npoints);
1774 pointArray1.GetPoint(pIn1,npoints);
1775 Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
1776 Float_t distPoint[3]={
static_cast<Float_t
>(xyz[0]),static_cast<Float_t>(xyz[1]),
static_cast<Float_t
>(xyz[2])};
1778 pIn0.SetXYZ(xyz[0], xyz[1],xyz[2]);
1779 pIn1.SetXYZ(distPoint[0], distPoint[1],distPoint[2]);
1781 track.Rotate(alpha);
1782 AliTrackPoint prot0 = pIn0.Rotate(alpha);
1783 AliTrackPoint prot1 = pIn1.Rotate(alpha);
1784 prot0.SetXYZ(prot0.GetX(),prot0.GetY(), prot0.GetZ(),covPoint);
1785 prot1.SetXYZ(prot1.GetX(),prot1.GetY(), prot1.GetZ(),covPoint);
1786 pIn0=prot0.Rotate(-alpha);
1787 pIn1=prot1.Rotate(-alpha);
1788 pointArray0.AddPoint(npoints, &pIn0);
1789 pointArray1.AddPoint(npoints, &pIn1);
1791 if (npoints>=npoints0)
break;
1793 if (npoints<npoints0/4.)
return 0;
1797 AliExternalTrackParam *track0=0;
1798 AliExternalTrackParam *track1=0;
1799 AliTrackPoint point1,point2,point3;
1801 pointArray0.GetPoint(point1,1);
1802 pointArray0.GetPoint(point2,11);
1803 pointArray0.GetPoint(point3,21);
1806 pointArray0.GetPoint(point1,npoints-21);
1807 pointArray0.GetPoint(point2,npoints-11);
1808 pointArray0.GetPoint(point3,npoints-1);
1810 if ((TMath::Abs(point1.GetX()-point3.GetX())+TMath::Abs(point1.GetY()-point3.GetY()))<10){
1811 printf(
"fit points not properly initialized\n");
1814 track0 = AliTrackerBase::MakeSeed(point1, point2, point3);
1815 track1 = AliTrackerBase::MakeSeed(point1, point2, point3);
1816 track0->ResetCovariance(10);
1817 track1->ResetCovariance(10);
1818 if (TMath::Abs(AliTrackerBase::GetBz())<0.01){
1819 ((Double_t*)track0->GetParameter())[4]= trackIn.GetParameter()[4];
1820 ((Double_t*)track1->GetParameter())[4]= trackIn.GetParameter()[4];
1822 for (Int_t jpoint=0; jpoint<
npoints; jpoint++){
1823 Int_t ipoint= (dir>0) ? jpoint: npoints-1-jpoint;
1827 pointArray0.GetPoint(pIn0,ipoint);
1828 pointArray1.GetPoint(pIn1,ipoint);
1829 AliTrackPoint prot0 = pIn0.Rotate(track0->GetAlpha());
1830 AliTrackPoint prot1 = pIn1.Rotate(track1->GetAlpha());
1831 if (TMath::Abs(prot0.GetX())<kRTPC0)
continue;
1832 if (TMath::Abs(prot0.GetX())>kRTPC1)
continue;
1834 if (!AliTrackerBase::PropagateTrackTo(track0,prot0.GetX(),kMass,5,kFALSE,kMaxSnp))
break;
1835 if (!AliTrackerBase::PropagateTrackTo(track1,prot0.GetX(),kMass,5,kFALSE,kMaxSnp))
break;
1836 if (TMath::Abs(track0->GetZ())>kMaxZ)
break;
1837 if (TMath::Abs(track0->GetX())>kMaxR)
break;
1838 if (TMath::Abs(track1->GetZ())>kMaxZ)
break;
1839 if (TMath::Abs(track1->GetX())>kMaxR)
break;
1840 if (dir>0 && track1->GetX()>refX)
continue;
1841 if (dir<0 && track1->GetX()<refX)
continue;
1842 if (TMath::Abs(track1->GetZ())<kZcut)
continue;
1845 Double_t pointPos[2]={0,0};
1846 Double_t pointCov[3]={0,0,0};
1847 pointPos[0]=prot0.GetY();
1848 pointPos[1]=prot0.GetZ();
1849 pointCov[0]=prot0.GetCov()[3];
1850 pointCov[1]=prot0.GetCov()[4];
1851 pointCov[2]=prot0.GetCov()[5];
1852 if (!track0->Update(pointPos,pointCov))
break;
1854 Double_t deltaX=prot1.GetX()-prot0.GetX();
1855 Double_t deltaYX=deltaX*TMath::Tan(TMath::ASin(track1->GetSnp()));
1856 Double_t deltaZX=deltaX*track1->GetTgl();
1858 pointPos[0]=prot1.GetY()-deltaYX;
1859 pointPos[1]=prot1.GetZ()-deltaZX;
1860 pointCov[0]=prot1.GetCov()[3];
1861 pointCov[1]=prot1.GetCov()[4];
1862 pointCov[2]=prot1.GetCov()[5];
1863 if (!track1->Update(pointPos,pointCov))
break;
1867 if (npoints2<npoints/4.)
return 0;
1868 AliTrackerBase::PropagateTrackTo(track0,refX,kMass,5.,
kTRUE,kMaxSnp);
1869 AliTrackerBase::PropagateTrackTo(track0,refX,kMass,1.,
kTRUE,kMaxSnp);
1870 track1->Rotate(track0->GetAlpha());
1871 AliTrackerBase::PropagateTrackTo(track1,track0->GetX(),kMass,5.,kFALSE,kMaxSnp);
1873 if (pcstream) (*pcstream)<<Form(
"fitDistort%s",GetName())<<
1874 "point0.="<<&pointArray0<<
1875 "point1.="<<&pointArray1<<
1876 "trackIn.="<<&track<<
1877 "track0.="<<track0<<
1878 "track1.="<<track1<<
1880 new(&trackIn) AliExternalTrackParam(*track0);
1897 if (type<0 || type>1) {
1898 AliError(
"Unknown type");
1902 TTreeSRedirector *pcstream =
new TTreeSRedirector(Form(
"correction%s.root",GetName()));
1909 AliMagF*
mag= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1910 if (!mag) AliError(
"Magnetic field - not initialized");
1912 for (Double_t x= -250; x<250; x+=step){
1913 for (Double_t y= -250; y<250; y+=step){
1914 Double_t
r = TMath::Sqrt(x*x+y*y);
1916 if (r>250)
continue;
1918 Double_t
phi = TMath::ATan2(y,x);
1920 for (Double_t z= -250; z<250; z+=step){
1921 Int_t roc=(z>0)?0:18;
1930 }
else if (type==1) {
1935 for (Int_t i=0; i<3; ++i) {
1936 xyzdist[i]=xyz[i]+dist[i];
1937 xyzcorr[i]=xyz[i]+corr[i];
1941 Double_t rdist = TMath::Sqrt(xyzdist[0]*xyzdist[0]+xyzdist[1]*xyzdist[1]);
1942 Double_t phidist = TMath::ATan2(xyzdist[1],xyzdist[0]);
1943 if ((phidist-phi)>TMath::Pi()) phidist-=TMath::Pi();
1944 if ((phidist-phi)<-TMath::Pi()) phidist+=TMath::Pi();
1946 Double_t drdist=rdist-
r;
1947 Double_t drphidist=(phidist-
phi)*r;
1950 Double_t rcorr = TMath::Sqrt(xyzcorr[0]*xyzcorr[0]+xyzcorr[1]*xyzcorr[1]);
1951 Double_t phicorr = TMath::ATan2(xyzcorr[1],xyzcorr[0]);
1952 if ((phicorr-phi)>TMath::Pi()) phicorr-=TMath::Pi();
1953 if ((phicorr-phi)<-TMath::Pi()) phicorr+=TMath::Pi();
1955 Double_t drcorr=rcorr-
r;
1956 Double_t drphicorr=(phicorr-
phi)*r;
1959 Double_t bxyz[3]={0.,0.,0.};
1960 Double_t dblxyz[3] = {Double_t(xyzdist[0]),Double_t(xyzdist[1]),Double_t(xyzdist[2])};
1964 mag->Field(dblxyz,bxyz);
1966 br = (bxyz[0]*xyz[0]+bxyz[1]*xyz[1])/rdist;
1967 brfi = (-bxyz[0]*xyz[1]+bxyz[1]*xyz[0])/rdist;
1971 (*pcstream)<<
"distortion"<<
1978 "x_dist=" << xyzdist[0] <<
1979 "y_dist=" << xyzdist[1] <<
1980 "z_dist=" << xyzdist[2] <<
1981 "r_dist=" << rdist <<
1982 "phi_dist=" << phidist <<
1984 "dx_dist=" << dist[0] <<
1985 "dy_dist=" << dist[1] <<
1986 "dz_dist=" << dist[2] <<
1987 "dr_dist=" << drdist <<
1988 "drphi_dist="<< drphidist <<
1991 "x_corr=" << xyzcorr[0] <<
1992 "y_corr=" << xyzcorr[1] <<
1993 "z_corr=" << xyzcorr[2] <<
1994 "r_corr=" << rcorr <<
1995 "phi_corr=" << phicorr <<
1997 "dx_corr=" << corr[0] <<
1998 "dy_corr=" << corr[1] <<
1999 "dz_corr=" << corr[2] <<
2000 "dr_corr=" << drcorr <<
2001 "drphi_corr="<< drphicorr <<
2013 TFile
f(Form(
"correction%s.root",GetName()));
2014 TTree *
tree = (TTree*)f.Get(
"distortion");
2015 TTree * tree2= tree->CopyTree(
"1");
2016 tree2->SetName(Form(
"dist%s",GetName()));
2017 tree2->SetDirectory(0);
2041 const Double_t kMaxSnp = 0.85;
2042 const Double_t kcutSnp=0.25;
2043 const Double_t kcutTheta=1.;
2044 const Double_t kRadiusTPC=85;
2047 const Double_t kMass = TDatabasePDG::Instance()->GetParticle(
"pi+")->Mass();
2049 const Int_t kMinEntries=20;
2053 tinput->SetBranchAddress(
"run",&run);
2054 tinput->SetBranchAddress(
"theta",&theta);
2055 tinput->SetBranchAddress(
"phi", &phi);
2056 tinput->SetBranchAddress(
"snp",&snp);
2057 tinput->SetBranchAddress(
"mean",&mean);
2058 tinput->SetBranchAddress(
"rms",&rms);
2059 tinput->SetBranchAddress(
"entries",&entries);
2060 tinput->SetBranchAddress(
"sector",§or);
2061 tinput->SetBranchAddress(
"dsec",&dsec);
2062 tinput->SetBranchAddress(
"refX",&refX);
2063 TTreeSRedirector *pcstream =
new TTreeSRedirector(Form(
"distortion%d_%d_%d.root",dtype,ptype,offset));
2065 Int_t nentries=tinput->GetEntries();
2066 Int_t ncorr=corrArray->GetEntries();
2067 Double_t corrections[100]={0};
2069 Double_t cov[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2071 if (dtype==5 || dtype==6) dtype=4;
2072 if (dtype==0) { dir=-1;}
2073 if (dtype==1) { dir=1;}
2074 if (dtype==2) { dir=-1;}
2075 if (dtype==3) { dir=1;}
2076 if (dtype==4) { dir=-1;}
2078 for (Int_t ientry=offset; ientry<nentries; ientry+=step){
2079 tinput->GetEntry(ientry);
2080 if (TMath::Abs(snp)>kMaxSnp)
continue;
2083 if (dtype==2) tPar[1]=theta*kRadiusTPC;
2086 tPar[4]=(gRandom->Rndm()-0.5)*0.02;
2093 if (TMath::Abs(snp) >kcutSnp)
continue;
2094 if (TMath::Abs(theta) >kcutTheta)
continue;
2095 printf(
"%f\t%f\t%f\t%f\t%f\t%f\n",entries, sector,theta,snp, mean,rms);
2096 Double_t bz=AliTrackerBase::GetBz();
2098 if (dtype!=2 && TMath::Abs(bz)>0.1 ) tPar[4]=snp/(refX*bz*kB2C*2);
2100 if (dtype==2 && TMath::Abs(bz)>0.1 ) {
2101 tPar[4]=snp/(kRadiusTPC*bz*kB2C*2);
2106 tPar[4]+=(gRandom->Rndm()-0.5)*0.02;
2107 AliExternalTrackParam
track(refX,phi,tPar,cov);
2111 Double_t pt=1./tPar[4];
2114 Double_t refXD=refX;
2115 (*pcstream)<<
"fit"<<
2134 "entries="<<entries;
2137 if (entries<kMinEntries) isOK=kFALSE;
2139 if (dtype!=4)
for (Int_t icorr=0; icorr<ncorr; icorr++) {
2141 corrections[icorr]=0;
2142 if (entries>kMinEntries){
2143 AliExternalTrackParam trackIn(refX,phi,tPar,cov);
2144 AliExternalTrackParam *trackOut = 0;
2147 if (dtype==0) {dir= -1;}
2148 if (dtype==1) {dir= 1;}
2149 if (dtype==2) {dir= -1;}
2150 if (dtype==3) {dir= 1;}
2153 if (!AliTrackerBase::PropagateTrackTo(&trackIn,refX,kMass,5,
kTRUE,kMaxSnp)) isOK=kFALSE;
2154 if (!trackOut->Rotate(trackIn.GetAlpha())) isOK=kFALSE;
2155 if (!AliTrackerBase::PropagateTrackTo(trackOut,trackIn.GetX(),kMass,5,kFALSE,kMaxSnp)) isOK=kFALSE;
2158 corrections[icorr]= trackOut->GetParameter()[ptype]-trackIn.GetParameter()[ptype];
2161 corrections[icorr]=0;
2166 (*pcstream)<<
"fit"<<
2167 Form(
"%s=",corr->GetName())<<corrections[icorr];
2170 if (dtype==4)
for (Int_t icorr=0; icorr<ncorr; icorr++) {
2175 corrections[icorr]=0;
2176 if (entries>kMinEntries){
2177 AliExternalTrackParam trackIn0(refX,phi,tPar,cov);
2178 AliExternalTrackParam trackIn1(refX,phi,tPar,cov);
2179 AliExternalTrackParam *trackOut0 = 0;
2180 AliExternalTrackParam *trackOut1 = 0;
2187 if (trackOut0 && trackOut1){
2188 if (!AliTrackerBase::PropagateTrackTo(&trackIn0,refX,kMass,5,
kTRUE,kMaxSnp)) isOK=kFALSE;
2189 if (!AliTrackerBase::PropagateTrackTo(&trackIn0,refX,kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2190 if (!trackOut0->Rotate(trackIn0.GetAlpha())) isOK=kFALSE;
2191 if (!AliTrackerBase::PropagateTrackTo(trackOut0,trackIn0.GetX(),kMass,5,kFALSE,kMaxSnp)) isOK=kFALSE;
2193 if (!AliTrackerBase::PropagateTrackTo(&trackIn1,refX,kMass,5,
kTRUE,kMaxSnp)) isOK=kFALSE;
2194 if (!trackIn1.Rotate(trackIn0.GetAlpha())) isOK=kFALSE;
2195 if (!AliTrackerBase::PropagateTrackTo(&trackIn1,trackIn0.GetX(),kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2196 if (!trackOut1->Rotate(trackIn1.GetAlpha())) isOK=kFALSE;
2197 if (!AliTrackerBase::PropagateTrackTo(trackOut1,trackIn1.GetX(),kMass,5,kFALSE,kMaxSnp)) isOK=kFALSE;
2199 corrections[icorr] = (trackOut0->GetParameter()[ptype]-trackIn0.GetParameter()[ptype]);
2200 corrections[icorr]-= (trackOut1->GetParameter()[ptype]-trackIn1.GetParameter()[ptype]);
2202 if ((TMath::Abs(trackOut0->GetX()-trackOut1->GetX())>0.1)||
2203 (TMath::Abs(trackOut0->GetX()-trackIn1.GetX())>0.1)||
2204 (TMath::Abs(trackOut0->GetAlpha()-trackOut1->GetAlpha())>0.00001)||
2205 (TMath::Abs(trackOut0->GetAlpha()-trackIn1.GetAlpha())>0.00001)||
2206 (TMath::Abs(trackIn0.GetTgl()-trackIn1.GetTgl())>0.0001)||
2207 (TMath::Abs(trackIn0.GetSnp()-trackIn1.GetSnp())>0.0001)
2214 corrections[icorr]=0;
2220 (*pcstream)<<
"fit"<<
2221 Form(
"%s=",corr->GetName())<<corrections[icorr];
2224 (*pcstream)<<
"fit"<<
"isOK="<<isOK<<
"\n";
2249 const Double_t kMaxSnp = 0.8;
2250 const Int_t kMinEntries=200;
2253 const Double_t kMass = TDatabasePDG::Instance()->GetParticle(
"pi+")->Mass();
2260 tinput->SetBranchAddress(
"run",&run);
2261 tinput->SetBranchAddress(
"theta",&theta);
2262 tinput->SetBranchAddress(
"phi", &phi);
2263 tinput->SetBranchAddress(
"snp",&snp);
2264 tinput->SetBranchAddress(
"mean",&mean);
2265 tinput->SetBranchAddress(
"rms",&rms);
2266 tinput->SetBranchAddress(
"entries",&entries);
2267 tinput->SetBranchAddress(
"sector",§or);
2268 tinput->SetBranchAddress(
"dsec",&dsec);
2269 tinput->SetBranchAddress(
"refX",&refXD);
2270 tinput->SetBranchAddress(
"z",&globalZ);
2271 tinput->SetBranchAddress(
"isec0",&isec0);
2272 tinput->SetBranchAddress(
"isec1",&isec1);
2273 TTreeSRedirector *pcstream =
new TTreeSRedirector(Form(
"distortionSector%d_%d_%d.root",dtype,ptype,offset));
2275 Int_t nentries=tinput->GetEntries();
2276 Int_t ncorr=corrArray->GetEntries();
2277 Double_t corrections[100]={0};
2279 Double_t cov[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2282 for (Int_t ientry=offset; ientry<nentries; ientry+=step){
2283 tinput->GetEntry(ientry);
2286 if (TMath::Abs(TMath::Abs(isec0%18)-TMath::Abs(isec1%18))==0)
id=1;
2287 if (TMath::Abs(TMath::Abs(isec0%36)-TMath::Abs(isec1%36))==0)
id=2;
2288 if (dtype==10 &&
id==-1)
continue;
2295 tPar[4]=(gRandom->Rndm()-0.1)*0.2;
2296 Double_t pt=1./tPar[4];
2298 printf(
"%f\t%f\t%f\t%f\t%f\t%f\n",entries, sector,theta,snp, mean,rms);
2299 Double_t bz=AliTrackerBase::GetBz();
2300 AliExternalTrackParam
track(refX,phi,tPar,cov);
2301 Double_t xyz[3],xyzIn[3],xyzOut[3];
2303 track.GetXYZAt(85,bz,xyzIn);
2304 track.GetXYZAt(245,bz,xyzOut);
2305 Double_t phiIn = TMath::ATan2(xyzIn[1],xyzIn[0]);
2306 Double_t phiOut = TMath::ATan2(xyzOut[1],xyzOut[0]);
2307 Double_t phiRef = TMath::ATan2(xyz[1],xyz[0]);
2308 Int_t sectorRef = TMath::Nint(9.*phiRef/TMath::Pi()-0.5);
2309 Int_t sectorIn = TMath::Nint(9.*phiIn/TMath::Pi()-0.5);
2310 Int_t sectorOut = TMath::Nint(9.*phiOut/TMath::Pi()-0.5);
2313 if (sectorIn!=sectorOut) isOK=kFALSE;
2314 if (sectorIn!=sectorRef) isOK=kFALSE;
2315 if (entries<kMinEntries/(1+TMath::Abs(globalZ/100.))) isOK=kFALSE;
2317 if (TMath::Abs(theta)>1) isOK=kFALSE;
2321 (*pcstream)<<
"fit"<<
2340 "entries="<<entries;
2342 AliExternalTrackParam *trackOut0 = 0;
2343 AliExternalTrackParam *trackOut1 = 0;
2344 AliExternalTrackParam *ptrackIn0 = 0;
2345 AliExternalTrackParam *ptrackIn1 = 0;
2347 for (Int_t icorr=0; icorr<ncorr; icorr++) {
2352 corrections[icorr]=0;
2353 if (entries>kMinEntries &&isOK){
2354 AliExternalTrackParam trackIn0(refX,phi,tPar,cov);
2355 AliExternalTrackParam trackIn1(refX,phi,tPar,cov);
2356 ptrackIn1=&trackIn0;
2357 ptrackIn0=&trackIn1;
2364 if (trackOut0 && trackOut1){
2366 if (!AliTrackerBase::PropagateTrackTo(&trackIn0,refX,kMass,1,
kTRUE,kMaxSnp)) isOK=kFALSE;
2367 if (!AliTrackerBase::PropagateTrackTo(&trackIn0,refX,kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2369 if (!trackOut0->Rotate(trackIn0.GetAlpha())) isOK=kFALSE;
2370 if (!trackIn1.Rotate(trackIn0.GetAlpha())) isOK=kFALSE;
2371 if (!trackOut1->Rotate(trackIn0.GetAlpha())) isOK=kFALSE;
2373 if (!AliTrackerBase::PropagateTrackTo(trackOut0,refX,kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2374 if (!AliTrackerBase::PropagateTrackTo(&trackIn1,refX,kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2375 if (!AliTrackerBase::PropagateTrackTo(trackOut1,refX,kMass,1,kFALSE,kMaxSnp)) isOK=kFALSE;
2377 corrections[icorr] = (trackOut0->GetParameter()[ptype]-trackIn0.GetParameter()[ptype]);
2378 corrections[icorr]-= (trackOut1->GetParameter()[ptype]-trackIn1.GetParameter()[ptype]);
2379 (*pcstream)<<
"fitDebug"<<
2381 "pIn0.="<<ptrackIn0<<
2382 "pIn1.="<<ptrackIn1<<
2383 "pOut0.="<<trackOut0<<
2384 "pOut1.="<<trackOut1<<
2390 corrections[icorr]=0;
2394 (*pcstream)<<
"fit"<<
2395 Form(
"%s=",corr->GetName())<<corrections[icorr];
2398 (*pcstream)<<
"fit"<<
"isOK="<<isOK<<
"\n";
2408 const Double_t cutErrY=0.1;
2409 const Double_t cutErrZ=0.1;
2410 const Double_t
kEpsilon=0.00000001;
2411 const Double_t kMaxDist=1.;
2412 const Double_t kMaxRMS=0.05;
2419 tree->SetBranchAddress(
"dY.",&vecdY);
2420 tree->SetBranchAddress(
"dZ.",&vecdZ);
2421 tree->SetBranchAddress(
"eY.",&veceY);
2422 tree->SetBranchAddress(
"eZ.",&veceZ);
2423 tree->SetBranchAddress(
"LTr.",<r);
2424 Int_t entries= tree->GetEntries();
2425 TTreeSRedirector *pcstream=
new TTreeSRedirector(
"distortionLaser_0.root");
2426 Double_t bz=AliTrackerBase::GetBz();
2429 for (Int_t ientry=0; ientry<entries; ientry++){
2430 tree->GetEntry(ientry);
2434 TVectorD * delta= (itype==0)? vecdY:vecdZ;
2435 TVectorD * err= (itype==0)? veceY:veceZ;
2436 TLinearFitter fitter(2,
"pol1");
2437 for (Int_t iter=0; iter<2; iter++){
2438 Double_t kfit0=0, kfit1=0;
2439 Int_t npoints=fitter.GetNpoints();
2442 kfit0=fitter.GetParameter(0);
2443 kfit1=fitter.GetParameter(1);
2445 for (Int_t irow=0; irow<159; irow++){
2448 Int_t nentries = 1000;
2449 if (veceY->GetMatrixArray()[irow]>cutErrY||veceZ->GetMatrixArray()[irow]>cutErrZ) nentries=0;
2450 if (veceY->GetMatrixArray()[irow]<kEpsilon||veceZ->GetMatrixArray()[irow]<
kEpsilon) nentries=0;
2453 Int_t first3=TMath::Max(irow-3,0);
2454 Int_t last3 =TMath::Min(irow+3,159-1);
2456 if ((*ltr->
GetVecSec())[irow]>=0 && err) {
2457 for (Int_t jrow=first3; jrow<=last3; jrow++){
2459 if ((*err)[jrow]<
kEpsilon)
continue;
2460 array[counter]=(*delta)[jrow];
2467 rms3 = TMath::RMS(counter,array);
2468 mean3 = TMath::Mean(counter,array);
2473 Double_t
theta =ltr->GetTgl();
2474 Double_t mean=delta->GetMatrixArray()[irow];
2475 Double_t gx=0,gy=0,gz=0;
2476 Double_t snp = (*ltr->
GetVecP2())[irow];
2489 Double_t oldR=TMath::Sqrt(gx*gx+gy*gy);
2490 Double_t fphi = TMath::ATan2(gy,gx);
2491 Double_t fsector = 9.*fphi/TMath::Pi();
2492 if (fsector<0) fsector+=18;
2493 Double_t dsec = fsector-Int_t(fsector)-0.5;
2495 Int_t
id= ltr->
GetId();
2499 Float_t xyz1[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
2500 Int_t
sector=(gz>0)?0:18;
2502 refX=TMath::Sqrt(xyz1[0]*xyz1[0]+xyz1[1]*xyz1[1]);
2505 if (TMath::Abs(rms3)>kMaxRMS) isOK=kFALSE;
2506 if (TMath::Abs(mean-mean3)>kMaxRMS) isOK=kFALSE;
2507 if (counter<4) isOK=kFALSE;
2508 if (npoints<90) isOK=kFALSE;
2510 fitter.AddPoint(&refX,mean);
2512 Double_t deltaF=kfit0+kfit1*refX;
2514 (*pcstream)<<
"fitFull"<<
2524 "npoints="<<npoints<<
2527 "counter="<<counter<<
2528 "sector="<<fsector<<
2537 "entries="<<nentries<<
2540 if (iter==1) (*pcstream)<<
"fit"<<
2549 "sector="<<fsector<<
2559 "entries="<<nentries;
2562 Double_t ky = TMath::Tan(TMath::ASin(snp));
2563 Int_t ncorr = corrArray->GetEntries();
2564 Double_t r0 = TMath::Sqrt(gx*gx+gy*gy);
2565 Double_t phi0 = TMath::ATan2(gy,gx);
2566 Double_t distortions[1000]={0};
2567 Double_t distortionsR[1000]={0};
2569 for (Int_t icorr=0; icorr<ncorr; icorr++) {
2571 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
2572 Int_t
sector= (gz>0)? 0:18;
2577 if (itype==0 && r0>1){
2578 Double_t r1 = TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
2579 Double_t phi1 = TMath::ATan2(distPoint[1],distPoint[0]);
2580 Double_t drphi= r0*(phi1-phi0);
2581 Double_t dr = r1-r0;
2582 distortions[icorr] = drphi-ky*dr;
2583 distortionsR[icorr] = dr;
2585 if (TMath::Abs(distortions[icorr])>kMaxDist) {isOKF=icorr+1; isOK=kFALSE; }
2586 if (TMath::Abs(distortionsR[icorr])>kMaxDist) {isOKF=icorr+1; isOK=kFALSE;}
2587 (*pcstream)<<
"fit"<<
2588 Form(
"%s=",corr->GetName())<<distortions[icorr];
2590 (*pcstream)<<
"fit"<<
"isOK="<<isOK<<
"\n";
2616 const Int_t kMinEntries=10;
2617 Double_t bz=AliTrackerBase::GetBz();
2618 Int_t idim[4]={0,1,2,3};
2622 Int_t nbins3=his0->GetAxis(3)->GetNbins();
2623 Int_t first3=his0->GetAxis(3)->GetFirst();
2624 Int_t last3 =his0->GetAxis(3)->GetLast();
2626 for (Int_t ibin3=first3; ibin3<last3; ibin3+=1){
2627 his0->GetAxis(3)->SetRange(TMath::Max(ibin3-integ,1),TMath::Min(ibin3+integ,nbins3));
2628 Double_t x3= his0->GetAxis(3)->GetBinCenter(ibin3);
2629 THnSparse * his3= his0->Projection(3,idim);
2631 Int_t nbins2 = his3->GetAxis(2)->GetNbins();
2632 Int_t first2 = his3->GetAxis(2)->GetFirst();
2633 Int_t last2 = his3->GetAxis(2)->GetLast();
2635 for (Int_t ibin2=first2; ibin2<last2; ibin2+=1){
2636 his3->GetAxis(2)->SetRange(TMath::Max(ibin2-integ,1),TMath::Min(ibin2+integ,nbins2));
2637 Double_t x2= his3->GetAxis(2)->GetBinCenter(ibin2);
2638 THnSparse * his2= his3->Projection(2,idim);
2639 Int_t nbins1 = his2->GetAxis(1)->GetNbins();
2640 Int_t first1 = his2->GetAxis(1)->GetFirst();
2641 Int_t last1 = his2->GetAxis(1)->GetLast();
2642 for (Int_t ibin1=first1; ibin1<last1; ibin1++){
2644 Double_t x1= his2->GetAxis(1)->GetBinCenter(ibin1);
2645 his2->GetAxis(1)->SetRange(TMath::Max(ibin1-1,1),TMath::Min(ibin1+1,nbins1));
2646 if (TMath::Abs(x1)<0.1){
2647 if (x1<0) his2->GetAxis(1)->SetRange(TMath::Max(ibin1-1,1),TMath::Min(ibin1,nbins1));
2648 if (x1>0) his2->GetAxis(1)->SetRange(TMath::Max(ibin1,1),TMath::Min(ibin1+1,nbins1));
2650 if (TMath::Abs(x1)<0.06){
2651 his2->GetAxis(1)->SetRange(TMath::Max(ibin1,1),TMath::Min(ibin1,nbins1));
2653 TH1 * hisDelta = his2->Projection(0);
2655 Double_t entries = hisDelta->GetEntries();
2656 Double_t mean=0, rms=0;
2657 if (entries>kMinEntries){
2658 mean = hisDelta->GetMean();
2659 rms = hisDelta->GetRMS();
2661 Double_t
sector = 9.*x2/TMath::Pi();
2662 if (sector<0) sector+=18;
2663 Double_t dsec = sector-Int_t(sector)-0.5;
2665 (*pcstream)<<hname<<
2672 "entries="<<entries<<
2715 const Int_t kMinEntries=10;
2720 Int_t idim0[4]={0 , 5, 8, 3};
2721 hisInput->GetAxis(1)->SetRangeUser(110,190);
2722 hisInput->GetAxis(2)->SetRangeUser(-10,35);
2723 hisInput->GetAxis(4)->SetRangeUser(-0.3,0.3);
2724 hisInput->GetAxis(7)->SetRangeUser(3,100);
2725 hisDelta= hisInput->Projection(0);
2726 hisInput->GetAxis(0)->SetRangeUser(-6.*hisDelta->GetRMS(), +6.*hisDelta->GetRMS());
2728 THnSparse *his0= hisInput->Projection(4,idim0);
2732 Int_t nbins1=his0->GetAxis(1)->GetNbins();
2733 Int_t first1=his0->GetAxis(1)->GetFirst();
2734 Int_t last1 =his0->GetAxis(1)->GetLast();
2736 Double_t bz=AliTrackerBase::GetBz();
2737 Int_t idim[4]={0,1, 2, 3};
2739 for (Int_t ibin1=first1; ibin1<=last1; ibin1++){
2741 Double_t x1= his0->GetAxis(1)->GetBinCenter(ibin1);
2742 his0->GetAxis(1)->SetRange(TMath::Max(ibin1-1,1),TMath::Min(ibin1+1,nbins1));
2744 THnSparse * his1 = his0->Projection(4,idim);
2745 Int_t nbins3 = his1->GetAxis(3)->GetNbins();
2746 Int_t first3 = his1->GetAxis(3)->GetFirst();
2747 Int_t last3 = his1->GetAxis(3)->GetLast();
2749 for (Int_t ibin3=first3-1; ibin3<=last3; ibin3+=1){
2750 his1->GetAxis(3)->SetRange(TMath::Max(ibin3-1,1),TMath::Min(ibin3+1,nbins3));
2751 Double_t x3= his1->GetAxis(3)->GetBinCenter(ibin3);
2753 his1->GetAxis(3)->SetRangeUser(-1,1);
2756 THnSparse * his3= his1->Projection(4,idim);
2757 Int_t nbins2 = his3->GetAxis(2)->GetNbins();
2758 Int_t first2 = his3->GetAxis(2)->GetFirst();
2759 Int_t last2 = his3->GetAxis(2)->GetLast();
2761 for (Int_t ibin2=first2; ibin2<=last2; ibin2+=1){
2762 his3->GetAxis(2)->SetRange(TMath::Max(ibin2-1,1),TMath::Min(ibin2+1,nbins2));
2763 Double_t x2= his3->GetAxis(2)->GetBinCenter(ibin2);
2764 hisDelta = his3->Projection(0);
2766 Double_t entries = hisDelta->GetEntries();
2767 Double_t mean=0, rms=0;
2768 if (entries>kMinEntries){
2769 mean = hisDelta->GetMean();
2770 rms = hisDelta->GetRMS();
2772 Double_t
sector = 9.*x2/TMath::Pi();
2773 if (sector<0) sector+=18;
2774 Double_t dsec = sector-Int_t(sector)-0.5;
2776 (*pcstream)<<hname<<
2783 "entries="<<entries<<
2792 printf(
"%f\t%f\t%f\t%f\t%f\n",x1,x3,x2, entries,mean);
2824 const Int_t kMinEntries=10;
2825 THnSparse * hisSector0=0;
2827 Double_t bz=AliTrackerBase::GetBz();
2841 for (Int_t isec0=0; isec0<72; isec0++){
2842 Int_t index0[9]={0, 4, 3, 7, 1, 2, 5, 6,8};
2845 hisInput->GetAxis(6)->SetRangeUser(isec0-0.1,isec0+0.1);
2846 hisSector0=hisInput->Projection(7,index0);
2849 for (Int_t isec1=isec0+1; isec1<72; isec1++){
2851 if ( TMath::Abs((isec0%18)-(isec1%18))>1.5 && TMath::Abs((isec0%18)-(isec1%18))<16.5)
continue;
2852 printf(
"Sectors %d\t%d\n",isec1,isec0);
2853 hisSector0->GetAxis(6)->SetRangeUser(isec1-0.1,isec1+0.1);
2854 TH1 * hisX=hisSector0->Projection(5);
2855 Double_t refX= hisX->GetMean();
2857 TH1 *hisDelta=hisSector0->Projection(0);
2858 Double_t dmean = hisDelta->GetMean();
2859 Double_t drms = hisDelta->GetRMS();
2860 hisSector0->GetAxis(0)->SetRangeUser(dmean-5.*drms, dmean+5.*drms);
2865 Int_t idim0[5]={0 , 1, 2, 3, 4};
2866 THnSparse *hisSector1= hisSector0->Projection(5,idim0);
2870 Int_t idim[5]={0, 1, 2, 3, 4};
2873 Int_t firstPhi=hisSector1->GetAxis(4)->GetFirst();
2874 Int_t lastPhi =hisSector1->GetAxis(4)->GetLast();
2876 for (Int_t ibinPhi=firstPhi; ibinPhi<=lastPhi; ibinPhi+=1){
2880 Double_t xPhi= hisSector1->GetAxis(4)->GetBinCenter(ibinPhi);
2881 Double_t psec = (9*xPhi/TMath::Pi());
2882 if (psec<0) psec+=18;
2883 Bool_t isOK0=kFALSE;
2884 Bool_t isOK1=kFALSE;
2885 if (TMath::Abs(psec-isec0%18-0.5)<1. || TMath::Abs(psec-isec0%18-17.5)<1.) isOK0=
kTRUE;
2886 if (TMath::Abs(psec-isec1%18-0.5)<1. || TMath::Abs(psec-isec1%18-17.5)<1.) isOK1=
kTRUE;
2887 if (!isOK0)
continue;
2888 if (!isOK1)
continue;
2890 hisSector1->GetAxis(4)->SetRange(TMath::Max(ibinPhi-2,firstPhi),TMath::Min(ibinPhi+2,lastPhi));
2891 if (isec1!=isec0+36) {
2892 hisSector1->GetAxis(4)->SetRange(TMath::Max(ibinPhi-3,firstPhi),TMath::Min(ibinPhi+3,lastPhi));
2895 htemp = hisSector1->Projection(4);
2896 xPhi=htemp->GetMean();
2898 THnSparse * hisPhi = hisSector1->Projection(4,idim);
2900 Int_t firstZ = hisPhi->GetAxis(3)->GetFirst();
2901 Int_t lastZ = hisPhi->GetAxis(3)->GetLast();
2903 for (Int_t ibinZ=firstZ; ibinZ<=lastZ; ibinZ+=1){
2907 hisPhi->GetAxis(3)->SetRange(TMath::Max(ibinZ,firstZ),TMath::Min(ibinZ,lastZ));
2908 if (isec1!=isec0+36) {
2909 hisPhi->GetAxis(3)->SetRange(TMath::Max(ibinZ-1,firstZ),TMath::Min(ibinZ-1,lastZ));
2911 htemp = hisPhi->Projection(3);
2912 Double_t xZ= htemp->GetMean();
2914 THnSparse * hisZ= hisPhi->Projection(3,idim);
2919 Int_t firstSnp = hisZ->GetAxis(2)->GetFirst();
2920 Int_t lastSnp = hisZ->GetAxis(2)->GetLast();
2921 for (Int_t ibinSnp=firstSnp; ibinSnp<=lastSnp; ibinSnp+=2){
2925 hisZ->GetAxis(2)->SetRange(TMath::Max(ibinSnp-1,firstSnp),TMath::Min(ibinSnp+1,lastSnp));
2926 if (isec1!=isec0+36) {
2927 hisZ->GetAxis(2)->SetRange(TMath::Max(ibinSnp-2,firstSnp),TMath::Min(ibinSnp+2,lastSnp));
2929 htemp = hisZ->Projection(2);
2930 Double_t xSnp= htemp->GetMean();
2932 THnSparse * hisSnp= hisZ->Projection(2,idim);
2936 Int_t firstTheta = hisSnp->GetAxis(1)->GetFirst();
2937 Int_t lastTheta = hisSnp->GetAxis(1)->GetLast();
2939 for (Int_t ibinTheta=firstTheta; ibinTheta<=lastTheta; ibinTheta+=2){
2942 hisSnp->GetAxis(1)->SetRange(TMath::Max(ibinTheta-2,firstTheta),TMath::Min(ibinTheta+2,lastTheta));
2943 if (isec1!=isec0+36) {
2944 hisSnp->GetAxis(1)->SetRange(TMath::Max(ibinTheta-3,firstTheta),TMath::Min(ibinTheta+3,lastTheta));
2946 htemp = hisSnp->Projection(1);
2947 Double_t xTheta=htemp->GetMean();
2949 hisDelta = hisSnp->Projection(0);
2951 Double_t entries = hisDelta->GetEntries();
2952 Double_t mean=0, rms=0;
2953 if (entries>kMinEntries){
2954 mean = hisDelta->GetMean();
2955 rms = hisDelta->GetRMS();
2957 Double_t
sector = 9.*xPhi/TMath::Pi();
2958 if (sector<0) sector+=18;
2959 Double_t dsec = sector-Int_t(sector)-0.5;
2961 (*pcstream)<<hname<<
2976 "entries="<<entries<<
2982 printf(
"%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\n",isec0, isec1, xPhi,xZ,xSnp, xTheta, entries,mean);
3008 TString ocdbStorage=
"";
3009 ocdbStorage+=
"local://"+gSystem->GetFromPipe(
"pwd")+
"/OCDB";
3010 AliCDBMetaData *metaData=
new AliCDBMetaData();
3011 metaData->SetObjectClassName(
"AliTPCCorrection");
3012 metaData->SetResponsible(
"Marian Ivanov");
3013 metaData->SetBeamPeriod(1);
3014 metaData->SetAliRootVersion(
"05-25-01");
3015 TString userName=gSystem->GetFromPipe(
"echo $USER");
3016 TString date=gSystem->GetFromPipe(
"date");
3018 if (!comment) metaData->SetComment(Form(
"Space point distortion calibration\n User: %s\n Data%s",userName.Data(),date.Data()));
3019 if (comment) metaData->SetComment(comment);
3021 id1=
new AliCDBId(
"TPC/Calib/Correction", startRun, endRun);
3022 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
3023 gStorage->Put(
this, (*id1), metaData);
3027 void AliTPCCorrection::FastSimDistortedVertex(Double_t orgVertex[3], Int_t nTracks, AliESDVertex &aV, AliESDVertex &avOrg, AliESDVertex &cV, AliESDVertex &cvOrg, TTreeSRedirector *
const pcstream, Double_t etaCuts){
3030 AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
3031 if (!magF) AliError(
"Magneticd field - not initialized");
3032 Double_t bz = magF->SolenoidField();
3034 AliVertexerTracks *vertexer =
new AliVertexerTracks(bz);
3038 UShort_t *aId =
new UShort_t[nTracks];
3041 UShort_t *cId =
new UShort_t [nTracks];
3043 Double_t mass = TDatabasePDG::Instance()->GetParticle(
"pi+")->Mass();
3044 TF1 fpt(
"fpt",Form(
"x*(1+(sqrt(x*x+%f^2)-%f)/([0]*[1]))^(-[0])",mass,mass),0.4,10);
3045 fpt.SetParameters(7.24,0.120);
3047 for(Int_t nt=0; nt<nTracks; nt++){
3048 Double_t
phi = gRandom->Uniform(0.0, 2*TMath::Pi());
3049 Double_t eta = gRandom->Uniform(-etaCuts, etaCuts);
3050 Double_t pt = fpt.GetRandom();
3053 if(gRandom->Rndm() < 0.5){
3059 Double_t
theta = 2*TMath::ATan(TMath::Exp(-eta))-TMath::Pi()/2.;
3061 pxyz[0]=pt*TMath::Cos(phi);
3062 pxyz[1]=pt*TMath::Sin(phi);
3063 pxyz[2]=pt*TMath::Tan(theta);
3064 Double_t cv[21]={0};
3065 AliExternalTrackParam *
t=
new AliExternalTrackParam(orgVertex, pxyz, cv, sign);
3071 if (pcstream) (*pcstream)<<
"track"<<
3077 if(( eta>0.07 )&&( eta<etaCuts )) {
3081 Int_t nn=aTrk.GetEntriesFast();
3084 }
else if(( eta<-0.07 )&&( eta>-etaCuts )){
3088 Int_t nn=cTrk.GetEntriesFast();
3095 vertexer->SetTPCMode();
3096 vertexer->SetConstraintOff();
3098 aV = *((AliESDVertex*)vertexer->FindPrimaryVertex(&daTrk,aId));
3099 avOrg = *((AliESDVertex*)vertexer->FindPrimaryVertex(&aTrk,aId));
3100 cV = *((AliESDVertex*)vertexer->FindPrimaryVertex(&dcTrk,cId));
3101 cvOrg = *((AliESDVertex*)vertexer->FindPrimaryVertex(&cTrk,cId));
3102 if (pcstream) (*pcstream)<<
"vertex"<<
3103 "x="<<orgVertex[0]<<
3104 "y="<<orgVertex[1]<<
3105 "z="<<orgVertex[2]<<
3148 if (!corr)
return 0;
3150 Double_t
phi=sector*TMath::Pi()/9.;
3151 Double_t gx = r*TMath::Cos(phi);
3152 Double_t gy = r*TMath::Sin(phi);
3154 Int_t nsector=(gz>=0) ? 0:18;
3158 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3160 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3161 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3162 Double_t phi0=TMath::ATan2(gy,gx);
3163 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3164 if (axisType==0)
return r1-r0;
3165 if (axisType==1)
return (phi1-phi0)*r0;
3166 if (axisType==2)
return distPoint[2]-gz;
3167 if (axisType==3)
return (TMath::Cos(phi)*(distPoint[0]-gx)+ TMath::Cos(phi)*(distPoint[1]-gy));
3183 if (!corr)
return 0;
3185 Double_t phi=sector*TMath::Pi()/9.;
3186 Double_t gx = r*TMath::Cos(phi);
3187 Double_t gy = r*TMath::Sin(phi);
3189 Int_t nsector=(gz>=0) ? 0:18;
3193 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3195 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3196 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3197 Double_t phi0=TMath::ATan2(gy,gx);
3198 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3199 if (axisType==0)
return r1-r0;
3200 if (axisType==1)
return (phi1-phi0)*r0;
3201 if (axisType==2)
return distPoint[2]-gz;
3202 if (axisType==3)
return (TMath::Cos(phi)*(distPoint[0]-gx)+ TMath::Cos(phi)*(distPoint[1]-gy));
3218 if (!corr)
return 0;
3220 Double_t phi=sector*TMath::Pi()/9.;
3221 Double_t gx = r*TMath::Cos(phi);
3222 Double_t gy = r*TMath::Sin(phi);
3224 Int_t nsector=(gz>=0) ? 0:18;
3228 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3230 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3231 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3232 Double_t phi0=TMath::ATan2(gy,gx);
3233 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3234 if (axisType==0)
return r1-r0;
3235 if (axisType==1)
return (phi1-phi0)*r0;
3236 if (axisType==2)
return distPoint[2]-gz;
3237 if (axisType==3)
return (TMath::Cos(phi)*(distPoint[0]-gx)+ TMath::Cos(phi)*(distPoint[1]-gy));
3246 if (!corr)
return 0;
3247 Double_t phi0= TMath::ATan2(gy,gx);
3248 Int_t nsector=(gz>=0) ? 0:18;
3249 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3251 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3252 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3253 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3254 if (axisType==0)
return r1-r0;
3255 if (axisType==1)
return (phi1-phi0)*r0;
3256 if (axisType==2)
return distPoint[2]-gz;
3265 if (!corr)
return 0;
3266 Double_t phi0= TMath::ATan2(gy,gx);
3267 Int_t nsector=(gz>=0) ? 0:18;
3268 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3269 Float_t dxyz[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3272 distPoint[0]+=dxyz[0];
3273 distPoint[1]+=dxyz[1];
3274 distPoint[2]+=dxyz[2];
3275 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3276 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3277 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3278 if (axisType==0)
return r1-r0;
3279 if (axisType==1)
return (phi1-phi0)*r0;
3280 if (axisType==2)
return distPoint[2]-gz;
3289 if (!corr)
return 0;
3290 Double_t phi0= TMath::ATan2(gy,gx);
3291 Int_t nsector=(gz>=0) ? 0:18;
3292 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3293 Float_t dxyz[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3296 distPoint[0]+=dxyz[0];
3297 distPoint[1]+=dxyz[1];
3298 distPoint[2]+=dxyz[2];
3299 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3300 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3301 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3302 if (axisType==0)
return r1-r0;
3303 if (axisType==1)
return (phi1-phi0)*r0;
3304 if (axisType==2)
return distPoint[2]-gz;
3314 if (!corr)
return 0;
3315 Double_t phi0= TMath::ATan2(gy,gx);
3316 Int_t nsector=(gz>=0) ? 0:18;
3317 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3319 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3320 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3321 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3322 if (axisType==0)
return r1-r0;
3323 if (axisType==1)
return (phi1-phi0)*r0;
3324 if (axisType==2)
return distPoint[2]-gz;
3333 if (!corr)
return 0;
3334 Double_t phi0= TMath::ATan2(gy,gx);
3335 Int_t nsector=(gz>=0) ? 0:18;
3336 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3337 Float_t dxyz[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3340 distPoint[0]+=dxyz[0];
3341 distPoint[1]+=dxyz[1];
3342 distPoint[2]+=dxyz[2];
3343 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3344 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3345 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3346 if (axisType==0)
return r1-r0;
3347 if (axisType==1)
return (phi1-phi0)*r0;
3348 if (axisType==2)
return distPoint[2]-gz;
3357 if (!corr)
return 0;
3358 Double_t phi0= TMath::ATan2(gy,gx);
3359 Int_t nsector=(gz>=0) ? 0:18;
3360 Float_t distPoint[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3361 Float_t dxyz[3]={
static_cast<Float_t
>(gx),static_cast<Float_t>(gy),
static_cast<Float_t
>(gz)};
3364 distPoint[0]+=dxyz[0];
3365 distPoint[1]+=dxyz[1];
3366 distPoint[2]+=dxyz[2];
3367 Double_t r0=TMath::Sqrt(gx*gx+gy*gy);
3368 Double_t r1=TMath::Sqrt(distPoint[0]*distPoint[0]+distPoint[1]*distPoint[1]);
3369 Double_t phi1=TMath::ATan2(distPoint[1],distPoint[0]);
3370 if (axisType==0)
return r1-r0;
3371 if (axisType==1)
return (phi1-phi0)*r0;
3372 if (axisType==2)
return distPoint[2]-gz;
3389 const Double_t cutErrY=0.05;
3392 const Double_t kEpsilon=0.00000001;
3400 tree->SetBranchAddress(
"dY.",&vecdY);
3401 tree->SetBranchAddress(
"dZ.",&vecdZ);
3402 tree->SetBranchAddress(
"eY.",&veceY);
3403 tree->SetBranchAddress(
"eZ.",&veceZ);
3404 tree->SetBranchAddress(
"LTr.",<r);
3405 Int_t entries= tree->GetEntries();
3406 TTreeSRedirector *pcstream=
new TTreeSRedirector(
"distortionLaser_0.root");
3407 Double_t bz=AliTrackerBase::GetBz();
3411 for (Int_t ientry=0; ientry<entries; ientry++){
3412 tree->GetEntry(ientry);
3419 printf(
"Entry\t%d\n",ientry);
3420 for (Int_t irow0=0; irow0<158; irow0+=1){
3422 TLinearFitter fitter10(4,
"hyp3");
3423 TLinearFitter fitter5(2,
"hyp1");
3424 Int_t sector= (Int_t)(*ltr->
GetVecSec())[irow0];
3425 if (sector<0)
continue;
3428 Double_t refX= (*ltr->
GetVecLX())[irow0];
3429 Int_t firstRow1 = TMath::Max(irow0-10,0);
3430 Int_t lastRow1 = TMath::Min(irow0+10,158);
3431 Double_t padWidth=(irow0<64)?0.4:0.6;
3433 for (Int_t irow1=firstRow1; irow1<=lastRow1; irow1++){
3435 if (veceY->GetMatrixArray()[irow1]>cutErrY)
continue;
3436 if (TMath::Abs(vecdY->GetMatrixArray()[irow1])<kEpsilon)
continue;
3437 Double_t idealX= (*ltr->
GetVecLX())[irow1];
3438 Double_t idealY= (*ltr->
GetVecLY())[irow1];
3440 Double_t gx= (*ltr->
GetVecGX())[irow1];
3441 Double_t gy= (*ltr->
GetVecGY())[irow1];
3442 Double_t gz= (*ltr->
GetVecGZ())[irow1];
3443 Double_t measY=(*vecdY)[irow1]+idealY;
3444 Double_t deltaR =
GetCorrXYZ(gx, gy, gz, 0,0);
3446 Double_t xxx[4]={idealX+deltaR-refX,TMath::Cos(idealY/padWidth), TMath::Sin(idealY/padWidth)};
3447 fitter10.AddPoint(xxx,measY,1);
3452 Double_t slope10 =0;
3453 Double_t cosPart10 = 0;
3454 Double_t sinPart10 =0;
3456 if (fitter10.GetNpoints()>10){
3458 rms10=TMath::Sqrt(fitter10.GetChisquare()/(fitter10.GetNpoints()-4));
3459 mean10 = fitter10.GetParameter(0);
3460 slope10 = fitter10.GetParameter(1);
3461 cosPart10 = fitter10.GetParameter(2);
3462 sinPart10 = fitter10.GetParameter(3);
3466 for (Int_t irow1=firstRow1+5; irow1<=lastRow1-5; irow1++){
3468 if (veceY->GetMatrixArray()[irow1]>cutErrY)
continue;
3469 if (TMath::Abs(vecdY->GetMatrixArray()[irow1])<kEpsilon)
continue;
3470 Double_t idealX= (*ltr->
GetVecLX())[irow1];
3471 Double_t idealY= (*ltr->
GetVecLY())[irow1];
3473 Double_t gx= (*ltr->
GetVecGX())[irow1];
3474 Double_t gy= (*ltr->
GetVecGY())[irow1];
3475 Double_t gz= (*ltr->
GetVecGZ())[irow1];
3476 Double_t measY=(*vecdY)[irow1]+idealY;
3477 Double_t deltaR =
GetCorrXYZ(gx, gy, gz, 0,0);
3479 Double_t expY= mean10+slope10*(idealX+deltaR-refX);
3480 if (TMath::Abs(measY-expY)>kSigmaCut*rms10)
continue;
3482 Double_t corr=cosPart10*TMath::Cos(idealY/padWidth)+sinPart10*TMath::Sin(idealY/padWidth);
3483 Double_t xxx[4]={idealX+deltaR-refX,TMath::Cos(idealY/padWidth), TMath::Sin(idealY/padWidth)};
3484 fitter5.AddPoint(xxx,measY-corr,1);
3489 if (fitter5.GetNpoints()<8) isOK=kFALSE;
3492 Double_t offset5 =0;
3496 rms5=TMath::Sqrt(fitter5.GetChisquare()/(fitter5.GetNpoints()-4));
3497 offset5 = fitter5.GetParameter(0);
3498 slope5 = fitter5.GetParameter(0);
3503 Double_t phi =(*ltr->
GetVecPhi())[irow0];
3504 Double_t
theta =ltr->GetTgl();
3505 Double_t mean=(vecdY)->GetMatrixArray()[irow0];
3506 Double_t gx=0,gy=0,gz=0;
3507 Double_t snp = (*ltr->
GetVecP2())[irow0];
3509 Int_t
id= ltr->
GetId();
3515 Double_t dRrec =
GetCorrXYZ(gx, gy, gz, 0,0);
3516 fitter10.GetParameters(fit10);
3517 fitter5.GetParameters(fit5);
3518 Double_t idealY= (*ltr->
GetVecLY())[irow0];
3519 Double_t measY=(*vecdY)[irow0]+idealY;
3520 Double_t corr=cosPart10*TMath::Cos(idealY/padWidth)+sinPart10*TMath::Sin(idealY/padWidth);
3521 if (TMath::Max(rms5,rms10)>0.06) isOK=kFALSE;
3523 (*pcstream)<<
"fitFull"<<
static AliTPCcalibDB * Instance()
static Double_t GetDistXYZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0)
AliExternalTrackParam * FitDistortedTrack(AliExternalTrackParam &trackIn, Double_t refX, Int_t dir, TTreeSRedirector *pcstream)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void DistortPointLocal(Float_t x[], Short_t roc)
static Double_t GetDistortionSector(Double_t sector, Double_t r, Double_t kZ, Int_t axisType, Int_t corrType=0)
Double_t fgkZList[kNZ]
points in the z direction (for the lookup table)
void CorrectPoint(Float_t x[], Short_t roc)
virtual void Print(Option_t *option="") const
Manager and of geomety classes for set: TPC.
Class providing the calibration parameters by accessing the CDB.
static Double_t GetCorrSector(Double_t sector, Double_t r, Double_t kZ, Int_t axisType, Int_t corrType=0)
Manager and of geomety classes for set: TPC.
static Double_t GetDistXYZIntegrateZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0, Double_t delta=5)
UInt_t GetNRows(UInt_t sector) const
Double_t Interpolate3DTable(Int_t order, Double_t x, Double_t y, Double_t z, Int_t nx, Int_t ny, Int_t nz, const Double_t xv[], const Double_t yv[], const Double_t zv[], TMatrixD **arrayofArrays)
static Double_t GetCorrectionSector(Double_t sector, Double_t r, Double_t kZ, Int_t axisType, Int_t corrType=0)
const TVectorD * GetVecGX() const
TFile f("CalibObjects.root")
virtual void SetOmegaTauT1T2(Float_t omegaTau, Float_t t1, Float_t t2)
static const Double_t fgkOFCRadius
Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm)
virtual Bool_t AddCorrectionCompact(AliTPCCorrection *corr, Double_t weight)
const TVectorD * GetVecGY() const
TH2F * CreateHistoDRPhiinXY(Float_t z=10., Int_t nx=100, Int_t nphi=100)
TTreeSRedirector * pcstream
virtual void GetDistortion(const Float_t x[], Short_t roc, Float_t dx[])
static Double_t GetCorrXYZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0)
static void MakeSectorDistortionTree(TTree *tinput, Int_t dtype, Int_t ptype, const TObjArray *corrArray, Int_t step=1, Int_t offset=0, Bool_t debug=0)
TH2F * CreateHistoDRPhiinZR(Float_t phi=0., Int_t nZ=100, Int_t nR=100)
virtual Int_t IsPowerOfTwo(Int_t i) const
TH2F * CreateHistoDRinZR(Float_t phi=0., Int_t nZ=100, Int_t nR=100)
Double_t fT1
tensor term of wt - T1
void PoissonRelaxation2D(TMatrixD &arrayV, TMatrixD &chargeDensity, TMatrixD &arrayErOverEz, TMatrixD &arrayDeltaEz, Int_t rows, Int_t columns, Int_t iterations, Bool_t rocDisplacement=kTRUE)
virtual void GetDistortionIntegralDz(const Float_t x[], Short_t roc, Float_t dx[], Float_t delta)
const TVectorD * GetVecLX() const
void CorrectPointLocal(Float_t x[], Short_t roc)
void Interpolate3DEdistortion(Int_t order, Double_t r, Float_t phi, Double_t z, const Double_t er[kNZ][kNPhi][kNR], const Double_t ephi[kNZ][kNPhi][kNR], const Double_t ez[kNZ][kNPhi][kNR], Double_t &erValue, Double_t &ephiValue, Double_t &ezValue)
virtual ~AliTPCCorrection()
const TVectorD * GetVecLY() const
Surveyed Laser Track positions.
TH2F * CreateTH2F(const char *name, const char *title, const char *xlabel, const char *ylabel, const char *zlabel, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup)
static const Double_t fgkTPCZ0
nominal gating grid position
virtual void GetCorrectionDz(const Float_t x[], Short_t roc, Float_t dx[], Float_t delta)
Double_t Interpolate2DTable(Int_t order, Double_t x, Double_t y, Int_t nx, Int_t ny, const Double_t xv[], const Double_t yv[], const TMatrixD &array)
Geometry class for a single ROC.
static void MakeTrackDistortionTree(TTree *tinput, Int_t dtype, Int_t ptype, const TObjArray *corrArray, Int_t step=1, Int_t offset=0, Bool_t debug=0)
const TVectorD * GetVecPhi() const
static void MakeDistortionMapSector(THnSparse *his0, TTreeSRedirector *pcstream, const char *hname, Int_t run, Int_t type)
Int_t fKLow
variable to help in the interpolation
static void MakeLaserDistortionTree(TTree *tree, TObjArray *corrArray, Int_t itype)
void Search(Int_t n, const Double_t xArray[], Double_t x, Int_t &low)
static AliTPCCorrection * GetVisualCorrection(Int_t position)
static Double_t GetCorrXYZDz(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0, Double_t delta=5)
static void AddVisualCorrection(AliTPCCorrection *corr, Int_t position)
Double_t Interpolate(const Double_t xArray[], const Double_t yArray[], Int_t order, Double_t x)
AliTPCCorrection * GetTPCComposedCorrection() const
TH2F * CreateHistoDZinXY(Float_t z=10., Int_t nx=100, Int_t ny=100)
TTree * CreateDistortionTree(Double_t step=5, Int_t type=0)
static void MakeDistortionMapCosmic(THnSparse *his0, TTreeSRedirector *pcstream, const char *hname, Int_t run, Float_t refX, Int_t type)
static TObjArray * fgVisualCorrection
array of orrection for visualization
void DistortPoint(Float_t x[], Short_t roc)
TH2F * CreateHistoDRinXY(Float_t z=10., Int_t nx=100, Int_t ny=100)
static const Double_t fgkCathodeV
Cathode Voltage (volts)
const TVectorD * GetVecGZ() const
IntegrationType fIntegrationType
Presentation of the underlying corrections, integrated, or differential.
Double_t fgkPhiList[kNPhi]
points in the phi direction (for the lookup table)
virtual void GetCorrection(const Float_t x[], Short_t roc, Float_t dx[])
void Interpolate2DEdistortion(Int_t order, Double_t r, Double_t z, const Double_t er[kNZ][kNR], Double_t &erValue)
void FastSimDistortedVertex(Double_t orgVertex[3], Int_t nTracks, AliESDVertex &aV, AliESDVertex &avOrg, AliESDVertex &cV, AliESDVertex &cvOrg, TTreeSRedirector *const pcstream, Double_t etaCuts)
static const Double_t fgkGG
Gating Grid voltage (volts)
void StoreInOCDB(Int_t startRun, Int_t endRun, const char *comment=0)
Double_t fT2
tensor term of wt - T2
static AliMagF::BMap_t mag
Double_t fgkRList[kNR]
points in the radial direction (for the lookup table)
static Double_t GetDistXYZDz(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0, Double_t delta=5)
virtual void GetDistortionDz(const Float_t x[], Short_t roc, Float_t dx[], Float_t delta)
static void MakeDistortionMap(THnSparse *his0, TTreeSRedirector *pcstream, const char *hname, Int_t run, Float_t refX, Int_t type, Int_t integ=1)
static AliTPCROC * Instance()
static void MakeLaserDistortionTreeOld(TTree *tree, TObjArray *corrArray, Int_t itype)
static Double_t GetCorrXYZIntegrateZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0, Double_t delta=5)
virtual void GetCorrectionIntegralDz(const Float_t x[], Short_t roc, Float_t dx[], Float_t delta)
void InitLookUpfulcrums()
const TVectorD * GetVecSec() const
Float_t GetPadRowRadii(Int_t isec, Int_t irow) const
virtual void Update(const TTimeStamp &timeStamp)
Float_t GetPadRowRadii(UInt_t isec, UInt_t irow) const
static const Double_t fgkIFCRadius
Mean Radius of the Inner Field Cage ( 82.43 min, 83.70 max) (cm)/hera/alice/wiechula/calib/guiTrees.
const TVectorD * GetVecP2() const
static const Double_t fgkdvdE
[cm/V] drift velocity dependency on the E field (from Magboltz for NeCO2N2 at standard environment) ...
TH2F * CreateHistoDZinZR(Float_t phi=0., Int_t nZ=100, Int_t nR=100)
void PoissonRelaxation3D(TMatrixD **arrayofArrayV, TMatrixD **arrayofChargeDensities, TMatrixD **arrayofEroverEz, TMatrixD **arrayofEPhioverEz, TMatrixD **arrayofEz, Int_t rows, Int_t columns, Int_t phislices, Float_t deltaphi, Int_t iterations, Int_t summetry, Bool_t rocDisplacement=kTRUE, IntegrationType integrationType=kIntegral)