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