]>
Commit | Line | Data |
---|---|---|
1 | /** | |
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. | |
7 | * | |
8 | * @par Inputs: | |
9 | * | |
10 | * | |
11 | * @par Outputs: | |
12 | * - | |
13 | * | |
14 | */ | |
15 | void MakeFlow(TString data = "", | |
16 | Int_t nevents = 0, | |
17 | TString type = "", | |
18 | Int_t etabins = 40, | |
19 | Int_t zVertex = 2, | |
20 | TString addFlow = "", | |
21 | Int_t addFType = 0, | |
22 | Int_t addFOrder = 0) | |
23 | { | |
24 | Bool_t proof = kFALSE; | |
25 | ||
26 | // --- Load libs --------------------------------------------------- | |
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)) { | |
33 | AliError("MakeFlow", "Failed to load PARs"); | |
34 | return; | |
35 | } | |
36 | } | |
37 | ||
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); | |
47 | ||
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 -------------------------------- | |
57 | AliAnalysisManager *mgr = new AliAnalysisManager("Forward Flow", | |
58 | "Flow in the forward region"); | |
59 | mgr->SetUseProgressBar(kTRUE, 10); | |
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"); | |
72 | AddTaskForwardFlow(type, etabins, zVertex, addFlow, addFType, addFOrder); | |
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 | } | |
88 | //---------------------------------------------------------------- | |
89 | void 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 | } | |
114 | // | |
115 | // EOF | |
116 | // |