2 * @file MakeMCCorrTrain.C
3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Fri Jun 1 13:54:47 2012
8 * @ingroup pwglf_forward_trains_specific
10 #include "TrainSetup.C"
12 //====================================================================
14 * Analysis train to make Forward and Central MC corrections
17 * @ingroup pwglf_forward_mc
18 * @ingroup pwglf_forward_trains_specific
20 class MakeMCCorrTrain : public TrainSetup
24 * Constructor. Date and time must be specified when running this
25 * in Termiante mode on Grid
27 * @param name Name of train (free form)
29 MakeMCCorrTrain(const char* name)
32 fOptions.Set("type", "ESD");
33 fOptions.Add("eff", "Effective SPD correction", false);
34 fOptions.Add("max-strips", "NUMBER",
35 "Maximum consequtive strips", 2);
41 * @param mgr Analysis manager
43 void CreateTasks(AliAnalysisManager* mgr)
45 // --- Output file name ------------------------------------------
46 AliAnalysisManager::SetCommonFileName("forward_mccorr.root");
48 // --- Load libraries/pars ---------------------------------------
49 fRailway->LoadLibrary("PWGLFforward2");
51 // --- Set load path ---------------------------------------------
52 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
53 gROOT->GetMacroPath()));
55 // --- Options ---------------------------------------------------
56 Bool_t spdEffective = fOptions.Has("eff");
57 UShort_t maxStrips = fOptions.AsInt("max-strips");
59 // --- Check if this is MC ---------------------------------------
60 if (!mgr->GetMCtruthEventHandler()) return;
62 // --- Task to copy header information ---------------------------
63 // gROOT->Macro("AddTaskCopyHeader.C");
65 // --- Add the task ----------------------------------------------
66 CoupleCar("AddTaskForwardMCCorr.C",Form("%d", maxStrips));
68 // --- Add the task ----------------------------------------------
69 CoupleCar("AddTaskCentralMCCorr.C", Form("%d", spdEffective));
71 //__________________________________________________________________
73 * Create physics selection , and add to manager
75 * @param mc Whether this is for MC
78 void CreatePhysicsSelection(Bool_t mc,
79 AliAnalysisManager* mgr)
81 TrainSetup::CreatePhysicsSelection(mc, mgr);
83 // --- Get input event handler -----------------------------------
84 AliInputEventHandler* ih =
85 dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
87 Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih);
89 // --- Get Physics selection -------------------------------------
90 AliPhysicsSelection* ps =
91 dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
93 Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps);
95 // --- Ignore trigger class when selecting events. This means ---
96 // --- that we get offline+(A,C,E) events too --------------------
97 // ps->SetSkipTriggerClassSelection(true);
99 //__________________________________________________________________
101 * @return 0 - AOD disabled
103 virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
105 * Do not the centrality selection
107 // void CreateCentralitySelection(Bool_t) {}
108 //__________________________________________________________________
109 const char* ClassName() const { return "MakeMCCorrTrain"; }
110 //__________________________________________________________________
112 * Overloaded to create new Extract.C in the output
115 * @param asShellScript
117 void SaveSetup(Bool_t asShellScript)
119 TrainSetup::SaveSetup(asShellScript);
127 std::ofstream f("Extract.C");
129 Error("SaveSetup", "Failed to open Extract.C");
132 f << "// Generated by " << ClassName() << "\n"
133 << "void Extract()\n"
135 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
136 << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractMCCorr.C\",fwd));\n"
137 << " ExtractMCCorr(\"forward_mccorr.root\");\n"
139 << "// EOF" << std::endl;
143 * Write a ROOT script to draw summary
148 std::ofstream f("Summarize.C");
150 Error("SaveSummarize", "Failed to open Summarize.C script");
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"
159 << "// 0x080 Central\n"
160 << "// 0x100 Landscape\n"
161 << "// 0x200 Pause\n"
163 << "void Summarize(const char* filename=\"forward_mccorr.root\",\n"
164 << " UShort_t what=0x11F)\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"
170 << "// EOF" << std::endl;
174 * Write a ROOT script to draw overview
179 std::ofstream f("Draw.C");
181 Error("SaveDraw", "Failed to open Draw.C script");
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"
194 << "void Draw(bool details=false)\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"
200 << "// EOF" << std::endl;
203 void PostShellCode(std::ostream& f)
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"
209 << " echo \"=== Draw results ...\"\n"
210 << " aliroot -l -b -q ${prefix}Draw.C\n"
211 << " if test x$dest = x ; then return ; fi\n"
212 << " echo \"=== Uploading to ${dest} ...\"\n"
213 << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);"