Fixes for AliForwardCorrectionManager persistency
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Feb 2011 12:39:29 +0000 (12:39 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Feb 2011 12:39:29 +0000 (12:39 +0000)
PWG2/FORWARD/analysis2/AliForwardCorrectionManager.cxx
PWG2/FORWARD/analysis2/AliForwardCorrectionManager.h
PWG2/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx
PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.h
PWG2/FORWARD/analysis2/AnalyseAOD.C
PWG2/FORWARD/analysis2/MakeAOD.C
PWG2/FORWARD/analysis2/Run.sh
PWG2/PWG2forward2LinkDef.h

index 5d63696f56689e101d3f54a0819f033851dca113..6894b8e41db480ab80c6bfa38654b31e49afc3c1 100644 (file)
@@ -7,7 +7,10 @@
 #include <AliLog.h>
 #include <TFile.h>
 #include <TSystem.h>
-
+#include <TBrowser.h>
+#include <TROOT.h>
+#include <iostream>
+#include <iomanip>
     
 //____________________________________________________________________
 AliForwardCorrectionManager* AliForwardCorrectionManager::fgInstance = 0;
@@ -821,6 +824,138 @@ AliForwardCorrectionManager::ReadAcceptance(UShort_t sys,
   // file->Close();
   return kTRUE;
 }
+//____________________________________________________________________
+void
+AliForwardCorrectionManager::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 << "AliForwardCorrectionManager:\n"
+           << ind << "  Initialised:      " 
+           << (fInit ? "yes" : "no") << std::endl;
+  if (fInit) 
+    std::cout << ind << "  Collision system: " 
+             << AliForwardUtil::CollisionSystemString(fSys) << "\n"
+             << ind << "  Sqrt(s_NN):       "
+             << AliForwardUtil::CenterOfMassEnergyString(fSNN) << "\n"
+             << ind << "  Magnetic field:   " 
+             << AliForwardUtil::MagneticFieldString(fField) << std::endl;
+  std::cout << ind << "  Paths:\n" 
+           << ind << "    ELoss Fits:     " << fELossFitsPath << "\n"
+           << ind << "    Merging eff.:   " << fMergingEffPath << "\n"
+           << ind << "    Secondary maps: " << fSecondaryMapPath << "\n"
+           << ind << "    2-hit corr.:    " << fSecondaryMapPath << "\n"
+           << ind << "    Vertex bias:    " << fVertexBiasPath << "\n"
+           << ind << "    Acceptance:     " << fAcceptancePath << std::endl;
+  gROOT->IncreaseDirLevel();
+  if (fELossFit)         fELossFit->Print(option);
+  else 
+    std::cout << ind << "  Energy loss fits  not initialised" << std::endl;
+  
+  if (fSecondaryMap)     fSecondaryMap->Print(option);
+  else 
+    std::cout << ind << "  Secondary particle correction not initialised" 
+             << std::endl;
+
+  if (fDoubleHit)        fDoubleHit->Print(option);
+  else 
+    std::cout << ind << "  Double hit corr. not initialised" << std::endl;
+
+  if (fVertexBias)       fVertexBias->Print(option);
+  else 
+    std::cout << ind << "  Vertex bias correction not initialised" << std::endl;
+  if (fMergingEfficiency) fMergingEfficiency->Print(option);
+  else 
+    std::cout << ind << "  Merging eff.  not initialised" << std::endl;
+
+  if (fAcceptance)       fAcceptance->Print(option);
+  else 
+    std::cout << ind << "  Acceptance corr.  not initialised" << std::endl;
+  gROOT->DecreaseDirLevel();  
+}
+
+//____________________________________________________________________
+void
+AliForwardCorrectionManager::Browse(TBrowser* b)
+{
+  if (fELossFit)         b->Add(fELossFit,          "Energy loss fits");
+  if (fSecondaryMap)     b->Add(fSecondaryMap,      "Secondary particle corr");
+  if (fDoubleHit)        b->Add(fDoubleHit,         "Double hit corr");
+  if (fVertexBias)       b->Add(fVertexBias,        "Vertex bias corr");
+  if (fMergingEfficiency) b->Add(fMergingEfficiency, "Merging eff");
+  if (fAcceptance)       b->Add(fAcceptance,        "Acceptance corr");
+}
+
+#if 1
+//______________________________________________________________________________
+void AliForwardCorrectionManager::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliForwardCorrectionManager.
+
+   if (R__b.IsReading()) {
+      R__b.ReadClassBuffer(AliForwardCorrectionManager::Class(),this);
+      if (fgInstance) 
+       AliWarning(Form("Singleton instance already set (%p) when reading "
+                       "singleton object (%p).  Read object will be new "
+                       "singleton object", fgInstance, this));
+      fgInstance = this;
+   } else {
+      R__b.WriteClassBuffer(AliForwardCorrectionManager::Class(),this);
+   }
+}
+#endif
+#if 0
+//______________________________________________________________________________
+void AliForwardCorrectionManager::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliForwardCorrectionManager.
+
+   UInt_t R__s, R__c;
+   if (R__b.IsReading()) {
+      Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
+      TObject::Streamer(R__b);
+      R__b >> fInit;
+      R__b >> fSys;
+      R__b >> fSNN;
+      R__b >> fField;
+      fELossFitsPath.Streamer(R__b);
+      fMergingEffPath.Streamer(R__b);
+      fSecondaryMapPath.Streamer(R__b);
+      fDoubleHitPath.Streamer(R__b);
+      fVertexBiasPath.Streamer(R__b);
+      fAcceptancePath.Streamer(R__b);
+      R__b >> fELossFit;
+      R__b >> fSecondaryMap;
+      R__b >> fDoubleHit;
+      R__b >> fVertexBias;
+      R__b >> fMergingEfficiency;
+      R__b >> fAcceptance;
+      R__b.CheckByteCount(R__s, R__c, AliForwardCorrectionManager::IsA());
+   } else {
+      R__c = R__b.WriteVersion(AliForwardCorrectionManager::IsA(), kTRUE);
+      TObject::Streamer(R__b);
+      R__b << fInit;
+      R__b << fSys;
+      R__b << fSNN;
+      R__b << fField;
+      fELossFitsPath.Streamer(R__b);
+      fMergingEffPath.Streamer(R__b);
+      fSecondaryMapPath.Streamer(R__b);
+      fDoubleHitPath.Streamer(R__b);
+      fVertexBiasPath.Streamer(R__b);
+      fAcceptancePath.Streamer(R__b);
+      R__b << fELossFit;
+      R__b << fSecondaryMap;
+      R__b << fDoubleHit;
+      R__b << fVertexBias;
+      R__b << fMergingEfficiency;
+      R__b << fAcceptance;
+      R__b.SetByteCount(R__c, kTRUE);
+   }
+}
+#endif
 
 //____________________________________________________________________
 //
index 76dbdc337c90ea549d96b962c42da71a070d2ea3..8812628483c1748a79eb7e96a4ba5ede0a594e36 100644 (file)
 #include "AliFMDCorrAcceptance.h"
 #include <TString.h>
 class TFile;
+class TBrowser;
 
 /**
  * Manager (singleton) of corrections 
+ *
+ * Note, that this class has a custom streamer.  That is to ensure
+ * that the singleton pointer is correctly set on reading in an object
+ * of this type.
  * 
  * @ingroup pwg2_forward_corr 
  */
@@ -38,6 +43,12 @@ public:
                                  kDoubleHit|
                                  kAcceptance)
   };
+  /** 
+   * Default constructor.  This is public for the sake of the ROOT I/O
+   * system, but should never be used outside of that system - that
+   * is, do not use this constructor
+   */
+  AliForwardCorrectionManager();
   /** 
    * Access to the singleton object 
    * 
@@ -279,11 +290,26 @@ public:
   /* 
    * @} 
    */
-private:
+  /**
+   * @{ 
+   * @name Misc 
+   */
   /** 
-   * Default constructor 
+   * Print this object 
+   * 
+   * @param option Passed verbatim to correction objects
    */
-  AliForwardCorrectionManager();
+  void Print(Option_t* option="") const;
+  /** 
+   * Browse this object 
+   * 
+   * @param b Browser to use 
+   */
+  void Browse(TBrowser* b);
+  /* 
+   * @}
+   */
+private:
   /** 
    * Copy constructor 
    * 
@@ -413,8 +439,7 @@ private:
   /* 
    * @}
    */
-
-  ClassDef(AliForwardCorrectionManager,1) // Manager of corrections 
+  ClassDef(AliForwardCorrectionManager,2) // Manager of corrections 
 };
 //____________________________________________________________________
 inline const TAxis* 
index cff88b5dab962ecd91ee028a843a9ee2825a352c..ada6a14814943745f1009a27cc9df40be7bb3cee 100644 (file)
@@ -168,7 +168,7 @@ AliForwardMCMultiplicityTask::InitializeSubs()
   const TAxis* pe = 0;
   const TAxis* pv = 0;
 
-  if (!ReadCorrections(pe,pv)) return;
+  if (!ReadCorrections(pe,pv,true)) return;
 
   fHistos.Init(*pe);
   fAODFMD.Init(*pe);
index d1933db50f493d9abbfa627e37257a5f9fb32a34..0b38c914c9f6b1d5ab24de5b68cdd30eab37f4df 100644 (file)
 
 
 //====================================================================
+AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name) 
+  : AliAnalysisTaskSE(name), 
+    fEnableLowFlux(true), 
+    fFirstEvent(true),
+    fCorrManager(0)
+{
+  // Set our persistent pointer 
+  fCorrManager = &AliForwardCorrectionManager::Instance();
+}
+
+//____________________________________________________________________
 Bool_t 
 AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
 {
@@ -90,7 +101,9 @@ AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
 }
 //____________________________________________________________________
 Bool_t
-AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe, const TAxis*& pv)
+AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe, 
+                                           const TAxis*& pv, 
+                                           Bool_t        mc)
 {
   UInt_t what = AliForwardCorrectionManager::kAll;
   if (!fEnableLowFlux)
@@ -111,12 +124,15 @@ AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe, const TAxis*& pv)
 
   AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
   if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
-      GetEventInspector().GetEnergy(),
-      GetEventInspector().GetField(),
-      false,
-      what)) return false;
+               GetEventInspector().GetEnergy(),
+               GetEventInspector().GetField(),
+               mc,
+               what)) return false;
   if (!CheckCorrections(what)) return false;
 
+  // Sett our persistency pointer 
+  // fCorrManager = &fcm;
+
   // Get the eta axis from the secondary maps - if read in
   if (!pe) {
     pe = fcm.GetEtaAxis();
index 42856abc14580b011322b7197b619c57c4bb0e98..4b426ddd53b7e6908e5478be2f12691cf2493829 100644 (file)
@@ -12,6 +12,7 @@ class AliFMDSharingFilter;
 class AliFMDDensityCalculator;
 class AliFMDCorrector;
 class AliFMDHistCollector;
+class AliForwardCorrectionManager;
 class AliESDEvent;
 class TH2D;
 class TList;
@@ -183,17 +184,15 @@ protected:
    * 
    * @param name Name of task 
    */
-  AliForwardMultiplicityBase(const char* name) 
-    : AliAnalysisTaskSE(name), 
-      fEnableLowFlux(true), 
-      fFirstEvent(true)
-  {}
+  AliForwardMultiplicityBase(const char* name); 
   /** 
    * Constructor
    */
-  AliForwardMultiplicityBase() : AliAnalysisTaskSE(), 
-      fEnableLowFlux(true), 
-      fFirstEvent(true)
+  AliForwardMultiplicityBase() 
+  : AliAnalysisTaskSE(), 
+    fEnableLowFlux(true), 
+    fFirstEvent(true),
+    fCorrManager(0)
   {}
   /** 
    * Copy constructor 
@@ -203,7 +202,8 @@ protected:
   AliForwardMultiplicityBase(const AliForwardMultiplicityBase& o)
     : AliAnalysisTaskSE(o),
       fEnableLowFlux(o.fEnableLowFlux), 
-      fFirstEvent(o.fFirstEvent)
+      fFirstEvent(o.fFirstEvent),
+      fCorrManager(o.fCorrManager)
   {}
   /** 
    * Assignment operator 
@@ -216,6 +216,7 @@ protected:
   {
     fEnableLowFlux = o.fEnableLowFlux;
     fFirstEvent    = o.fFirstEvent;
+    fCorrManager   = o.fCorrManager;
     return *this;
   }
   /** 
@@ -231,7 +232,9 @@ protected:
    * Read corrections
    *
    */
-  virtual Bool_t ReadCorrections(const TAxis*& pe, const TAxis*& pv);
+  virtual Bool_t ReadCorrections(const TAxis*& pe, 
+                                const TAxis*& pv,
+                                Bool_t mc=false);
   /**
    * Get the ESD event. IF this is the first event, initialise
    */
@@ -249,8 +252,17 @@ protected:
 
   Bool_t                 fEnableLowFlux;// Whether to use low-flux specific code
   Bool_t                 fFirstEvent;   // Whether the event is the first seen 
+private:
+  /**
+   * A pointer to the corrections manager.  This is here to make the
+   * corrections manager persistent - that is, when we write the
+   * analysis train to a file (as done in PROOF) we should also write
+   * down the corrections mananger.   This pointer ensures that. 
+   * 
+   */
+  AliForwardCorrectionManager* fCorrManager; // Pointer to corrections manager
 
-  ClassDef(AliForwardMultiplicityBase,1) // Forward multiplicity class
+  ClassDef(AliForwardMultiplicityBase,2) // Forward multiplicity class
 };
 
 #endif
index d89b26e67760487936b564e0143bd24a83627f48..1ee960bcbdb22aa269f18c96ab8238cbf465eee2 100644 (file)
@@ -564,11 +564,13 @@ public:
     if (fSumCentral) { 
       dndetaCentral = fSumCentral->ProjectionX("dndetaCentral", -1, -1, "e");
       dndetaCentral->SetTitle("ALICE Central");
-      dndetaCentral->Scale(1./fNTriggered, "width");
+      // dndetaCentral->Scale(1./fNTriggered, "width");
+      dndetaCentral->Scale(1./(fNB-fNA-fNC+2*fNE), "width");
       dndetaCentral->SetMarkerColor(kGray+3);
       dndetaCentral->SetMarkerStyle(22);
       dndetaCentral->SetMarkerSize(1);
       dndetaCentral->SetFillStyle(0);
+      dndetaCentral->GetXaxis()->SetRangeUser(-1,1);
       Rebin(dndetaCentral, rebin <= 1 ? 1 : 2*(rebin/2));
       // 1 -> 1
       // 2 -> 2*2/2 -> 2*1 -> 2
index ad5f428be731cc936cd28e12c45ca905338247ca..4f692eeea3e9c487288829c62a23473603d44978 100644 (file)
@@ -97,15 +97,15 @@ void MakeAOD(const char* esddir,
   // Centrality 
   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/Compile.C");
   // gDebug = 10;
-  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCopyHeader.C","+");
+  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCopyHeader.C","");
   // gDebug = 10;
-  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/AliESDCentrality.C","+g");
+  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/AliESDCentrality.C","");
   // gDebug = 0;
   AddTaskCopyHeader();
 
 
   // Central multiplicity
-  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCentralMult.C","+");
+  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCentralMult.C","");
   AddTaskCentralMult();
 #endif
 
index 1d2d1b8f58120ca733bfc83cf4d6cb90bafcb929..8e4bde8a735b50f9412f963ea6329df78419ec0c 100755 (executable)
@@ -17,6 +17,7 @@ hhd=1
 comp=1
 tit=
 pass1=Pass1.C
+output=forward.root
 
 usage()
 {
@@ -77,7 +78,9 @@ while test $# -gt 0 ; do
        -V|--vz-max)         vzmax=$2         ; shift ;; 
        -e|--energy)         cms=$2           ; shift ;;
        -S|--title)          tit="$2"         ; shift ;;
-       -E|--eloss)          pass1=MakeELossFits.C ; nodraw=1 ;;
+       -E|--eloss)          pass1=MakeELossFits.C ; 
+                            output=forward_eloss.root ;
+                            nodraw=1 ;;
        -t|--type)           
            if test "x$type" = "x" ; then type=$2 ; else type="$type|$2"; fi
            shift ;;
@@ -120,11 +123,14 @@ if test $noanal -lt 1 ; then
        EventStat_temp.root \
        outputs_valid \
        `printf %09d.stat $nev` 
-    if  test $fail -gt 0               || \
-       test ! -f AnalysisResults.root || \
-       test ! -f AliAODs.root ; then 
-       echo "Analysis failed" 
-       exit 1
+    if  test $fail -gt 0  ; then 
+        echo "Return value $fail not 0" ; exit $fail 
+    fi
+    if test ! -f ${output} ; then 
+       echo "$output not made" ; exit 1; 
+    fi
+    if test ! -f AliAODs.root ; then 
+       echo "No AOD creates" ; exit 1;
     fi
     echo "Analysis done"
 fi
index a04447515961600c19cbd219e69d7015ab3c238d..ef3aab4d8b80cea5a7f5827c299d669dec377bce 100644 (file)
@@ -58,7 +58,8 @@
 #pragma link C++ class AliForwardMultiplicityBase+;
 #pragma link C++ class AliForwardMultiplicityTask+;
 #pragma link C++ class AliForwardMCMultiplicityTask+;
-#pragma link C++ class AliForwardCorrectionManager+;
+// Note: custom streamer to ensure singleton consistency!
+#pragma link C++ class AliForwardCorrectionManager-;
 #pragma link C++ class AliForwardMCCorrectionsTask+;
 
 #else