]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCExBEffectiveSector.cxx
Code checker fixies
[u/mrichter/AliRoot.git] / TPC / AliTPCExBEffectiveSector.cxx
index bf0b67ce94062592c2dcec0f1bb0170f01a03184..fcd1b9cc59f5c3813b28b19e1c9db6236ac94e1c 100644 (file)
@@ -124,6 +124,10 @@ void AliTPCExBEffectiveSector::GetCorrection(const Float_t x[],const Short_t roc
   // Calculates the correction using the lookup table (histogram) of distortion
   // The histogram is created as poscl - postrack
   //   
+  dx[0]=0;
+  dx[1]=0;
+  dx[2]=0;
+  if (!fCorrectionRPhi) return;
   Double_t phi      = TMath::ATan2(x[1],x[0]);
   Double_t r        = TMath::Sqrt(x[1]*x[1]+x[0]*x[0]);
   Double_t sector   = 9.*phi/TMath::Pi();
@@ -136,33 +140,27 @@ void AliTPCExBEffectiveSector::GetCorrection(const Float_t x[],const Short_t roc
   if (roc%36>=18) kZ=-TMath::Abs(kZ);
   if (TMath::Abs(kZ)<0.15){
     kZ = (roc%36<18) ? 0.15:-0.15;
-  }
-  
+  }  
   //
   Double_t dlR=0;
   Double_t dlRPhi=0;
   Double_t dlZ=0;
+  Double_t rr=TMath::Max(r,fCorrectionRPhi->GetYaxis()->GetXmin()+0.01);
+  rr=TMath::Min(rr,fCorrectionRPhi->GetYaxis()->GetXmax()-0.01);
+  Double_t kZZ=TMath::Max(kZ,fCorrectionRPhi->GetZaxis()->GetXmin()+0.001);
+  kZZ=TMath::Min(kZZ,fCorrectionRPhi->GetZaxis()->GetXmax()-0.001);
+
   if (fCorrectionRPhi) {  
-    Double_t rr=TMath::Max(r,fCorrectionRPhi->GetYaxis()->GetXmin());
-    rr=TMath::Min(rr,fCorrectionRPhi->GetYaxis()->GetXmax());
-    Double_t kZZ=TMath::Max(kZ,fCorrectionRPhi->GetZaxis()->GetXmin());
-    kZZ=TMath::Min(kZZ,fCorrectionRPhi->GetZaxis()->GetXmax());
-    //    dlRPhi= -fCorrectionRPhi->GetBinContent(fCorrectionRPhi->FindBin(sector,rr,kZZ));
-    dlRPhi= -fCorrectionRPhi->Interpolate(sector,rr,kZZ);
+    //    dlRPhi= -fCorrectionRPhi->Interpolate(sector,rr,kZZ);
+    dlRPhi= -fCorrectionRPhi->GetBinContent(fCorrectionRPhi->FindBin(sector,rr,kZZ));
   }
   if (fCorrectionR)    {
-    Double_t rr=TMath::Max(r,fCorrectionR->GetYaxis()->GetXmin());
-    rr=TMath::Min(rr,fCorrectionR->GetYaxis()->GetXmax());
-    Double_t kZZ=TMath::Max(kZ,fCorrectionR->GetZaxis()->GetXmin());
-    kZZ=TMath::Min(kZZ,fCorrectionR->GetZaxis()->GetXmax());
-    dlR= -fCorrectionR->Interpolate(sector,rr,kZZ);
+    //    dlR= -fCorrectionR->Interpolate(sector,rr,kZZ);
+    dlR= -fCorrectionR->GetBinContent(fCorrectionR->FindBin(sector,rr,kZZ));
   }
   if (fCorrectionZ)    {
-    Double_t rr=TMath::Max(r,fCorrectionZ->GetYaxis()->GetXmin());
-    rr=TMath::Min(rr,fCorrectionZ->GetYaxis()->GetXmax());
-    Double_t kZZ=TMath::Max(kZ,fCorrectionZ->GetZaxis()->GetXmin());
-    kZZ=TMath::Min(kZZ,fCorrectionZ->GetZaxis()->GetXmax());
-    dlZ= -fCorrectionZ->Interpolate(sector,rr,kZZ);
+    //    dlZ= -fCorrectionZ->Interpolate(sector,rr,kZZ);
+    dlZ= -fCorrectionZ->GetBinContent(fCorrectionZ->FindBin(sector,rr,kZZ));
   }
   Double_t dr    = fC0*dlR  + fC1*dlRPhi;
   Double_t drphi = -fC1*dlR + fC0*dlRPhi;
@@ -192,7 +190,7 @@ void AliTPCExBEffectiveSector::Print(const Option_t* option) const {
   }    
 }
 
-void  AliTPCExBEffectiveSector::MakeResidualMap(THnSparse * hisInput, const char *sname){
+void  AliTPCExBEffectiveSector::MakeResidualMap(THnSparse * hisInput, const char *sname, Int_t ptype, Int_t dtype){
   //
   // Make cluster residual map from the n-dimensional histogram
   // hisInput supposed to have given format:
@@ -203,7 +201,7 @@ void  AliTPCExBEffectiveSector::MakeResidualMap(THnSparse * hisInput, const char
   Int_t nbins1=hisInput->GetAxis(1)->GetNbins();
   Int_t nbins2=hisInput->GetAxis(2)->GetNbins();
   Int_t nbins3=hisInput->GetAxis(3)->GetNbins();
-
+  TF1 *fgaus=0;
   TH3F * hisResMap3D = 
     new TH3F("his3D","his3D",
             nbins1,hisInput->GetAxis(1)->GetXmin(), hisInput->GetAxis(1)->GetXmax(),
@@ -314,12 +312,38 @@ void  AliTPCExBEffectiveSector::MakeResidualMap(THnSparse * hisInput, const char
        Double_t entries= his->GetEntries();
        //printf("%f\t%f\t%f\t%f\t%f\t%f\n", sector,localX,kZ, entries, mean,rms);
        hisResMap3D->SetBinContent(ibin1,ibin2,ibin3, mean);
+       Double_t phi=TMath::Pi()*sector/9;
+       if (phi>TMath::Pi()) phi+=TMath::Pi();
+       Double_t meanG=0;
+       Double_t rmsG=0;
+       if (entries>50){
+         if (!fgaus) {     
+           his->Fit("gaus","Q","goff");
+           fgaus= (TF1*)((his->GetListOfFunctions()->FindObject("gaus"))->Clone());
+           fgaus->SetName("gausk");
+         }
+         if (fgaus) his->Fit(fgaus,"Q","goff");
+         if (fgaus){
+           meanG=fgaus->GetParameter(1);
+           rmsG=fgaus->GetParameter(2);
+         }
+       }
+       Double_t dsec=sector-Int_t(sector)-0.5;
+       Double_t snp=dsec*TMath::Pi()/9.;
        (*pcstream)<<"delta"<<
+         "ptype="<<ptype<<
+         "dtype="<<dtype<<
          "sector="<<sector<<
+         "dsec="<<dsec<<
+         "snp="<<snp<<
+         "phi="<<phi<<
          "localX="<<localX<<
          "kZ="<<kZ<<
+         "theta="<<kZ<<
          "mean="<<mean<<
          "rms="<<rms<<
+         "meanG="<<meanG<<
+         "rmsG="<<rmsG<<
          "entries="<<entries<<
          "meanA="<<meanA<<
          "rmsA="<<rmsA<<