]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/macros/setupDxHFE.C
Updated macros for D-electron correlation analysis (Matthias):
[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   "libPWGHFcorrelationHF.so "
48   ;
49
50 void setupDxHFE(const char* localAodDirectory, int nofDirectories, const char* lhcPeriod, const char* mcProd="")
51 {
52   //
53   // adding include path and libraries
54   //
55   gSystem->AddIncludePath(includePath);
56   TString libraries=libraryDependencies;
57   TObjArray* pTokens=libraries.Tokenize(" ");
58   if (pTokens) {
59     for (int i=0; i<pTokens->GetEntriesFast(); i++) {
60       if (gSystem->Load(pTokens->At(i)->GetName())==0) {
61         cout << "loading " << pTokens->At(i)->GetName() << endl;
62       }
63     }
64     delete pTokens;
65   }
66   libraries="";
67
68   //
69   // allow run-single-task to fetch the analysis name and library names
70   //
71   if (gDirectory) gDirectory->Add(new TNamed("analysis_name", analysisName));
72   if (gDirectory) gDirectory->Add(new TNamed("analysis_libraries", libraryDependencies));
73
74   if (lhcPeriod) {
75     //
76     // setting up the runs for the dpecified period
77     //
78     TString alienHandlerName(analysisName); alienHandlerName+="Handler";
79     AliAnalysisAlien* alienHandler=new AliAnalysisAlien(alienHandlerName);
80     gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/AddGoodRuns.C");
81     int nruns=AddGoodRuns(alienHandler, lhcPeriod, mcProd);
82     if (nruns<=0) {
83       ::Error("setupDxHFE.C", Form("can not find any good runs for period %s", lhcPeriod));
84       return;
85     }
86     gDirectory->Add(alienHandler);
87     ::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()));
88
89   } else if (localAodDirectory) {
90     //
91     // create AOD tree from local files
92     // the created object is added automatically to gDirectory and can be fetched
93     // from there later
94     //
95     gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/MakeAODInputChain.C");
96     TString aodPathName(localAodDirectory);
97     if (!aodPathName.EndsWith("/")) aodPathName+="/";
98     aodPathName+="AliAOD.root";
99     if (gSystem->AccessPathName(aodPathName)==0) {
100       // Create a chain with one set of AliAOD.root and AliAOD.VertexingHF.root. The set needs 
101       // to be located in the same folder as you run from (physically or linked)
102       ::Info("setupDxHFE.C", Form("make chain from single chunk %s", aodPathName));
103       TChain* chain = MakeAODInputChain(localAodDirectory ,1, -1);
104     } else {
105       // Assume several folders containing different AODs. 
106       // The AODs need to be in folders named 1, 2,...
107       ::Info("setupDxHFE.C", Form("make chain from directory %s", localAodDirectory));
108       chain=MakeAODInputChain(localAodDirectory, 1, nofDirectories);
109     }
110     ::Info("setupDxHFE.C", Form("local AOD chain: %d entries", chain->GetEntries()));
111   }
112 }
113
114 void setupDxHFE(const char* lhcPeriod=NULL, const char* mcProd="")
115 {
116   // Grid mode with optional calling of AddGoodRuns for specified
117   // period
118   setupDxHFE(NULL, 0, lhcPeriod, mcProd);
119 }
120
121 void setupDxHFE(const char* localAodDirectory, int nofDirectories)
122 {
123   // local mode for AOD data
124   setupDxHFE(localAodDirectory, nofDirectories, NULL);
125 }