]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/PHOSTasks/PHOS_PbPb/macros/single-task/setupPi0Flow.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_PbPb / macros / single-task / setupPi0Flow.C
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 /// @file   setupPi0Flow.C
5 /// @author Matthias.Richter@cern.ch, modified for PHOSPi0Flow by Henrik.Qvigstad@cern.ch
6 /// @date   2012-09-12
7 /// @brief  Setup the environment specifically for running Pi0Flow analysis
8 ///
9 /// Helper macro to initialize the environment for Pi0Flow. The macro can just
10 /// prepend other macros like run-single-task in the command line.
11 /// Usage:
12 /// aliroot -b -q -l setupPi0Flow.C'("localAodDirectory", nFiles)' run-single-task.C'(...)'
13 /// aliroot -b -q -l setupPi0Flow.C'("lhcPeriod", "mcPeriod")' run-single-task.C'(...)'
14 ///
15 /// Example:
16 /// aliroot -b -q -l setupPi0Flow.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 ///   nFiles
27 /// - loading the runs defined by AddGoodRuns of vertexingHF using lhcPeriod and
28 ///   optional mcPeriod
29
30 ///////////////////////////////////////////////////////////////////////////////////////////////////
31 //
32 // environment specific for Pi0Flow
33 //
34 const char* analysisName="PHOSPi0Flow";
35 const char* includePath="-I$ALICE_ROOT/include -I$ALICE_ROOT/PHOS -I$ALICE_ROOT/PWGGA/PHOSTasks/PHOS_PbPb";
36 const char* libraryDependencies="libCore.so libTree.so libGeom.so libVMC.so libPhysics.so libMinuit.so libGui.so libXMLParser.so libMinuit2.so libProof.so libSTEERBase.so libESD.so libAOD.so libOADB.so libANALYSIS.so libANALYSISalice.so libCDB.so libRAWDatabase.so libSTEER.so libCORRFW.so libPHOSUtils.so libPHOSbase.so libPHOSpi0Calib.so libPHOSrec.so libPHOSshuttle.so libPHOSsim.so libPWGGAPHOSTasks.so libTender.so libTRDbase.so libVZERObase.so libVZEROrec.so libTenderSupplies.so libPWGGAUtils.so";
37
38 void setupPi0Flow(const char* localAodDirectory, int nFiles, const char* lhcPeriod, const char* mcProd="", const TString& dataType="AOD")
39 {
40   //
41   // adding include path and libraries
42   //
43   gSystem->AddIncludePath(includePath);
44   TString libraries=libraryDependencies;
45   TObjArray* pTokens=libraries.Tokenize(" ");
46   TString buf;
47   if (pTokens) {
48     for (int i=0; i<pTokens->GetEntriesFast(); i++) {
49       buf = pTokens->At(i)->GetName();
50       buf.ReplaceAll(".so", "");
51       if (gSystem->Load(buf)==0) {
52         cout << "loading " << pTokens->At(i)->GetName() << endl;
53       }
54     }
55     delete pTokens;
56   }
57   libraries="";
58
59   //
60   // allow run-single-task to fetch the analysis name and library names
61   //
62   if (gDirectory) gDirectory->Add(new TNamed("analysis_name", analysisName));
63   if (gDirectory) gDirectory->Add(new TNamed("analysis_libraries", libraryDependencies));
64
65   if (lhcPeriod) {
66     //
67     // setting up the runs for the dpecified period
68     //
69     TString alienHandlerName(analysisName); alienHandlerName+="Handler";
70     AliAnalysisAlien* alienHandler=new AliAnalysisAlien(alienHandlerName);
71     gROOT->LoadMacro("$ALICE_ROOT/PWGGA/PHOSTasks/PHOS_PbPb/macros/single-task/AddGoodRuns.C");
72     int nruns=AddGoodRuns(alienHandler, lhcPeriod, mcProd);
73     if (nruns<=0) {
74       ::Error("setupPi0Flow.C", Form("can not find any good runs for period %s", lhcPeriod));
75       return;
76     }
77     gDirectory->Add(alienHandler);
78     ::Info("setupPi0Flow.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()));
79
80   } else if (localAodDirectory) {
81     //
82     // create AOD tree from local files
83     // the created object is added automatically to gDirectory and can be fetched
84     // from there later
85     //
86     //gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/MakeAODInputChain.C");
87     TChain* chain = 0x0;
88     if( dataType.EqualTo("AOD") ) {
89       gROOT->LoadMacro("$ALICE_ROOT/PWGGA/PHOSTasks/PHOS_PbPb/macros/single-task/MakeAODInputChain.C");
90       chain = MakeAODInputChain(localAodDirectory, nFiles);
91     } 
92     else if ( dataType.EqualTo("ESD") ) {
93       gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/CreateESDChain.C");
94       chain = CreateESDChain(localAodDirectory, nFiles);
95     }
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("setupPi0Flow.C", Form("make chain from single chunk %s", aodPathName));
103     //   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("setupPi0Flow.C", Form("make chain from directory %s", localAodDirectory));
108     //   chain=MakeAODInputChain(localAodDirectory, nFiles);
109     // }
110     ::Info("setupPi0Flow.C", Form("local AOD chain: %d entries", chain->GetEntries()));
111   }
112 }
113
114 void setupPi0Flow(const char* lhcPeriod=NULL, const char* mcProd="")
115 {
116   // Grid mode with optional calling of AddGoodRuns for specified
117   // period
118   setupPi0Flow(NULL, 0, lhcPeriod, mcProd);
119 }
120
121 void setupPi0Flow(const char* localAodDirectory, int nFiles)
122 {
123   // local mode for AOD data
124   setupPi0Flow(localAodDirectory, nFiles, NULL);
125 }