]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/trains/MakeMCCorrTrain.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / trains / MakeMCCorrTrain.C
CommitLineData
39fd42ed 1/**
2 * @file MakeMCCorrTrain.C
3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Fri Jun 1 13:54:47 2012
5 *
6 * @brief
7 *
8 * @ingroup pwglf_forward_trains_specific
9 */
10#include "TrainSetup.C"
11
12//====================================================================
13/**
14 * Analysis train to make Forward and Central MC corrections
15 *
16 *
17 * @ingroup pwglf_forward_mc
18 * @ingroup pwglf_forward_trains_specific
19 */
20class MakeMCCorrTrain : public TrainSetup
21{
22public:
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 */
29 MakeMCCorrTrain(const char* name)
a5195188 30 : TrainSetup(name)
39fd42ed 31 {
32 fOptions.Set("type", "ESD");
bfab35d9 33 fOptions.Add("eff", "Effective SPD correction", false);
a5195188 34 fOptions.Add("max-strips", "NUMBER",
35 "Maximum consequtive strips", 2);
39fd42ed 36 }
37protected:
38 /**
39 * Create the tasks
40 *
39fd42ed 41 * @param mgr Analysis manager
42 */
43 void CreateTasks(AliAnalysisManager* mgr)
44 {
45 // --- Output file name ------------------------------------------
46 AliAnalysisManager::SetCommonFileName("forward_mccorr.root");
47
48 // --- Load libraries/pars ---------------------------------------
78ac7e09 49 fRailway->LoadLibrary("PWGLFforward2");
39fd42ed 50
51 // --- Set load path ---------------------------------------------
52 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
53 gROOT->GetMacroPath()));
a5195188 54
55 // --- Options ---------------------------------------------------
56 Bool_t spdEffective = fOptions.Has("eff");
57 UShort_t maxStrips = fOptions.AsInt("max-strips");
39fd42ed 58
59 // --- Check if this is MC ---------------------------------------
60 if (!mgr->GetMCtruthEventHandler()) return;
61
62 // --- Task to copy header information ---------------------------
63 // gROOT->Macro("AddTaskCopyHeader.C");
64
65 // --- Add the task ----------------------------------------------
78ac7e09 66 CoupleCar("AddTaskForwardMCCorr.C",Form("%d", maxStrips));
39fd42ed 67
68 // --- Add the task ----------------------------------------------
78ac7e09 69 CoupleCar("AddTaskCentralMCCorr.C", Form("%d", spdEffective));
39fd42ed 70 }
71 //__________________________________________________________________
72 /**
73 * Create physics selection , and add to manager
74 *
75 * @param mc Whether this is for MC
76 * @param mgr Manager
77 */
78 void CreatePhysicsSelection(Bool_t mc,
79 AliAnalysisManager* mgr)
80 {
81 TrainSetup::CreatePhysicsSelection(mc, mgr);
82
83 // --- Get input event handler -----------------------------------
84 AliInputEventHandler* ih =
85 dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
86 if (!ih)
87 Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
88
89 // --- Get Physics selection -------------------------------------
90 AliPhysicsSelection* ps =
91 dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
92 if (!ps)
93 Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps);
94
95 // --- Ignore trigger class when selecting events. This means ---
96 // --- that we get offline+(A,C,E) events too --------------------
97 // ps->SetSkipTriggerClassSelection(true);
98 }
99 //__________________________________________________________________
100 /**
101 * @return 0 - AOD disabled
102 */
103 virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
104 /**
105 * Do not the centrality selection
106 */
78ac7e09 107 // void CreateCentralitySelection(Bool_t) {}
39fd42ed 108 //__________________________________________________________________
109 const char* ClassName() const { return "MakeMCCorrTrain"; }
110 //__________________________________________________________________
111 /**
112 * Overloaded to create new Extract.C in the output
113 * directory
114 *
115 * @param asShellScript
116 */
117 void SaveSetup(Bool_t asShellScript)
118 {
119 TrainSetup::SaveSetup(asShellScript);
120
bfab35d9 121 SaveExtract();
122 SaveSummarize();
a84618ac 123 SaveDraw();
bfab35d9 124 }
125 void SaveExtract()
126 {
39fd42ed 127 std::ofstream f("Extract.C");
128 if (!f) {
129 Error("SaveSetup", "Failed to open Extract.C");
130 return;
131 }
132 f << "// Generated by " << ClassName() << "\n"
133 << "void Extract()\n"
134 << "{\n"
bfab35d9 135 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
136 << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractMCCorr.C\",fwd));\n"
8449e3e0 137 << " ExtractMCCorr(\"forward_mccorr.root\");\n"
39fd42ed 138 << "}\n"
139 << "// EOF" << std::endl;
140 f.close();
141 }
bfab35d9 142 /**
143 * Write a ROOT script to draw summary
144 *
145 */
146 void SaveSummarize()
147 {
148 std::ofstream f("Summarize.C");
149 if (!f) {
150 Error("SaveSummarize", "Failed to open Summarize.C script");
151 return;
152 }
153 f << "// Generated by " << ClassName() << "\n"
154 << "// WHAT is a bit mask of\n"
155 << "// 0x001 Event inspector\n"
156 << "// 0x002 Track density\n"
157 << "// 0x004 Vertex bins\n"
158 << "// 0x008 Results\n"
d4a5ea4a 159 << "// 0x080 Central\n"
bfab35d9 160 << "// 0x100 Landscape\n"
d4a5ea4a 161 << "// 0x200 Pause\n"
bfab35d9 162 << "//\n"
163 << "void Summarize(const char* filename=\"forward_mccorr.root\",\n"
a84618ac 164 << " UShort_t what=0x11F)\n"
bfab35d9 165 << "{\n"
166 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
167 << " gROOT->LoadMacro(Form(\"%s/DrawMCCorrSummary.C\",fwd));\n"
168 << " DrawMCCorrSummary(filename,what);\n"
169 << "}\n"
170 << "// EOF" << std::endl;
171 f.close();
172 }
a84618ac 173 /**
174 * Write a ROOT script to draw overview
175 *
176 */
177 void SaveDraw()
178 {
179 std::ofstream f("Draw.C");
180 if (!f) {
181 Error("SaveDraw", "Failed to open Draw.C script");
182 return;
183 }
184 f << "// Generated by " << ClassName() << "\n"
185 << "// WHAT is a bit mask of\n"
186 << "// 0x001 Event inspector\n"
187 << "// 0x002 Track density\n"
188 << "// 0x004 Vertex bins\n"
189 << "// 0x008 Results\n"
190 << "// 0x080 Central\n"
191 << "// 0x100 Landscape\n"
192 << "// 0x200 Pause\n"
193 << "//\n"
194 << "void Draw(bool details=false)\n"
195 << "{\n"
196 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
197 << " gROOT->LoadMacro(Form(\"%s/corrs/DrawCorrSecMap.C\",fwd));\n"
198 << " DrawCorrSecMap(999,0,0,999,\"fmd_corrections.root\",details);\n"
199 << "}\n"
200 << "// EOF" << std::endl;
201 f.close();
202 }
91b3e533 203 void PostShellCode(std::ostream& f)
204 {
205 f << " echo \"=== Extracting Corrections ...\"\n"
206 << " aliroot -l -b -q ${prefix}Extract.C\n"
207 << " echo \"=== Summarizing results ...\"\n"
208 << " aliroot -l -b -q ${prefix}Summarize.C\n"
a84618ac 209 << " echo \"=== Draw results ...\"\n"
210 << " aliroot -l -b -q ${prefix}Draw.C\n"
91b3e533 211 << " if test x$dest = x ; then return ; fi\n"
212 << " echo \"=== Uploading to ${dest} ...\"\n"
213 << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);"
214 << std::endl;
215 }
39fd42ed 216};
217
218//
219// EOF
220//