]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG0/AliPWG0Helper.cxx
New TPC monitoring package from Stefan Kniege. The monitoring package can be started...
[u/mrichter/AliRoot.git] / PWG0 / AliPWG0Helper.cxx
index b25baaf5c8c2e0000e83dcebdf92b99c4783c553..5466eec538dace8ceeb9d4bd0dc6e1a6a90bcab3 100644 (file)
 #include <AliESD.h>
 #include <AliESDVertex.h>
 
-#include <AliGenEventHeader.h>
-#include <AliGenPythiaEventHeader.h>
-#include <AliGenCocktailEventHeader.h>
-
-
 //____________________________________________________________________
 ClassImp(AliPWG0Helper)
 
 //____________________________________________________________________
-Bool_t AliPWG0Helper::IsEventTriggered(AliESD* aEsd)
+Bool_t AliPWG0Helper::IsEventTriggered(AliESD* aEsd, Trigger trigger)
 {
   // check if the event was triggered
   //
@@ -33,8 +28,21 @@ Bool_t AliPWG0Helper::IsEventTriggered(AliESD* aEsd)
 
   ULong64_t triggerMask = aEsd->GetTriggerMask();
 
-  if (triggerMask&32 && ((triggerMask&1) || (triggerMask&2)))
-    return kTRUE;
+  switch (trigger)
+  {
+    case kMB1:
+    {
+      if (triggerMask&32 || ((triggerMask&1) || (triggerMask&2)))
+        return kTRUE;
+      break;
+    }
+    case kMB2:
+    {
+      if (triggerMask&32 && ((triggerMask&1) || (triggerMask&2)))
+        return kTRUE;
+      break;
+    }
+  }
 
   return kFALSE;
 }
@@ -61,6 +69,8 @@ Bool_t AliPWG0Helper::IsVertexReconstructed(AliESD* aEsd)
   if (vtx_res[2]==0 || vtx_res[2]>0.1)
     return kFALSE;
 
+  // check Ncontributors, if <0 it means error *gna*
+
   return kTRUE;
 }
 
@@ -119,48 +129,7 @@ Bool_t AliPWG0Helper::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimari
 }
 
 //____________________________________________________________________
-const Int_t AliPWG0Helper::GetPythiaEventProcessType(AliHeader* aHeader, Bool_t adebug) {
-  //
-  // get the process type of the event.
-  // 
-
-  // can only read pythia headers, either directly or from cocktalil header
-  AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
-  
-  if (!pythiaGenHeader) {
-    
-    AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
-    if (!genCocktailHeader) {
-      printf("AliPWG0Helper::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
-      return -1;
-    }
-
-    TList* headerList = genCocktailHeader->GetHeaders();
-    if (!headerList) {     
-      return -1;
-    }
-    
-    for (Int_t i=0; i<headerList->GetEntries(); i++) {
-      pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
-      if (pythiaGenHeader)
-       break;
-    }        
-    
-    if (!pythiaGenHeader) {
-      printf("AliPWG0Helper::GetProcessType : Could not find Pythia header. \n");
-      return -1;
-    }
-  }
-  
-  if (adebug) {
-    printf("AliPWG0Helper::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
-  }
-
-  return pythiaGenHeader->ProcessType();        
-}
-
-//____________________________________________________________________
-void AliPWG0Helper::CreateProjections(TH3* hist)
+void AliPWG0Helper::CreateProjections(TH3* hist, Bool_t save)
 {
   // create projections of 3d hists to all 2d combinations
   // the histograms are not returned, just use them from memory or use this to create them in a file
@@ -168,18 +137,24 @@ void AliPWG0Helper::CreateProjections(TH3* hist)
   TH1* proj = hist->Project3D("yx");
   proj->SetXTitle(hist->GetXaxis()->GetTitle());
   proj->SetYTitle(hist->GetYaxis()->GetTitle());
+  if (save)
+    proj->Write();
 
   proj = hist->Project3D("zx");
   proj->SetXTitle(hist->GetXaxis()->GetTitle());
   proj->SetYTitle(hist->GetZaxis()->GetTitle());
+  if (save)
+    proj->Write();
 
   proj = hist->Project3D("zy");
   proj->SetXTitle(hist->GetYaxis()->GetTitle());
   proj->SetYTitle(hist->GetZaxis()->GetTitle());
+  if (save)
+    proj->Write();
 }
 
 //____________________________________________________________________
-void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors)
+void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors, Bool_t save)
 {
   // create projections of the 3d hists divides them
   // axis decides to which plane, if axis is 0 to all planes
@@ -187,9 +162,9 @@ void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char*
 
   if (axis == 0)
   {
-    CreateDividedProjections(hist, hist2, "yx", putErrors);
-    CreateDividedProjections(hist, hist2, "zx", putErrors);
-    CreateDividedProjections(hist, hist2, "zy", putErrors);
+    CreateDividedProjections(hist, hist2, "yx", putErrors, save);
+    CreateDividedProjections(hist, hist2, "zx", putErrors, save);
+    CreateDividedProjections(hist, hist2, "zy", putErrors, save);
 
     return;
   }
@@ -214,7 +189,10 @@ void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char*
     proj2->SetXTitle(GetAxisTitle(hist2, axis[0]));
 
   TH1* division = dynamic_cast<TH1*> (proj->Clone(Form("%s_div_%s", proj->GetName(), proj2->GetName())));
-  division->Divide(proj2);
+  //printf("doing axis: %s, x axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsX(), proj2->GetNbinsX(), division->GetXaxis()->GetBinLowEdge(1), proj2->GetXaxis()->GetBinLowEdge(1), division->GetXaxis()->GetBinUpEdge(division->GetNbinsX()), proj2->GetXaxis()->GetBinUpEdge(proj2->GetNbinsX()));
+  //printf("doing axis: %s, y axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsY(), proj2->GetNbinsY(), division->GetYaxis()->GetBinLowEdge(1), proj2->GetYaxis()->GetBinLowEdge(1), division->GetYaxis()->GetBinUpEdge(division->GetNbinsY()), proj2->GetYaxis()->GetBinUpEdge(proj2->GetNbinsY()));
+  division->Divide(proj, proj2, 1, 1, "B");
+  division->SetTitle(Form("%s divided %s", proj->GetTitle(), proj2->GetTitle()));
 
   if (putErrors)
   {
@@ -222,7 +200,7 @@ void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char*
     if (division->GetDimension() == 1)
     {
       Int_t nBins = division->GetNbinsX();
-      for (Int_t i = 0; i <= nBins; ++i)
+      for (Int_t i = 1; i <= nBins; ++i)
         if (proj2->GetBinContent(i) != 0)
           division->SetBinError(i, TMath::Sqrt(proj->GetBinContent(i)) / proj2->GetBinContent(i));
     }
@@ -230,12 +208,19 @@ void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char*
     {
       Int_t nBinsX = division->GetNbinsX();
       Int_t nBinsY = division->GetNbinsY();
-      for (Int_t i = 0; i <= nBinsX; ++i)
-        for (Int_t j = 0; j <= nBinsY; ++j)
+      for (Int_t i = 1; i <= nBinsX; ++i)
+        for (Int_t j = 1; j <= nBinsY; ++j)
           if (proj2->GetBinContent(i, j) != 0)
             division->SetBinError(i, j, TMath::Sqrt(proj->GetBinContent(i, j)) / proj2->GetBinContent(i, j));
     }
   }
+
+  if (save)
+  {
+    proj->Write();
+    proj2->Write();
+    division->Write();
+  }
 }
 
 //____________________________________________________________________