2 * @file MakeFMDELossTrain.C
3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Fri Jun 1 13:53:02 2012
9 * @ingroup pwglf_forward_trains_specific
11 #include "TrainSetup.C"
13 //====================================================================
15 * Analysis train to do energy loss fits
17 * @ingroup pwglf_forward_trains_specific
18 * @ingroup pwglf_forward_eloss
20 class MakeFMDELossTrain : public TrainSetup
26 * @param name Name of train
28 MakeFMDELossTrain(const char* name = "FMD Energy Loss")
31 fOptions.Add("only-mb", "Only collect statistics from MB events");
32 fOptions.Add("config", "FILE", "Configuration", "elossFitConfig.C");
33 fOptions.Add("corr", "DIR", "Corrections dir", "");
34 fOptions.Set("type", "ESD");
37 //------------------------------------------------------------------
39 * Create the analysis manager
41 * @param name Name of the analysis
43 * @return Created analysis manager
45 virtual AliAnalysisManager* CreateAnalysisManager(const char* name)
47 AliAnalysisManager* mgr = TrainSetup::CreateAnalysisManager(name);
48 // mgr->SetAutoBranchLoading(false);
51 //__________________________________________________________________
55 * @param mgr Analysis manager
57 void CreateTasks(AliAnalysisManager* mgr)
59 // --- Output file name ------------------------------------------
60 AliAnalysisManager::SetCommonFileName("forward_eloss.root");
62 // --- Load libraries/pars ---------------------------------------
63 fRailway->LoadLibrary("PWGLFforward2");
65 // --- Set load path ---------------------------------------------
66 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
67 gROOT->GetMacroPath()));
69 // --- Check if this is MC ---------------------------------------
70 Bool_t mc = HasMCHandler();
71 Bool_t onlyMB = fOptions.AsBool("only-mb");
72 TString config = fOptions.Get("config");
74 if (fOptions.Has("corr")) corrs = fOptions.Get("corr");
76 // --- Add the task ----------------------------------------------
77 CoupleCar("AddTaskFMDELoss.C", Form("%d,%d,\"%s\",\"%s\"",
81 fRailway->LoadAux(gSystem->Which(gROOT->GetMacroPath(), config), true);
83 fRailway->LoadAux(Form("%s/fmd_corrections.root",corrs.Data()), true);
87 * Create entrality selection if enabled
89 * @param mc Whether this is MC or not
90 * @param mgr Analysis manager
92 virtual void CreateCentralitySelection(Bool_t mc)
94 if (!fOptions.Has("cent")) return;
95 TrainSetup::CreateCentralitySelection(mc);
98 * Crete output handler - we don't want one here.
102 AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
104 //__________________________________________________________________
105 const char* ClassName() const { return "MakeFMDELossTrain"; }
106 //__________________________________________________________________
108 * Overloaded to create new Extract.C in the output
111 * @param asShellScript
113 void SaveSetup(Bool_t asShellScript)
115 TrainSetup::SaveSetup(asShellScript);
122 std::ofstream f("Extract.C");
124 Error("SaveSetup", "Failed to open Extract.C");
127 f << "// Generated by " << ClassName() << "\n"
128 << "void Extract(Bool_t mc=" << HasMCHandler() << ",\n"
129 << " const char* file=\"forward_eloss.root\")\n"
131 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
132 << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractELoss.C\",fwd));\n"
133 << " ExtractELoss(file,mc);\n"
135 << "// EOF" << std::endl;
140 std::ofstream f("Summarize.C");
142 Error("SaveSummarize", "Failed to open Summarize.C script");
146 << "// Generated by " << ClassName() << "\n"
148 << "void Summarize(Bool_t mc=" << HasMCHandler() << ",\n"
149 << " const char* filename=\"forward_eloss.root\")\n"
151 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
152 << " gROOT->LoadMacro(Form(\"%s/corrs/DrawCorrELoss.C\",fwd));\n"
153 << " DrawCorrELoss(mc,filename);\n"
155 << "// EOF" << std::endl;
160 std::ofstream f("ReFit.C");
162 Error("SaveRerun", "Failed to open ReFit.C script");
166 << "// Generated by " << ClassName() << "\n"
167 << "// If force=true, then force set parameters\n"
168 << "// If shift=true, enable extra shift in Delta from sigma/xi\n"
170 << "void ReFit(Bool_t force=false,\n"
171 << " Bool_t shift=true,\n"
172 << " const char* filename=\"forward_eloss.root\")\n"
174 << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
175 << " gROOT->LoadMacro(Form(\"%s/corrs/RerunELossFits.C\",fwd));\n"
176 << " RerunELossFits(force,filename);\n"
178 << "// EOF" << std::endl;
181 void PostShellCode(std::ostream& f)
183 f << " mc=" << std::boolalpha << HasMCHandler() << "\n"
184 << " echo \"=== Extracting Corrections ...\"\n"
185 << " aliroot -l -b -q ${prefix}Extract.C\\($mc\\)\n"
186 << " echo \"=== Summarizing results ...\"\n"
187 << " aliroot -l -b -q ${prefix}Summarize.C\\($mc\\)\n"
188 << " if test x$dest = x ; then return ; fi\n"
189 << " echo \"=== Uploading to ${dest} ...\"\n"
190 << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);\n"