]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakedNdeta.C
Mior fixes
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakedNdeta.C
1 /**
2  * @file   MakedNdeta.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 09:41:56 2011
5  * 
6  * @brief  Run second pass analysis - make @f$ dN/d\eta@f$
7  * 
8  * @ingroup pwg2_forward_scripts_makers
9  */
10 /** 
11  * Run second pass analysis - make @f$ dN/d\eta@f$
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  * @param aoddir     AOD input directory. Any file matching the pattern 
20  *                   *AliAODs*.root are added to the chain 
21  * @param nEvents    Number of events to process.  If 0 or less, then 
22  *                   all events are analysed
23  * @param trig       Trigger to use 
24  * @param useCent    Whether to use centrality or not 
25  * @param scheme     Normalisation scheme 
26  * @param vzMin      Least @f$ v_z@f$ (centimeter)
27  * @param vzMax      Largest @f$ v_z@f$ (centimeter)
28  * @param proof      If larger then 1, run in PROOF-Lite mode with this 
29  *                   many number of workers. 
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 pwg2_forward_dndeta
34  */
35 void MakedNdeta(const char* aoddir   = ".", 
36                 Int_t       nEvents  = -1, 
37                 const char* trig     = "INEL",
38                 Bool_t      useCent  = false,
39                 const char* scheme   = 0,
40                 Double_t    vzMin    = -10,
41                 Double_t    vzMax    = +10,
42                 Int_t       proof    = 0,
43                 const char* name     = 0,
44                 const char* mcfile   = 0)
45 {
46   if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
47     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
48                              "$ALICE_ROOT/ANALYSIS/macros",
49                              gROOT->GetMacroPath()));
50     gSystem->AddIncludePath("-I${ALICE_ROOT}/include");
51     gSystem->Load("libANALYSIS");
52     gSystem->Load("libANALYSISalice");
53     gROOT->LoadMacro("TrainSetup.C+");
54     MakedNdetaTrain t(name, trig, vzMin, vzMax, scheme, useCent, false);
55     t.SetDataDir(aoddir);
56     t.SetDataSet("");
57     t.SetAllowOverwrite(true);
58     t.SetProofServer(Form("workers=%d",proof));
59     t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, proof > 0);
60     return;
61   }
62   // --- Libraries to load -------------------------------------------
63   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
64
65   // --- Check for proof mode, and possibly upload pars --------------
66   if (proof> 0) { 
67     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
68     LoadPars(proof);
69   }
70   
71   // --- Our data chain ----------------------------------------------
72   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
73   TChain* chain = MakeChain("AOD", aoddir,true);
74   // If 0 or less events is select, choose all 
75   if (nEvents <= 0) nEvents = chain->GetEntries();
76
77   // --- Set the macro path ------------------------------------------
78   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
79                            "$ALICE_ROOT/ANALYSIS/macros",
80                            gROOT->GetMacroPath()));
81
82   // --- Creating the manager and handlers ---------------------------
83   AliAnalysisManager *mgr  = new AliAnalysisManager(name, "Forward dN/deta");
84   AliAnalysisManager::SetCommonFileName("forward_dndeta.root");
85
86   // --- ESD input handler -------------------------------------------
87   AliAODInputHandler *aodInputHandler = new AliAODInputHandler();
88   mgr->SetInputEventHandler(aodInputHandler);      
89        
90   // --- Add tasks ---------------------------------------------------
91   // Forward 
92   gROOT->LoadMacro("AddTaskForwarddNdeta.C");
93   AddTaskForwarddNdeta(trig, vzMin, vzMax, useCent, scheme, true, mcfile);
94   // Central
95   gROOT->LoadMacro("AddTaskCentraldNdeta.C");
96   AddTaskCentraldNdeta(trig, vzMin, vzMax, useCent, scheme,false, mcfile);
97   // MC
98   gROOT->LoadMacro("AddTaskMCTruthdNdeta.C");
99   AddTaskMCTruthdNdeta(trig, vzMin, vzMax, useCent, scheme);
100
101   
102   // --- Run the analysis --------------------------------------------
103   TStopwatch t;
104   if (!mgr->InitAnalysis()) {
105     Error("MakedNdeta", "Failed to initialize analysis train!");
106     return;
107   }
108   // Skip terminate if we're so requested and not in Proof or full mode
109   mgr->SetSkipTerminate(false);
110   // Some informative output 
111   mgr->PrintStatus();
112   // mgr->SetDebugLevel(3);
113   if (mgr->GetDebugLevel() < 1 && !proof) 
114     mgr->SetUseProgressBar(kTRUE,100);
115   
116   // Run the train 
117   t.Start();
118   Printf("=== RUNNING ANALYSIS ==================================");
119   mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
120   t.Stop();
121   t.Print();
122 }
123 //
124 // EOF
125 //