]>
Commit | Line | Data |
---|---|---|
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 | */ | |
20 | class MakeMCCorrTrain : 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 | */ | |
29 | MakeMCCorrTrain(const char* name) | |
30 | : TrainSetup(name) | |
31 | { | |
32 | fOptions.Set("type", "ESD"); | |
bfab35d9 | 33 | fOptions.Add("eff", "Effective SPD correction", false); |
39fd42ed | 34 | } |
35 | protected: | |
36 | /** | |
37 | * Create the tasks | |
38 | * | |
39fd42ed | 39 | * @param mgr Analysis manager |
40 | */ | |
41 | void CreateTasks(AliAnalysisManager* mgr) | |
42 | { | |
43 | // --- Output file name ------------------------------------------ | |
44 | AliAnalysisManager::SetCommonFileName("forward_mccorr.root"); | |
45 | ||
46 | // --- Load libraries/pars --------------------------------------- | |
47 | fHelper->LoadLibrary("PWGLFforward2"); | |
48 | ||
49 | // --- Set load path --------------------------------------------- | |
50 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", | |
51 | gROOT->GetMacroPath())); | |
52 | ||
53 | // --- Check if this is MC --------------------------------------- | |
54 | if (!mgr->GetMCtruthEventHandler()) return; | |
55 | ||
56 | // --- Task to copy header information --------------------------- | |
57 | // gROOT->Macro("AddTaskCopyHeader.C"); | |
58 | ||
59 | // --- Add the task ---------------------------------------------- | |
60 | gROOT->Macro("AddTaskForwardMCCorr.C"); | |
61 | ||
62 | // --- Add the task ---------------------------------------------- | |
bfab35d9 | 63 | gROOT->Macro(Form("AddTaskCentralMCCorr.C(%d)", fOptions.Has("eff"))); |
39fd42ed | 64 | } |
65 | //__________________________________________________________________ | |
66 | /** | |
67 | * Create physics selection , and add to manager | |
68 | * | |
69 | * @param mc Whether this is for MC | |
70 | * @param mgr Manager | |
71 | */ | |
72 | void CreatePhysicsSelection(Bool_t mc, | |
73 | AliAnalysisManager* mgr) | |
74 | { | |
75 | TrainSetup::CreatePhysicsSelection(mc, mgr); | |
76 | ||
77 | // --- Get input event handler ----------------------------------- | |
78 | AliInputEventHandler* ih = | |
79 | dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler()); | |
80 | if (!ih) | |
81 | Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih); | |
82 | ||
83 | // --- Get Physics selection ------------------------------------- | |
84 | AliPhysicsSelection* ps = | |
85 | dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection()); | |
86 | if (!ps) | |
87 | Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps); | |
88 | ||
89 | // --- Ignore trigger class when selecting events. This means --- | |
90 | // --- that we get offline+(A,C,E) events too -------------------- | |
91 | // ps->SetSkipTriggerClassSelection(true); | |
92 | } | |
93 | //__________________________________________________________________ | |
94 | /** | |
95 | * @return 0 - AOD disabled | |
96 | */ | |
97 | virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; } | |
98 | /** | |
99 | * Do not the centrality selection | |
100 | */ | |
101 | // void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {} | |
102 | //__________________________________________________________________ | |
103 | const char* ClassName() const { return "MakeMCCorrTrain"; } | |
104 | //__________________________________________________________________ | |
105 | /** | |
106 | * Overloaded to create new Extract.C in the output | |
107 | * directory | |
108 | * | |
109 | * @param asShellScript | |
110 | */ | |
111 | void SaveSetup(Bool_t asShellScript) | |
112 | { | |
113 | TrainSetup::SaveSetup(asShellScript); | |
114 | ||
bfab35d9 | 115 | SaveExtract(); |
116 | SaveSummarize(); | |
117 | } | |
118 | void SaveExtract() | |
119 | { | |
39fd42ed | 120 | std::ofstream f("Extract.C"); |
121 | if (!f) { | |
122 | Error("SaveSetup", "Failed to open Extract.C"); | |
123 | return; | |
124 | } | |
125 | f << "// Generated by " << ClassName() << "\n" | |
126 | << "void Extract()\n" | |
127 | << "{\n" | |
bfab35d9 | 128 | << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" |
129 | << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractMCCorr.C\",fwd));\n" | |
8449e3e0 | 130 | << " ExtractMCCorr(\"forward_mccorr.root\");\n" |
39fd42ed | 131 | << "}\n" |
132 | << "// EOF" << std::endl; | |
133 | f.close(); | |
134 | } | |
bfab35d9 | 135 | /** |
136 | * Write a ROOT script to draw summary | |
137 | * | |
138 | */ | |
139 | void SaveSummarize() | |
140 | { | |
141 | std::ofstream f("Summarize.C"); | |
142 | if (!f) { | |
143 | Error("SaveSummarize", "Failed to open Summarize.C script"); | |
144 | return; | |
145 | } | |
146 | f << "// Generated by " << ClassName() << "\n" | |
147 | << "// WHAT is a bit mask of\n" | |
148 | << "// 0x001 Event inspector\n" | |
149 | << "// 0x002 Track density\n" | |
150 | << "// 0x004 Vertex bins\n" | |
151 | << "// 0x008 Results\n" | |
d4a5ea4a | 152 | << "// 0x080 Central\n" |
bfab35d9 | 153 | << "// 0x100 Landscape\n" |
d4a5ea4a | 154 | << "// 0x200 Pause\n" |
bfab35d9 | 155 | << "//\n" |
156 | << "void Summarize(const char* filename=\"forward_mccorr.root\",\n" | |
d4a5ea4a | 157 | << " UShort_t what=0x1F)\n" |
bfab35d9 | 158 | << "{\n" |
159 | << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" | |
160 | << " gROOT->LoadMacro(Form(\"%s/DrawMCCorrSummary.C\",fwd));\n" | |
161 | << " DrawMCCorrSummary(filename,what);\n" | |
162 | << "}\n" | |
163 | << "// EOF" << std::endl; | |
164 | f.close(); | |
165 | } | |
91b3e533 | 166 | void PostShellCode(std::ostream& f) |
167 | { | |
168 | f << " echo \"=== Extracting Corrections ...\"\n" | |
169 | << " aliroot -l -b -q ${prefix}Extract.C\n" | |
170 | << " echo \"=== Summarizing results ...\"\n" | |
171 | << " aliroot -l -b -q ${prefix}Summarize.C\n" | |
172 | << " if test x$dest = x ; then return ; fi\n" | |
173 | << " echo \"=== Uploading to ${dest} ...\"\n" | |
174 | << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);" | |
175 | << std::endl; | |
176 | } | |
39fd42ed | 177 | }; |
178 | ||
179 | // | |
180 | // EOF | |
181 | // |