]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/trains/MakeAODTrain.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / trains / MakeAODTrain.C
1 /**
2  * @file   MakeAODTrain.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Tue Jul 12 10:05:30 2011
5  * 
6  * @brief  Run first pass analysis - make AOD tree
7  * 
8  * @ingroup pwglf_forward_trains
9  */
10 //====================================================================
11 #include "TrainSetup.C"
12
13 /**
14  * Analysis train to make Forward and Central multiplicity
15  * 
16  * To run, do 
17  * @code 
18  * gROOT->LoadMacro("TrainSetup.C");
19  * // Make train 
20  * MakeAODTrain t("My Analysis");
21  * // Set variaous parameters on the train 
22  * t.SetDataDir("/home/of/data");
23  * t.AddRun(118506)
24  * // Run it 
25  * t.Run("LOCAL", "FULL", -1, false, false);
26  * @endcode 
27  *
28  * @ingroup pwglf_forward_aod
29  * @ingroup pwglf_forward_trains
30  */
31 class MakeAODTrain : public TrainSetup
32 {
33 public:
34   /** 
35    * Constructor.  Date and time must be specified when running this
36    * in Termiante mode on Grid
37    * 
38    * @param name     Name of train (free form)
39    * @param sys      Collision system (1: pp, 2: PbPb)
40    * @param sNN      Center of mass energy [GeV]
41    * @param field    L3 magnetic field - one of {-5,0,+5} kG
42    * @param useCent  Whether to use centrality 
43    * @param dateTime Append date and time to name 
44    * @param year     Year     - if not specified, current year
45    * @param month    Month    - if not specified, current month
46    * @param day      Day      - if not specified, current day
47    * @param hour     Hour     - if not specified, current hour
48    * @param min      Minutes  - if not specified, current minutes
49    */
50   MakeAODTrain(const  char* name, 
51                UShort_t     sys      = 0, 
52                UShort_t     sNN      = 0, 
53                Short_t      field    = 0, 
54                Bool_t       useCent  = false, 
55                Bool_t       dateTime = false, 
56                UShort_t     year     = 0, 
57                UShort_t     month    = 0, 
58                UShort_t     day      = 0, 
59                UShort_t     hour     = 0, 
60                UShort_t     min      = 0) 
61     : TrainSetup(name, dateTime, 
62                  year, month, day, hour, min),
63       fSys(sys), 
64       fSNN(sNN), 
65       fField(field),
66       fUseCent(useCent)
67   {}
68   /** 
69    * Run this analysis 
70    * 
71    * @param mode     Mode - see TrainSetup::EMode
72    * @param oper     Operation - see TrainSetup::EOperation
73    * @param nEvents  Number of events (negative means all)
74    * @param mc       If true, assume simulated events 
75    * @param usePar   If true, use PARs 
76    */
77   void Run(const char* mode, const char* oper, 
78            Int_t nEvents=-1, Bool_t mc=false,
79            Bool_t usePar=false)
80   {
81     Info("Run", "Running in mode=%s, oper=%s, events=%d, MC=%d, Par=%d", 
82          mode, oper, nEvents, mc, usePar);
83     Exec("ESD", mode, oper, nEvents, mc, usePar);
84   }
85   /** 
86    * Run this analysis 
87    * 
88    * @param mode     Mode - see TrainSetup::EMode
89    * @param oper     Operation - see TrainSetup::EOperation
90    * @param nEvents  Number of events (negative means all)
91    * @param mc       If true, assume simulated events 
92    * @param usePar   If true, use PARs 
93    */
94   void Run(EMode mode, EOper oper, Int_t nEvents=-1, Bool_t mc=false, 
95            Bool_t usePar = false)
96   {
97     Info("Run", "Running in mode=%d, oper=%d, events=%d, MC=%d, Par=%d", 
98          mode, oper, nEvents, mc, usePar);
99     Exec(kESD, mode, oper, nEvents, mc, usePar);
100   }
101 protected:
102   /** 
103    * Create the tasks 
104    * 
105    * @param mode Processing mode
106    * @param par  Whether to use par files 
107    * @param mgr  Analysis manager 
108    */
109   void CreateTasks(EMode mode, Bool_t par, AliAnalysisManager* mgr)
110   {
111     // --- Output file name ------------------------------------------
112     AliAnalysisManager::SetCommonFileName("forward.root");
113
114     // --- Load libraries/pars ---------------------------------------
115     LoadLibrary("PWGLFforward2", mode, par, true);
116     
117     // --- Set load path ---------------------------------------------
118     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
119                              gROOT->GetMacroPath()));
120
121     // --- Check if this is MC ---------------------------------------
122     Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
123     
124     // --- Task to copy header information ---------------------------
125     gROOT->Macro("AddTaskCopyHeader.C");
126
127     // --- Add the task ----------------------------------------------
128     gROOT->Macro(Form("AddTaskForwardMult.C(%d,%d,%d,%d)", 
129                       mc, fSys, fSNN, fField));
130     AddExtraFile(gSystem->Which(gROOT->GetMacroPath(), "ForwardAODConfig.C"));
131
132     // --- Add the task ----------------------------------------------
133     gROOT->Macro(Form("AddTaskCentralMult.C(%d,%d,%d,%d)", 
134                       mc, fSys, fSNN, fField));
135     AddExtraFile(gSystem->Which(gROOT->GetMacroPath(), "CentralAODConfig.C"));
136   }
137   //__________________________________________________________________
138   /** 
139    * Create physics selection , and add to manager
140    * 
141    * @param mc Whether this is for MC 
142    * @param mgr Manager 
143    */
144   void CreatePhysicsSelection(Bool_t mc,
145                               AliAnalysisManager* mgr)
146   {
147     TrainSetup::CreatePhysicsSelection(mc, mgr);
148
149     // --- Get input event handler -----------------------------------
150     AliInputEventHandler* ih =
151       dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
152     if (!ih) 
153       Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
154     
155     // --- Get Physics selection -------------------------------------
156     AliPhysicsSelection* ps = 
157       dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
158     if (!ps) 
159       Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)",ps);
160
161     // --- Ignore trigger class when selecting events.  This means ---
162     // --- that we get offline+(A,C,E) events too --------------------
163     // ps->SetSkipTriggerClassSelection(true);
164   }
165   //__________________________________________________________________
166   /** 
167    * Create the centrality selection only if requested
168    * 
169    * @param mc  Monte-Carlo truth flag 
170    * @param mgr Manager
171    */
172   void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr)
173   {
174     if (!fUseCent) return;
175     TrainSetup::CreateCentralitySelection(mc, mgr);
176   }
177   UShort_t fSys;
178   UShort_t fSNN;
179   Short_t  fField;
180   Bool_t   fUseCent;
181 };
182 //
183 // EOF
184 //