/** * @file MakeMCCorrTrain.C * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> * @date Fri Jun 1 13:54:47 2012 * * @brief * * @ingroup pwglf_forward_trains_specific */ #include "TrainSetup.C" //==================================================================== /** * Analysis train to make Forward and Central MC corrections * * * @ingroup pwglf_forward_mc * @ingroup pwglf_forward_trains_specific */ class MakeMCCorrTrain : public TrainSetup { public: /** * Constructor. Date and time must be specified when running this * in Termiante mode on Grid * * @param name Name of train (free form) */ MakeMCCorrTrain(const char* name) : TrainSetup(name) { fOptions.Set("type", "ESD"); fOptions.Add("eff", "Effective SPD correction", false); fOptions.Add("max-strips", "NUMBER", "Maximum consequtive strips", 2); } protected: /** * Create the tasks * * @param mgr Analysis manager */ void CreateTasks(AliAnalysisManager* mgr) { // --- Output file name ------------------------------------------ AliAnalysisManager::SetCommonFileName("forward_mccorr.root"); // --- Load libraries/pars --------------------------------------- fRailway->LoadLibrary("PWGLFforward2"); // --- Set load path --------------------------------------------- gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", gROOT->GetMacroPath())); // --- Options --------------------------------------------------- Bool_t spdEffective = fOptions.Has("eff"); UShort_t maxStrips = fOptions.AsInt("max-strips"); // --- Check if this is MC --------------------------------------- if (!mgr->GetMCtruthEventHandler()) return; // --- Task to copy header information --------------------------- // gROOT->Macro("AddTaskCopyHeader.C"); // --- Add the task ---------------------------------------------- CoupleCar("AddTaskForwardMCCorr.C",Form("%d", maxStrips)); // --- Add the task ---------------------------------------------- CoupleCar("AddTaskCentralMCCorr.C", Form("%d", spdEffective)); } //__________________________________________________________________ /** * Create physics selection , and add to manager * * @param mc Whether this is for MC * @param mgr Manager */ void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager* mgr) { TrainSetup::CreatePhysicsSelection(mc, mgr); // --- Get input event handler ----------------------------------- AliInputEventHandler* ih = dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler()); if (!ih) Fatal("CreatePhysicsSelection", "Couldn't get input handler (%p)", ih); // --- Get Physics selection ------------------------------------- AliPhysicsSelection* ps = dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection()); if (!ps) Fatal("CreatePhysicsSelection", "Couldn't get PhysicsSelection (%p)", ps); // --- Ignore trigger class when selecting events. This means --- // --- that we get offline+(A,C,E) events too -------------------- // ps->SetSkipTriggerClassSelection(true); } //__________________________________________________________________ /** * @return 0 - AOD disabled */ virtual AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; } /** * Do not the centrality selection */ // void CreateCentralitySelection(Bool_t) {} //__________________________________________________________________ const char* ClassName() const { return "MakeMCCorrTrain"; } //__________________________________________________________________ /** * Overloaded to create new Extract.C in the output * directory * * @param asShellScript */ void SaveSetup(Bool_t asShellScript) { TrainSetup::SaveSetup(asShellScript); SaveExtract(); SaveSummarize(); SaveDraw(); } void SaveExtract() { std::ofstream f("Extract.C"); if (!f) { Error("SaveSetup", "Failed to open Extract.C"); return; } f << "// Generated by " << ClassName() << "\n" << "void Extract()\n" << "{\n" << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" << " gROOT->LoadMacro(Form(\"%s/corrs/ExtractMCCorr.C\",fwd));\n" << " ExtractMCCorr(\"forward_mccorr.root\");\n" << "}\n" << "// EOF" << std::endl; f.close(); } /** * Write a ROOT script to draw summary * */ void SaveSummarize() { std::ofstream f("Summarize.C"); if (!f) { Error("SaveSummarize", "Failed to open Summarize.C script"); return; } f << "// Generated by " << ClassName() << "\n" << "// WHAT is a bit mask of\n" << "// 0x001 Event inspector\n" << "// 0x002 Track density\n" << "// 0x004 Vertex bins\n" << "// 0x008 Results\n" << "// 0x080 Central\n" << "// 0x100 Landscape\n" << "// 0x200 Pause\n" << "//\n" << "void Summarize(const char* filename=\"forward_mccorr.root\",\n" << " UShort_t what=0x11F)\n" << "{\n" << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" << " gROOT->LoadMacro(Form(\"%s/DrawMCCorrSummary.C\",fwd));\n" << " DrawMCCorrSummary(filename,what);\n" << "}\n" << "// EOF" << std::endl; f.close(); } /** * Write a ROOT script to draw overview * */ void SaveDraw() { std::ofstream f("Draw.C"); if (!f) { Error("SaveDraw", "Failed to open Draw.C script"); return; } f << "// Generated by " << ClassName() << "\n" << "// WHAT is a bit mask of\n" << "// 0x001 Event inspector\n" << "// 0x002 Track density\n" << "// 0x004 Vertex bins\n" << "// 0x008 Results\n" << "// 0x080 Central\n" << "// 0x100 Landscape\n" << "// 0x200 Pause\n" << "//\n" << "void Draw(bool details=false)\n" << "{\n" << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" << " gROOT->LoadMacro(Form(\"%s/corrs/DrawCorrSecMap.C\",fwd));\n" << " DrawCorrSecMap(999,0,0,999,\"fmd_corrections.root\",details);\n" << "}\n" << "// EOF" << std::endl; f.close(); } void PostShellCode(std::ostream& f) { f << " echo \"=== Extracting Corrections ...\"\n" << " aliroot -l -b -q ${prefix}Extract.C\n" << " echo \"=== Summarizing results ...\"\n" << " aliroot -l -b -q ${prefix}Summarize.C\n" << " echo \"=== Draw results ...\"\n" << " aliroot -l -b -q ${prefix}Draw.C\n" << " if test x$dest = x ; then return ; fi\n" << " echo \"=== Uploading to ${dest} ...\"\n" << " aliroot -l -b -q Upload.C\\(\\\"${dest}\\\"\\);" << std::endl; } }; // // EOF //