]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/FORWARD/analysis2/AliFMDHistCollector.cxx
Fixes, AOD merge now uses AODConfig
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDHistCollector.cxx
index 214cc194544869f62e57c31ae6721b16c29c912d..87ca3f6354c04d6e9fb6b1af71380ae59c5b26dd 100644 (file)
@@ -44,6 +44,7 @@ AliFMDHistCollector::AliFMDHistCollector()
     fList(0),
     fSumRings(0),
     fCoverage(0),
+    fSkipped(0),
     fMergeMethod(kStraightMean),
     fFiducialMethod(kByCut),
     fSkipFMDRings(0),
@@ -64,6 +65,7 @@ AliFMDHistCollector::AliFMDHistCollector(const char* title)
     fList(0),
     fSumRings(0),
     fCoverage(0),
+    fSkipped(0),
     fMergeMethod(kStraightMean),
     fFiducialMethod(kByCut),
     fSkipFMDRings(0),
@@ -83,6 +85,7 @@ AliFMDHistCollector::AliFMDHistCollector(const AliFMDHistCollector& o)
     fList(o.fList),
     fSumRings(o.fSumRings),
     fCoverage(o.fCoverage),
+    fSkipped(o.fSkipped),
     fMergeMethod(o.fMergeMethod),
     fFiducialMethod(o.fFiducialMethod),
     fSkipFMDRings(o.fSkipFMDRings),
@@ -123,6 +126,7 @@ AliFMDHistCollector::operator=(const AliFMDHistCollector& o)
   fList           = o.fList;
   fSumRings       = o.fSumRings;
   fCoverage       = o.fCoverage;
+  fSkipped        = o.fSkipped;
   fMergeMethod    = o.fMergeMethod;
   fFiducialMethod = o.fFiducialMethod;
   fSkipFMDRings   = o.fSkipFMDRings;
@@ -170,6 +174,17 @@ AliFMDHistCollector::SetupForData(const TAxis& vtxAxis,
   fCoverage->SetZTitle("n_{bins}");
   fList->Add(fCoverage);
                       
+  fSkipped = new TH1D("skipped", "Rings skipped", 5, 1, 6);
+  fSkipped->SetDirectory(0);
+  fSkipped->SetFillColor(kRed+1);
+  fSkipped->SetFillStyle(3001);
+  fSkipped->SetYTitle("Events");
+  fSkipped->GetXaxis()->SetBinLabel(1,"FMD1i");
+  fSkipped->GetXaxis()->SetBinLabel(2,"FMD2i");
+  fSkipped->GetXaxis()->SetBinLabel(3,"FMD2o");
+  fSkipped->GetXaxis()->SetBinLabel(4,"FMD3i");
+  fSkipped->GetXaxis()->SetBinLabel(5,"FMD3o");
+  fList->Add(fSkipped);
 
   // --- Add parameters to output ------------------------------------
   fList->Add(AliForwardUtil::MakeParameter("nCutBins",fNCutBins));
@@ -454,7 +469,8 @@ AliFMDHistCollector::Collect(const AliForwardUtil::Histos& hists,
                             UShort_t                vtxbin, 
                             TH2D&                   out,
                             Double_t                cent,
-                            Bool_t                  eta2phi)
+                            Bool_t                  eta2phi,
+                            Bool_t                  add)
 {
   // 
   // Do the calculations 
@@ -474,9 +490,9 @@ AliFMDHistCollector::Collect(const AliForwardUtil::Histos& hists,
   // Double_t vMax    = vtxAxis->GetBinUpEdge(vtxbin);
   VtxBin*  bin     = GetVtxBin(vtxbin);
   if (!bin) return false;
-  Bool_t   ret     = bin->Collect(hists, sums, out, fSumRings, cent, 
+  Bool_t   ret     = bin->Collect(hists, sums, out, fSumRings, fSkipped, cent, 
                                  fMergeMethod, fSkipFMDRings,
-                                 fByCent, eta2phi);
+                                 fByCent, eta2phi, add);
 
   return ret;
 }
@@ -733,28 +749,48 @@ AliFMDHistCollector::VtxBin::GetLast(Int_t  idx) const
   return last;
 }
 
+#define PRINT_OVERFLOW(D,R,T,H) do {                                   \
+  printf("Content of FMD%d%c overflow %s rebinning", D, R, T);         \
+  Int_t i = 0;                                                         \
+  for (Int_t ix = 1; ix <= t->GetNbinsX(); ix++) {                     \
+  Double_t c = t->GetBinContent(ix, t->GetNbinsY()+1);                 \
+  if (c <= 1e-9) continue;                                             \
+  if ((i % 10) == 0) printf("\n  ");                                   \
+  printf("%3d: %5.2f ", ix, c);                                                \
+  i++;                                                                 \
+  }                                                                    \
+  printf("\n");                                                                \
+  } while (false)
+
 //____________________________________________________________________
 Bool_t
 AliFMDHistCollector::VtxBin::Collect(const AliForwardUtil::Histos& hists, 
                                     AliForwardUtil::Histos&       sums, 
                                     TH2D&                         out,
                                     TH2D*                         sumRings,
+                                    TH1D*                         skipped,
                                     Double_t                      cent,
                                     MergeMethod                   m,
                                     UShort_t                      skips,
                                     TList*                        byCent,
-                                    Bool_t                        eta2phi)
+                                    Bool_t                        eta2phi,
+                                    Bool_t                        add)
 {
   for (UShort_t d=1; d<=3; d++) { 
     UShort_t nr = (d == 1 ? 1 : 2);
     for (UShort_t q=0; q<nr; q++) { 
       Char_t      r = (q == 0 ? 'I' : 'O');
-      if (CheckSkip(d, r, skips)) continue;
-
+      Int_t       i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1));
       TH2D*       h = hists.Get(d,r);
+      if (CheckSkip(d, r, skips) || !h || 
+         h->TestBit(AliForwardUtil::kSkipRing)) {
+       // Skipping a ring - either because disable, not there, or
+       // because of flagged (too many outliers, ...)
+       skipped->Fill(i);
+       continue;
+      }
       TH2D*       o = sums.Get(d, r);
       TH2D*       t = static_cast<TH2D*>(h->Clone(Form("FMD%d%c_tmp",d,r)));
-      Int_t       i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1));
       
       // Get valid range 
       Int_t first = 0;
@@ -783,48 +819,55 @@ AliFMDHistCollector::VtxBin::Collect(const AliForwardUtil::Histos& hists,
          t->SetBinContent(iEta,nY+1,1);
       }
       
-      // Add to our per-ring sum 
-      o->Add(t);
+      if (add) {
+       // Add to our per-ring sum 
+       o->Add(t);
 
-      // If we store hit maps, update here 
-      if (fHitMap) fHitMap->Get(d, r)->Add(t);
+       // If we store hit maps, update here 
+       if (fHitMap) fHitMap->Get(d, r)->Add(t);
+      
 
-      if (byCent) { 
-       TH3* dNdetaCent = static_cast<TH3*>(byCent->At(i-1));
-       if (cent >= 0 && dNdetaCent) { 
-         Int_t iCent = dNdetaCent->GetYaxis()->FindBin(cent);
+       if (byCent) { 
+         TH3* dNdetaCent = static_cast<TH3*>(byCent->At(i-1));
+         if (cent >= 0 && dNdetaCent) { 
+           Int_t iCent = dNdetaCent->GetYaxis()->FindBin(cent);
          
-         if (iCent > 0 && iCent <= dNdetaCent->GetNbinsY()) { 
-           // Make a projection of data 
-           TH1* proj = static_cast<TH1*>(t->ProjectionX("tmp", 1, nY));
-           proj->SetDirectory(0);
-           for (Int_t iEta = 1; iEta <= nX; iEta++) {
-             Double_t v1 = proj->GetBinContent(iEta);
-             Double_t e1 = proj->GetBinError(iEta);
-             Double_t v2 = dNdetaCent->GetBinContent(iEta, iCent, 1);
-             Double_t e2 = dNdetaCent->GetBinError(iEta, iCent, 1);
-             dNdetaCent->SetBinContent(iEta,iCent,1, v1+v2);
-             dNdetaCent->SetBinError(iEta,iCent,1, TMath::Sqrt(e1*e1+e2*e2));
+           if (iCent > 0 && iCent <= dNdetaCent->GetNbinsY()) { 
+             // Make a projection of data 
+             TH1* proj = static_cast<TH1*>(t->ProjectionX("tmp", 1, nY));
+             proj->SetDirectory(0);
+             for (Int_t iEta = 1; iEta <= nX; iEta++) {
+               Double_t v1 = proj->GetBinContent(iEta);
+               Double_t e1 = proj->GetBinError(iEta);
+               Double_t v2 = dNdetaCent->GetBinContent(iEta, iCent, 1);
+               Double_t e2 = dNdetaCent->GetBinError(iEta, iCent, 1);
+               dNdetaCent->SetBinContent(iEta,iCent,1, v1+v2);
+               dNdetaCent->SetBinError(iEta,iCent,1, TMath::Sqrt(e1*e1+e2*e2));
              
-             // Check under-/overflow bins
-             Double_t uF = t->GetBinContent(iEta, 0);
-             Double_t oF = t->GetBinContent(iEta, nY+1);
-             if (uF > 0) {
-               Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 0);
-               dNdetaCent->SetBinContent(iEta, iCent, 0, old + uF);
-             }
-             if (oF > 0) {
-               Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 2);
-               dNdetaCent->SetBinContent(iEta, iCent, 2, old + oF);
-             }
-           } // for(iEta)
-           delete proj;
-         } // if(iCent)
-       } // if (cent)
-      } // if (byCent)
+               // Check under-/overflow bins
+               Double_t uF = t->GetBinContent(iEta, 0);
+               Double_t oF = t->GetBinContent(iEta, nY+1);
+               if (uF > 0) {
+                 Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 0);
+                 dNdetaCent->SetBinContent(iEta, iCent, 0, old + uF);
+               }
+               if (oF > 0) {
+                 Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 2);
+                 dNdetaCent->SetBinContent(iEta, iCent, 2, old + oF);
+               }
+             } // for(iEta)
+             delete proj;
+           } // if(iCent)
+         } // if (cent)
+       } // if (byCent)
+      } // if (add)
 
       // Outer rings have better phi segmentation - rebin to same as inner. 
-      if (q == 1) t->RebinY(2);
+      if (q == 1) {
+       // PRINT_OVERFLOW(d, r, "before", t);
+       t->RebinY(2);   
+       // PRINT_OVERFLOW(d, r, "after", t);
+      }
 
       nY = t->GetNbinsY();