]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Updates to scripts. Mostly documentation and some new functionalities
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Jul 2011 09:16:17 +0000 (09:16 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Jul 2011 09:16:17 +0000 (09:16 +0000)
20 files changed:
PWG2/FORWARD/analysis2/AddTaskCentralMCCorr.C
PWG2/FORWARD/analysis2/AddTaskCentralMult.C
PWG2/FORWARD/analysis2/AddTaskCentraldNdeta.C
PWG2/FORWARD/analysis2/AddTaskFMDELoss.C
PWG2/FORWARD/analysis2/AddTaskForwardFlow.C
PWG2/FORWARD/analysis2/AddTaskForwardMCCorr.C
PWG2/FORWARD/analysis2/AddTaskForwardMult.C
PWG2/FORWARD/analysis2/AddTaskForwardQA.C
PWG2/FORWARD/analysis2/AddTaskForwarddNdeta.C
PWG2/FORWARD/analysis2/AddTaskMCTruthdNdeta.C
PWG2/FORWARD/analysis2/AliFMDDensityCalculator.h
PWG2/FORWARD/analysis2/ForwardAODConfig.C
PWG2/FORWARD/analysis2/MakeAOD.C
PWG2/FORWARD/analysis2/MakeELossFits.C
PWG2/FORWARD/analysis2/MakeFlow.C
PWG2/FORWARD/analysis2/MakeMCCorr.C
PWG2/FORWARD/analysis2/corrs/DrawAnaELoss.C
PWG2/FORWARD/analysis2/scripts/MakeChain.C
PWG2/FORWARD/analysis2/trains/MakeAODTrain.C
PWG2/FORWARD/analysis2/trains/MakeQATrain.C

index 36000d7e7ba239c28532ca6544a5d4339a665498..92c8cfa3a3e8b9397dc3353cb238dcbcd696a97e 100644 (file)
@@ -20,6 +20,9 @@
 AliAnalysisTask*
 AddTaskCentralMCCorr()
 {
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
   // --- Creating the manager and handlers ---------------------------
   AliAnalysisManager *mgr  = AliAnalysisManager::GetAnalysisManager();
   if (!mgr->GetMCtruthEventHandler()) { 
index 56081dffebae77449098cbbc164613c1ecc1ccaf..0017bbf1ed429d162a8bbaf61ecdf84d0934efef 100644 (file)
@@ -18,8 +18,10 @@ AliAnalysisTask*
 AddTaskCentralMult(Bool_t mc=false, 
                   UShort_t sys=0, UShort_t sNN=0, Short_t field=0)
 {
-  gSystem->Load("libPWG2forward2");
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
 
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     Error("AddTaskCentralMult", "No analysis manager to connect to.");
index 99fc42c2b311933f169c3ae29b81efa13c193fe6..75b635bdee9a18694bba9d01887aed28e2ab2c05 100644 (file)
@@ -33,6 +33,9 @@ AddTaskCentraldNdeta(const char* trig     = "INEL",
                     Bool_t      cutEdges = false,
                     const char* mcanalysisfilename = "none")
 {
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
   // --- Analysis manager --------------------------------------------
   AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
 
index 06b4d23f4c4abf25060ee9befcfd57883a7eb0a6..f25862a6700d3dd17ca72fd23b5799fbde670852 100644 (file)
 AliAnalysisTask*
 AddTaskFMDELoss(Bool_t mc, Bool_t useCent)
 {
-  gSystem->Load("libPWG2forward2");
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
 
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     Error("AddTaskFMDELoss", "No analysis manager to connect to.");
index b52518768eb1eed4afe8dbc17e1198d1aca124b6..eba475ed8a379788c58a76ae23589276fe2b3d6e 100644 (file)
 /** 
  * Add Flow task to train 
  * 
- * @param type 
- * @param etabins 
- * @param addFlow 
- * @param addFType 
- * @param addFOrder 
+ * @param type         Type of analysis (v<n> n="1","2","3",or "4")
+ * @param etabins      How may eta bins to make 
+ * @param addFlow      If true, add flow to MC particles
+ * @param addFType     Which type of flow to add to MC particles
+ * @param addFOrder    Order of flow to add to MC particles
  *
  * @ingroup pwg2_forward_flow
  */
@@ -29,23 +29,27 @@ void AddTaskForwardFlow(TString type = "",
                         Int_t addFType = 0,
                         Int_t addFOrder = 0)
 {
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     Error("AddFMDFlowTask", "No analysis manager to connect to.");
     return NULL;
   }   
 
-  AliAODInputHandler* aodInput = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  // --- Check that we're processing AODs ----------------------------
+  AliAODInputHandler* aodInput = 
+    dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()
+                                      ->GetInputEventHandler());
    
-  Bool_t aod = kFALSE;
-  if (aodInput) aod = kTRUE;
-  if (!aod) {
+  if (!aodInput) {
     Error("AddTaskForwardFlow", "No analysis manager to connect to.");
     return NULL;
   }
 
-  // --- Check which harmonics to calculate --- //
-
+  // --- Check which harmonics to calculate --------------------------
   Bool_t v1 = kTRUE;
   Bool_t v2 = kTRUE;
   Bool_t v3 = kTRUE;
@@ -58,15 +62,16 @@ void AddTaskForwardFlow(TString type = "",
     if (!type.Contains("4")) v4 = kFALSE;
   }
 
-  // --- Create output containers and find input from fmd task --- //
+  // --- Create output containers and find input from fmd task -------
 
   TString outputFile = AliAnalysisManager::GetCommonFileName();
   outputFile += ":FlowResults";
 
-  AliAnalysisDataContainer* qcout = mgr->CreateContainer("QCumulants", TList::Class(), AliAnalysisManager::kOutputContainer, outputFile);
+  AliAnalysisDataContainer* qcout = 
+    mgr->CreateContainer("QCumulants", TList::Class(), 
+                        AliAnalysisManager::kOutputContainer, outputFile);
 
-  // --- For the selected flow tasks the input and output is set --- //
-  
+  // --- For the selected flow tasks the input and output is set -----
   AliForwardFlowTaskQC* qc = new AliForwardFlowTaskQC("QCumulants");
 
   qc->SetDoHarmonics(v1, v2, v3, v4);
@@ -80,3 +85,6 @@ void AddTaskForwardFlow(TString type = "",
 
   return;
 }
+//
+// EOF
+//
index d2fb187a6a0c27eca83aecb552d4edc4b70af089..85bed6bbca3d8e0a5b557e528d30cc7d73f2bef9 100644 (file)
@@ -19,6 +19,9 @@
 AliAnalysisTask*
 AddTaskForwardMCCorr()
 {
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
   // --- Creating the manager and handlers ---------------------------
   AliAnalysisManager *mgr  = AliAnalysisManager::GetAnalysisManager();
   if (!mgr->GetMCtruthEventHandler()) { 
index 1a36bb166321e3d29c8119156155efe4129f97e9..7d4771b577a03ce4def6b6c94271156cbfed335c 100644 (file)
 AliAnalysisTask*
 AddTaskForwardMult(Bool_t mc, UShort_t sys=0, UShort_t sNN=0, Short_t field=0)
 {
-  gSystem->Load("libPWG2forward2");
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
 
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     Error("AddTaskForwardMult", "No analysis manager to connect to.");
index 94c988eddb448e82215752d98bf916f337cf1bea..73f26649223e4aa742c70193cbdd975889ad6bbe 100644 (file)
@@ -3,26 +3,29 @@
  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
  * @date   Wed Mar 23 12:14:03 2011
  * 
- * @brief  
- * 
+ * @brief  Include the Forward QA task in a train.  
  * 
  * @ingroup pwg2_forward_scripts_tasks
  */
 /**
- * @defgroup pwg2_forward_eloss Energy Loss Fits
+ * @defgroup pwg2_forward_qa Quality Assurance
  * @ingroup pwg2_forward_topical
  */
-
 /**
- * This is the macro to include the FMD energy fitter in a train.  
+ * This is the macro to include the Forward QA task in a train.  
  * 
+ * @param mc       Monte-carlo input 
+ * @param useCent  Use centrality 
+ *
  * @ingroup pwg2_forward_eloss
  */
 AliAnalysisTask*
 AddTaskForwardQA(Bool_t mc, Bool_t useCent)
 {
-  gSystem->Load("libPWG2forward2");
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
 
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     Error("AddTaskForwardQA", "No analysis manager to connect to.");
index fe90312731f45f1bfcef2cf348594cb4f3dc6607..6f265ea2adf8317550c9c95d45ad27618d839026 100644 (file)
@@ -33,6 +33,9 @@ AddTaskForwarddNdeta(const char* trig     = "INEL",
                     Bool_t      cutEdges = false,
                     const char* mcanalysisfilename = "none")
 {
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
   // --- Analysis manager --------------------------------------------
   AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
 
index 3d01052bcb68ac76d53419d76dd6d44adebcc0df..ca85a19f79d8b80d7fcbf937e20ecbdb190933e4 100644 (file)
@@ -31,7 +31,10 @@ AddTaskMCTruthdNdeta(const char* trig     = "INEL",
                     const char* scheme   = 0,
                     Bool_t      cutEdges = false)
 {
-  // --- Analysis manager --------------------------------------------
+  // --- Load libraries ----------------------------------------------
+  gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
+
+  // --- Get analysis manager ----------------------------------------
   AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
 
   // --- Make our object ---------------------------------------------
index f700a6900eebc630040c6f0f74b5b84969ecc866..049d5bc3935f2cfeaac6338c1babfc9d18a21a84 100644 (file)
@@ -47,6 +47,19 @@ class AliFMDCorrELossFit;
 class AliFMDDensityCalculator : public TNamed
 {
 public:
+  /**
+   * How to correct for the missing phi coverage at the corners of the
+   * sensors 
+   * 
+   */
+  enum { 
+    /** No correction */
+    kPhiNoCorrect,
+    /** Correct the calculated number charged particles */
+    kPhiCorrectNch,
+    /** Correct the energy loss */
+    kPhiCorrectELoss
+  };
   /** 
    * Constructor 
    */
@@ -144,7 +157,7 @@ public:
    *
    * @param u If >0, use the phi acceptance (default is false)
    */
-  void SetUsePhiAcceptance(UShort_t u) { fUsePhiAcceptance = u; }
+  void SetUsePhiAcceptance(UShort_t u=kPhiCorrectNch) { fUsePhiAcceptance = u; }
   /** 
    * Set the lower multiplicity cut.  This overrides the setting in
    * the energy loss fits.
index 07ffd8e96ccb1e9285eb83734097a54924671dc8..338441d32442fb2554e3cae31f6b58829d45b605 100644 (file)
@@ -98,8 +98,12 @@ ForwardAODConfig(AliForwardMultiplicityBase* task)
   // Set whether or not to include sigma in cut
   task->GetDensityCalculator().SetCuts(cDensity);
   
-  // Set whether or not to use the phi acceptance 
-  task->GetDensityCalculator().SetUsePhiAcceptance(true);
+  // Set whether or not to use the phi acceptance
+  //   AliFMDDensityCalculator::kPhiNoCorrect
+  //   AliFMDDensityCalculator::kPhiCorrectNch
+  //   AliFMDDensityCalculator::kPhiCorrectELoss
+  task->GetDensityCalculator()
+    .SetUsePhiAcceptance(AliFMDDensityCalculator::kPhiCorrectNch);
 
   // --- Corrector ---------------------------------------------------
   // Whether to use the secondary map correction
index 5b22fb6945c547bc2b5c533c152df3b9feeee209..b9d9c47d5fa2db981a2996da53db27ddcf9eddfb 100644 (file)
@@ -2,6 +2,7 @@
  * @defgroup pwg2_forward_scripts_makers Maker scripts 
  * @ingroup pwg2_forward_scripts
  */
+//====================================================================
 /**
  * @file   MakeAOD.C
  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
@@ -11,6 +12,7 @@
  * 
  * @ingroup pwg2_forward_scripts_makers
  */
+//====================================================================
 /** 
  * Run first pass of the analysis - that is read in ESD and produce AOD
  * 
@@ -45,13 +47,12 @@ void MakeAOD(const char* esddir,
 {
   // --- 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+g");
+    const char* builder = 
+      "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C" 
+    gROOT->LoadMacro(builder);
+
+    BuildTrain("MakeAODTrain");
+
     MakeAODTrain t(name, 0, 0, 0, centrality, false);
     t.SetDataDir(esddir);
     t.SetDataSet("");
index 065b0848be6fc0b6eff208e9bed2e29ec04e32ea..6b24a8b24639a482567c3605806b95fd2251516f 100644 (file)
@@ -3,14 +3,32 @@
  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
  * @date   Wed Mar 23 14:08:14 2011
  * 
- * @brief  
+ * @brief  Generate energy loss fits 
  * 
- * 
- * @ingroup pwg2_forward_eloss
+ * @ingroup pwg2_forward_scripts_makers
  */
 /** 
  * Run a pass on ESD data to produce the energ loss fits 
  * 
+ * If the ROOT AliEn interface library (libRAliEn) can be loaded, 
+ * and the parameter @a name is not empty, then use the plugin to do
+ * the analysis.  Note that in this case, the output is placed 
+ * in a sub-directory named by @a name after escaping spaces and special 
+ * characters 
+ *
+ * If PROOF mode is selected, then Terminate will be run on the master node 
+ * in any case. 
+ *
+ * @param esddir     ESD input directory. Any file matching the pattern 
+ *                   *AliESDs*.root are added to the chain 
+ * @param nEvents    Number of events to process.  If 0 or less, then 
+ *                   all events are analysed
+ * @param proof      If larger then 1, run in PROOF-Lite mode with this 
+ *                   many number of workers. 
+ * @param mc         Data is assumed to be from simulations  
+ * @param cent       Whether to use centrality or not 
+ * @param name       Name of train - free form.  This will be the name
+ *                   of the output directory if the plug-in is used 
  *
  * @ingroup pwg2_forward_eloss
  */
@@ -23,13 +41,11 @@ void MakeELossFits(const char* esddir,
 {
   // --- 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+");
+    const char* builder = 
+      "$(ALICE_ROOT)/PWG2/FORWARD/analysis2/trains/BuildTrain.C" 
+    gROOT->LoadMacro(builder);
+    BuildTrain("FMDELossTrain");
+
     FMDELossTrain t(name, cent, false);
     t.SetDataDir(esddir);
     t.SetDataSet("");
index 3360e306cdc92b3309fa8a59c8b7725d80807fbd..506680508e0cad84eee0aa1bba855a442a343a68 100644 (file)
@@ -3,7 +3,7 @@
  * @author Alexander Hansen 
  * @date   Wed Mar 23 12:11:33 2011
  * 
- * @brief  
+ * @brief Analyse AODs for flow 
  * 
  * @ingroup pwg2_forward_scripts_makers
  * 
  * The .txt file is expected to contain the path to the files 
  * from the current directory or the absolute path.
  * 
- * @par Inputs: 
- *  
- * 
- * @par Outputs: 
- * - 
+ * @param data         Input data (directory, list, or ROOT file)
+ * @param nevents      Number of events to scan 
+ * @param type         Type of analysis (v<n>)
+ * @param etabins      How may eta bins to make 
+ * @param addFlow      If true, add flow to MC particles
+ * @param addFType     Which type of flow to add to MC particles
+ * @param addFOrder    Order of flow to add to MC particles
+ * @param proof 
  *
  * @ingroup pwg2_forward_flow
  */
@@ -52,27 +55,15 @@ void MakeFlow(TString data      = "",
                           gROOT->GetMacroPath()));
 
   // --- Add to chain either AOD ------------------------------------
-  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(".root")) {
-    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());
-  }
+  gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
+  TChain* chain = MakeChain("AOD", data.Data(), true);
+  // If 0 or less events is select, choose all 
+  if (nEvents <= 0) nEvents = chain->GetEntries();
 
   // --- Initiate the event handlers --------------------------------
-  AliAnalysisManager *mgr  = new AliAnalysisManager("Forward Flow", 
-                                                   "Flow in the forward region");
+  AliAnalysisManager *mgr  = 
+    new AliAnalysisManager("Forward Flow", 
+                          "Flow in the forward region");
 
   // --- AOD input handler -------------------------------------------
   AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
index bccfef0b3b1a118ed8a5afbd5b28bbf8290c5963..cd842a98c0239ee4c2d950d6b87f3ad8b4f6b8be 100644 (file)
@@ -1,14 +1,15 @@
 /**
- * @file   MakedNdeta.C
+ * @file   MakeMCCorr.C
  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
- * @date   Wed Mar 23 09:41:56 2011
+ * @date   Tue Jul 12 10:06:07 2011
  * 
- * @brief  Run second pass analysis - make @f$ dN/d\eta@f$
+ * @brief  Generate MC corrections 
  * 
  * @ingroup pwg2_forward_scripts_makers
  */
+//====================================================================
 /** 
- * Run second pass analysis - make @f$ dN/d\eta@f$
+ * Generatew MC corrections 
  * 
  * If the ROOT AliEn interface library (libRAliEn) can be loaded, 
  * and the parameter @a name is not empty, then use the plugin to do
@@ -27,7 +28,8 @@
  * @param name       Name of train - free form.  This will be the name
  *                   of the output directory if the plug-in is used 
  *
- * @ingroup pwg2_forward_dndeta
+ * @ingroup pwg2_forward_corr
+ * @ingroup pwg2_forward_scripts_makers
  */
 void MakeMCCorr(const char* esddir   = ".", 
                Int_t       nEvents  = -1, 
@@ -40,13 +42,11 @@ void MakeMCCorr(const char* esddir   = ".",
     Error("MakeMCCorr", "Plug-in mode not implemented yet!");
     return;
 
-    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+");
+    const char* fwdPath = 
+      gSystem->ExpandPathName("$(ALICE_ROOT)/PWG2/FORWARD/analysis2");
+    gROOT->LoadMacro(Form("%s/trains/BuildTrain.C", fwdPath));
+    BuildTrain("MakeMCCorrTrain");
+
     MakeMCCorrTrain t(name, vzMin, vzMax);
     t.SetDataDir(esddir);
     t.SetDataSet("");
index d0ed075ec4d58e96a1c7cb70d2a5f9ea051a162a..7c45626c71673e199d8707cf16d01c01e91a7804 100644 (file)
@@ -129,6 +129,38 @@ TCanvas* CheckCanvas()
   canvas->SetBottomMargin(0.15);
   return canvas;
 }
+
+//____________________________________________________________________
+void CleanStack(THStack* stack)
+{
+  TIter next(stack->GetHists());
+  TObject* o = 0;
+  while ((o = next())) { 
+    TString name(o->GetName());
+    if (name.Contains("_t_")) 
+      stack->RecursiveRemove(o);
+  }
+}
+  
+
+//____________________________________________________________________
+THStack*
+AddToStack(TList* stacks, TList* fitter, const char* name)
+{
+  TObject* o = fitter->FindObject(name);
+  if (!o) { 
+    Warning("AddToStack", "Object %s not found in %s", name, 
+           fitter->GetName());
+    // fitter->ls();
+    return 0;
+  }
+  THStack* toAdd = static_cast<THStack*>(o);
+  CleanStack(toAdd);
+  Info("AddToStack", "Adding %s to stacks", name);
+  stacks->Add(toAdd);
+  return toAdd;
+}
+
   
 //____________________________________________________________________
 /** 
@@ -150,28 +182,19 @@ void DrawSummary(const char* fname="forward_eloss.root")
   }
   canvas->Clear();
 
-  THStack* chi2nu;
-  THStack* c;
-  THStack* delta;
-  THStack* xi;
-  THStack* sigma;
-  THStack* sigman;
-  THStack* n;
-  TList stacks;
-  stacks.Add(chi2nu = static_cast<THStack*>(fitter->FindObject("chi2")));
-  stacks.Add(c      = static_cast<THStack*>(fitter->FindObject("c")));
-  stacks.Add(delta  = static_cast<THStack*>(fitter->FindObject("delta")));
-  stacks.Add(xi     = static_cast<THStack*>(fitter->FindObject("xi")));
-  stacks.Add(sigma  = static_cast<THStack*>(fitter->FindObject("sigma")));
-  stacks.Add(sigman = static_cast<THStack*>(fitter->FindObject("sigman")));
-  stacks.Add(n      = static_cast<THStack*>(fitter->FindObject("n")));
-  Int_t baseA = stacks.GetEntries()+1;
-  Int_t i=2;
+  TList    stacks;
+  THStack* chi2nu  = AddToStack(&stacks, fitter, "chi2");
+  THStack* c       = AddToStack(&stacks, fitter, "c");
+  THStack* delta   = AddToStack(&stacks, fitter, "delta");
+  THStack* xi      = AddToStack(&stacks, fitter, "xi");
+  THStack* sigma   = AddToStack(&stacks, fitter, "sigma");
+  THStack* sigman  = AddToStack(&stacks, fitter, "sigman");
+  THStack* n       = AddToStack(&stacks, fitter, "n");
+  Int_t    baseA   = stacks.GetEntries()+1;
+  Int_t    i       = 2;
   while (true) { 
-    TObject* o = fitter->FindObject(Form("a%d",i++));
-    if (!o) break;
-    Info("DrawFits", "Adding %s", o->GetName());
-    stacks.Add(o);
+    if (!AddToStack(&stacks, fitter, Form("a%d",i++)))
+      break;
   }
   // stacks.ls();
   Int_t nMax = stacks.GetEntries();
@@ -185,9 +208,11 @@ void DrawSummary(const char* fname="forward_eloss.root")
     if (!hasData) nMax--;
   }
 
-  canvas->SetRightMargin(0.05);
-  canvas->SetTopMargin(0.05);
-  canvas->Divide(2, (nMax+1)/2, 0.1, 0, 0);
+  canvas->SetRightMargin(0.01);
+  canvas->SetTopMargin(0.01);
+  Int_t nX = 2;
+  Int_t nY = (nMax+1) / 2;
+  canvas->Divide(nX, nY, 0.1, 0, 0);
 
   TIter next(&stacks);
   THStack* stack = 0;
@@ -195,8 +220,13 @@ void DrawSummary(const char* fname="forward_eloss.root")
   Int_t b = 1;
   while ((stack = static_cast<THStack*>(next()))) {
     if (i > nMax) break;
-    TVirtualPad* p = canvas->cd(1+i/5 + 2*(i%5));
-    p->SetLeftMargin(.15);
+    Int_t ipad = 1+i/nY + 2 * (i % nY);
+    Info("DrawSummary", "cd'ing to canvas %d for %s", ipad, 
+        stack->GetName());
+    TVirtualPad* p = canvas->cd(ipad);
+    p->SetLeftMargin(.6/nY);
+    p->SetTopMargin(.01);
+    p->SetRightMargin(.01);
     p->SetFillColor(0);
     p->SetFillStyle(0);
     p->SetGridx();
@@ -211,16 +241,23 @@ void DrawSummary(const char* fname="forward_eloss.root")
     if (i == 3)                     stack->SetMaximum(0.1);   // xi
     if (i == 4 || i == 5)           stack->SetMaximum(0.5);    // sigma{,n}
     if (i == 7)                     stack->SetMaximum(0.5);    // a
-    yaxis->SetTitleSize(0.15);
+    if (i == 0) p->SetLogy();
+    yaxis->SetTitleSize(0.3/nY);
     yaxis->SetLabelSize(0.08);
-    yaxis->SetTitleOffset(0.35);
+    yaxis->SetTitleOffset(2.5/nY);
     yaxis->SetNdivisions(5);
-
+    yaxis->SetTitleFont(42);
+    yaxis->SetLabelFont(42);
+    yaxis->SetDecimals();
+    
     TAxis* xaxis = stack->GetHistogram()->GetXaxis();
-    xaxis->SetTitleSize(0.15);
+    xaxis->SetTitleSize(0.3/nY);
     xaxis->SetLabelSize(0.08);
-    xaxis->SetTitleOffset(0.35);
+    xaxis->SetTitleOffset(2./nY);
     xaxis->SetNdivisions(10);
+    xaxis->SetTitleFont(42);
+    xaxis->SetLabelFont(42);
+    xaxis->SetDecimals();
 
     // Redraw 
     stack->Draw("nostack");
@@ -228,6 +265,7 @@ void DrawSummary(const char* fname="forward_eloss.root")
     if (i >= 5) b = 2;
     p->cd();
   }
+  canvas->SaveAs("fit_results.png");
   canvas->Print(pdfName, "Title:Fit summary");
 }
 
@@ -330,11 +368,14 @@ void DrawEtaBins(const char* fname="AnalysisResults.root")
        Error("PrintFits", "Couldn't get EDists list for FMD%d%c", d,r);
        continue; 
       }
+      
+      Info("DrawEtaBins", "Drawing for FMD%d%c", d, r);
       TIter next(edists);
       TH1*  dist = 0;
       Int_t i    = 0;
       Int_t j    = 1;
       while ((dist = static_cast<TH1*>(next()))) { 
+       Info("DrawEtaBins", "FMD%d%c: %s", d, r, dist->GetName());
        if (i == 4) { 
          i = 0;
          j++;
@@ -397,14 +438,15 @@ void DrawEtaBins(const char* fname="AnalysisResults.root")
  * @ingroup pwg2_forward_scripts_corr
  */
 void
-DrawAnaELoss(const char* fname="forward_eloss.root")
+DrawAnaELoss(const char* fname="forward_eloss.root", bool onlySummary=true)
 {
   if (!CheckCanvas()) {
     Error("DrawFits", "No canvas");
     return;
   }
-  canvas->Print(Form("%s[", pdfName));
+  if (!onlySummary) canvas->Print(Form("%s[", pdfName));
   DrawSummary(fname);
+  if (onlySummary) return;
   DrawRings(fname);
   DrawEtaBins(fname);
   canvas->Print(Form("%s]", pdfName));
index c04c54aa04801a34d98dad6239f82df80e86d864..50cf259afe11d4a3dc652f6f8af4e711603ecfc7 100644 (file)
@@ -1,3 +1,61 @@
+/**
+ * @file   MakeChain.C
+ * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
+ * @date   Tue Jul 12 10:20:07 2011
+ * 
+ * @brief  Script to generate a chain of files 
+ * 
+ * @ingroup pwg2_forward_scripts
+ */
+/** 
+ * Check if a path points to a file 
+ * 
+ * @param path Path
+ * 
+ * @return True if the path points to a regular file 
+ *
+ * @ingroup pwg2_forward_scripts
+ */
+Bool_t
+IsFile(const char* path)
+{
+  Long_t id;
+  Long_t size;
+  Long_t flags;
+  Long_t modtime;
+  gSystem->GetPathInfo(path, &id, &size, &flags, &modtime);
+  return !((flags & 0x2) == 0x2);
+}
+
+/** 
+ * Test if we can open a file 
+ * 
+ * @param name    Name of file 
+ * @param pattern Pattern to check against 
+ * 
+ * @return True on success
+ */
+Bool_t
+TestFile(const TString& name, const char* pattern=0)
+{
+  // If this is not a root file, ignore 
+  if (!name.EndsWith(".root")) return false;
+
+  // If this file does not contain the pattern, ignore 
+  if (pattern && pattern[0] != '\0' && !name.Contains(pattern)) return false;
+  if (name.Contains("friends")) return false;
+    
+  Bool_t ret  = true;
+  TFile* test = TFile::Open(data.Data(), "READ");
+  if (!test || test->IsZombie()) { 
+    Warning("TestFile", "Failed to open file %s", data.Data());
+    ret = false;
+  }
+  else 
+    test->Close();
+  return ret;
+}
+
 /** 
  * Scan a directory (optionally recursive) for data files to add to
  * the chain.  Only ROOT files, and files which name contain the
@@ -37,27 +95,43 @@ ScanDirectory(TSystemDirectory* dir, TChain* chain,
       continue;
     }
     
-    // If this is not a root file, ignore 
-    if (!name.EndsWith(".root")) continue;
-
-    // If this file does not contain the pattern, ignore 
-    if (!name.Contains(pattern)) continue;
-    if (name.Contains("friends")) continue;
-    
     // Get the path 
     TString data(Form("%s/%s", file->GetTitle(), name.Data()));
 
-    TFile* test = TFile::Open(data.Data(), "READ");
-    if (!test || test->IsZombie()) { 
-      Warning("ScanDirectory", "Failed to open file %s", data.Data());
-      continue;
-    }
-    test->Close();
+    // Check the fuile 
+    if (!TestFile(data, pattern)) continue;
     chain->Add(data);
-
   }
 }
-
+/** 
+ * Scan an input list of files 
+ * 
+ * @param chain Chain to add to 
+ * @param path  file with list of files to add 
+ * 
+ * @return true on success 
+ */
+Bool_t 
+ScanInputList(TChain* chain, const TString& path, const char* treeName)
+{
+  std::ifstream in(path.Data()); 
+  if (!in) { 
+    Error("ScanInputList", "Failed to open input list %s", path.Data());
+    return false;
+  }
+  TString line;
+  while (in.good()) { 
+    line.ReadLine(in); // Skip white-space
+    if (line.IsNull()) break; // Nothing -> EOF
+    if (line[0] == '#') continue; // Ignore comment lines 
+    if (!TestFile(line, 0)) continue; 
+    chain->Add(line);
+  }
+  in.close();
+  return true;
+}
+    
+  
 /** 
  * Make a chain of specified data 
  * 
@@ -90,12 +164,29 @@ MakeChain(const char* what, const char* datadir, bool recursive=false)
   // --- Our data chain ----------------------------------------------
   TChain* chain = new TChain(treeName);
 
-  // --- Get list of ESDs --------------------------------------------
+  // --- Get list of files --------------------------------------------
   // Open source directory, and make sure we go back to were we were 
   TString oldDir(gSystem->WorkingDirectory());
-  TSystemDirectory d(datadir, datadir);
-  ScanDirectory(&d, chain, pattern, recursive);
-
+  TString path(gSystem->ExpandPathName(datadir));
+  if (!IsFile(path)) {
+    TSystemDirectory d(datadir, datadir);
+    ScanDirectory(&d, chain, pattern, recursive);
+  }
+  else if (path.EndsWith(".root")) { 
+    if (TestFile(path, pattern)) chain->Add(path);
+  }
+  else { 
+    // Input seems to be a list - parse it 
+    ScanInputList(chain, path);
+  }
+  
+  // Make sure we do not make an empty chain 
+  if (chain->GetListOfFiles()->GetEntries() <= 0) { 
+    Warning("MakeChain", "Chain %s is empty for input %s", 
+           treeName, datadir);
+    delete chain;
+    chain = 0;
+  }
   return chain;
 }
 //
index ccfc98ea4b0908834f3fcf947ebdddd2bf0575ab..5621cfae272debc02ee9e1be4d36c5c8a7fe6ee7 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * @file   MakeAODTrain.C
+ * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
+ * @date   Tue Jul 12 10:05:30 2011
+ * 
+ * @brief  Run first pass analysis - make AOD tree
+ * 
+ * @ingroup pwg2_forward_trains
+ */
 //====================================================================
 /**
  * Analysis train to make Forward and Central multiplicity
index 9972a6faa1efb6f42b2e8e016c8a50d459f2daee..f137c465a2d21c20137d0614358e3f38453c9746 100644 (file)
@@ -75,7 +75,7 @@ protected:
   void CreateTasks(EMode mode, Bool_t par, AliAnalysisManager* mgr)
   {
     // --- Output file name ------------------------------------------
-    AliAnalysisManager::SetCommonFileName("forward_eloss.root");
+    AliAnalysisManager::SetCommonFileName("forward_qa.root");
 
     // --- Load libraries/pars ---------------------------------------
     LoadLibrary("PWG2forward2", mode, par, true);