]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/MakeFlow.C
Possiblity to use MC primary vertex in IsSelected
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeFlow.C
CommitLineData
9d05ffeb 1/**
58f5fae2 2 * Script to analyse AOD input for flow
3 *
4 * Takes either a single (AOD) .root file as input or a .txt
5 * The .txt file is expected to contain the path to the files
6 * from the current directory or the absolute path.
9d05ffeb 7 *
8 * @par Inputs:
58f5fae2 9 *
9d05ffeb 10 *
11 * @par Outputs:
12 * -
13 *
14 */
58f5fae2 15void MakeFlow(TString data = "",
16 Int_t nevents = 0,
9d05ffeb 17 TString type = "",
58f5fae2 18 Int_t etabins = 40,
19 Int_t zVertex = 2,
20 TString addFlow = "",
21 Int_t addFType = 0,
22 Int_t addFOrder = 0)
9d05ffeb 23{
58f5fae2 24 Bool_t proof = kFALSE;
9d05ffeb 25
58f5fae2 26 // --- Load libs ---------------------------------------------------
9d05ffeb 27 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
28
29 // --- Check for proof mode, and possibly upload pars --------------
30 if (proof> 0) {
31 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
32 if (!LoadPars(proof)) {
58f5fae2 33 AliError("MakeFlow", "Failed to load PARs");
9d05ffeb 34 return;
35 }
36 }
37
58f5fae2 38 // --- Add to chain either AOD ------------------------------------
39 if (data.Length() <= 1) {
40 AliError("You didn't add a data file");
41 return;
42 }
43 TChain* chain = new TChain("aodTree");
44
45 if (data.Contains(".txt"))
46 MakeChain(data, chain);
9d05ffeb 47
58f5fae2 48 if (data.Contains(".root")) {
49 if (!TFile::Open(data.Data())) {
50 AliError(Form("AOD file %s not found", data.Data()));
51 return;
52 }
53 chain->Add(data.Data());
54 }
55
56 // --- Initiate the event handlers --------------------------------
9d05ffeb 57 AliAnalysisManager *mgr = new AliAnalysisManager("Forward Flow",
58f5fae2 58 "Flow in the forward region");
59 mgr->SetUseProgressBar(kTRUE, 10);
9d05ffeb 60
61 // --- AOD input handler -------------------------------------------
62 AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
63 mgr->SetInputEventHandler(aodInputHandler);
64
65 // --- Create output handler ---------------------------------------
66 AliAODHandler* aodOut = new AliAODHandler();
67 mgr->SetOutputEventHandler(aodOut);
68 aodOut->SetOutputFileName("AliAODs.Flow.root");
69
70 // --- Add the tasks ---------------------------------------------
71 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskForwardFlow.C");
58f5fae2 72 AddTaskForwardFlow(type, etabins, zVertex, addFlow, addFType, addFOrder);
9d05ffeb 73
74 // --- Run the analysis --------------------------------------------
75 TStopwatch t;
76 if (!mgr->InitAnalysis()) {
77 Error("MakeFlow", "Failed to initialize analysis train!");
78 return;
79 }
80 mgr->PrintStatus();
81
82 t.Start();
83 if (nevents == 0) mgr->StartAnalysis("local", chain);
84 if (nevents != 0) mgr->StartAnalysis("local", chain, nevents);
85 t.Stop();
86 t.Print();
87}
58f5fae2 88//----------------------------------------------------------------
89void MakeChain(TString data = "", TChain* chain = 0)
90{
91 // creates chain of files in a given directory or file containing a list.
92
93 // Open the input stream
94 ifstream in;
95 in.open(data.Data());
96
97 // Read the input list of files and add them to the chain
98 TString line;
99 while(in.good())
100 {
101 in >> line;
102
103 if (line.Length() == 0)
104 continue;
105
106 if (TFile::Open(line))
107 chain->Add(line);
108 }
109
110 in.close();
111
112 return;
113}
9d05ffeb 114//
115// EOF
116//