]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/MakeFlow.C
Lots of small improvements and optimizations to flow task.
[u/mrichter/AliRoot.git] / PWGLF / 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  
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  * @par Inputs: 
19  *  
20  * 
21  * @par Outputs: 
22  * - 
23  *
24  * @ingroup pwglf_forward_flow
25  */
26 void MakeFlow(const char* data  = "", 
27               Int_t   nEvents   = -1, 
28               TString type      = "", 
29               Bool_t  mc        = kFALSE,
30               const char* name  = 0,
31               Int_t   proof     = 0,
32               TString addFlow   = "",
33               Int_t   addFType  = 0,
34               Int_t   addFOrder = 0,
35               Bool_t  gdb       = kFALSE)
36 {
37   // --- Load libs ---------------------------------------------------
38   gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
39
40   // --- Possibly use plug-in for this -------------------------------
41   if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
42  
43     gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/trains/TrainSetup.C+");
44     gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/trains/MakeFlowTrain.C+");
45
46     char* tok = strtok(name, " ,:");
47     TString server = "", dataset = "", datadir = "", jobname = "";
48     if (tok[0] == NULL) Fatal("Input name invalid!");
49     if (strcmp(tok, "hehi00.nbi.dk") == 0) {
50       server = tok;
51       dataset = data;
52       datadir = "";
53       tok = strtok(NULL, " ,:");
54       jobname = tok;
55     } else {
56       server = Form("workers=%d", proof);
57       dataset = "";
58       datadir = data;
59       jobname = tok;
60     }
61     printf("Making flow train on server: %s\t with datadir: %s\t on dataset: %s\n", 
62             server.Data(), datadir.Data(), dataset.Data());
63
64     MakeFlowTrain t(jobname.Data(), type.Data(), mc, addFlow.Data(), addFType, addFOrder, false);
65     t.SetProofServer(server.Data());
66     t.SetDataDir(datadir.Data());
67     t.SetDataSet(dataset.Data());
68     t.SetDebugLevel(1);
69     t.SetUseGDB(gdb);
70     t.Run("proof", "full", nEvents, proof > 0);
71
72     return;
73   }
74
75   // --- Set the macro path ------------------------------------------
76   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2:"
77                            "$ALICE_ROOT/ANALYSIS/macros",
78                            gROOT->GetMacroPath()));
79
80   // --- Add to chain either AOD ------------------------------------
81   if (data == '\0') {
82     AliError("You didn't add a data file");
83     return;
84   }
85   gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/MakeChain.C");
86   TChain* chain = MakeChain("AOD", data, true);
87   // If 0 or less events is select, choose all 
88   if (nEvents <= 0) nEvents = chain->GetEntries();
89
90   // --- Initiate the event handlers --------------------------------
91   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward Flow", 
92                                                     "Flow in the forward region");
93
94   // --- AOD input handler -------------------------------------------
95   AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
96   mgr->SetInputEventHandler(aodInputHandler); 
97
98   // --- Add the tasks ---------------------------------------------
99   gROOT->LoadMacro("AddTaskForwardFlow.C");
100   AddTaskForwardFlow(type, mc, addFlow, addFType, addFOrder);
101   mgr->SetDebugLevel(1);
102
103   // --- Run the analysis --------------------------------------------
104   TStopwatch t;
105   if (!mgr->InitAnalysis()) {
106     Error("MakeFlow", "Failed to initialize analysis train!");
107     return;
108   }
109   mgr->PrintStatus();
110   Printf("****************************************");
111   Printf("Doing flow analysis on %d Events", nEvents);
112   Printf("****************************************");
113   // 
114   mgr->SetDebugLevel(0);
115   if (mgr->GetDebugLevel() < 1) 
116     mgr->SetUseProgressBar(kTRUE, nEvents < 10000 ? 100 : 1000);
117
118 //  mgr->SetSkipTerminate(true);
119
120   t.Start();
121   mgr->StartAnalysis("local", chain, nEvents);
122   t.Stop();
123   t.Print();
124 }
125 //----------------------------------------------------------------
126 //
127 // EOF
128 //