]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/TRD/AliTRDrecoTask.cxx
fix 3D -> 2D projection algorithm
[u/mrichter/AliRoot.git] / PWGPP / TRD / AliTRDrecoTask.cxx
index 74a3dde02ca3dddc1271b05f091fc8db7e891aa1..37d260de98080738fe196e58f221d91e8aa658dc 100644 (file)
@@ -545,10 +545,10 @@ void AliTRDrecoTask::SetNormZ(TH2 *h2, Int_t bxmin, Int_t bxmax, Int_t bymin, In
       s += c; is++;\r
     }\r
   }\r
-  s/= is?is:1;\r
+  s/= (is?is:1);\r
   for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){\r
     for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){\r
-      if((c = h2->GetBinContent(ix, iy))<thr) h2->SetBinContent(ix, iy, thr-100);\r
+      if((c = h2->GetBinContent(ix, iy))<thr) h2->SetBinContent(ix, iy, thr-1000);\r
       else h2->SetBinContent(ix, iy, 100.*(c/s-1.));\r
     }\r
   }\r
@@ -688,10 +688,16 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const
 // build the 2D projection and adjust binning\r
 \r
   const Char_t *title[] = {"Mean", "#mu", "MPV"};\r
-  if(!fH) return NULL;\r
+  if(!fH){\r
+    AliDebug(1, Form("Missing 3D in %s", GetName()));\r
+    return NULL;\r
+  }\r
   TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis());\r
   TH2D *h2s(NULL), *hyx(NULL);\r
-  if(!(h2s = (TH2D*)fH->Project3D("yx"))) return NULL;\r
+  if(!(h2s = (TH2D*)fH->Project3D("yx"))){\r
+    AliDebug(1, Form("Failed Project3D(\"yx\") in %s", GetName()));\r
+    return NULL;\r
+  }\r
   // save a copy of the original distribution\r
   if(!del){\r
     hyx = (TH2D*)h2s->Clone();\r
@@ -722,14 +728,16 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const
   AliDebug(2, Form("%s[%s] nx[%d] ny[%d]", h2->GetName(), h2->GetTitle(), nx, ny));\r
   for(Int_t iy(0); iy<ny; iy++){\r
     for(Int_t ix(0); ix<nx; ix++){\r
-      h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, ix*dxBin+1, iy*dyBin+1, iy*dyBin+1);\r
+      h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin);\r
       Int_t ne((Int_t)h->Integral());\r
+      //printf("  x[%2d %2d] y[%2d %2d] ne[%4d]\n", ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin, ne);\r
       if(ne<nstat/2){\r
         h2->SetBinContent(ix+1, iy+1, -999);\r
         h2->SetBinError(ix+1, iy+1, 1.);\r
         n++;\r
       }else{\r
-        h = fH->ProjectionZ(Form("%s_z", h2->GetName()), (ix-1)*dxBin+1, (ix+1)*dxBin+1, (iy-1)*dyBin+1, (iy+1)*dyBin+1);\r
+        // redo the projection by adding 1 bin @ left and 1 bin @ right for smoothing\r
+        h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin, (ix+1)*dxBin+1, iy*dyBin, (iy+1)*dyBin+1);\r
         Float_t v(h->GetMean()), ve(h->GetRMS());\r
         if(mid==1){\r
           TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());\r
@@ -756,7 +764,10 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const
     }\r
   }\r
   if(h) delete h;\r
-  if(n==nx*ny){delete h2; h2=NULL;} // clean empty projections\r
+  if(n==nx*ny){  // clean empty projections\r
+    AliDebug(1, Form("Empty projection in %s", GetName()));\r
+    delete h2; h2=NULL;\r
+  }\r
   return h2;\r
 }\r
 \r