]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakeFlow.C
Updates to scripts. Mostly documentation and some new functionalities
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeFlow.C
1 /**
2  * @file   MakeFlow.C
3  * @author Alexander Hansen 
4  * @date   Wed Mar 23 12:11:33 2011
5  * 
6  * @brief Analyse AODs for flow 
7  * 
8  * @ingroup pwg2_forward_scripts_makers
9  * 
10  */
11 /**
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.
17  * 
18  * @param data         Input data (directory, list, or ROOT file)
19  * @param nevents      Number of events to scan 
20  * @param type         Type of analysis (v<n>)
21  * @param etabins      How may eta bins to make 
22  * @param addFlow      If true, add flow to MC particles
23  * @param addFType     Which type of flow to add to MC particles
24  * @param addFOrder    Order of flow to add to MC particles
25  * @param proof 
26  *
27  * @ingroup pwg2_forward_flow
28  */
29 void MakeFlow(TString data      = "", 
30               Int_t   nevents   = 0, 
31               TString type      = "", 
32               Int_t   etabins   = 40,
33               TString addFlow   = "",
34               Int_t   addFType  = 0,
35               Int_t   addFOrder = 0,
36               Bool_t  proof     = false)
37 {
38   Bool_t proof = kFALSE;
39
40   // --- Load libs ---------------------------------------------------
41   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
42
43   // --- Check for proof mode, and possibly upload pars --------------
44   if (proof> 0) { 
45     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
46     if (!LoadPars(proof)) { 
47       AliError("MakeFlow", "Failed to load PARs");
48       return;
49     }
50   }
51
52   // --- Set the macro path ------------------------------------------
53   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
54                            "$ALICE_ROOT/ANALYSIS/macros",
55                            gROOT->GetMacroPath()));
56
57   // --- Add to chain either AOD ------------------------------------
58   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
59   TChain* chain = MakeChain("AOD", data.Data(), true);
60   // If 0 or less events is select, choose all 
61   if (nEvents <= 0) nEvents = chain->GetEntries();
62
63   // --- Initiate the event handlers --------------------------------
64   AliAnalysisManager *mgr  = 
65     new AliAnalysisManager("Forward Flow", 
66                            "Flow in the forward region");
67
68   // --- AOD input handler -------------------------------------------
69   AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
70   mgr->SetInputEventHandler(aodInputHandler);      
71
72   // --- Add the tasks ---------------------------------------------
73   gROOT->LoadMacro("AddTaskForwardFlow.C");
74   AddTaskForwardFlow(type, etabins, addFlow, addFType, addFOrder);
75
76   // --- Run the analysis --------------------------------------------
77   TStopwatch t;
78   if (!mgr->InitAnalysis()) {
79     Error("MakeFlow", "Failed to initialize analysis train!");
80     return;
81   }
82   mgr->PrintStatus();
83   // 
84   if (proof) mgr->SetDebugLevel(3);
85   if (mgr->GetDebugLevel() < 1 && !proof) 
86     mgr->SetUseProgressBar(kTRUE,chain->GetEntries() < 10000 ? 10 : 100);
87
88   t.Start();
89   if (nevents == 0) mgr->StartAnalysis("local", chain);
90   if (nevents != 0) mgr->StartAnalysis("local", chain, nevents);
91   t.Stop();
92   t.Print();
93 }
94 //----------------------------------------------------------------
95 void MakeChain(TString data = "", TChain* chain = 0)
96 {
97   // creates chain of files in a given directory or file containing a list.
98   
99   // Open the input stream
100   ifstream in;
101   in.open(data.Data());
102
103   // Read the input list of files and add them to the chain
104   TString line;
105   while(in.good()) 
106   {
107     in >> line;
108       
109     if (line.Length() == 0)
110       continue;      
111     
112     if (TFile::Open(line))
113       chain->Add(line);
114   }
115
116   in.close();
117
118   return;
119 }
120 //
121 // EOF
122 //