]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FORWARD/analysis2/AliFMDHistCollector.cxx
corrected obvious typo. which value to chose between 0.045 and 0.050 is a bit matter...
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDHistCollector.cxx
index 37fdb807fe7289d35f5d11ced351336374414d23..7d73098f4c44f26cab4c535a9593b6aeecb24c35 100644 (file)
@@ -33,6 +33,50 @@ ClassImp(AliFMDHistCollector)
 ; // For Emacs
 #endif 
 
+//____________________________________________________________________
+AliFMDHistCollector::AliFMDHistCollector()
+  : fNCutBins(0), 
+    fCorrectionCut(0), 
+    fFirstBins(), 
+    fLastBins(), 
+    fDebug(0),
+    fList(0),
+    fSumRings(0),
+    fCoverage(0),
+    fMergeMethod(kStraightMean),
+    fFiducialMethod(kByCut)
+{}
+
+//____________________________________________________________________
+AliFMDHistCollector::AliFMDHistCollector(const char* title)
+  : TNamed("fmdHistCollector", title), 
+    fNCutBins(2), 
+    fCorrectionCut(0.5), 
+    fFirstBins(1), 
+    fLastBins(1), 
+    fDebug(0),
+    fList(0),
+    fSumRings(0),
+    fCoverage(0),
+    fMergeMethod(kStraightMean),
+    fFiducialMethod(kByCut)
+{
+}
+//____________________________________________________________________
+AliFMDHistCollector::AliFMDHistCollector(const AliFMDHistCollector& o)
+  : TNamed(o), 
+    fNCutBins(o.fNCutBins), 
+    fCorrectionCut(o.fCorrectionCut),
+    fFirstBins(o.fFirstBins), 
+    fLastBins(o.fLastBins), 
+    fDebug(o.fDebug),
+    fList(o.fList),
+    fSumRings(o.fSumRings),
+    fCoverage(o.fCoverage),
+    fMergeMethod(o.fMergeMethod),
+    fFiducialMethod(o.fFiducialMethod)
+{}
+
 //____________________________________________________________________
 AliFMDHistCollector::~AliFMDHistCollector()
 { 
@@ -63,6 +107,7 @@ AliFMDHistCollector::operator=(const AliFMDHistCollector& o)
   fCoverage       = o.fCoverage;
   fMergeMethod    = o.fMergeMethod;
   fFiducialMethod = o.fFiducialMethod;
+
   return *this;
 }
 
@@ -151,10 +196,17 @@ AliFMDHistCollector::Init(const TAxis& vtxAxis,
       // Store the result for later use 
       fFirstBins[(iVz-1)*5+iIdx] = first;
       fLastBins[(iVz-1)*5+iIdx]  = last;
-      TH2D* obg = static_cast<TH2D*>(bg->Clone());
+      TH2D* obg = static_cast<TH2D*>(bg->Clone(Form("secMapFMD%d%c", d, r)));
       obg->SetDirectory(0);
       obg->Reset();
       vtxList->Add(obg);
+      
+      TH2D* hitmap = static_cast<TH2D*>(bg->Clone(Form("hitMapFMD%d%c", d, r)));
+      if(r == 'O') hitmap->RebinY(2);
+      hitmap->SetDirectory(0);
+      hitmap->GetZaxis()->SetTitle("");
+      hitmap->Reset();
+      vtxList->Add(hitmap);
 
       // Fill diagnostics histograms 
       for (Int_t ie = first+fNCutBins; ie <= last-fNCutBins; ie++) {
@@ -212,8 +264,10 @@ AliFMDHistCollector::DefineOutput(TList* dir)
   fList->SetOwner();
   fList->SetName(GetName());
   dir->Add(fList);
+
 }
 
+
 //____________________________________________________________________
 Int_t
 AliFMDHistCollector::GetIdx(UShort_t d, Char_t r) const
@@ -477,7 +531,8 @@ AliFMDHistCollector::MergeBins(Double_t c,   Double_t e,
 
 //____________________________________________________________________
 Bool_t
-AliFMDHistCollector::Collect(AliForwardUtil::Histos& hists,
+AliFMDHistCollector::Collect(const AliForwardUtil::Histos& hists,
+                            AliForwardUtil::Histos& sums,
                             UShort_t                vtxbin, 
                             TH2D&                   out)
 {
@@ -492,6 +547,18 @@ AliFMDHistCollector::Collect(AliForwardUtil::Histos& hists,
   // Return:
   //    true on successs 
   //
+  AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
+  const TAxis* vtxAxis = fcm.GetVertexAxis();
+  Double_t vMin    = vtxAxis->GetBinLowEdge(vtxbin);
+  Double_t vMax    = vtxAxis->GetBinUpEdge(vtxbin);
+  TList* vtxList 
+    = static_cast<TList*>(fList->FindObject(Form("%c%02d_%c%02d", 
+                                               vMin < 0 ? 'm' : 'p', 
+                                               int(TMath::Abs(vMin)), 
+                                               vMax < 0 ? 'm' : 'p', 
+                                               int(TMath::Abs(vMax)))));
+  
+  
   for (UShort_t d=1; d<=3; d++) { 
     UShort_t nr = (d == 1 ? 1 : 2);
     for (UShort_t q=0; q<nr; q++) { 
@@ -499,13 +566,32 @@ AliFMDHistCollector::Collect(AliForwardUtil::Histos& hists,
       TH2D*       h = hists.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));
+      TH2D*       o = sums.Get(d, r);
 
-      // Outer rings have better phi segmentation - rebin to same as inner. 
-      if (q == 1) t->RebinY(2);
-
+      // Get valid range 
       Int_t first = 0;
       Int_t last  = 0;
       GetFirstAndLast(d, r, vtxbin, first, last);
+      
+      // Zero outside valid range 
+      for (Int_t iPhi = 0; iPhi <= t->GetNbinsY()+1; iPhi++) { 
+       // Lower range 
+       for (Int_t iEta = 1; iEta < first; iEta++) { 
+         t->SetBinContent(iEta,iPhi,0);
+         t->SetBinError(iEta,iPhi,0);
+       }
+       for (Int_t iEta = last+1; iEta <= t->GetNbinsX(); iEta++) {
+         t->SetBinContent(iEta,iPhi,0);
+         t->SetBinError(iEta,iPhi,0);
+       }
+      }
+      for (Int_t iEta = first; iEta <= last; iEta++)
+       t->SetBinContent(iEta,0,1);
+      // Add to our per-ring sum 
+      o->Add(t);
+      
+      // Outer rings have better phi segmentation - rebin to same as inner. 
+      if (q == 1) t->RebinY(2);
 
       // Now update profile output 
       for (Int_t iEta = first; iEta <= last; iEta++) { 
@@ -518,7 +604,8 @@ AliFMDHistCollector::Collect(AliForwardUtil::Histos& hists,
        Float_t noc      = overlap >= 0? 0.5 : 1;
        out.SetBinContent(iEta, 0, ooc + noc);
 
-       for (Int_t iPhi = 1; iPhi <= h->GetNbinsY(); iPhi++) { 
+       // Should we loop over h or t Y bins - I think it's t
+       for (Int_t iPhi = 1; iPhi <= t->GetNbinsY(); iPhi++) { 
          Double_t c  = t->GetBinContent(iEta,iPhi);
          Double_t e  = t->GetBinError(iEta,iPhi);
          Double_t ee = t->GetXaxis()->GetBinCenter(iEta);
@@ -547,6 +634,9 @@ AliFMDHistCollector::Collect(AliForwardUtil::Histos& hists,
        }
       }
       // Remove temporary histogram 
+      TH2D* hRingSumVtx 
+       = static_cast<TH2D*>(vtxList->FindObject(Form("hitMapFMD%d%c", d, r)));
+      hRingSumVtx->Add(t);
       delete t;
     } // for r
   } // for d 
@@ -566,7 +656,7 @@ AliFMDHistCollector::Print(Option_t* /* option */) const
   char ind[gROOT->GetDirLevel()+1];
   for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
   ind[gROOT->GetDirLevel()] = '\0';
-  std::cout << ind << "AliFMDHistCollector: " << GetName() << '\n'
+  std::cout << ind << ClassName() << ": " << GetName() << '\n'
            << ind << " # of cut bins:          " << fNCutBins << '\n'
            << ind << " Correction cut:         " << fCorrectionCut << '\n'
            << ind << " Merge method:           ";
@@ -577,22 +667,26 @@ AliFMDHistCollector::Print(Option_t* /* option */) const
   case kLeastError:         std::cout << "least error\n"; break;
   }
     
-  std::cout << ind << " Bin ranges:\n" << ind << "  v_z bin";
+  std::cout << ind << " Bin ranges:\n" << ind << "  rings  ";
   Int_t nVz = fFirstBins.fN / 5;
-  for (UShort_t iVz = 1; iVz <= nVz; iVz++) 
-    std::cout << " | " << std::setw(7) << iVz;
-  std::cout << '\n' << ind << "  / ring ";
-  for (UShort_t iVz = 1; iVz <= nVz; iVz++) 
-    std::cout << "-+--------";
-  std::cout << std::endl;
-    
   for (Int_t iIdx = 0; iIdx < 5; iIdx++) {
     UShort_t d = 0;
     Char_t   r = 0;
     GetDetRing(iIdx, d, r);
+    std::cout << ind << " | FMD" << d << r << " ";
+  }
+  std::cout << '\n' << ind << "  /vz_bin ";
+  for (Int_t iIdx = 0; iIdx < 5; iIdx++) 
+    std::cout << "-+--------";
+  std::cout << std::endl;
+
+  for (UShort_t iVz = 1; iVz <= nVz; iVz++) {
+    std::cout << " " << std::setw(7) << iVz << "   ";
+    for (Int_t iIdx = 0; iIdx < 5; iIdx++) {
+      UShort_t d = 0;
+      Char_t   r = 0;
+      GetDetRing(iIdx, d, r);
     
-    std::cout << ind << "  FMD" << d << r << "  ";
-    for (UShort_t iVz = 1; iVz <= nVz; iVz++) {
       Int_t first, last;
       GetFirstAndLast(iIdx, iVz, first, last);
       std::cout << " | " << std::setw(3) << first << "-"