]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/macros/setupDxHFE.C
fda1a7f3d4c1185f4388c7b7d74f957262c50156
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / macros / setupDxHFE.C
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 /// @file   setupDxHFE.C
5 /// @author Matthias.Richter@cern.ch
6 /// @date   2012-09-12
7 /// @brief  Setup the environment specifically for running DxHFE analysis
8 ///
9 /// Helper macro to initialize the environment for DxHFE. The macro can just
10 /// prepend other macros like run-single-task in the command line.
11 /// Usage:
12 /// aliroot -b -q -l setupDxHFE.C'("localAodDir")' run-single-task.C'(...)'
13 ///
14 /// Example:
15 /// aliroot -b -q -l setupDxHFE.C run-single-task.C'(...)'
16 ///
17 /// The macro has the following tasks:
18 /// - load the necessary libraries, in order to have those library names also
19 ///   available for the alien handler initialization, a specific configuration
20 ///   object is created
21 /// - setting a default analysis name via a configuration object
22 /// - the optional parameter 'localAodDir' allows to create an input chain from
23 ///   local AODs; either a single AliAOD.root, or a folder containing directories
24 ///   named "1, 2, ..."
25
26 ///////////////////////////////////////////////////////////////////////////////////////////////////
27 //
28 // environment specific for DxHFE
29 //
30 const char* includePath="-I$ALICE_ROOT/PWGHF/correlationHF -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWGHF/hfe";
31 const char* libraryDependencies=
32   "libSTEERBase "
33   "libESD "
34   "libAOD "
35   "libANALYSIS "
36   "libANALYSISalice "
37   "libPWGflowBase.so "
38   "libPWGflowTasks.so "
39   "libCORRFW.so "
40   "libPWGHFvertexingHF.so "
41   "libPWGHFhfe.so "
42   "libPWGHFcorrelationHF.so "
43   ;
44
45 void setupDxHFE(const char* aodDirectory=NULL)
46 {
47   gSystem->AddIncludePath(includePath);
48   TString libraries=libraryDependencies;
49   TObjArray* pTokens=libraries.Tokenize(" ");
50   if (pTokens) {
51     for (int i=0; i<pTokens->GetEntriesFast(); i++) {
52       if (gSystem->Load(pTokens->At(i)->GetName())==0) {
53         cout << "loading " << pTokens->At(i)->GetName() << endl;
54       }
55     }
56     delete pTokens;
57   }
58   libraries="";
59
60   // allow run-single-task to fetch the analysis name and library names
61   if (gDirectory) gDirectory->Add(new TNamed("analysis_name", "DxHFECorrelation"));
62   if (gDirectory) gDirectory->Add(new TNamed("analysis_libraries", libraryDependencies));
63
64   if (aodDirectory) {
65     // create AOD tree from local files
66     // the created object is added automatically to gDirectory and can be fetched
67     // from there later
68     gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/MakeAODInputChain.C");
69     TString aodPathName(aodDirectory);
70     if (!aodPathName.EndsWith("/")) aodPathName+="/";
71     aodPathName+="AliAOD.root";
72     if (gSystem->AccessPathName(aodPathName)==0) {
73       // Create a chain with one set of AliAOD.root and AliAOD.VertexingHF.root. The set needs 
74       // to be located in the same folder as you run from (physically or linked)
75       ::Info("setupDxHFE.C", Form("make chain from single chunk %s", aodPathName));
76       TChain* chain = MakeAODInputChain(aodDirectory ,1, -1);
77     } else {
78       // Assume several folders containing different AODs. 
79       // The AODs need to be in folders named 1, 2,...
80       ::Info("setupDxHFE.C", Form("make chain from directory %s", aodDirectory));
81       chain=MakeAODInputChain(aodDirectory, 1, 10);
82     }
83     ::Info("setupDxHFE.C", Form("local AOD chain: %d entries", chain->GetEntries()));
84   }
85 }