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