]>
Commit | Line | Data |
---|---|---|
39fd42ed | 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_specific | |
9 | */ | |
10 | #include "TrainSetup.C" | |
11 | #include <sstream> | |
12 | ||
13 | //==================================================================== | |
14 | /** | |
15 | * Analysis train to make Forward and Central multiplicity | |
16 | * | |
17 | * | |
18 | * @ingroup pwglf_forward_aod | |
19 | * @ingroup pwglf_forward_trains_specific | |
20 | */ | |
21 | class MakeAODTrain : public TrainSetup | |
22 | { | |
23 | public: | |
24 | /** | |
25 | * Constructor. | |
26 | * | |
27 | * @param name Name of train (free form) | |
28 | */ | |
29 | MakeAODTrain(const TString& name) | |
30 | : TrainSetup(name) | |
31 | { | |
8449e3e0 | 32 | fOptions.Add("run", "NUMBER", "Run number for corrs", 0); |
39fd42ed | 33 | fOptions.Add("sys", "SYSTEM", "1:pp, 2:PbPb, 3:pPb", ""); |
34 | fOptions.Add("snn", "ENERGY", "Center of mass energy in GeV", ""); | |
35 | fOptions.Add("field", "STRENGTH","L3 field strength in kG", ""); | |
36 | fOptions.Add("forward-config", "FILE", "Forward configuration", | |
37 | "ForwardAODConfig.C"); | |
38 | fOptions.Add("central-config", "FILE", "Forward configuration", | |
39 | "CentralAODConfig.C"); | |
40 | fOptions.Add("cent", "Use centrality"); | |
41 | fOptions.Add("tpc-ep", "Use TPC event plane"); | |
42 | fOptions.Add("satelitte", "Use satelitte interactions"); | |
43 | fOptions.Add("corr", "DIR", "Corrections dir", ""); | |
44 | fOptions.Set("type", "ESD"); | |
45 | } | |
46 | protected: | |
47 | /** | |
48 | * Create the tasks | |
49 | * | |
39fd42ed | 50 | * @param mgr Analysis manager |
51 | */ | |
52 | void CreateTasks(AliAnalysisManager* mgr) | |
53 | { | |
54 | // --- Output file name ------------------------------------------ | |
55 | AliAnalysisManager::SetCommonFileName("forward.root"); | |
56 | ||
57 | // --- Load libraries/pars --------------------------------------- | |
58 | fHelper->LoadLibrary("PWGLFforward2"); | |
59 | ||
60 | // --- Set load path --------------------------------------------- | |
61 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", | |
62 | gROOT->GetMacroPath())); | |
63 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros", | |
64 | gROOT->GetMacroPath())); | |
65 | ||
66 | // --- Check if this is MC --------------------------------------- | |
67 | Bool_t mc = mgr->GetMCtruthEventHandler() != 0; | |
68 | ||
69 | // --- Add TPC eventplane task | |
70 | if (fOptions.Has("tpc-ep")) gROOT->Macro("AddTaskEventplane.C"); | |
71 | ||
72 | // --- Task to copy header information --------------------------- | |
73 | gROOT->Macro("AddTaskCopyHeader.C"); | |
74 | ||
75 | // --- Get options ----------------------------------------------- | |
8449e3e0 | 76 | ULong_t run = fOptions.AsInt("run", 0); |
39fd42ed | 77 | UShort_t sys = fOptions.AsInt("sys", 0); |
78 | UShort_t sNN = fOptions.AsInt("snn", 0); | |
79 | UShort_t fld = fOptions.AsInt("field", 0); | |
80 | TString cor = ""; | |
81 | if (fOptions.Has("corr")) cor = fOptions.Get("corr"); | |
82 | ||
83 | // --- Add the task ---------------------------------------------- | |
84 | TString fwdConfig = fOptions.Get("forward-config"); | |
8449e3e0 | 85 | gROOT->Macro(Form("AddTaskForwardMult.C(%d,%ld,%d,%d,%d,\"%s\",\"%s\")", |
86 | mc, run, sys, sNN, fld, fwdConfig.Data(), cor.Data())); | |
39fd42ed | 87 | fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig), true); |
88 | ||
89 | // --- Add the task ---------------------------------------------- | |
90 | TString cenConfig = fOptions.Get("central-config"); | |
8449e3e0 | 91 | gROOT->Macro(Form("AddTaskCentralMult.C(%d,%ld,%d,%d,%d,\"%s\",\"%s\")", |
92 | mc, run, sys, sNN, fld, cenConfig.Data(), cor.Data())); | |
39fd42ed | 93 | fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), cenConfig), true); |
94 | ||
95 | // --- Add MC particle task -------------------------------------- | |
96 | if (mc) gROOT->Macro("AddTaskMCParticleFilter.C"); | |
97 | ||
8449e3e0 | 98 | if (!cor.IsNull()) { |
99 | fHelper->LoadAux(Form("%s/fmd_corrections.root",cor.Data()), true); | |
100 | fHelper->LoadAux(Form("%s/spd_corrections.root",cor.Data()), true); | |
101 | } | |
39fd42ed | 102 | } |
103 | //__________________________________________________________________ | |
104 | /** | |
105 | * Create physics selection , and add to manager | |
106 | * | |
107 | * @param mc Whether this is for MC | |
108 | * @param mgr Manager | |
109 | */ | |
110 | void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager* mgr) | |
111 | { | |
112 | TrainSetup::CreatePhysicsSelection(mc, mgr); | |
113 | ||
114 | // --- Get input event handler ----------------------------------- | |
115 | AliInputEventHandler* ih = | |
116 | dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler()); | |
117 | if (!ih) | |
118 | Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih); | |
119 | ||
120 | // --- Get Physics selection ------------------------------------- | |
121 | AliPhysicsSelection* ps = | |
122 | dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection()); | |
123 | if (!ps) | |
124 | Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)",ps); | |
125 | ||
126 | // --- Special for pPb pilot run Sep. 2012 ----------------------- | |
127 | UShort_t sys = fOptions.AsInt("sys", 0); | |
128 | if (sys == 3) { | |
129 | Warning("CreatePhysicsSelection", | |
130 | "Special setup for pPb pilot run September, 2012"); | |
131 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros", | |
132 | gROOT->GetMacroPath())); | |
133 | gROOT->LoadMacro("PhysicsSelectionOADB_CINT5_pA.C"); | |
134 | gROOT->ProcessLine(Form("((AliPhysicsSelection*)%p)" | |
135 | "->SetCustomOADBObjects(" | |
136 | "OADBSelection_CINT5_V0A(),0);", ps)); | |
137 | ps->SetSkipTriggerClassSelection(true); | |
138 | } | |
139 | // --- Ignore trigger class when selecting events. This means --- | |
140 | // --- that we get offline+(A,C,E) events too -------------------- | |
141 | // ps->SetSkipTriggerClassSelection(true); | |
142 | } | |
143 | //__________________________________________________________________ | |
144 | /** | |
145 | * Create the centrality selection only if requested | |
146 | * | |
147 | * @param mc Monte-Carlo truth flag | |
148 | * @param mgr Manager | |
149 | */ | |
150 | void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr) | |
151 | { | |
152 | if (!fOptions.Has("cent")) return; | |
153 | TrainSetup::CreateCentralitySelection(mc, mgr); | |
154 | } | |
155 | //__________________________________________________________________ | |
156 | const char* ClassName() const { return "MakeAODTrain"; } | |
157 | //__________________________________________________________________ | |
158 | /** | |
159 | * Overloaded to create new dNdeta.C and dndeta.sh in the output | |
160 | * directory | |
161 | * | |
162 | * @param asShellScript | |
163 | */ | |
164 | void SaveSetup(Bool_t asShellScript) | |
165 | { | |
166 | TrainSetup::SaveSetup(asShellScript); | |
167 | ||
168 | if (!fHelper) { | |
169 | Warning("MakeAODTrain::SaveSetup", | |
170 | "Cannot make dNdeta.C script with helper"); | |
171 | return; | |
172 | } | |
173 | ||
174 | OptionList uopts(fHelper->Options()); | |
175 | ||
176 | TString cls("MakedNdetaTrain"); | |
177 | TString name(fName); name.Append("_dndeta"); | |
178 | OptionList opts(fOptions); | |
179 | opts.Remove("forward-config"); | |
180 | opts.Remove("central-config"); | |
181 | opts.Remove("sys"); | |
182 | opts.Remove("snn"); | |
183 | opts.Remove("field"); | |
184 | opts.Remove("bare-ps"); | |
185 | opts.Remove("tpc-ep"); | |
186 | opts.Remove("corr"); | |
187 | opts.Add("trig", "TRIGGER", "Trigger type"); | |
188 | opts.Add("vzMin", "CENTIMETER", "Lower bound on Ip Z", -10.); | |
189 | opts.Add("vzMax", "CENTIMETER", "Upper bound on Ip Z", +10.); | |
190 | opts.Add("scheme", "FLAGS", "Normalization scheme", | |
191 | "TRIGGER EVENT BACKGROUND"); | |
192 | opts.Add("cut-edges", "Cut edges of acceptance"); | |
193 | opts.Add("trigEff", "EFFICIENCY", "Trigger efficiency", 1.); | |
194 | opts.Add("trigEff0", "EFFICIENCY", "0-bin trigger efficiency", 1.); | |
195 | ||
196 | ||
197 | // Rewrite our URL | |
198 | TString outString = fHelper->OutputLocation(); | |
199 | if (outString.IsNull()) outString = fEscapedName; | |
200 | TUrl outUrl(outString); | |
201 | ||
202 | if (uopts.Find("pattern")) uopts.Set("pattern", "*/AliAOD.root"); | |
203 | if (uopts.Find("concat")) uopts.Set("concat", true); | |
204 | ||
205 | std::stringstream s; | |
206 | uopts.Store(s, "", "&", false, true); | |
207 | outUrl.SetOptions(s.str().c_str()); | |
208 | ||
209 | opts.Set("url", outUrl.GetUrl()); | |
210 | opts.Set("type", "AOD"); | |
211 | ||
212 | SaveSetupROOT("dNdeta", cls, name, opts, &uopts); | |
213 | if (asShellScript) | |
214 | SaveSetupShell("dndeta", cls, name, opts, &uopts); | |
215 | ||
216 | if (!fHelper || fHelper->Mode() != Helper::kGrid) return; | |
217 | ||
218 | SaveDownloadAODs(); | |
219 | } | |
220 | void SaveDownloadAODs() | |
221 | { | |
222 | std::ofstream f("DownloadAODs.C"); | |
223 | if (!f) { | |
224 | Error("SaveDownloadAODs", "Failed to open DownloadAODs.C"); | |
225 | return; | |
226 | } | |
227 | f << "// Generated by " << ClassName() << "\n" | |
228 | << "void DownloadAODs()\n" | |
229 | << "{\n" | |
230 | << " if (!TGrid::Connect(\"alien://\")) {\n" | |
231 | << " Error(\"DownloadAODs\",\"Failed to connect to AliEn\");\n" | |
232 | << " return;\n" | |
233 | << " }\n\n" | |
234 | << " TString dir(\"" << fHelper->OutputPath() << "\");\n" | |
235 | << " TString pat(\"*/AliAOD.root\");\n" | |
236 | << " TGridResult* r = gGrid->Query(dir,pat);\n" | |
237 | << " if (!r) {\n" | |
238 | << " Error(\"DownloadAODs\",\"No result from query\");\n" | |
239 | << " return;\n" | |
240 | << " }\n\n" | |
241 | << " Int_t n = r->GetEntries();\n" | |
242 | << " for (Int_t i = 0; i < n; i++) {\n" | |
243 | << " TString path(r->GetKey(i, \"turl\"));\n" | |
244 | << " TString sub(gSystem->BaseName(gSystem->DirName(path)));\n" | |
245 | << " TString out = TString::Format(\"AliAOD_%s.root\",sub.Data());\n" | |
246 | << " if (!TFile::Cp(path, out)) {\n" | |
247 | << " Warning(\"DownloadAODs\",\"Failed to copy %s -> %s\",\n" | |
248 | << " path.Data(), out.Data());\n" | |
249 | << " continue;\n" | |
250 | << " }\n" | |
251 | << " }\n" | |
252 | << "}\n" | |
253 | << "// EOF\n" | |
254 | << std::endl; | |
255 | f.close(); | |
256 | } | |
257 | }; | |
258 | // | |
259 | // EOF | |
260 | // |