]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding helper function to count empty bins in AliCorrectionMatrix
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Nov 2006 08:19:19 +0000 (08:19 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Nov 2006 08:19:19 +0000 (08:19 +0000)
adding ESDfriend support in CreateESDChain.C
support for several aliroot version in PWG0Helper

PWG0/AliCorrectionMatrix3D.cxx
PWG0/AliCorrectionMatrix3D.h
PWG0/CreateESDChain.C
PWG0/PWG0Helper.C

index c805387e8a0f522819637cdfd13859f4f8cd25c9..a714603956c4a4352d96a41c4b03b0ede7b9bde3 100644 (file)
@@ -8,6 +8,7 @@
 //
 
 #include <TH3F.h>
+#include <TH1F.h>
 
 #include <AliLog.h>
 
@@ -162,3 +163,51 @@ void AliCorrectionMatrix3D::SaveHistograms()
   if (GetGeneratedHistogram() && GetMeasuredHistogram())
     AliPWG0Helper::CreateDividedProjections(GetGeneratedHistogram(), GetMeasuredHistogram());
 }
+
+//____________________________________________________________________
+Int_t AliCorrectionMatrix3D::CheckEmptyBins(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax, Bool_t quiet)
+{
+  //
+  // counts the number of empty Bins in a given region
+  //
+
+  TH3F* hist = GetGeneratedHistogram();
+  if (!hist)
+    return -1;
+
+  Int_t emptyBins = 0;
+  for (Int_t x=hist->GetXaxis()->FindBin(xmin); x<=hist->GetXaxis()->FindBin(xmax); ++x)
+    for (Int_t y=hist->GetYaxis()->FindBin(ymin); y<=hist->GetYaxis()->FindBin(ymax); ++y)
+      for (Int_t z=hist->GetZaxis()->FindBin(zmin); z<=hist->GetZaxis()->FindBin(zmax); ++z)
+        if (hist->GetBinContent(x, y, z) == 0)
+        {
+          if (!quiet)
+            printf("Empty bin in %s at vtx = %f, eta = %f, pt = %f\n", GetName(), hist->GetXaxis()->GetBinCenter(x), hist->GetYaxis()->GetBinCenter(y), hist->GetZaxis()->GetBinCenter(z));
+          ++emptyBins;
+        }
+
+  return emptyBins;
+}
+
+//____________________________________________________________________
+TH1F* AliCorrectionMatrix3D::PlotBinErrors(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
+{
+  //
+  // makes a 1d plots of the relative bin errors
+  //
+
+  TH3F* hist = GetCorrectionHistogram();
+  if (!hist)
+    return 0;
+    
+  TH1F* target = new TH1F("relerrors", "relerrors", 100, 0, 10);
+
+  for (Int_t x=hist->GetXaxis()->FindBin(xmin); x<=hist->GetXaxis()->FindBin(xmax); ++x)
+    for (Int_t y=hist->GetYaxis()->FindBin(ymin); y<=hist->GetYaxis()->FindBin(ymax); ++y)
+      for (Int_t z=hist->GetZaxis()->FindBin(zmin); z<=hist->GetZaxis()->FindBin(zmax); ++z)
+        if (hist->GetBinContent(x, y, z) != 0)
+          target->Fill(100 * hist->GetBinError(x, y, z) / hist->GetBinContent(x, y, z));
+
+  return target;
+}
+
index 99435d3b5bba79a6861a82c23cf0798ccf83dbd2..16fb80a52665514feaa3bb725cdee3060ca9444a 100644 (file)
@@ -12,6 +12,7 @@
 #include <AliCorrectionMatrix.h>
 
 class TH3F;
+class TH1F;
 
 class AliCorrectionMatrix3D : public AliCorrectionMatrix
 {
@@ -45,6 +46,10 @@ public:
 
   virtual void SaveHistograms();
 
+  Int_t CheckEmptyBins(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax, Bool_t quiet = kFALSE);
+  TH1F* PlotBinErrors(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax);
+
+
 protected:
   ClassDef(AliCorrectionMatrix3D,1)
 };
index b9009f7b5eef8622736b0a649e8d3627c8c8d3d1..a6a2926351146944d8d0e79a19e4915e7a812c6a 100644 (file)
@@ -1,14 +1,36 @@
 /* $Id$ */
 
-// Helper macros for creating chains
-
-TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0)
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// This helper macros creates a chain of ESD files for you. Source can be either a text
+// file with the file paths or a directory. In the latter case all ESD files in all subdirectories
+// are considered.
+//
+// Author: Jan.Fiete.Grosse-Oetringhaus@cern.ch
+
+TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0, Bool_t addFileName = kFALSE, Bool_t addFriend = kFALSE, Bool_t check = kFALSE)
 {
   // creates chain of files in a given directory or file containing a list.
   // In case of directory the structure is expected as:
   // <aDataDir>/<dir0>/AliESDs.root
   // <aDataDir>/<dir1>/AliESDs.root
   // ...
+  //
+  // if addFileName is true the list only needs to contain the directories that contain the AliESDs.root files
+  // if addFriend is true a file AliESDfriends.root is expected in the same directory and added to the chain as friend
 
   if (!aDataDir)
     return 0;
@@ -21,7 +43,10 @@ TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20,
   }
 
   TChain* chain = new TChain("esdTree");
-  TChain* chaingAlice = 0;
+  TChain* chainFriend = 0;
+  
+  if (addFriend)
+    chainFriend = new TChain("esdFriendTree");
 
   if (flags & 2)
   {
@@ -64,11 +89,14 @@ TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20,
     Int_t count = 0;
 
     // Read the input list of files and add them to the chain
-    TString esdfile;
-    while(in.good()) {
-      in >> esdfile;
-      if (!esdfile.Contains("root")) continue; // protection
-
+    TString line;
+    while(in.good()) 
+    {
+      in >> line;
+      
+      if (line.Length() == 0)
+        continue;      
+      
       if (offset > 0)
       {
         --offset;
@@ -78,12 +106,45 @@ TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20,
       if (count++ == aRuns)
         break;
 
+      TString esdFile(line);
+
+      if (addFileName)
+        esdFile += "/AliESDs.root";
+        
+      TString esdFileFriend(esdFile);
+      esdFileFriend.ReplaceAll("AliESDs.root", "AliESDfriends.root");
+        
+      if (check)
+      {
+        TFile* file = TFile::Open(esdFile);
+        if (!file)
+          continue;
+        file->Close();
+        
+        if (chainFriend)
+        {
+          TFile* file = TFile::Open(esdFileFriend);
+          if (!file)
+            continue;
+          file->Close();
+        }
+        
+        printf("%s\n", line.Data());
+      }        
+        
         // add esd file
-      chain->Add(esdfile);
+      chain->Add(esdFile);
+
+        // add file
+      if (chainFriend)
+        chainFriend->Add(esdFileFriend);
     }
 
     in.close();
   }
+  
+  if (chainFriend)
+    chain->AddFriend(chainFriend);
 
   return chain;
 }
@@ -102,7 +163,7 @@ void LookupWrite(TChain* chain, const char* target)
   outfile.open(target);
 
   while ((obj = iter->Next()))
-    outfile << obj->GetTitle() << "#AliESDs.root" << endl;
+    outfile << obj->GetTitle() << endl;
 
   outfile.close();
 
index 9ea4e486a83f230d78d0a2625e7d7e93cf25d0ed..91b3321470e9e3607ea68e181689216b92542332 100644 (file)
@@ -21,7 +21,7 @@ TVirtualProof* connectProof(const char* proofServer)
   return proof;
 }
 
-Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot)
+Bool_t prepareQuery(TString libraries, TString packages, Int_t useAliRoot)
 {
   // if not proof load libraries
   if (!gProof)
@@ -46,8 +46,8 @@ Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot)
   }
   else
   {
-    if (useAliRoot)
-      ProofEnableAliRoot();
+    if (useAliRoot > 0)
+      ProofEnableAliRoot(useAliRoot);
 
     TObjArray* packagesList = packages.Tokenize(";");
     for (Int_t i=0; i<packagesList->GetEntries(); ++i)
@@ -62,6 +62,12 @@ Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot)
         return kFALSE;
       }
 
+      if (gProof->UploadPackage(Form("%s.par", str->String().Data())))
+      {
+        printf("Uploading of package %s failed\n", str->String().Data());
+        return kFALSE;
+      }
+
       if (gProof->EnablePackage(str->String()))
       {
         printf("Loading of package %s failed\n", str->String().Data());
@@ -102,7 +108,7 @@ Int_t executeQuery(TChain* chain, TList* inputList, TString selectorName, const
   return result;
 }
 
-void ProofEnableAliRoot()
+void ProofEnableAliRoot(Int_t aliroot)
 {
   // enables a locally deployed AliRoot in a PROOF cluster
 
@@ -114,7 +120,14 @@ void ProofEnableAliRoot()
      gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C");
   */
 
-  const char* location = "/home/alicecaf/ALICE/aliroot-head";
+  const char* location = 0;
+  
+  switch (aliroot)
+  {
+    case 1: location = "/home/alicecaf/ALICE/aliroot-v4-04-Release"; break;
+    case 2: location = "/home/alicecaf/ALICE/aliroot-head"; break;
+    default: return;
+  }
 
   gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE);
   gProof->AddIncludePath(Form("%s/include", location));