]>
Commit | Line | Data |
---|---|---|
39fd42ed | 1 | /** |
2 | * @file MakedNdetaTrain.C | |
3 | * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> | |
4 | * @date Fri Jun 1 13:51:26 2012 | |
5 | * | |
6 | * @brief | |
7 | * | |
8 | * @ingroup pwglf_forward_trains_specific | |
9 | * | |
10 | */ | |
11 | ||
12 | #include "TrainSetup.C" | |
13 | ||
14 | //==================================================================== | |
15 | /** | |
16 | * Analysis train to make @f$ dN/d\eta@f$ | |
17 | * | |
18 | * | |
19 | * @ingroup pwglf_forward_dndeta | |
20 | * @ingroup pwglf_forward_trains_specific | |
21 | */ | |
22 | class MakedNdetaTrain : public TrainSetup | |
23 | { | |
24 | public: | |
25 | /** | |
26 | * Constructor. | |
27 | * | |
28 | * @param name Name of train (free form) | |
29 | */ | |
30 | MakedNdetaTrain(const char* name) | |
31 | : TrainSetup(name) | |
32 | { | |
33 | fOptions.Add("trig", "TYPE", "Trigger type", "INEL"); | |
34 | fOptions.Add("vzMin", "CENTIMETER", "Min Ip Z", "-10"); | |
35 | fOptions.Add("vzMax", "CENTIMETER", "Max Ip Z", "+10"); | |
5f2f85f0 | 36 | fOptions.Add("scheme", "SCHEME", "Normalization scheme", "EVENT,TRIGGER"); |
39fd42ed | 37 | fOptions.Add("trigEff", "EFFICENCY", "Trigger effeciency", "1"); |
38 | fOptions.Add("trigEff0", "EFFICENCY", "0-bin trigger effeciency", "1"); | |
dc1adf8d | 39 | fOptions.Add("cent", "ESTIMATOR", "Use centrality", "none"); |
bfab35d9 | 40 | fOptions.Add("mc", "Also make dN/deta for MC truth"); |
bfab35d9 | 41 | fOptions.Add("satellite","Restrict analysis to satellite events", false); |
dc1adf8d | 42 | fOptions.Add("forward-config", "FILE", "Forward configuration", |
43 | "dNdetaConfig.C"); | |
44 | fOptions.Add("central-config", "FILE", "Central configuration", | |
45 | "dNdetaConfig.C"); | |
46 | fOptions.Add("truth-config", "FILE", "MC-Truth configuration", | |
47 | "dNdetaConfig.C"); | |
39fd42ed | 48 | } |
49 | protected: | |
50 | /** | |
51 | * Create the tasks | |
52 | * | |
39fd42ed | 53 | */ |
54 | void CreateTasks(AliAnalysisManager*) | |
55 | { | |
56 | // --- Output file name ------------------------------------------ | |
57 | AliAnalysisManager::SetCommonFileName("forward_dndeta.root"); | |
58 | ||
59 | // --- Load libraries/pars --------------------------------------- | |
78ac7e09 | 60 | fRailway->LoadLibrary("PWGLFforward2"); |
39fd42ed | 61 | |
62 | // --- Set load path --------------------------------------------- | |
63 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", | |
64 | gROOT->GetMacroPath())); | |
65 | ||
66 | // --- Get parameters -------------------------------------------- | |
bfab35d9 | 67 | TString trig = fOptions.Get("trig"); |
68 | TString scheme = fOptions.Get("scheme"); | |
69 | Double_t vzMin = fOptions.AsDouble("vzmin", -10); | |
70 | Double_t vzMax = fOptions.AsDouble("vzmax", +10); | |
71 | Double_t effT = fOptions.AsDouble("trigEff", 1); | |
72 | Double_t effT0 = fOptions.AsDouble("trigEff0", 1); | |
dc1adf8d | 73 | TString cent = fOptions.Get("cent"); |
bfab35d9 | 74 | Bool_t mc = fOptions.Has("mc"); |
bfab35d9 | 75 | Bool_t satonly = fOptions.AsBool("satellite"); |
dc1adf8d | 76 | TString fwdCfg = fOptions.Get("forward-config"); |
77 | TString cenCfg = fOptions.Get("central-config"); | |
78 | TString mcCfg = fOptions.Get("truth-config"); | |
78ac7e09 | 79 | if (!mc) mc = fRailway->IsMC(); |
dc1adf8d | 80 | if (!fOptions.Has("cent")) cent="none"; |
81 | ||
5f2f85f0 | 82 | // Info("", "Centrality option is '%s'", cent.Data()); |
dc1adf8d | 83 | fOptions.Show(std::cout); |
39fd42ed | 84 | |
85 | // --- Form arguments -------------------------------------------- | |
dc1adf8d | 86 | TString fargs; |
87 | fargs.Form("\"%s\",\"%s\",%f,%f,\"%s\",\"%s\",%g,%g,%d", | |
88 | fwdCfg.Data(), trig.Data(), vzMin, vzMax, cent.Data(), | |
89 | scheme.Data(), effT, effT0, satonly); | |
90 | TString cargs(fargs); | |
91 | cargs.ReplaceAll(fwdCfg, cenCfg); | |
92 | // Info("", "fargs=\"%s\", cargs=\"%s\"", fargs.Data(), cargs.Data()); | |
bfab35d9 | 93 | |
39fd42ed | 94 | // --- Add the task ---------------------------------------------- |
78ac7e09 | 95 | CoupleCar("AddTaskForwarddNdeta.C", fargs); |
96 | CoupleCar("AddTaskCentraldNdeta.C", cargs); | |
dc1adf8d | 97 | if (mc) { |
98 | TString margs(fargs); | |
99 | margs.ReplaceAll(fwdCfg, mcCfg); | |
78ac7e09 | 100 | CoupleCar("AddTaskMCTruthdNdeta.C", margs); |
dc1adf8d | 101 | } |
39fd42ed | 102 | } |
103 | //__________________________________________________________________ | |
104 | /** | |
105 | * Do not the centrality selection | |
106 | */ | |
73b32206 | 107 | //__________________________________________________________________ |
78ac7e09 | 108 | void CreateCentralitySelection(Bool_t) {} |
73b32206 | 109 | /** |
110 | * Do not create MC input handler | |
111 | * | |
112 | * @return Always null | |
113 | */ | |
114 | AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; } | |
39fd42ed | 115 | //__________________________________________________________________ |
116 | /** | |
117 | * Crete output handler - we don't want one here. | |
118 | * | |
119 | * @return 0 | |
120 | */ | |
121 | AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; } | |
122 | //__________________________________________________________________ | |
123 | const char* ClassName() const { return "MakedNdetaTrain"; } | |
124 | //__________________________________________________________________ | |
125 | /** | |
126 | * Overloaded to create new draw.C | |
127 | * | |
128 | * @param asShellScript | |
129 | */ | |
130 | void SaveSetup(Bool_t asShellScript) | |
131 | { | |
132 | TrainSetup::SaveSetup(asShellScript); | |
133 | ||
bfab35d9 | 134 | SaveDraw(); |
135 | SaveSummarize(); | |
136 | } | |
137 | void SaveSummarize() | |
138 | { | |
139 | std::ofstream f("Summarize.C"); | |
140 | if (!f) { | |
141 | Error("SaveSummarize", "Failed to open Summarize.C script"); | |
142 | return; | |
143 | } | |
144 | f << "// Generated by " << ClassName() << "\n" | |
145 | << "// WHAT is a bit mask of\n" | |
146 | << "// 0x001 Forward\n" | |
147 | << "// 0x002 Central\n" | |
148 | << "// 0x004 Sums\n" | |
149 | << "// 0x008 Results\n" | |
150 | << "// 0x010 Only min-bias (no centrality)\n" | |
7095962e CHC |
151 | << "// 0x080 Assume simulation results\n" |
152 | << "// 0x100 Landscape\n" | |
153 | << "// 0x200 Pause\n" | |
154 | << "// 0x400 Also draw single result canvas\n" | |
bfab35d9 | 155 | << "//\n" |
156 | << "void Summarize(const char* filename=\"forward_dndeta.root\",\n" | |
7095962e | 157 | << " UShort_t what=0x10F)\n" |
bfab35d9 | 158 | << "{\n" |
91b3e533 | 159 | << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" |
160 | << " gROOT->LoadMacro(Form(\"%s/DrawdNdetaSummary.C\",fwd));\n" | |
7095962e | 161 | << " DrawdNdetaSummary(filename,what & 0x3FF);\n" |
91b3e533 | 162 | << "\n" |
7095962e | 163 | << " if (!(what & 0x400)) return;\n" |
91b3e533 | 164 | << " gROOT->SetMacroPath(Form(\"../:%s\",gROOT->GetMacroPath()));\n" |
165 | << " gROOT->Macro(\"Draw.C\");\n" | |
bfab35d9 | 166 | << "}\n" |
167 | << "// EOF" << std::endl; | |
168 | f.close(); | |
169 | } | |
170 | /** | |
171 | * Make a ROOT script to draw results | |
172 | * | |
173 | */ | |
174 | void SaveDraw() | |
175 | { | |
73b32206 | 176 | std::ofstream o("Draw.C"); |
39fd42ed | 177 | if (!o) { |
73b32206 | 178 | Error("MakedNdetaTrain::SaveSetup", "Failed to open Draw.C"); |
39fd42ed | 179 | return; |
180 | } | |
181 | ||
182 | o << "// Created by " << ClassName() << "\n" | |
dc1adf8d | 183 | << "Bool_t SetupDrawer(const TString& title, Bool_t old)\n" |
184 | << "{\n" | |
185 | << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" | |
186 | << " gROOT->LoadMacro(Form(\"%s/DrawdNdeta.C+\",fwd));\n" | |
187 | << " if (title.EqualTo(\"help\",TString::kIgnoreCase)) {\n" | |
188 | << " if (old)\n" | |
189 | << " DrawdNdeta(\"help\",\"\",5); // Get the help\n" | |
190 | << " else\n" | |
191 | << " DrawdNdeta(\"help\",\"\",\"\"); // Get the help\n" | |
192 | << " return false;\n" | |
193 | << " }\n" | |
194 | << " return true;\n" | |
195 | << "}\n" | |
196 | << std::endl; | |
197 | o << "// Will draw dN/deta results from produced file\n" | |
39fd42ed | 198 | << "// \n" |
199 | << "// Options can be specified as needed. To get help, pass the\n" | |
7095962e | 200 | << "// string \"help\" for the title:\n" |
39fd42ed | 201 | << "// \n" |
7095962e | 202 | << "// root -l Draw.C\\(\\\"help\\\"\\)\n" |
bfab35d9 | 203 | << "// \n"; |
7095962e | 204 | o << "void Draw(const TString& title=\"" << fName << "\",\n" |
39fd42ed | 205 | << " UShort_t rebin=5,\n" |
bfab35d9 | 206 | << " UShort_t others=0xf,\n" |
a84618ac | 207 | << " UInt_t flags=0x1CE07,\n" |
39fd42ed | 208 | << " UShort_t sNN=0,\n" |
209 | << " UShort_t sys=0,\n" | |
210 | << " UShort_t trg=0,\n" | |
bfab35d9 | 211 | << " Float_t eff=0,\n" |
f71c22f5 CHC |
212 | << " UShort_t centMin=0,\n" |
213 | << " UShort_t centMax=100,\n" | |
bfab35d9 | 214 | << " Float_t vzMin=999,\n" |
39fd42ed | 215 | << " Float_t vzMax=-999)\n" |
216 | << "{\n" | |
dc1adf8d | 217 | << " if (!SetupDrawer(title, true)) return;\n" |
39fd42ed | 218 | << " DrawdNdeta(\"forward_dndeta.root\",\n" |
219 | << " title,\n" | |
220 | << " rebin,\n" | |
221 | << " others,\n" | |
222 | << " flags,\n" | |
223 | << " sNN,\n" | |
224 | << " sys,\n" | |
225 | << " trg,\n" | |
bfab35d9 | 226 | << " eff,\n" |
f71c22f5 CHC |
227 | << " centMin,\n" |
228 | << " centMax,\n" | |
39fd42ed | 229 | << " vzMin,\n" |
d43c6cd0 | 230 | << " vzMax,\n" |
dc1adf8d | 231 | << " \"dNdeta_<trig>\");\n" |
39fd42ed | 232 | << "}\n" |
dc1adf8d | 233 | << std::endl; |
234 | o << "// Alternative using strings\n" | |
235 | << "void Draw(const TString& title,\n" | |
236 | << " const TString& others=\"ALL\",\n" | |
237 | << " const TString& options=\"DEFAULT\",\n" | |
238 | << " const TString& formats=\"ALL\",\n" | |
239 | << " UShort_t rebin=5,\n" | |
240 | << " Float_t eff=0,\n" | |
241 | << " UShort_t centMin=0,\n" | |
242 | << " UShort_t centMax=0,\n" | |
243 | << " Float_t vzMin=+999,\n" | |
244 | << " Float_t vzMax=-999,\n" | |
245 | << " const TString& base="")\n" | |
246 | << "{\n" | |
247 | << " if (!SetupDrawer(title, false)) return;\n" | |
248 | << " DrawdNdeta(\"forward_dndeta.root\",\n" | |
249 | << " title,others,options,formats,\n" | |
250 | << " rebin,eff,centMin,centMax,\n" | |
251 | << " vzMin,vzMax,\"dNdeta_<trig>\");\n" | |
252 | << "}\n" | |
39fd42ed | 253 | << "//\n" |
254 | << "// EOF\n" | |
255 | << "//" << std::endl; | |
256 | o.close(); | |
257 | } | |
91b3e533 | 258 | void PostShellCode(std::ostream& f) |
259 | { | |
260 | f << " echo \"=== Summarizing results ...\"\n" | |
261 | << " aliroot -l -b -q ${prefix}Summarize.C\n" | |
262 | << " echo \"=== Draw results ...\"\n" | |
263 | << " aliroot -l -b -q ${prefix}Draw.C\n" | |
264 | << std::endl; | |
265 | } | |
39fd42ed | 266 | }; |
267 | // | |
268 | // EOF | |
269 | // |