3 * @author Alexander Hansen
4 * @date Wed Mar 23 12:11:33 2011
8 * @ingroup pwglf_forward_scripts_makers
12 * Script to analyse AOD input for flow
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.
24 * @ingroup pwglf_forward_flow
26 void MakeFlow(TString data = "",
34 Bool_t proof = kFALSE)
36 Bool_t proof = kFALSE;
38 // --- Load libs ---------------------------------------------------
39 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
41 // --- Check for proof mode, and possibly upload pars --------------
43 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadPars.C");
44 if (!LoadPars(proof)) {
45 AliError("MakeFlow", "Failed to load PARs");
50 // --- Set the macro path ------------------------------------------
51 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2:"
52 "$ALICE_ROOT/ANALYSIS/macros",
53 gROOT->GetMacroPath()));
55 // --- Add to chain either AOD ------------------------------------
57 AliError("You didn't add a data file");
60 TChain* chain = new TChain("aodTree");
62 if (data.Contains(".txt")) MakeChain(data, chain);
64 if (data.Contains(".root")) {
65 TFile* test = TFile::Open(data.Data());
67 AliError(Form("AOD file %s not found", data.Data()));
70 test->Close(); // Remember to close!
71 chain->Add(data.Data());
74 // --- Initiate the event handlers --------------------------------
75 AliAnalysisManager *mgr = new AliAnalysisManager("Forward Flow",
76 "Flow in the forward region");
78 // --- AOD input handler -------------------------------------------
79 AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
80 mgr->SetInputEventHandler(aodInputHandler);
82 // --- Add the tasks ---------------------------------------------
83 gROOT->LoadMacro("AddTaskForwardFlow.C");
84 AddTaskForwardFlow(type, etabins, mc, addFlow, addFType, addFOrder);
86 // --- Run the analysis --------------------------------------------
88 if (!mgr->InitAnalysis()) {
89 Error("MakeFlow", "Failed to initialize analysis train!");
93 Printf("****************************************");
94 Printf("Doing flow analysis on %d Events", nevents == 0 ? chain->GetEntries() : nevents);
95 Printf("****************************************");
97 if (proof) mgr->SetDebugLevel(3);
98 if (mgr->GetDebugLevel() < 1 && !proof)
99 mgr->SetUseProgressBar(kTRUE,chain->GetEntries() < 10000 ? 100 : 1000);
101 // mgr->SetSkipTerminate(true);
104 if (nevents == 0) mgr->StartAnalysis("local", chain);
105 if (nevents != 0) mgr->StartAnalysis("local", chain, nevents);
109 //----------------------------------------------------------------
110 void MakeChain(TString data = "", TChain* chain = 0)
112 // creates chain of files in a given directory or file containing a list.
114 // Open the input stream
116 in.open(data.Data());
118 // Read the input list of files and add them to the chain
125 if (line.Length() == 0)
127 if (!(file = TFile::Open(line)))
128 gROOT->ProcessLine(Form(".!rm %s", line.Data()));