/** * @file MakedNdetaTrain.C * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> * @date Fri Jun 1 13:51:26 2012 * * @brief * * @ingroup pwglf_forward_trains_specific * */ #include "TrainSetup.C" //==================================================================== /** * Analysis train to make @f$ dN/d\eta@f$ * * * @ingroup pwglf_forward_dndeta * @ingroup pwglf_forward_trains_specific */ class MakedNdetaTrain : public TrainSetup { public: /** * Constructor. * * @param name Name of train (free form) */ MakedNdetaTrain(const char* name) : TrainSetup(name) { fOptions.Add("trig", "TYPE", "Trigger type", "INEL"); fOptions.Add("vzMin", "CENTIMETER", "Min Ip Z", "-10"); fOptions.Add("vzMax", "CENTIMETER", "Max Ip Z", "+10"); fOptions.Add("scheme", "SCHEME", "Normalization scheme", "EVENT,TRIGGER"); fOptions.Add("trigEff", "EFFICENCY", "Trigger effeciency", "1"); fOptions.Add("trigEff0", "EFFICENCY", "0-bin trigger effeciency", "1"); fOptions.Add("cent", "ESTIMATOR", "Use centrality", "none"); fOptions.Add("mc", "Also make dN/deta for MC truth"); fOptions.Add("satellite","Restrict analysis to satellite events", false); fOptions.Add("forward-config", "FILE", "Forward configuration", "dNdetaConfig.C"); fOptions.Add("central-config", "FILE", "Central configuration", "dNdetaConfig.C"); fOptions.Add("truth-config", "FILE", "MC-Truth configuration", "dNdetaConfig.C"); } protected: /** * Create the tasks * */ void CreateTasks(AliAnalysisManager*) { // --- Output file name ------------------------------------------ AliAnalysisManager::SetCommonFileName("forward_dndeta.root"); // --- Load libraries/pars --------------------------------------- fRailway->LoadLibrary("PWGLFforward2"); // --- Set load path --------------------------------------------- gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", gROOT->GetMacroPath())); // --- Get parameters -------------------------------------------- TString trig = fOptions.Get("trig"); TString scheme = fOptions.Get("scheme"); Double_t vzMin = fOptions.AsDouble("vzmin", -10); Double_t vzMax = fOptions.AsDouble("vzmax", +10); Double_t effT = fOptions.AsDouble("trigEff", 1); Double_t effT0 = fOptions.AsDouble("trigEff0", 1); TString cent = fOptions.Get("cent"); Bool_t mc = fOptions.Has("mc"); Bool_t satonly = fOptions.AsBool("satellite"); TString fwdCfg = fOptions.Get("forward-config"); TString cenCfg = fOptions.Get("central-config"); TString mcCfg = fOptions.Get("truth-config"); if (!mc) mc = fRailway->IsMC(); if (!fOptions.Has("cent")) cent="none"; // Info("", "Centrality option is '%s'", cent.Data()); fOptions.Show(std::cout); // --- Form arguments -------------------------------------------- TString fargs; fargs.Form("\"%s\",\"%s\",%f,%f,\"%s\",\"%s\",%g,%g,%d", fwdCfg.Data(), trig.Data(), vzMin, vzMax, cent.Data(), scheme.Data(), effT, effT0, satonly); TString cargs(fargs); cargs.ReplaceAll(fwdCfg, cenCfg); // Info("", "fargs=\"%s\", cargs=\"%s\"", fargs.Data(), cargs.Data()); // --- Add the task ---------------------------------------------- CoupleCar("AddTaskForwarddNdeta.C", fargs); CoupleCar("AddTaskCentraldNdeta.C", cargs); if (mc) { TString margs(fargs); margs.ReplaceAll(fwdCfg, mcCfg); CoupleCar("AddTaskMCTruthdNdeta.C", margs); } } //__________________________________________________________________ /** * Do not the centrality selection */ //__________________________________________________________________ void CreateCentralitySelection(Bool_t) {} /** * Do not create MC input handler * * @return Always null */ AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; } //__________________________________________________________________ /** * Crete output handler - we don't want one here. * * @return 0 */ AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; } //__________________________________________________________________ const char* ClassName() const { return "MakedNdetaTrain"; } //__________________________________________________________________ /** * Overloaded to create new draw.C * * @param asShellScript */ void SaveSetup(Bool_t asShellScript) { TrainSetup::SaveSetup(asShellScript); SaveDraw(); SaveSummarize(); } 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 Forward\n" << "// 0x002 Central\n" << "// 0x004 Sums\n" << "// 0x008 Results\n" << "// 0x010 Only min-bias (no centrality)\n" << "// 0x080 Assume simulation results\n" << "// 0x100 Landscape\n" << "// 0x200 Pause\n" << "// 0x400 Also draw single result canvas\n" << "//\n" << "void Summarize(const char* filename=\"forward_dndeta.root\",\n" << " UShort_t what=0x10F)\n" << "{\n" << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" << " gROOT->LoadMacro(Form(\"%s/DrawdNdetaSummary.C\",fwd));\n" << " DrawdNdetaSummary(filename,what & 0x3FF);\n" << "\n" << " if (!(what & 0x400)) return;\n" << " gROOT->SetMacroPath(Form(\"../:%s\",gROOT->GetMacroPath()));\n" << " gROOT->Macro(\"Draw.C\");\n" << "}\n" << "// EOF" << std::endl; f.close(); } /** * Make a ROOT script to draw results * */ void SaveDraw() { std::ofstream o("Draw.C"); if (!o) { Error("MakedNdetaTrain::SaveSetup", "Failed to open Draw.C"); return; } o << "// Created by " << ClassName() << "\n" << "Bool_t SetupDrawer(const TString& title, Bool_t old)\n" << "{\n" << " const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n" << " gROOT->LoadMacro(Form(\"%s/DrawdNdeta.C+\",fwd));\n" << " if (title.EqualTo(\"help\",TString::kIgnoreCase)) {\n" << " if (old)\n" << " DrawdNdeta(\"help\",\"\",5); // Get the help\n" << " else\n" << " DrawdNdeta(\"help\",\"\",\"\"); // Get the help\n" << " return false;\n" << " }\n" << " return true;\n" << "}\n" << std::endl; o << "// Will draw dN/deta results from produced file\n" << "// \n" << "// Options can be specified as needed. To get help, pass the\n" << "// string \"help\" for the title:\n" << "// \n" << "// root -l Draw.C\\(\\\"help\\\"\\)\n" << "// \n"; o << "void Draw(const TString& title=\"" << fName << "\",\n" << " UShort_t rebin=5,\n" << " UShort_t others=0xf,\n" << " UInt_t flags=0x1CE07,\n" << " UShort_t sNN=0,\n" << " UShort_t sys=0,\n" << " UShort_t trg=0,\n" << " Float_t eff=0,\n" << " UShort_t centMin=0,\n" << " UShort_t centMax=100,\n" << " Float_t vzMin=999,\n" << " Float_t vzMax=-999)\n" << "{\n" << " if (!SetupDrawer(title, true)) return;\n" << " DrawdNdeta(\"forward_dndeta.root\",\n" << " title,\n" << " rebin,\n" << " others,\n" << " flags,\n" << " sNN,\n" << " sys,\n" << " trg,\n" << " eff,\n" << " centMin,\n" << " centMax,\n" << " vzMin,\n" << " vzMax,\n" << " \"dNdeta_<trig>\");\n" << "}\n" << std::endl; o << "// Alternative using strings\n" << "void Draw(const TString& title,\n" << " const TString& others=\"ALL\",\n" << " const TString& options=\"DEFAULT\",\n" << " const TString& formats=\"ALL\",\n" << " UShort_t rebin=5,\n" << " Float_t eff=0,\n" << " UShort_t centMin=0,\n" << " UShort_t centMax=0,\n" << " Float_t vzMin=+999,\n" << " Float_t vzMax=-999,\n" << " const TString& base="")\n" << "{\n" << " if (!SetupDrawer(title, false)) return;\n" << " DrawdNdeta(\"forward_dndeta.root\",\n" << " title,others,options,formats,\n" << " rebin,eff,centMin,centMax,\n" << " vzMin,vzMax,\"dNdeta_<trig>\");\n" << "}\n" << "//\n" << "// EOF\n" << "//" << std::endl; o.close(); } void PostShellCode(std::ostream& f) { f << " echo \"=== Summarizing results ...\"\n" << " aliroot -l -b -q ${prefix}Summarize.C\n" << " echo \"=== Draw results ...\"\n" << " aliroot -l -b -q ${prefix}Draw.C\n" << std::endl; } }; // // EOF //