]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/macros/setupDxHFE.C
fix: parse the delimiter correctly
[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'("localAodDirectory", nofDirectories)' run-single-task.C'(...)'
13 /// aliroot -b -q -l setupDxHFE.C'("lhcPeriod", "mcPeriod")' run-single-task.C'(...)'
14 ///
15 /// Example:
16 /// aliroot -b -q -l setupDxHFE.C run-single-task.C'(...)'
17 ///
18 /// The macro has the following tasks:
19 /// - load the necessary libraries, in order to have those library names also
20 ///   available for the alien handler initialization, a specific configuration
21 ///   object is created
22 /// - setting a default analysis name via a configuration object
23 /// - the optional parameter 'localAodDirectory' allows to create an input chain from
24 ///   local AODs; either a single AliAOD.root, or a folder containing directories
25 ///   named "1, 2, ...", the number of directories is specified as parameter
26 ///   nofDirectories
27 /// - loading the runs defined by AddGoodRuns of vertexingHF using lhcPeriod and
28 ///   optional mcPeriod
29
30 ///////////////////////////////////////////////////////////////////////////////////////////////////
31 //
32 // environment specific for DxHFE
33 //
34 const char* analysisName="DxHFECorrelation";
35 const char* includePath="-I$ALICE_ROOT/PWGHF/correlationHF -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWGHF/hfe";
36 const char* libraryDependencies=
37   "libSTEERBase "
38   "libESD "
39   "libAOD "
40   "libANALYSIS "
41   "libANALYSISalice "
42   "libPWGflowBase.so "
43   "libPWGflowTasks.so "
44   "libCORRFW.so "
45   "libPWGHFvertexingHF.so "
46   "libPWGHFhfe.so "
47   ;
48 // Note: "libPWGHFcorrelationHF.so " shouldn't be added here. If the library is
49 // loaded already, compilation of source files by Cint does not have any effect.
50 // The already existing class implementations are not overidden. To just load
51 // all necessary libraries to make the classes available in aliroot use macro
52 // LoadLibraries.C
53
54 void setupDxHFE(const char* localAodDirectory, int nofDirectories, const char* lhcPeriod, const char* mcProd="")
55 {
56   //
57   // adding include path and libraries
58   //
59   gSystem->AddIncludePath(includePath);
60   TString libraries=libraryDependencies;
61   TObjArray* pTokens=libraries.Tokenize(" ");
62   if (pTokens) {
63     for (int i=0; i<pTokens->GetEntriesFast(); i++) {
64       if (gSystem->Load(pTokens->At(i)->GetName())==0) {
65         cout << "loading " << pTokens->At(i)->GetName() << endl;
66       }
67     }
68     delete pTokens;
69   }
70   libraries="";
71
72   //
73   // allow run-single-task to fetch the analysis name and library names
74   //
75   if (gDirectory) gDirectory->Add(new TNamed("analysis_name", analysisName));
76   if (gDirectory) gDirectory->Add(new TNamed("analysis_libraries", libraryDependencies));
77
78   if (lhcPeriod) {
79     //
80     // setting up the runs for the dpecified period
81     //
82     TString alienHandlerName(analysisName); alienHandlerName+="Handler";
83     AliAnalysisAlien* alienHandler=new AliAnalysisAlien(alienHandlerName);
84     gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/AddGoodRuns.C");
85     int nruns=AddGoodRuns(alienHandler, lhcPeriod, mcProd);
86     if (nruns<=0) {
87       ::Error("setupDxHFE.C", Form("can not find any good runs for period %s", lhcPeriod));
88       return;
89     }
90     gDirectory->Add(alienHandler);
91     ::Info("setupDxHFE.C", Form("setting up alien plugin '%s' for period %s\n>>>>> please use '%s' as input parameter for run-single-task.C <<<<<<", alienHandlerName.Data(), lhcPeriod, alienHandlerName.Data()));
92
93   } else if (localAodDirectory) {
94     //
95     // create AOD tree from local files
96     // the created object is added automatically to gDirectory and can be fetched
97     // from there later
98     //
99     gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/MakeAODInputChain.C");
100     TString aodPathName(localAodDirectory);
101     if (!aodPathName.EndsWith("/")) aodPathName+="/";
102     aodPathName+="AliAOD.root";
103     if (gSystem->AccessPathName(aodPathName)==0) {
104       // Create a chain with one set of AliAOD.root and AliAOD.VertexingHF.root. The set needs 
105       // to be located in the same folder as you run from (physically or linked)
106       ::Info("setupDxHFE.C", Form("make chain from single chunk %s", aodPathName.Data()));
107       TChain* chain = MakeAODInputChain(localAodDirectory ,1, -1);
108     } else {
109       // Assume several folders containing different AODs. 
110       // The AODs need to be in folders named 1, 2,...
111       aodPathName=localAodDirectory;
112       if (!aodPathName.EndsWith("/")) aodPathName+="/";
113       ::Info("setupDxHFE.C", Form("make chain from directory %s", aodPathName.Data()));
114       chain=MakeAODInputChain(aodPathName, 1, nofDirectories);
115     }
116     ::Info("setupDxHFE.C", Form("local AOD chain: %d entries", chain->GetEntries()));
117   }
118 }
119
120 void setupDxHFE(const char* lhcPeriod=NULL, const char* mcProd="")
121 {
122   // Grid mode with optional calling of AddGoodRuns for specified
123   // period
124   setupDxHFE(NULL, 0, lhcPeriod, mcProd);
125 }
126
127 void setupDxHFE(const char* localAodDirectory, int nofDirectories)
128 {
129   // local mode for AOD data
130   setupDxHFE(localAodDirectory, nofDirectories, NULL);
131 }