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