]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Some fixes
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Mar 2011 12:09:52 +0000 (12:09 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Mar 2011 12:09:52 +0000 (12:09 +0000)
14 files changed:
PWG2/FORWARD/analysis2/AddTaskCentralMult.C
PWG2/FORWARD/analysis2/AddTaskFMDELoss.C
PWG2/FORWARD/analysis2/AliAODForwardMult.cxx
PWG2/FORWARD/analysis2/AliAODForwardMult.h
PWG2/FORWARD/analysis2/AliBasedNdetaTask.cxx
PWG2/FORWARD/analysis2/AliCentralMultiplicityTask.cxx
PWG2/FORWARD/analysis2/AliCentralMultiplicityTask.h
PWG2/FORWARD/analysis2/AliForwardFlowTaskQC.cxx
PWG2/FORWARD/analysis2/AliForwardFlowTaskQC.h
PWG2/FORWARD/analysis2/AliForwardFlowUtil.cxx
PWG2/FORWARD/analysis2/MakeAOD.C
PWG2/FORWARD/analysis2/MakeELossFits.C
PWG2/FORWARD/analysis2/MakeFlow.C
PWG2/FORWARD/analysis2/TrainSetup.C

index b7d5d50545f617c453281ff558e75c5d3b448e80..237dfd9c97073cba0985f040393f4024c94ab72e 100644 (file)
@@ -30,6 +30,11 @@ AddTaskCentralMult(UShort_t sys=0, UShort_t sNN=0, Short_t field=0)
   if(sys>0 && sNN > 0)
     task->GetManager().Init(sys, sNN, field);
   mgr->AddTask(task);
+  // --- Set options on task -----------------------------------------
+  // Whether to do correction for secondaries
+  task->SetUseSecondary(true);
+  // Whether to do correction for acceptance
+  task->SetUseAcceptance(true);
   
   // --- Make the output container and connect it --------------------
   TString outputfile = AliAnalysisManager::GetCommonFileName();
index 77088f6655b31b4dabc81901e3b1372ac17e9ce9..62447c2276f088753531b92f7f4c18bfcd87c4e7 100644 (file)
@@ -19,7 +19,7 @@
  * @ingroup pwg2_forward_eloss
  */
 AliAnalysisTask*
-AddTaskFMDELoss(Bool_t mc, Float_t blow=0, Float_t bhigh=100)
+AddTaskFMDELoss(Bool_t mc, Bool_t useCent)
 {
   gSystem->Load("libPWG2forward2");
 
@@ -31,8 +31,8 @@ AddTaskFMDELoss(Bool_t mc, Float_t blow=0, Float_t bhigh=100)
   
   // --- Make the task and add it to the manager ---------------------
   AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("fmdEnergyFitter");
-  task->SetBLow(blow);
-  task->SetBLow(bhigh);
+  // task->SetBLow(blow);
+  // task->SetBLow(bhigh);
   mgr->AddTask(task);
   
   // --- Set parameters on the algorithms ----------------------------
@@ -48,7 +48,7 @@ AddTaskFMDELoss(Bool_t mc, Float_t blow=0, Float_t bhigh=100)
   // Set maximum energy loss to consider 
   task->GetEnergyFitter().SetMaxE(15); 
   // Set number of energy loss bins 
-  task->GetEnergyFitter().SetNEbins(450);
+  task->GetEnergyFitter().SetNEbins(100);
   // Set whether to use increasing bin sizes 
   task->GetEnergyFitter().SetUseIncreasingBins(true);
   // Set whether to do fit the energy distributions 
@@ -65,16 +65,13 @@ AddTaskFMDELoss(Bool_t mc, Float_t blow=0, Float_t bhigh=100)
   // Set the minimum number of entries in the distribution before
   // trying to fit to the data
   task->GetEnergyFitter().SetMinEntries(1000);
-  task->GetEnergyFitter().SetMaxRelativeParameterError(0.12);
-  task->GetEnergyFitter().SetMaxChi2PerNDF(10);
-  task->GetEnergyFitter().SetMinWeight(1e-5);
   // --- Set limits on fits the energy -------------------------------
   // Maximum relative error on parameters 
   AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
   // Least weight to use 
   AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
   // Maximum value of reduced chi^2 
-  AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 5;
+  AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 10;
     
   // --- Make the output container and connect it --------------------
   TString outputfile = AliAnalysisManager::GetCommonFileName();
index 68011dfa395be849ee79dd1c0cdc9b7b334d7697..1a7d6299742fd209ef154fb0f6feffd634f49955 100644 (file)
@@ -19,7 +19,8 @@
 #include <iostream>
 #include <TMath.h>
 #include <TObjString.h>
-
+#include <TObjArray.h>
+#include "AliLog.h"
 ClassImp(AliAODForwardMult)
 #ifdef DOXY_INPUT
 ; // For Emacs 
@@ -231,6 +232,27 @@ AliAODForwardMult::MakeTriggerHistogram(const char* name)
 
   return ret;
 }
+//____________________________________________________________________
+UInt_t 
+AliAODForwardMult::MakeTriggerMask(const char* what)
+{
+  UShort_t    trgMask = 0;
+  TString     trgs(what);
+  trgs.ToUpper();
+  TObjString* trg;
+  TIter       next(trgs.Tokenize(" ,|"));
+  while ((trg = static_cast<TObjString*>(next()))) { 
+    TString s(trg->GetString());
+    if      (s.IsNull()) continue;
+    if      (s.CompareTo("INEL")  == 0) trgMask |= AliAODForwardMult::kInel;
+    else if (s.CompareTo("INEL>0")== 0) trgMask |= AliAODForwardMult::kInelGt0;
+    else if (s.CompareTo("NSD")   == 0) trgMask |= AliAODForwardMult::kNSD;
+    else 
+      AliWarningGeneral("MakeTriggerMask", 
+                       Form("Unknown trigger %s", s.Data()));
+  }
+  return trgMask;
+}
 
 //____________________________________________________________________
 Bool_t
index 38d20e6154ebc1c3ac6fafa5719d31fe71d42d45..eb6c96eb0c92d51169517312a7684439c61db2eb 100644 (file)
@@ -183,11 +183,11 @@ public:
    */  
   TH2D& GetHistogram() { return fHist; } // Get histogram 
   /** 
-   * Get the trigger mask 
+   * Get the trigger bits 
    * 
-   * @return Trigger mask 
+   * @return Trigger bits 
    */
-  UInt_t GetTriggerMask() const { return fTriggers; } // Get triggers
+  UInt_t GetTriggerBits() const { return fTriggers; } // Get triggers
   /** 
    * Set the trigger mask 
    * 
@@ -369,6 +369,21 @@ public:
    * @return Newly allocated histogram 
    */
   static TH1I* MakeTriggerHistogram(const char* name="triggers");
+  /** 
+   * Utility function to make a trigger mask from the passed string. 
+   * 
+   * The string is a comma or space seperated list of case-insensitive
+   * strings
+   * 
+   * - INEL 
+   * - INEL>0
+   * - NSD 
+   * 
+   * @param what Which triggers to put in the mask. 
+   * 
+   * @return The generated trigger mask. 
+   */
+  static UInt_t MakeTriggerMask(const char* what);
 protected: 
   Bool_t  fIsMC;     // Whether this is from MC 
   TH2D    fHist;     // Histogram of d^2N_{ch}/(deta dphi) for this event
index d9ea49a3798d5fa031b697d26db301a54240470b..c979a75a23b183f2a976ffbb75cb9ac1d765646e 100644 (file)
@@ -234,22 +234,7 @@ AliBasedNdetaTask::SetTriggerMask(const char* mask)
   // Parameters:
   //    mask Trigger mask
   //
-  UShort_t    trgMask = 0;
-  TString     trgs(mask);
-  trgs.ToUpper();
-  TObjString* trg;
-  TIter       next(trgs.Tokenize(" ,|"));
-  while ((trg = static_cast<TObjString*>(next()))) { 
-    TString s(trg->GetString());
-    if      (s.IsNull()) continue;
-    if      (s.CompareTo("INEL")  == 0) trgMask = AliAODForwardMult::kInel;
-    else if (s.CompareTo("INEL>0")== 0) trgMask = AliAODForwardMult::kInelGt0;
-    else if (s.CompareTo("NSD")   == 0) trgMask = AliAODForwardMult::kNSD;
-    else 
-      Warning("SetTriggerMask", "Unknown trigger %s", s.Data());
-  }
-  if (trgMask == 0) trgMask = 1;
-  SetTriggerMask(trgMask);
+  SetTriggerMask(AliAODForwardMult::MakeTriggerMask(mask));
 }
 //________________________________________________________________________
 void 
index 38af8e85d88f2807c39d73b42eac3933c710035b..d2ea6c8ec94ab46045a83f66e06fe72bf0b78fe3 100644 (file)
@@ -37,6 +37,7 @@ AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name)
     fAODCentral(kFALSE),
     fManager(),
     fUseSecondary(true),
+    fUseAcceptance(true),
     fFirstEventSeen(false)
 {
   // 
@@ -55,6 +56,7 @@ AliCentralMultiplicityTask::AliCentralMultiplicityTask()
     fAODCentral(),
     fManager(),
     fUseSecondary(true),
+    fUseAcceptance(true),
     fFirstEventSeen(false)
 {
   // 
@@ -69,6 +71,7 @@ AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplic
     fAODCentral(o.fAODCentral),
     fManager(o.fManager),
     fUseSecondary(o.fUseSecondary),
+    fUseAcceptance(o.fUseAcceptance),
     fFirstEventSeen(o.fFirstEventSeen)
 {
   //
@@ -82,11 +85,12 @@ AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o)
   // 
   // Assignment operator 
   //
-  fData          = o.fData;
-  fList          = o.fList;
-  fAODCentral    = o.fAODCentral;
-  fManager       = o.fManager;
-  fUseSecondary  = o.fUseSecondary;
+  fData           = o.fData;
+  fList           = o.fList;
+  fAODCentral     = o.fAODCentral;
+  fManager        = o.fManager;
+  fUseSecondary   = o.fUseSecondary;
+  fUseAcceptance  = o.fUseAcceptance;
   fFirstEventSeen = o.fFirstEventSeen;
   return *this;
 }
@@ -138,7 +142,6 @@ void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
                      inspector.GetEnergy(),
                      inspector.GetField());
     
-    //std::cout<<inspector.GetCollisionSystem()<<"  "<<inspector.GetEnergy()<<"    "<<inspector.GetField()<<std::endl;
     AliInfo("Manager of corrections in AliCentralMultiplicityTask init");
     fFirstEventSeen = kTRUE;
   }
@@ -183,35 +186,38 @@ void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
   
   
   // Corrections
-  TH2D* hSecMap     = 0;
   TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin);
-  //if (fUseSecondary) 
-    hSecMap = fManager.GetSecMapCorrection(vtxbin);
+  TH2D* hSecMap     = fManager.GetSecMapCorrection(vtxbin);
   
-    //if (fUseSecondary && !hSecMap)
-  if (!hSecMap)                   AliFatal("No secondary map!");
-  if (!hAcceptance)               AliFatal("No acceptance!");
+  if (!hSecMap)     AliFatal("No secondary map!");
+  if (!hAcceptance) AliFatal("No acceptance!");
     
-  if (hSecMap) aodHist->Divide(hSecMap);
+  if (fUseSecondary && hSecMap) aodHist->Divide(hSecMap);
   
   for(Int_t nx = 1; nx <= aodHist->GetNbinsX(); nx++) {
     Float_t accCor = hAcceptance->GetBinContent(nx);
+    Float_t accErr = hAcceptance->GetBinError(nx);
     
     Bool_t etabinSeen = kFALSE;  
     for(Int_t ny = 1; ny <= aodHist->GetNbinsY(); ny++) {
+      // Get currrent value 
       Float_t aodValue = aodHist->GetBinContent(nx,ny);
+      Float_t aodErr   = aodHist->GetBinError(nx,ny);
+
+      // Set underflow bin
       Float_t secCor   = 0;
       if(hSecMap) secCor   = hSecMap->GetBinContent(nx,ny);
       if (secCor > 0.5) etabinSeen = kTRUE;
       if (aodValue < 0.000001) { aodHist->SetBinContent(nx,ny, 0); continue; }
+
+      if (!fUseAcceptance) continue; 
+
+      // Acceptance correction 
       if (accCor   < 0.000001) accCor = 1;
       Float_t aodNew   = aodValue / accCor ;
-      aodHist->SetBinContent(nx,ny, aodNew);
-      Float_t aodErr   = aodHist->GetBinError(nx,ny);
-      Float_t accErr   = hAcceptance->GetBinError(nx);
-      
       Float_t error    = aodNew*TMath::Sqrt(TMath::Power(aodErr/aodValue,2) +
                                            TMath::Power(accErr/accCor,2) );
+      aodHist->SetBinContent(nx,ny, aodNew);
       //test
       aodHist->SetBinError(nx,ny,error);
       aodHist->SetBinError(nx,ny,aodErr);
index 24d6b2d1b8bf9a928699396d5b48a5642bf43073..e140b711219271928e36064e182af8d43a08a8f1 100644 (file)
@@ -105,6 +105,12 @@ public:
    * @param use Whether to use secondary corrections 
    */
   virtual void SetUseSecondary(Bool_t use) { fUseSecondary = use; }
+  /** 
+   * Set whether to use the acceptance corrections 
+   * 
+   * @param use Whether to use acceptance corrections 
+   */
+  virtual void SetUseAcceptance(Bool_t use) { fUseAcceptance = use; }
 
   //__________________________________________________________________
   /**
@@ -269,6 +275,7 @@ protected:
   AliAODCentralMult      fAODCentral;     // Output object
   Manager                fManager;        //Manager object for corrections
   Bool_t                 fUseSecondary;   // Whether to secondary map
+  Bool_t                 fUseAcceptance;  // Whether to use acceptance corr.
   Bool_t                 fFirstEventSeen; // Have we seen first event     
   ClassDef(AliCentralMultiplicityTask,1)  // Forward multiplicity class
 };
index c6f617e16bdee0da7e44069dd3e8743a0e254884..a19c5822274993f012da9ddb3fccca4b306776ca 100644 (file)
@@ -105,7 +105,7 @@ AliForwardFlowTaskQC::AliForwardFlowTaskQC(const AliForwardFlowTaskQC& o) :
   DefineOutput(1, TList::Class());
 }
 //_____________________________________________________________________
-void AliForwardFlowTaskQC::CreateOutputObjects()
+void AliForwardFlowTaskQC::UserCreateOutputObjects()
 {
   //
   // Create output objects
index de61fffed89c8f2e54cf63bb5eab7f17fdec5c7f..d7a9e765457d1869418914c4696a71b363d88de7 100644 (file)
@@ -62,7 +62,7 @@ public:
    * 
    * @todo Check if this shouldn't be UserCreateOutputObjects!
    */
-  virtual void CreateOutputObjects();
+  virtual void UserCreateOutputObjects();
   /**
    * Initialize the task
    *
index ca3719bc7049f876511461df5b77f7a53cf9747d..b26202ba65da966757cd7a547ba9fe4fa49cf494 100644 (file)
@@ -45,11 +45,8 @@ Bool_t AliForwardFlowUtil::AODCheck(const AliAODForwardMult* aodfm) const
   // Parameters: 
   //  AliAODForwardMult: forward mult object with trigger and vertex info
   //
-  if (!aodfm->IsTriggerBits(AliAODForwardMult::kInel)) return kFALSE;
-  if (!aodfm->HasIpZ()) return kFALSE;
-  if (!aodfm->InRange(-fZvertex,fZvertex)) return kFALSE;
-
-  return kTRUE;
+  return aodfm->CheckEvent(AliAODForwardMult::kInel, -fZvertex, fZvertex, 
+                          0, 0);
 }
 //_____________________________________________________________________
 Bool_t AliForwardFlowUtil::LoopAODFMD(const AliAODEvent* aodevent) const
index 64bf2105c1a1feb09ff06a9cda35929f740f0c8b..4d8aea2f4cb09bcb0a269bc7ddde36cc2cab23b0 100644 (file)
@@ -84,7 +84,8 @@ void MakeAOD(const char* esddir,
                           gROOT->GetMacroPath()));
 
   // --- Creating the manager and handlers ---------------------------
-  AliAnalysisManager *mgr  = new AliAnalysisManager(name, "Forward multiplicity");
+  AliAnalysisManager *mgr  = new AliAnalysisManager(name, 
+                                                   "Forward multiplicity");
   AliAnalysisManager::SetCommonFileName("forward.root");
 
   // --- ESD input handler -------------------------------------------
index f721a4c50adfeee0b9bcfb2eb3449cefd927d89e..29ed0ef6986a4945a67ed29c41db658f49bb0058 100644 (file)
  * @ingroup pwg2_forward_eloss
  */
 void MakeELossFits(const char* esddir, 
-                  Int_t       nEvents=1000, 
-                  Int_t       proof=0,
-                  Bool_t      mc=false,
-                  Bool_t      cent=false)
+                  Int_t       nEvents = 1000, 
+                  Int_t       proof   = 0,
+                  Bool_t      mc      = false,
+                  Bool_t      cent    = false,
+                  const char* name    = 0)
 {
+  // --- Possibly use plug-in for this -------------------------------
+  if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
+    gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
+                            "$ALICE_ROOT/ANALYSIS/macros",
+                            gROOT->GetMacroPath()));
+    gSystem->AddIncludePath("-I${ALICE_ROOT}/include");
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gROOT->LoadMacro("TrainSetup.C+");
+    FMDELossTrain t(name, cent, false);
+    t.SetDataDir(esddir);
+    t.SetDataSet("");
+    t.SetProofServer(Form("workers=%d",proof));
+    t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
+    return;
+  }
+
   // --- Libraries to load -------------------------------------------
   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
 
@@ -46,82 +64,31 @@ void MakeELossFits(const char* esddir,
                                                    "Forward energy loss");
   AliAnalysisManager::SetCommonFileName("forward_eloss.root");
 
+  // --- ESD input handler -------------------------------------------
   AliESDInputHandler *esdHandler = new AliESDInputHandler();
-  esdHandler->SetInactiveBranches("AliESDACORDE "
-                                 "AliRawDataErrorLogs "
-                                 "CaloClusters "
-                                 "Cascades "
-                                 "EMCALCells "
-                                 "EMCALTrigger "
-                                 "Kinks "
-                                 "Cascades "
-                                 "MuonTracks "
-                                 "TrdTracks "
-                                 "CaloClusters "
-                                 "HLTGlobalTrigger");
   mgr->SetInputEventHandler(esdHandler);      
-  
-  // AOD output handler
-  AliAODHandler* aodHandler   = new AliAODHandler();
-  mgr->SetOutputEventHandler(aodHandler);
-  aodHandler->SetOutputFileName("AliAODs.root");
+       
+  // --- Monte Carlo handler -----------------------------------------
+  if (mc) {
+    AliMCEventHandler* mcHandler = new AliMCEventHandler();
+    mgr->SetMCtruthEventHandler(mcHandler);
+    mcHandler->SetReadTR(true);    
+  }
 
   // --- Add tasks ---------------------------------------------------
   gROOT->LoadMacro("AddTaskPhysicsSelection.C");
   AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
   
-  gROOT->LoadMacro("AddTaskCentrality.C");
-  AddTaskCentrality();
-  
-  AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("fmdEnergyFitter");
-  mgr->AddTask(task);
+  // Centrality 
+  if(cent) {
+    gROOT->LoadMacro("AddTaskCentrality.C");
+    AddTaskCentrality();
+  }
   
-  // --- Make the output container and connect it --------------------
-  TString outputfile = AliAnalysisManager::GetCommonFileName();
-  AliAnalysisDataContainer* histOut = 
-    mgr->CreateContainer("Forward", TList::Class(), 
-                        AliAnalysisManager::kOutputContainer,outputfile);
-  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
-  mgr->ConnectOutput(task, 1, histOut);
+  // FMD ELoss fitter 
+  gROOT->LoadMacro("AddTaskFMDELoss.C");
+  AddTaskFMDELoss(mc, cent);
 
-  // --- Set parameters on the algorithms ----------------------------
-  // Set the number of SPD tracklets for which we consider the event a
-  // low flux event
-  task->GetEventInspector().SetLowFluxCut(1000); 
-  // Set the maximum error on v_z [cm]
-  task->GetEventInspector().SetMaxVzErr(0.2);
-  // Set the eta axis to use - note, this overrides whatever is used
-  // by the rest of the algorithms - but only for the energy fitter
-  // algorithm. 
-  task->GetEnergyFitter().SetEtaAxis(200, -4, 6);
-  // Set maximum energy loss to consider 
-  task->GetEnergyFitter().SetMaxE(15); 
-  // Set number of energy loss bins 
-  task->GetEnergyFitter().SetNEbins(100);
-  // Set whether to use increasing bin sizes 
-  task->GetEnergyFitter().SetUseIncreasingBins(true);
-  // Set whether to do fit the energy distributions 
-  task->GetEnergyFitter().SetDoFits(kTRUE);
-  // Set whether to make the correction object 
-  task->GetEnergyFitter().SetDoMakeObject(kTRUE);
-  // Set the low cut used for energy
-  task->GetEnergyFitter().SetLowCut(0.4);
-  // Set the number of bins to subtract from maximum of distributions
-  // to get the lower bound of the fit range
-  task->GetEnergyFitter().SetFitRangeBinWidth(4);
-  // Set the maximum number of landaus to try to fit (max 5)
-  task->GetEnergyFitter().SetNParticles(5);
-  // Set the minimum number of entries in the distribution before
-  // trying to fit to the data
-  task->GetEnergyFitter().SetMinEntries(1000);
-  // --- Set limits on fits the energy -------------------------------
-  // Maximum relative error on parameters 
-  AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
-  // Least weight to use 
-  AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
-  // Maximum value of reduced chi^2 
-  AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 10;
-  
   // --- Run the analysis --------------------------------------------
   TStopwatch t;
   if (!mgr->InitAnalysis()) {
@@ -131,11 +98,12 @@ void MakeELossFits(const char* esddir,
   // Some informative output 
   mgr->PrintStatus();
   // mgr->SetDebugLevel(3);
-  if (mgr->GetDebugLevel() < 1 && proof <= 0) mgr->SetUseProgressBar(kTRUE);
+  if (mgr->GetDebugLevel() < 1 && proof <= 0) 
+    mgr->SetUseProgressBar(kTRUE,100);
 
   // Run the train 
   t.Start();
-  Printf("=== RUNNING ANALYSIS ==================================");
+  Printf("=== RUNNING ANALYSIS on %9 events ========================",nEvents);
   mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
   t.Stop();
   t.Print();
index f0757fc54ec780fadc9c4056525e13d558da47f1..557a3ccce9d013e8c6b11bc2dd3b52e2bfa51e6c 100644 (file)
@@ -30,7 +30,8 @@ void MakeFlow(TString data      = "",
              Int_t   zVertex   = 2,
              TString addFlow   = "",
               Int_t   addFType  = 0,
-              Int_t   addFOrder = 0)
+              Int_t   addFOrder = 0,
+             Bool_t  proof     = false)
 {
   Bool_t proof = kFALSE;
 
@@ -46,28 +47,33 @@ void MakeFlow(TString data      = "",
     }
   }
 
+  // --- Set the macro path ------------------------------------------
+  gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
+                          "$ALICE_ROOT/ANALYSIS/macros",
+                          gROOT->GetMacroPath()));
+
   // --- Add to chain either AOD ------------------------------------
-  if (data.Length() <= 1) {
+  if (data.IsNull()) {
     AliError("You didn't add a data file");
     return;
   }
   TChain* chain = new TChain("aodTree");
 
-  if (data.Contains(".txt"))
-    MakeChain(data, chain);
+  if (data.Contains(".txt")) MakeChain(data, chain);
 
   if (data.Contains(".root")) {
-    if (!TFile::Open(data.Data())) {
+    TFile* test = TFile::Open(data.Data())
+    if (!test) {
       AliError(Form("AOD file %s not found", data.Data()));
       return;
     }
+    test->Close(); // Remember to close!
     chain->Add(data.Data());
   }
 
   // --- Initiate the event handlers --------------------------------
   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward Flow", 
                                                    "Flow in the forward region");
-  mgr->SetUseProgressBar(kTRUE, 10);
 
   // --- AOD input handler -------------------------------------------
   AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
@@ -79,7 +85,7 @@ void MakeFlow(TString data      = "",
   aodOut->SetOutputFileName("AliAODs.Flow.root");
 
   // --- Add the tasks ---------------------------------------------
-  gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskForwardFlow.C");
+  gROOT->LoadMacro("AddTaskForwardFlow.C");
   AddTaskForwardFlow(type, etabins, zVertex, addFlow, addFType, addFOrder);
 
   // --- Run the analysis --------------------------------------------
@@ -89,6 +95,10 @@ void MakeFlow(TString data      = "",
     return;
   }
   mgr->PrintStatus();
+  // 
+  if (proof) mgr->SetDebugLevel(3);
+  if (mgr->GetDebugLevel() < 1 && !proof) 
+    mgr->SetUseProgressBar(kTRUE,nEvents < 10000 ? 10 : 100);
 
   t.Start();
   if (nevents == 0) mgr->StartAnalysis("local", chain);
index 900154c6a598c0db7bde95826a59b3497b913b7e..b5ba0102b8677775e51139e36c947065c52e2405 100644 (file)
@@ -11,6 +11,7 @@
 
 #ifndef __CINT__
 #include <fstream>
+#include <iostream>
 
 #include <TAlienCollection.h>
 #include <TArrayI.h>
@@ -324,51 +325,57 @@ struct TrainSetup
   /** 
    * Set ROOT version to use 
    * 
-   * @param v 
+   * @param v Version string of ROOT 
    */
   void SetROOTVersion(const char* v)    { fRootVersion = v; }
   //__________________________________________________________________
   /** 
    * Set AliROOT version to use 
    * 
-   * @param v 
+   * @param v Version string of AliROOT 
    */
   void SetAliROOTVersion(const char* v) { fAliRootVersion = v; }
   //__________________________________________________________________
   /** 
-   * Set the proof server URL
+   * Set the PROOF server URL
    * 
-   * @param s 
+   * @param s PROOF server URL 
    */
   void SetProofServer(const char* s)    { fProofServer = s; }
   //__________________________________________________________________
   /** 
    * Set the GRID/Local data dir 
    * 
-   * @param d 
+   * @param d Directory with data 
    */
-  void SetDataDir(const char* d)        { fDataDir = d; }
+  void SetDataDir(const char* d) { fDataDir = d; }
   //__________________________________________________________________
   /** 
    * Set the PROOF data set 
    * 
-   * @param d 
+   * @param d PROOF registered data set 
    */
-  void SetDataSet(const char* d)        { fDataSet = d; }
+  void SetDataSet(const char* d) { fDataSet = d; }
   //__________________________________________________________________
   /** 
    * Set the XML file to use 
    * 
-   * @param x 
+   * @param x XML file 
    */
-  void SetXML(const char* x)            { fXML = x; }
+  void SetXML(const char* x) { fXML = x; }
   //__________________________________________________________________
   /** 
    * Set how many replicas of the output we want 
    * 
-   * @param n 
+   * @param n Number of replicas requested 
    */
-  void SetNReplica(Int_t n)             { fNReplica = n; }
+  void SetNReplica(Int_t n) { fNReplica = n; }
+  /** 
+   * Set the ESD pass to use 
+   * 
+   * @param pass Pass number 
+   */
+  void SetESDPass(Int_t pass) { fESDPass = pass; }
   //__________________________________________________________________
   /** 
    * Add a source file to be copied and byte compiled on slaves 
@@ -650,8 +657,8 @@ protected:
     gROOT->SetMacroPath(Form("%s:$ALICE_ROOT/ANALYSIS/macros",
                             gROOT->GetMacroPath()));
 
-    // --- Physics selction ------------------------------------------
-    CreatePhysicsSelection(mc, mgr);
+    // --- Physics selction - only for ESD ---------------------------
+    if (type == kESD) CreatePhysicsSelection(mc, mgr);
     
     // --- Create tasks ----------------------------------------------
     CreateTasks(mode, usePar, mgr);
@@ -745,7 +752,8 @@ protected:
    * 
    * @return Grid handler 
    */
-  virtual AliAnalysisAlien* CreateGridHandler(EType type, EMode mode, EOper oper)
+  virtual AliAnalysisAlien* 
+  CreateGridHandler(EType type, EMode mode, EOper oper)
   {
     if (mode != kGrid) return 0;
 
@@ -946,13 +954,14 @@ protected:
    */
   virtual AliVEventHandler* CreateOutputHandler(EType type)
   {
+    AliAODHandler* ret = new AliAODHandler();
     switch (type) { 
-    case kESD: // Fall through 
-    case kAOD: { 
-      AliAODHandler* ret = new AliAODHandler();
+    case kESD: 
       ret->SetOutputFileName("AliAOD.root");
-      return ret;
-    }
+      break;
+    case kAOD: 
+      ret->SetOutputFileName("AliAOD.pass2.root");
+      break;
     }
     return 0;
   }
@@ -1433,29 +1442,34 @@ protected:
  * 
  * @ingroup pwg2_forward_scripts_makers
  */
-class ForwardELoss : public TrainSetup
+class FMDELossTrain : public TrainSetup
 {
 public:
   /** 
    * Constructor.  Date and time must be specified when running this
    * in Termiante mode on Grid
    * 
-   * @param dateTime Append date and time to name 
+   * @param name     Name of train 
+   * @param useCent  Whether to use centrality or not 
+   * @param dateTime Append date and time to name
    * @param year     Year
    * @param month    Month 
    * @param day      Day
    * @param hour     Hour 
    * @param min      Minutes
    */
-  ForwardELoss(Bool_t   dateTime, 
-              UShort_t year  = 0, 
-              UShort_t month = 0, 
-              UShort_t day   = 0, 
-              UShort_t hour  = 0, 
-              UShort_t min   = 0) 
-    : TrainSetup("Forward energy loss", dateTime, 
-                year, month, day, hour, min) 
+  FMDELossTrain(const char* name  = "FMD Energy Loss",
+               Bool_t   useCent  = false,
+               Bool_t   dateTime = false, 
+               UShort_t year     = 0, 
+               UShort_t month    = 0, 
+               UShort_t day      = 0, 
+               UShort_t hour     = 0, 
+               UShort_t min      = 0) 
+    : TrainSetup(name, dateTime, year, month, day, hour, min), 
+      fUseCent(useCent)
   {}
+  //__________________________________________________________________
   /** 
    * Run this analysis 
    * 
@@ -1467,11 +1481,9 @@ public:
   void Run(const char* mode, const char* oper, 
           Int_t nEvents=-1, Bool_t mc=false)
   {
-    EMode eMode = ParseMode(mode);
-    EOper eOper = ParseOperation(oper);
-    
-    Run(eMode, eOper, nEvents, mc);
+    Exec("ESD", mode, oper, nEvents, mc);
   }
+  //__________________________________________________________________
   /** 
    * Run this analysis 
    * 
@@ -1484,6 +1496,8 @@ public:
   {
     Exec(kESD, mode, oper, nEvents, mc, true);
   }
+protected:
+  //__________________________________________________________________
   /** 
    * Create the tasks 
    * 
@@ -1509,12 +1523,30 @@ public:
     // --- Add the task ----------------------------------------------
     gROOT->Macro(Form("AddTaskForwardMultEloss.C(%d)", mc));
   }
+  /** 
+   * Crete output handler - we don't want one here. 
+   * 
+   * @return 0
+   */
+  AliVEventHandler* CreateOutputHandler(EType) { return 0; }
 };
 
 //====================================================================
 /**
  * Analysis train to make Forward and Central multiplicity
  * 
+ * To run, do 
+ * @code 
+ * gROOT->LoadMacro("TrainSetup.C");
+ * // Make train 
+ * MakeAODTrain t("My Analysis");
+ * // Set variaous parameters on the train 
+ * t.SetDataDir("/home/of/data");
+ * t.AddRun(118506)
+ * // Run it 
+ * t.Run("LOCAL", "FULL", -1, false, false);
+ * @endcode 
+ *
  * @ingroup pwg2_forward_scripts_makers
  * @ingroup pwg2_forward_aod
  */
@@ -1558,8 +1590,8 @@ public:
   /** 
    * Run this analysis 
    * 
-   * @param mode     Mode
-   * @param oper     Operation
+   * @param mode     Mode - see TrainSetup::EMode
+   * @param oper     Operation - see TrainSetup::EOperation
    * @param nEvents  Number of events (negative means all)
    * @param mc       If true, assume simulated events 
    * @param usePar   If true, use PARs 
@@ -1573,8 +1605,8 @@ public:
   /** 
    * Run this analysis 
    * 
-   * @param mode     Mode
-   * @param oper     Operation
+   * @param mode     Mode - see TrainSetup::EMode
+   * @param oper     Operation - see TrainSetup::EOperation
    * @param nEvents  Number of events (negative means all)
    * @param mc       If true, assume simulated events 
    * @param usePar   If true, use PARs 
@@ -1629,16 +1661,19 @@ protected:
   void CreatePhysicsSelection(Bool_t mc,
                              AliAnalysisManager* mgr)
   {
-    gROOT->Macro(Form("AddTaskPhysicsSelection.C(%d)", mc));
-    mgr->RegisterExtraFile("event_stat.root");
+    TrainSetup::CreatePhysicsSelection(mc, mgr);
 
     // --- Get input event handler -----------------------------------
     AliInputEventHandler* ih =
-      static_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
+      dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
+    if (!ih) 
+      Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
     
     // --- Get Physics selection -------------------------------------
     AliPhysicsSelection* ps = 
-      static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+      dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+    if (!ps) 
+      Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps);
 
     // --- Ignore trigger class when selecting events.  This means ---
     // --- that we get offline+(A,C,E) events too --------------------
@@ -1653,6 +1688,18 @@ protected:
 /**
  * Analysis train to make @f$ dN/d\eta@f$
  * 
+ * To run, do 
+ * @code 
+ * gROOT->LoadMacro("TrainSetup.C");
+ * // Make train 
+ * MakedNdetaTrain t("My Analysis");
+ * // Set variaous parameters on the train 
+ * t.SetDataDir("/home/of/data");
+ * t.AddRun(118506)
+ * // Run it 
+ * t.Run("LOCAL", "FULL", -1, false, false);
+ * @endcode 
+ *
  * @ingroup pwg2_forward_scripts_makers
  * @ingroup pwg2_forward_dndeta
  */
@@ -1698,8 +1745,8 @@ public:
   /** 
    * Run this analysis 
    * 
-   * @param mode     Mode
-   * @param oper     Operation
+   * @param mode     Mode - see TrainSetup::EMode
+   * @param oper     Operation - see TrainSetup::EOperation
    * @param nEvents  Number of events (negative means all)
    * @param usePar   If true, use PARs 
    */
@@ -1711,8 +1758,8 @@ public:
   /** 
    * Run this analysis 
    * 
-   * @param mode     Mode
-   * @param oper     Operation
+   * @param mode     Mode - see TrainSetup::EMode
+   * @param oper     Operation - see TrainSetup::EOperation
    * @param nEvents  Number of events (negative means all)
    * @param usePar   If true, use PARs 
    */
@@ -1772,12 +1819,6 @@ protected:
     gROOT->Macro(Form("AddTaskCentraldNdeta.C(\"%s\",%f,%f,%d,\"%s\")",
                      fTrig.Data(), fVzMin, fVzMax, fUseCent, fScheme.Data()));
   }
-  //__________________________________________________________________
-  /** 
-   * Do nothing 
-   * 
-   */
-  void CreatePhysicsSelection(Bool_t,AliAnalysisManager*) {}
   /** 
    * Crete output handler - we don't want one here. 
    *