]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG0/AliCorrectionMatrix.cxx
updated multiplicity analysis for the INEL>0 case
[u/mrichter/AliRoot.git] / PWG0 / AliCorrectionMatrix.cxx
index c54a5323878b8898842ce1acd0bc4a798bd132ff..7cf9901d7cb201ccc8e769196928805ced3072f2 100644 (file)
@@ -160,8 +160,10 @@ void AliCorrectionMatrix::Divide()
   // divides generated by measured to get the correction
   //
 
-  if (!fhMeas || !fhGene || !fhCorr)
+  if (!fhMeas || !fhGene || !fhCorr) {
+    AliDebug(AliLog::kError, "measured or generated histograms not available");
     return;
+  }
 
   fhCorr->Divide(fhGene, fhMeas, 1, 1, "B");
 
@@ -189,6 +191,18 @@ void AliCorrectionMatrix::Multiply()
   fhGene->Multiply(fhMeas, fhCorr, 1, 1, "B");
 }
 
+//____________________________________________________________________
+void AliCorrectionMatrix::Add(AliCorrectionMatrix* aMatrixToAdd, Float_t c) {
+  //
+  // adds the measured and generated of aMatrixToAdd to measured and generated of this
+  // 
+  // NB: the correction will naturally stay the same
+  
+  fhMeas->Add(aMatrixToAdd->GetMeasuredHistogram(), c);
+  fhGene->Add(aMatrixToAdd->GetGeneratedHistogram(), c);
+}
+
+
 //____________________________________________________________________
 Bool_t AliCorrectionMatrix::LoadHistograms(const Char_t* dir)
 {
@@ -339,8 +353,36 @@ void AliCorrectionMatrix::SetCorrectionToUnity()
   if (!fhCorr)
     return;
 
-  for (Int_t x=1; x<=fhCorr->GetNbinsX(); ++x)
-    for (Int_t y=1; y<=fhCorr->GetNbinsY(); ++y)
-      for (Int_t z=1; z<=fhCorr->GetNbinsZ(); ++z)
+  for (Int_t x=0; x<=fhCorr->GetNbinsX()+1; ++x)
+    for (Int_t y=0; y<=fhCorr->GetNbinsY()+1; ++y)
+      for (Int_t z=0; z<=fhCorr->GetNbinsZ()+1; ++z)
+      {
         fhCorr->SetBinContent(x, y, z, 1);
+        fhCorr->SetBinError(x, y, z, 0);
+      }
+}
+
+//____________________________________________________________________
+void AliCorrectionMatrix::Scale(Double_t factor)
+{
+  // scales the generated and measured histogram with the given factor
+
+  Printf("Scaling histograms with %f", factor);
+
+  fhMeas->Scale(factor);
+  fhGene->Scale(factor);
+}
+
+//____________________________________________________________________
+void AliCorrectionMatrix::ResetErrorsOnCorrections()
+{
+  // set the errors on the correction matrix to 0
+
+  if (!fhCorr)
+    return;
+
+  for (Int_t x=0; x<=fhCorr->GetNbinsX()+1; ++x)
+    for (Int_t y=0; y<=fhCorr->GetNbinsY()+1; ++y)
+      for (Int_t z=0; z<=fhCorr->GetNbinsZ()+1; ++z)
+        fhCorr->SetBinError(x, y, z, 0);
 }