]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/MakeForwardQA.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / MakeForwardQA.C
1 /**
2  * @file   MakeForwardQA.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 14:08:14 2011
5  * 
6  * @brief  Generate energy loss fits 
7  * 
8  * @ingroup pwglf_forward_scripts_makers
9  */
10 /** 
11  * Run a pass on ESD data to produce the energ loss fits 
12  * 
13  * If the ROOT AliEn interface library (libRAliEn) can be loaded, 
14  * and the parameter @a name is not empty, then use the plugin to do
15  * the analysis.  Note that in this case, the output is placed 
16  * in a sub-directory named by @a name after escaping spaces and special 
17  * characters 
18  *
19  * If PROOF mode is selected, then Terminate will be run on the master node 
20  * in any case. 
21  *
22  * @param esddir     ESD input directory. Any file matching the pattern 
23  *                   *AliESDs*.root are added to the chain 
24  * @param nEvents    Number of events to process.  If 0 or less, then 
25  *                   all events are analysed
26  * @param proof      If larger then 1, run in PROOF-Lite mode with this 
27  *                   many number of workers. 
28  * @param mc         Data is assumed to be from simulations  
29  * @param cent       Whether to use centrality or not 
30  * @param name       Name of train - free form.  This will be the name
31  *                   of the output directory if the plug-in is used 
32  *
33  * @ingroup pwglf_forward_eloss
34  */
35 void MakeForwardQA(const char* esddir, 
36                    Int_t       nEvents = 1000, 
37                    Int_t       proof   = 0,
38                    Bool_t      mc      = false,
39                    Bool_t      cent    = false,
40                    const char* name    = 0)
41 {
42   // --- Possibly use plug-in for this -------------------------------
43   if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
44     const char* builder = 
45       "$(ALICE_ROOT)/PWGLF/FORWARD/analysis2/trains/BuildTrain.C";
46     gROOT->LoadMacro(builder);
47
48     BuildTrain("MakeQATrain");
49
50     MakeQATrain t(name, cent, false);
51     t.SetDataDir(esddir);
52     t.SetDataSet("");
53     t.SetProofServer(Form("workers=%d",proof));
54     t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
55     return;
56   }
57
58   // --- Libraries to load -------------------------------------------
59   gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
60
61   // --- Check for proof mode, and possibly upload pars --------------
62   if (proof > 0) {
63     gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadPars.C");
64     LoadPars(proof);
65   }
66   
67   // --- Our data chain ----------------------------------------------
68   gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/MakeChain.C");
69   TChain* chain = MakeChain("ESD",esddir, true);
70   // If 0 or less events is select, choose all 
71   if (nEvents <= 0) nEvents = chain->GetEntries();
72   Info("MakeForwardQA", "Will analyse %d events", nEvents);
73
74   // --- Set the macro path ------------------------------------------
75   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2:"
76                            "$ALICE_ROOT/ANALYSIS/macros",
77                            gROOT->GetMacroPath()));
78
79   // --- Creating the manager and handlers ---------------------------
80   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward QA Train", 
81                                                     "Forward QA");
82   AliAnalysisManager::SetCommonFileName("forward_qa.root");
83
84   // --- ESD input handler -------------------------------------------
85   AliESDInputHandler *esdHandler = new AliESDInputHandler();
86   mgr->SetInputEventHandler(esdHandler);      
87        
88   // --- Monte Carlo handler -----------------------------------------
89   if (mc) {
90     AliMCEventHandler* mcHandler = new AliMCEventHandler();
91     mgr->SetMCtruthEventHandler(mcHandler);
92     mcHandler->SetReadTR(true);    
93   }
94
95   // --- Add tasks ---------------------------------------------------
96   gROOT->LoadMacro("AddTaskPhysicsSelection.C");
97   AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
98   
99   // Centrality 
100   if(cent) {
101     gROOT->LoadMacro("AddTaskCentrality.C");
102     AddTaskCentrality();
103   }
104   
105   // FMD ELoss fitter 
106   gROOT->LoadMacro("AddTaskForwardQA.C");
107   AddTaskForwardQA(mc, cent);
108
109   // --- Run the analysis --------------------------------------------
110   TStopwatch t;
111   if (!mgr->InitAnalysis()) {
112     Error("RunManager", "Failed to initialize analysis train!");
113     return;
114   }
115   // Some informative output 
116   mgr->PrintStatus();
117   // mgr->SetDebugLevel(3);
118   if (mgr->GetDebugLevel() < 1 && proof <= 0) 
119     mgr->SetUseProgressBar(kTRUE,100);
120
121   // Run the train 
122   t.Start();
123   Printf("=== RUNNING ANALYSIS on %9d events ========================",nEvents);
124   mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
125   t.Stop();
126   t.Print();
127 }
128 //
129 // EOF
130 //