Make sure that histograms are obtained from output list in
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Nov 2010 13:29:24 +0000 (13:29 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Nov 2010 13:29:24 +0000 (13:29 +0000)
AliForwardMultiplicity::Terminate and all called member functions.

This is to allow for PROOF mode where terminate isn't called until
after the sub-jobs output files have been merged properly.

Also make sure that all objects needed are persistent - needed
when the analysis train is written to a file.

PWG2/FORWARD/analysis2/AliFMDCorrections.cxx
PWG2/FORWARD/analysis2/AliFMDCorrections.h
PWG2/FORWARD/analysis2/AliFMDDensityCalculator.cxx
PWG2/FORWARD/analysis2/AliFMDDensityCalculator.h
PWG2/FORWARD/analysis2/AliFMDSharingFilter.cxx
PWG2/FORWARD/analysis2/AliFMDSharingFilter.h
PWG2/FORWARD/analysis2/AliForwardMultiplicity.cxx
PWG2/FORWARD/analysis2/AliForwardMultiplicity.h
PWG2/FORWARD/analysis2/AliForwardUtil.cxx
PWG2/FORWARD/analysis2/AliForwardUtil.h
PWG2/FORWARD/analysis2/RunManager.C

index bec656673806887e14d7e4b8195301789e8bb5bb..3b3afb265067644d921f851e0c1eaab66edb6081 100644 (file)
@@ -147,20 +147,20 @@ AliFMDCorrections::Correct(AliForwardUtil::Histos& hists,
 
 //____________________________________________________________________
 void
-AliFMDCorrections::ScaleHistograms(Int_t nEvents)
+AliFMDCorrections::ScaleHistograms(TList* dir, Int_t nEvents)
 {
   if (nEvents <= 0) return;
+  TList* d = static_cast<TList*>(dir->FindObject(GetName()));
+  if (!d) return;
 
   TIter    next(&fRingHistos);
   RingHistos* o = 0;
-  while ((o = static_cast<RingHistos*>(next()))) {
-    o->fDensity->Scale(1. / nEvents);
-  }
+  while ((o = static_cast<RingHistos*>(next())))
+    o->ScaleHistograms(d, nEvents);
 }
-
 //____________________________________________________________________
 void
-AliFMDCorrections::Output(TList* dir)
+AliFMDCorrections::DefineOutput(TList* dir)
 {
   TList* d = new TList;
   d->SetName(GetName());
@@ -174,15 +174,13 @@ AliFMDCorrections::Output(TList* dir)
 
 //====================================================================
 AliFMDCorrections::RingHistos::RingHistos()
-  : fDet(0),
-    fRing('\0'),
+  : AliForwardUtil::RingHistos(), 
     fDensity(0)
 {}
 
 //____________________________________________________________________
 AliFMDCorrections::RingHistos::RingHistos(UShort_t d, Char_t r)
-  : fDet(d), 
-    fRing(r),
+  : AliForwardUtil::RingHistos(d,r), 
     fDensity(0)
 {
   fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r), 
@@ -196,9 +194,7 @@ AliFMDCorrections::RingHistos::RingHistos(UShort_t d, Char_t r)
 }
 //____________________________________________________________________
 AliFMDCorrections::RingHistos::RingHistos(const RingHistos& o)
-  : TObject(o), 
-    fDet(o.fDet), 
-    fRing(o.fRing),
+  : AliForwardUtil::RingHistos(o), 
     fDensity(o.fDensity)
 {}
 
@@ -206,8 +202,7 @@ AliFMDCorrections::RingHistos::RingHistos(const RingHistos& o)
 AliFMDCorrections::RingHistos&
 AliFMDCorrections::RingHistos::operator=(const RingHistos& o)
 {
-  fDet  = o.fDet;
-  fRing = o.fRing;
+  AliForwardUtil::RingHistos::operator=(o);
   
   if (fDensity) delete fDensity;
   
@@ -225,10 +220,19 @@ AliFMDCorrections::RingHistos::~RingHistos()
 void
 AliFMDCorrections::RingHistos::Output(TList* dir)
 {
-  TList* d = new TList;
-  d->SetName(Form("FMD%d%c", fDet, fRing)); 
+  TList* d = DefineOutputList(dir);
   d->Add(fDensity);
-  dir->Add(d);
+}
+
+//____________________________________________________________________
+void
+AliFMDCorrections::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
+{ 
+  TList* l = GetOutputList(dir);
+  if (!l) return; 
+
+  TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data()));
+  if (density) density->Scale(1./nEvents);
 }
 
 //____________________________________________________________________
index 6b39cbadade4f5e19e0ac71f2c4dcfab3e0d1f12..5e82593ab22922e04f8dfe402d206220ffbc15ab 100644 (file)
@@ -69,18 +69,18 @@ public:
    * 
    * @param nEvents Number of events 
    */
-  void ScaleHistograms(Int_t nEvents);
+  void ScaleHistograms(TList* dir, Int_t nEvents);
   /** 
    * Output diagnostic histograms to directory 
    * 
    * @param dir List to write in
    */  
-  void Output(TList* dir);
+  void DefineOutput(TList* dir);
 protected:
   /** 
    * Internal data structure to keep track of the histograms
    */
-  struct RingHistos : public TObject 
+  struct RingHistos : public AliForwardUtil::RingHistos 
   { 
     /** 
      * Default CTOR
@@ -112,9 +112,14 @@ protected:
      */
     ~RingHistos();
     void Output(TList* dir);
-    UShort_t  fDet;          // Detector
-    Char_t    fRing;         // Ring
+    /** 
+     * Scale the histograms to the total number of events 
+     * 
+     * @param nEvents Number of events 
+     */
+    void ScaleHistograms(TList* dir, Int_t nEvents);
     TH2D*     fDensity;      // Distribution primary Nch
+    ClassDef(RingHistos,1);
   };
   /** 
    * Get the ring histogram container 
index c09fbdacc5f4da2eac27dccc6547e7253c529ae8..93f62bdfc9b79a462f604b3aee7c033c48a9a859 100644 (file)
@@ -217,20 +217,21 @@ AliFMDDensityCalculator::AcceptanceCorrection(Char_t r, UShort_t t) const
 
 //____________________________________________________________________
 void
-AliFMDDensityCalculator::ScaleHistograms(Int_t nEvents)
+AliFMDDensityCalculator::ScaleHistograms(TList* dir, Int_t nEvents)
 {
   if (nEvents <= 0) return;
+  TList* d = static_cast<TList*>(dir->FindObject(GetName()));
+  if (!d) return;
 
   TIter    next(&fRingHistos);
   RingHistos* o = 0;
-  while ((o = static_cast<RingHistos*>(next()))) {
-    o->fDensity->Scale(1. / nEvents);
-  }
+  while ((o = static_cast<RingHistos*>(next())))
+    o->ScaleHistograms(d, nEvents);
 }
 
 //____________________________________________________________________
 void
-AliFMDDensityCalculator::Output(TList* dir)
+AliFMDDensityCalculator::DefineOutput(TList* dir)
 {
   TList* d = new TList;
   d->SetName(GetName());
@@ -244,8 +245,7 @@ AliFMDDensityCalculator::Output(TList* dir)
 
 //====================================================================
 AliFMDDensityCalculator::RingHistos::RingHistos()
-  : fDet(0),
-    fRing('\0'),
+  : AliForwardUtil::RingHistos(),
     fEvsN(0), 
     fEvsM(0), 
     fDensity(0)
@@ -253,19 +253,18 @@ AliFMDDensityCalculator::RingHistos::RingHistos()
 
 //____________________________________________________________________
 AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
-  : fDet(d), 
-    fRing(r),
+  : AliForwardUtil::RingHistos(d,r),
     fEvsN(0), 
     fEvsM(0),
     fDensity(0)
 {
-  fEvsN = new TH2D(Form("FMD%d%c_Eloss_N_nocorr", d, r), 
+  fEvsN = new TH2D(Form("%s_Eloss_N_nocorr", fName.Data()), 
                   Form("Energy loss vs uncorrected inclusive "
-                       "N_{ch} in FMD%d%c", d, r), 
+                       "N_{ch} in %s", fName.Data()), 
                   100, -.5, 24.5, 100, -.5, 24.5);
-  fEvsM = new TH2D(Form("FMD%d%c_Eloss_N_corr", d, r), 
-                  Form("Energy loss vs corrected inclusive N_{ch} in FMD%d%c",
-                       d, r), 100, -.5, 24.5, 100, -.5, 24.5);
+  fEvsM = new TH2D(Form("%s_Eloss_N_corr", fName.Data()), 
+                  Form("Energy loss vs corrected inclusive N_{ch} in %s",
+                       fName.Data()), 100, -.5, 24.5, 100, -.5, 24.5);
   fEvsN->SetXTitle("#Delta E/#Delta E_{mip}");
   fEvsN->SetYTitle("Inclusive N_{ch} (uncorrected)");
   fEvsN->Sumw2();
@@ -275,8 +274,8 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
   fEvsM->Sumw2();
   fEvsM->SetDirectory(0);
 
-  fDensity = new TH2D(Form("FMD%d%c_Incl_Density", d, r), 
-                     Form("in FMD%d%c", d, r), 
+  fDensity = new TH2D(Form("%s_Incl_Density", fName.Data()), 
+                     Form("Inclusive N_{ch} densitu in %s", fName.Data()), 
                      200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40), 
                      0, 2*TMath::Pi());
   fDensity->SetDirectory(0);
@@ -286,9 +285,7 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
 }
 //____________________________________________________________________
 AliFMDDensityCalculator::RingHistos::RingHistos(const RingHistos& o)
-  : TObject(o), 
-    fDet(o.fDet), 
-    fRing(o.fRing), 
+  : AliForwardUtil::RingHistos(o), 
     fEvsN(o.fEvsN), 
     fEvsM(o.fEvsM),
     fDensity(o.fDensity)
@@ -298,8 +295,7 @@ AliFMDDensityCalculator::RingHistos::RingHistos(const RingHistos& o)
 AliFMDDensityCalculator::RingHistos&
 AliFMDDensityCalculator::RingHistos::operator=(const RingHistos& o)
 {
-  fDet  = o.fDet;
-  fRing = o.fRing;
+  AliForwardUtil::RingHistos::operator=(o);
   
   if (fEvsN)    delete  fEvsN;
   if (fEvsM)    delete  fEvsM;
@@ -323,12 +319,21 @@ AliFMDDensityCalculator::RingHistos::~RingHistos()
 void
 AliFMDDensityCalculator::RingHistos::Output(TList* dir)
 {
-  TList* d = new TList;
-  d->SetName(Form("FMD%d%c", fDet, fRing)); 
+  TList* d = DefineOutputList(dir);
   d->Add(fEvsN);
   d->Add(fEvsM);
   d->Add(fDensity);
-  dir->Add(d);
+}
+
+//____________________________________________________________________
+void
+AliFMDDensityCalculator::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
+{
+  TList* l = GetOutputList(dir);
+  if (!l) return; 
+
+  TH1* density = GetOutputHist(l,Form("%s_Incl_Density", fName.Data()));
+  if (density) density->Scale(1./nEvents);
 }
 
 //____________________________________________________________________
index ffafb52fac8ca172e3be380ba11b9d17e566959f..5c1058afe40433977ef1164e862c0aea41ef9025 100644 (file)
@@ -73,13 +73,13 @@ public:
    * 
    * @param nEvents Number of events 
    */
-  void ScaleHistograms(Int_t nEvents);
+  void ScaleHistograms(TList* dir, Int_t nEvents);
   /** 
    * Output diagnostic histograms to directory 
    * 
    * @param dir List to write in
    */  
-  void Output(TList* dir);
+  void DefineOutput(TList* dir);
 protected:
   /** 
    * Get the number of particles corresponding to the signal mult
@@ -130,7 +130,7 @@ protected:
   /** 
    * Internal data structure to keep track of the histograms
    */
-  struct RingHistos : public TObject 
+  struct RingHistos : public AliForwardUtil::RingHistos
   { 
     /** 
      * Default CTOR
@@ -162,11 +162,16 @@ protected:
      */
     ~RingHistos();
     void Output(TList* dir);
-    UShort_t  fDet;          // Detector
-    Char_t    fRing;         // Ring
+    /** 
+     * Scale the histograms to the total number of events 
+     * 
+     * @param nEvents Number of events 
+     */
+    void ScaleHistograms(TList* dir, Int_t nEvents);
     TH2D*     fEvsN;         // Correlation of Eloss vs uncorrected Nch
     TH2D*     fEvsM;         // Correlation of Eloss vs corrected Nch
     TH2D*     fDensity;      // Distribution inclusive Nch
+    ClassDef(RingHistos,1);
   };
   /** 
    * Get the ring histogram container 
index 26176494dd34d877b201aac3e327dee1b5d74158..dcb0863be78fe2839fbea389a3d853dba6b56d9d 100644 (file)
@@ -324,21 +324,21 @@ AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
 
 //____________________________________________________________________
 void
-AliFMDSharingFilter::ScaleHistograms(Int_t nEvents)
+AliFMDSharingFilter::ScaleHistograms(TList* dir, Int_t nEvents)
 {
   if (nEvents <= 0) return;
+  TList* d = static_cast<TList*>(dir->FindObject(GetName()));
+  if (!d) return;
 
   TIter    next(&fRingHistos);
   RingHistos* o = 0;
-  while ((o = static_cast<RingHistos*>(next()))) {
-    o->fBefore->Scale(1. / nEvents);
-    o->fAfter->Scale(1. / nEvents);
-  }
+  while ((o = static_cast<RingHistos*>(next())))
+    o->ScaleHistograms(d, nEvents);
 }
 
 //____________________________________________________________________
 void
-AliFMDSharingFilter::Output(TList* dir)
+AliFMDSharingFilter::DefineOutput(TList* dir)
 {
   TList* d = new TList;
   d->SetName(GetName());
@@ -353,8 +353,7 @@ AliFMDSharingFilter::Output(TList* dir)
   
 //====================================================================
 AliFMDSharingFilter::RingHistos::RingHistos()
-  : fDet(0),
-    fRing('\0'),
+  : AliForwardUtil::RingHistos(), 
     fBefore(0), 
     fAfter(0), 
     fHits(0),
@@ -363,19 +362,18 @@ AliFMDSharingFilter::RingHistos::RingHistos()
 
 //____________________________________________________________________
 AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
-  : fDet(d), 
-    fRing(r),
+  : AliForwardUtil::RingHistos(d,r), 
     fBefore(0), 
     fAfter(0),
     fHits(0),
     fNHits(0)
 {
-  fBefore = new TH1D(Form("FMD%d%c_ESD_Eloss", d, r), 
-                    Form("Energy loss in FMD%d%c (reconstruction)", d, r), 
-                    1000, 0, 25);
-  fAfter  = new TH1D(Form("FMD%d%c_Ana_Eloss", d, r), 
-                    Form("Energy loss in FMD%d%c (sharing corrected)", d, r), 
+  fBefore = new TH1D(Form("%s_ESD_Eloss", fName.Data()), 
+                    Form("Energy loss in %s (reconstruction)", fName.Data()), 
                     1000, 0, 25);
+  fAfter  = new TH1D(Form("%s_Ana_Eloss", fName.Data()), 
+                    Form("Energy loss in %s (sharing corrected)",
+                         fName.Data()), 1000, 0, 25);
   fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
   fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
   fBefore->SetFillColor(kRed+1);
@@ -389,8 +387,8 @@ AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
   // fAfter->Sumw2();
   fAfter->SetDirectory(0);
 
-  fHits = new TH1D(Form("FMD%d%c_Hits", d, r), 
-                  Form("Number of hits in FMD%d%c", d, r), 
+  fHits = new TH1D(Form("%s_Hits", fName.Data()), 
+                  Form("Number of hits in %s", fName.Data()), 
                   200, 0, 200000);
   fHits->SetDirectory(0);
   fHits->SetXTitle("# of hits");
@@ -398,9 +396,7 @@ AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
 }
 //____________________________________________________________________
 AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
-  : TObject(o), 
-    fDet(o.fDet), 
-    fRing(o.fRing), 
+  : AliForwardUtil::RingHistos(o), 
     fBefore(o.fBefore), 
     fAfter(o.fAfter),
     fHits(o.fHits),
@@ -411,6 +407,7 @@ AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
 AliFMDSharingFilter::RingHistos&
 AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
 {
+  AliForwardUtil::RingHistos::operator=(o);
   fDet = o.fDet;
   fRing = o.fRing;
   
@@ -438,12 +435,26 @@ AliFMDSharingFilter::RingHistos::Finish()
   fHits->Fill(fNHits);
 }
 
+//____________________________________________________________________
+void
+AliFMDSharingFilter::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
+{
+  TList* l = GetOutputList(dir);
+  if (!l) return; 
+
+  TH1D* before = static_cast<TH1D*>(l->FindObject(Form("%s_ESD_ELoss",
+                                                      fName.Data())));
+  TH1D* after  = static_cast<TH1D*>(l->FindObject(Form("%s_Ana_ELoss",
+                                                      fName.Data())));
+  if (before) before->Scale(1./nEvents);
+  if (after)  after->Scale(1./nEvents);
+}
+
 //____________________________________________________________________
 void
 AliFMDSharingFilter::RingHistos::Output(TList* dir)
 {
-  TList* d = new TList;
-  d->SetName(Form("FMD%d%c", fDet, fRing)); 
+  TList* d = DefineOutputList(dir);
   d->Add(fBefore);
   d->Add(fAfter);
   d->Add(fHits);
index d01dc121a265dd094045da0f5875846d3c864744..71bf3cb77fdead72ea4bd4b253df796cca2e83b8 100644 (file)
@@ -3,6 +3,7 @@
 #include <TNamed.h>
 #include <TH2.h>
 #include <TList.h>
+#include "AliForwardUtil.h"
 class AliESDFMD;
 class TAxis;
 class TList;
@@ -64,11 +65,6 @@ public:
    */
   AliFMDSharingFilter& operator=(const AliFMDSharingFilter& o);
 
-  /** 
-   * Initialise the filter 
-   * 
-   */
-  void   Init() {}
   /** 
    * Set the low cut used for sharing 
    * 
@@ -103,14 +99,21 @@ public:
    * 
    * @param nEvents Number of events 
    */
-  void ScaleHistograms(Int_t nEvents);
+  void ScaleHistograms(TList* dir, Int_t nEvents);
   
-  void Output(TList* dir);
+  /** 
+   * Define the output histograms.  These are put in a sub list of the
+   * passed list.   The histograms are merged before the parent task calls 
+   * AliAnalysisTaskSE::Terminate 
+   * 
+   * @param dir Directory to add to 
+   */
+  void DefineOutput(TList* dir);
 protected:
   /** 
    * Internal data structure to keep track of the histograms
    */
-  struct RingHistos : public TObject 
+  struct RingHistos : public AliForwardUtil::RingHistos
   { 
     /** 
      * Default CTOR
@@ -144,17 +147,21 @@ protected:
     /** 
      * Initialise this object 
      */
-    void Init() {} 
     void Clear(const Option_t* ="") { fNHits = 0; } 
     void Incr() { fNHits++; } 
     void Finish(); 
     void Output(TList* dir);
-    UShort_t  fDet;          // Detector
-    Char_t    fRing;         // Ring
+    /** 
+     * Scale the histograms to the total number of events 
+     * 
+     * @param nEvents Number of events 
+     */
+    void ScaleHistograms(TList* dir, Int_t nEvents);
     TH1D*     fBefore;       // Distribution of signals before filter
     TH1D*     fAfter;        // Distribution of signals after filter
     TH1D*     fHits;         // Distribution of hit strips. 
     Int_t     fNHits;        // Number of hit strips per event
+    ClassDef(RingHistos,1);
   };
   /** 
    * Get the ring histogram container 
index f6393b0ee6e538e5c0518061eecf2b2f44465e79..f0d353bdd85121ec6935bab7970d5c4fbb97f01a 100644 (file)
@@ -111,7 +111,7 @@ AliForwardMultiplicity::InitializeSubs()
   AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
   pars->Init(kTRUE);
 
-  fHEventsTr = new TH1I("nEvents", "Number of events w/trigger", 
+  fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger", 
                      pars->GetNvtxBins(), 
                      -pars->GetVtxCutZ(), 
                      pars->GetVtxCutZ());
@@ -120,6 +120,7 @@ AliForwardMultiplicity::InitializeSubs()
   fHEventsTr->SetFillColor(kRed+1);
   fHEventsTr->SetFillStyle(3001);
   fHEventsTr->SetDirectory(0);
+  fList->Add(fHEventsTr);
   // fHEventsTr->Sumw2();
 
   fHEventsTrVtx = new TH1I("nEventsTrVtx", 
@@ -132,6 +133,7 @@ AliForwardMultiplicity::InitializeSubs()
   fHEventsTrVtx->SetFillColor(kBlue+1);
   fHEventsTrVtx->SetFillStyle(3001);
   fHEventsTrVtx->SetDirectory(0);
+  fList->Add(fHEventsTrVtx);
   // fHEventsTrVtx->Sumw2();
 
       
@@ -148,6 +150,7 @@ AliForwardMultiplicity::InitializeSubs()
   fHTriggers->GetXaxis()->SetBinLabel(6,"B");
   fHTriggers->GetXaxis()->SetBinLabel(7,"C");
   fHTriggers->GetXaxis()->SetBinLabel(8,"E");
+  fList->Add(fHTriggers);
 
   TAxis e(pars->GetNetaBins(), pars->GetEtaMin(), pars->GetEtaMax());
   fHistos.Init(e);
@@ -156,7 +159,8 @@ AliForwardMultiplicity::InitializeSubs()
   fHData = static_cast<TH2D*>(fAODFMD.GetHistogram().Clone("d2Ndetadphi"));
   fHData->SetStats(0);
   fHData->SetDirectory(0);
-  fSharingFilter.Init();
+  fList->Add(fHData);
+
   fHistCollector.Init(*(fHEventsTr->GetXaxis()));
 }
 
@@ -176,6 +180,10 @@ AliForwardMultiplicity::UserCreateOutputObjects()
   TObject* obj = &fAODFMD;
   ah->AddBranch("AliAODForwardMult", &obj);
 
+  fSharingFilter.DefineOutput(fList);
+  fDensityCalculator.DefineOutput(fList);
+  fCorrections.DefineOutput(fList);
+
   // fTree = new TTree("T", "T");
   // fTree->Branch("forward", &fAODFMD);
 
@@ -214,12 +222,14 @@ AliForwardMultiplicity::UserExec(Option_t*)
   fAODFMD.Clear();
 
   // Read trigger information from the ESD and store in AOD object
-  if (!ReadTriggers(esd)) { 
+  UInt_t triggers = 0;
+  if (!AliForwardUtil::ReadTriggers(esd, triggers, fHTriggers)) { 
 #ifdef VERBOSE
     AliWarning("Failed to read triggers from ESD");
 #endif
     return;
   }
+  fAODFMD.SetTriggerBits(triggers);
 
   // Mark this event for storage 
   MarkEventForStore();
@@ -245,7 +255,7 @@ AliForwardMultiplicity::UserExec(Option_t*)
 
   // Get the vertex information 
   Double_t vz   = 0;
-  Bool_t   vzOk = ReadVertex(esd, vz);
+  Bool_t   vzOk = AliForwardUtil::ReadVertex(esd, vz);
 
   fHEventsTr->Fill(vz);
   if (!vzOk) { 
@@ -306,41 +316,27 @@ AliForwardMultiplicity::Terminate(Option_t*)
     AliError("No output list defined");
     return;
   }
+  
+  // Get our histograms from the container 
+  TH1I* hEventsTr    = static_cast<TH1I*>(list->FindObject("nEventsTr"));
+  TH1I* hEventsTrVtx = static_cast<TH1I*>(list->FindObject("nEventsTrVtx"));
+  TH2D* hData        = static_cast<TH2D*>(list->FindObject("d2Ndetadphi"));
+  
+  
   // TH1D* dNdeta = fHData->ProjectionX("dNdeta", 0, -1, "e");
-  TH1D* dNdeta = fHData->ProjectionX("dNdeta", 1, -1, "e");
-  TH1D* norm   = fHData->ProjectionX("dNdeta", 0, 1,  "");
+  TH1D* dNdeta = hData->ProjectionX("dNdeta", 1, -1, "e");
+  TH1D* norm   = hData->ProjectionX("dNdeta", 0, 1,  "");
   dNdeta->SetTitle("dN_{ch}/d#eta in the forward regions");
   dNdeta->SetYTitle("#frac{1}{N}#frac{dN_{ch}}{d#eta}");
   dNdeta->Divide(norm);
   dNdeta->SetStats(0);
-  dNdeta->Scale(Double_t(fHEventsTrVtx->GetEntries())/fHEventsTr->GetEntries(),
+  dNdeta->Scale(Double_t(hEventsTrVtx->GetEntries())/hEventsTr->GetEntries(),
                "width");
-
-  list->Add(fHEventsTr);
-  list->Add(fHEventsTrVtx);
-  list->Add(fHTriggers);
-  list->Add(fHData);
   list->Add(dNdeta);
   
-  TList* last = new TList;
-  last->SetName("LastEvent");
-  list->Add(last);
-  last->Add(&fAODFMD.GetHistogram());
-  last->Add(fHistos.fFMD1i);
-  last->Add(fHistos.fFMD2i);
-  last->Add(fHistos.fFMD2o);
-  last->Add(fHistos.fFMD3i);
-  last->Add(fHistos.fFMD3o);
-
-
-  fSharingFilter.ScaleHistograms(fHEventsTr->Integral());
-  fSharingFilter.Output(list);
-
-  fDensityCalculator.ScaleHistograms(fHEventsTrVtx->Integral());
-  fDensityCalculator.Output(list);
-
-  fCorrections.ScaleHistograms(fHEventsTrVtx->Integral());
-  fCorrections.Output(list);
+  fSharingFilter.ScaleHistograms(list,hEventsTr->Integral());
+  fDensityCalculator.ScaleHistograms(list,hEventsTrVtx->Integral());
+  fCorrections.ScaleHistograms(list,hEventsTrVtx->Integral());
 }
 
 //____________________________________________________________________
@@ -356,133 +352,6 @@ AliForwardMultiplicity::MarkEventForStore() const
 
   ah->SetFillAOD(kTRUE);
 }
-//____________________________________________________________________
-Bool_t
-AliForwardMultiplicity::ReadTriggers(AliESDEvent* esd)
-{
-  // Get the analysis manager - should always be there 
-  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
-  if (!am) { 
-    AliWarning("No analysis manager defined!");
-    return kFALSE;
-  }
-
-  // Get the input handler - should always be there 
-  AliInputEventHandler* ih = 
-    static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
-  if (!ih) { 
-    AliWarning("No input handler");
-    return kFALSE;
-  }
-  
-  // Get the physics selection - add that by using the macro 
-  // AddTaskPhysicsSelection.C 
-  AliPhysicsSelection* ps = 
-    static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
-  if (!ps) { 
-    AliWarning("No physics selection");
-    return kFALSE;
-  }
-  
-  // Check if this is a collision candidate (INEL)
-  Bool_t inel = ps->IsCollisionCandidate(esd);
-  if (inel) { 
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kInel);
-    fHTriggers->Fill(.5);
-  }
-  
-
-  // IF this is inel, see if we have a tracklet 
-  if (inel) { 
-    const AliMultiplicity* spdmult = esd->GetMultiplicity();
-    if (!spdmult) {
-      AliWarning("No SPD multiplicity");
-    }
-    else { 
-      Int_t n = spdmult->GetNumberOfTracklets();
-      for (Int_t j = 0; j < n; j++) { 
-       if(TMath::Abs(spdmult->GetEta(j)) < 1) { 
-         fAODFMD.SetTriggerBits(AliAODForwardMult::kInelGt0);
-         fHTriggers->Fill(1.5);
-         break;
-       }
-      }
-    }
-  }
-
-  // Analyse some trigger stuff 
-  AliTriggerAnalysis ta;
-  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kNSD);
-    fHTriggers->Fill(2.5);
-  }
-
-  // Get trigger stuff 
-  TString triggers = esd->GetFiredTriggerClasses();
-  if (triggers.Contains("CBEAMB-ABCE-NOPF-ALL")) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kEmpty);
-    fHTriggers->Fill(3.5);
-  }
-
-  if (triggers.Contains("CINT1A-ABCE-NOPF-ALL")) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kA);
-    fHTriggers->Fill(4.5);
-  }
-
-  if (triggers.Contains("CINT1B-ABCE-NOPF-ALL")) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kB);
-    fHTriggers->Fill(5.5);
-  }
-
-
-  if (triggers.Contains("CINT1C-ABCE-NOPF-ALL")) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kC);
-    fHTriggers->Fill(6.5);
-  }
-
-  if (triggers.Contains("CINT1-E-NOPF-ALL")) {
-    fAODFMD.SetTriggerBits(AliAODForwardMult::kE);
-    fHTriggers->Fill(7.5);
-  }
-
-  return kTRUE;
-}
-//____________________________________________________________________
-Bool_t
-AliForwardMultiplicity::ReadVertex(AliESDEvent* esd, Double_t& vz)
-{
-  // Get the vertex 
-  const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
-  if (!vertex) { 
-#ifdef VERBOSE
-    AliWarning("No SPD vertex found in ESD");
-#endif
-    return kFALSE;
-  }
-
-  // Check that enough tracklets contributed 
-  if(vertex->GetNContributors() <= 0) {
-#ifdef VERBOSE
-    AliWarning(Form("Number of contributors to vertex is %d<=0",
-                   vertex->GetNContributors()));
-#endif
-    return kFALSE;
-  }
-
-  // Check that the uncertainty isn't too large 
-  if (vertex->GetZRes() > 0.1) { 
-#ifdef VERBOSE
-    AliWarning(Form("Uncertaintity in Z of vertex is too large %f > 0.1", 
-                   vertex->GetZRes()));
-#endif
-    return kFALSE;
-  }
-
-  // Get the z coordiante 
-  vz = vertex->GetZ();
-              
-  return kTRUE;
-}
 
 //____________________________________________________________________
 void
index 2bbbaec9b08e097d790b68c3d129ed34d1bb16f6..2f77714f19e4f15d74fe0ee6d76df067b06fc8cf 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef ALIROOT_PWG2_FORWARD_ALIFORWARDMULTIPLICTY_H
-#define ALIROOT_PWG2_FORWARD_ALIFORWARDMULTIPLICTY_H
+#ifndef ALIROOT_PWG2_FORWARD_ALIFORWARDMULTIPLICITY_H
+#define ALIROOT_PWG2_FORWARD_ALIFORWARDMULTIPLICITY_H
 #include <AliAnalysisTaskSE.h>
 #include "AliForwardUtil.h"
 #include "AliFMDSharingFilter.h"
@@ -135,23 +135,6 @@ protected:
    * 
    */
   virtual void MarkEventForStore() const;
-  /** 
-   * Read the trigger information and store in output
-   * 
-   * @param esd ESD event object 
-   * 
-   * @return true in case of success 
-   */
-  virtual Bool_t ReadTriggers(AliESDEvent* esd); 
-  /** 
-   * Read the vertex information, and return the z coordinate 
-   * 
-   * @param esd ESD event object
-   * @param vz  On return, the z coordinate of the primary vertex
-   * 
-   * @return true on success 
-   */
-  virtual Bool_t ReadVertex(AliESDEvent* esd, Double_t& vz);
 
   TH1I*                  fHEventsTr;    // Histogram of events w/trigger
   TH1I*                  fHEventsTrVtx; // Events w/trigger and vertex 
index 1bccf15e22868d94f31578354d7321395c7d1860..bdf2227f2c080508428bbde6fbcf46387477f3d5 100644 (file)
@@ -1,5 +1,14 @@
 #include "AliForwardUtil.h"
+#include <AliAnalysisManager.h>
+#include "AliAODForwardMult.h"
+#include <AliLog.h>
+#include <AliInputEventHandler.h>
+#include <AliESDEvent.h>
+#include <AliPhysicsSelection.h>
+#include <AliTriggerAnalysis.h>
+#include <AliMultiplicity.h>
 #include <TH2D.h>
+#include <TH1I.h>
 #include <TMath.h>
 
 //====================================================================
@@ -75,6 +84,163 @@ AliForwardUtil::Histos::Get(UShort_t d, Char_t r)
   default: return 0;
 }
 #endif
+//====================================================================
+TList*
+AliForwardUtil::RingHistos::DefineOutputList(TList* d) const
+{
+  if (!d) return 0;
+  TList* list = new TList;
+  list->SetName(fName.Data());
+  d->Add(list);
+  return list;
+}
+//____________________________________________________________________
+TList*
+AliForwardUtil::RingHistos::GetOutputList(TList* d) const
+{
+  if (!d) return 0;
+  TList* list = static_cast<TList*>(d->FindObject(fName.Data()));
+  return list;
+}
+
+//____________________________________________________________________
+TH1*
+AliForwardUtil::RingHistos::GetOutputHist(TList* d, const char* name) const
+{
+  return static_cast<TH1*>(d->FindObject(name));
+}
+
+//====================================================================
+Bool_t
+AliForwardUtil::ReadTriggers(AliESDEvent* esd, UInt_t& triggers,
+                            TH1I* hTriggers)
+{
+  triggers = 0;
+
+  // Get the analysis manager - should always be there 
+  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
+  if (!am) { 
+    AliWarningGeneral("ReadTriggers","No analysis manager defined!");
+    return kFALSE;
+  }
+
+  // Get the input handler - should always be there 
+  AliInputEventHandler* ih = 
+    static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
+  if (!ih) { 
+    AliWarningGeneral("ReadTriggers","No input handler");
+    return kFALSE;
+  }
+  
+  // Get the physics selection - add that by using the macro 
+  // AddTaskPhysicsSelection.C 
+  AliPhysicsSelection* ps = 
+    static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+  if (!ps) { 
+    AliWarningGeneral("ReadTriggers","No physics selection");
+    return kFALSE;
+  }
+  
+  // Check if this is a collision candidate (INEL)
+  Bool_t inel = ps->IsCollisionCandidate(esd);
+  if (inel) { 
+    triggers |= AliAODForwardMult::kInel;
+    hTriggers->Fill(0.5);
+  }
+
+  // IF this is inel, see if we have a tracklet 
+  if (inel) { 
+    const AliMultiplicity* spdmult = esd->GetMultiplicity();
+    if (!spdmult) {
+      AliWarningGeneral("ReadTriggers","No SPD multiplicity");
+    }
+    else { 
+      Int_t n = spdmult->GetNumberOfTracklets();
+      for (Int_t j = 0; j < n; j++) { 
+       if(TMath::Abs(spdmult->GetEta(j)) < 1) { 
+         triggers |= AliAODForwardMult::kInelGt0;
+         hTriggers->Fill(1.5);
+         break;
+       }
+      }
+    }
+  }
+
+  // Analyse some trigger stuff 
+  AliTriggerAnalysis ta;
+  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
+    triggers |= AliAODForwardMult::kNSD;
+    hTriggers->Fill(2.5);
+  }
+
+  // Get trigger stuff 
+  TString trigStr = esd->GetFiredTriggerClasses();
+  if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
+    triggers |= AliAODForwardMult::kEmpty;
+    hTriggers->Fill(3.5);
+  }
+
+  if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
+    triggers |= AliAODForwardMult::kA;
+    hTriggers->Fill(4.5);
+  }
+
+  if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
+    triggers |= AliAODForwardMult::kB;
+    hTriggers->Fill(5.5);
+  }
+
+
+  if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
+    triggers |= AliAODForwardMult::kC;
+    hTriggers->Fill(6.5);
+  }
+
+  if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
+    triggers |= AliAODForwardMult::kE;
+    hTriggers->Fill(7.5);
+  }
+
+  return kTRUE;
+}
+//____________________________________________________________________
+Bool_t
+AliForwardUtil::ReadVertex(AliESDEvent* esd, Double_t& vz, Double_t maxErr)
+{
+  // Get the vertex 
+  const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
+  if (!vertex) { 
+#ifdef VERBOSE
+    AliWarningGeneral("ReadVertex","No SPD vertex found in ESD");
+#endif
+    return kFALSE;
+  }
+
+  // Check that enough tracklets contributed 
+  if(vertex->GetNContributors() <= 0) {
+#ifdef VERBOSE
+    AliWarningGeneral("ReadVertex",
+                     Form("Number of contributors to vertex is %d<=0",
+                          vertex->GetNContributors()));
+#endif
+    return kFALSE;
+  }
+
+  // Check that the uncertainty isn't too large 
+  if (vertex->GetZRes() > maxErr) { 
+#ifdef VERBOSE
+    AliWarningGeneral("ReadVertex",
+                     Form("Uncertaintity in Z of vertex is too large %f > %d", 
+                          vertex->GetZRes(), maxErr));
+#endif
+    return kFALSE;
+  }
+
+  // Get the z coordiante 
+  vz = vertex->GetZ();
+              
+  return kTRUE;
+}
 
 //
 // EOF
index 5a6a40cfa15df492ca58032646b928b73aca1b71..996704e1d84f46a18736fc2bc6f540282381bdb1 100644 (file)
@@ -1,8 +1,12 @@
 #ifndef ALIROOT_PWG2_FORWARD_ALIFORWARDUTIL_H
 #define ALIROOT_PWG2_FORWARD_ALIFORWARDUTIL_H
 #include <TObject.h>
+#include <TString.h>
 class TH2D;
+class TH1I;
+class TH1;
 class TAxis;
+class AliESDEvent;
 
 /** 
  * Utilities used in the forward multiplcity analysis 
@@ -11,7 +15,29 @@ class TAxis;
  */
 class AliForwardUtil : public TObject
 {
- public:
+public:
+  /** 
+   * Read the trigger information from the ESD event 
+   * 
+   * @param esd        ESD event 
+   * @param triggers   On return, contains the trigger bits 
+   * @param hTriggers  Histogram to fill 
+   * 
+   * @return @c true on success, @c false otherwise 
+   */
+  static Bool_t ReadTriggers(AliESDEvent* esd, UInt_t& triggers, 
+                            TH1I* hTriggers);
+  /** 
+   * Read the vertex information from the ESD event 
+   * 
+   * @param esd  ESD event 
+   * @param vz   On return, the vertex Z position 
+   * 
+   * @return @c true on success, @c false otherwise 
+   */
+  static Bool_t ReadVertex(AliESDEvent* esd, Double_t& vz,
+                          Double_t maxErr=0.1);
+  //__________________________________________________________________
   /** 
    * Structure to hold histograms 
    *
@@ -85,8 +111,39 @@ class AliForwardUtil : public TObject
     TH2D* fFMD2o; // Histogram for FMD2o
     TH2D* fFMD3i; // Histogram for FMD3i
     TH2D* fFMD3o; // Histogram for FMD3o
+
+    ClassDef(Histos,1) 
   };
 
+  //__________________________________________________________________
+  struct RingHistos : public TObject
+  {
+    RingHistos() : fDet(0), fRing('\0'), fName("") {}
+    RingHistos(UShort_t d, Char_t r) 
+      : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r)) 
+    {}
+    RingHistos(const RingHistos& o) 
+      : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName)
+    {}
+    virtual ~RingHistos() {}
+    RingHistos& operator=(const RingHistos& o) 
+    {
+      TObject::operator=(o);
+      fDet  = o.fDet;
+      fRing = o.fRing;
+      fName = o.fName;
+      return *this;
+    }
+    TList* DefineOutputList(TList* d) const;
+    TList* GetOutputList(TList* d) const;
+    TH1* GetOutputHist(TList* d, const char* name) const;
+    UShort_t fDet; 
+    Char_t   fRing;
+    TString  fName;
+
+    ClassDef(RingHistos,1) 
+  };
+    
 };
 
 #endif
index 283390cf44cc8812d38a0ab71821968df572c797..c77faf3d0462fbfcae7a56cd752010819eda0bd2 100644 (file)
@@ -10,7 +10,8 @@
  * @ingroup pwg2_forward_analysis_scripts
  */
 void RunManager(const char* esd, Bool_t mc=kFALSE, Int_t nEvents=1000,
-               Int_t nCutBins=1, Float_t correctionCut=0.1)
+               Int_t nCutBins=1, Float_t correctionCut=0.1, 
+               const char* mode="local")
 {
   gSystem->Load("libVMC");
   gSystem->Load("libTree");
@@ -70,14 +71,26 @@ void RunManager(const char* esd, Bool_t mc=kFALSE, Int_t nEvents=1000,
   // Run the analysis
     
   TStopwatch t;
-  if (mgr->InitAnalysis()) {
-    mgr->PrintStatus();
-    mgr->SetUseProgressBar(kTRUE);
-    t.Start();
-    mgr->StartAnalysis("local", chain, nEvents);
-    t.Stop();
-    t.Print();
-  }  
+  if (!mgr->InitAnalysis()) {
+    Error("RunManager", "Failed to initialize analysis train!");
+    return;
+  }
+  // Some informative output 
+  mgr->PrintStatus();
+  mgr->SetUseProgressBar(kTRUE);
+
+  // Write train to file - a test 
+  TDirectory* savDir = gDirectory;
+  TFile* file = TFile::Open("analysisTrain.root", "RECREATE");
+  mgr->Write();
+  file->Close();
+  savDir->cd();
+  
+  // Run the train 
+  t.Start();
+  mgr->StartAnalysis(mode, chain, nEvents);
+  t.Stop();
+  t.Print();
 }
 //
 // EOF