Fix some documentation issues
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / trains / MakeMultDistsTrain.C
1 /**
2  * @file   MakeMultDistsTrain.C
3  * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4  * @date   Fri Jun  1 13:51:26 2012
5  * 
6  * @brief  
7  * 
8  * @ingroup pwglf_forward_trains_specific
9  * 
10  */
11
12 #include "TrainSetup.C"
13
14 //====================================================================
15 /**
16  * Analysis train to make @f$ P(N_{ch})@f$
17  * 
18  *
19  * @ingroup pwglf_forward_multdists
20  * @ingroup pwglf_forward_trains_specific
21  */
22 class MakeMultDistsTrain : public TrainSetup
23 {
24 public:
25   /** 
26    * Constructor.  
27    * 
28    * @param name     Name of train (free form)
29    */
30   MakeMultDistsTrain(const char* name)
31   : TrainSetup(name)
32   {
33     fOptions.Add("trig",       "TYPE", "Trigger type", "V0AND");
34     fOptions.Add("vzMin",      "CENTIMETER", "Min Ip Z", -4);
35     fOptions.Add("vzMax",      "CENTIMETER", "Max Ip Z", +4);
36     fOptions.Add("phi-acc",    "Use stored phi acceptance", true);
37     fOptions.Add("asymmetric", "Make asymmetric (+/-) bins", false);
38   }
39 protected:
40   /** 
41    * Create the tasks 
42    * 
43    */
44   void CreateTasks(AliAnalysisManager*)
45   {
46     // --- Output file name ------------------------------------------
47     AliAnalysisManager::SetCommonFileName("forward_multdists.root");
48
49     // --- Load libraries/pars ---------------------------------------
50     fHelper->LoadLibrary("PWGLFforward2");
51     
52     // --- Set load path ---------------------------------------------
53     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
54                              gROOT->GetMacroPath()));
55
56     // --- Get parameters --------------------------------------------
57     TString  trig   = fOptions.AsString("trig", "V0AND");
58     Double_t vzMin  = fOptions.AsDouble("vzmin", -4);
59     Double_t vzMax  = fOptions.AsDouble("vzmax", +4);
60     Bool_t   phiAcc = fOptions.AsBool("phi-acc");
61     Bool_t   aSymm  = fOptions.AsBool("asymmetric");
62
63     // --- Form arguments --------------------------------------------
64     TString args;
65     args.Form("\"%s\",%f,%f,%d,%d",
66               trig.Data(), vzMin, vzMax, phiAcc, aSymm);
67     // --- Add the task ----------------------------------------------
68     gROOT->Macro(Form("AddTaskForwardMultDists.C(%s);", args.Data()));
69   }
70   //__________________________________________________________________
71   /** 
72    * Do not the centrality selection
73    */
74   //__________________________________________________________________
75   void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {}
76   /** 
77    * Do not create MC input handler 
78    * 
79    * @return Always null
80    */
81   AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; }
82   //__________________________________________________________________
83   /** 
84    * Crete output handler - we don't want one here. 
85    * 
86    * @return 0
87    */
88   AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
89   //__________________________________________________________________
90   const char* ClassName() const { return "MakeMultDistsTrain"; }
91   //__________________________________________________________________
92   /** 
93    * Overloaded to create new draw.C 
94    * 
95    * @param asShellScript 
96    */
97   void SaveSetup(Bool_t asShellScript)
98   {
99     TrainSetup::SaveSetup(asShellScript);
100
101     SaveSummarize();
102     SaveUnfold();
103     SaveDraw();
104   }
105   void SaveUnfold() 
106   {
107     std::ofstream f("Unfold.C");
108     if (!f) { 
109       Error("SaveUnfold", "Failed to open Unfold.C script");
110       return;
111     }
112     f << "// Generated by " << ClassName() << "\n"
113       << "void Unfold(const char* other=\"\",\n"
114       << "            Double_t    regP=20,\n"
115       << "            const char* here=\"forward_multdists.root\")\n"
116       << "{\n"
117       << "  const char* rooUnfold = gSystem->Getenv(\"ROOUNFOLD\");\n"
118       << "  if (rooUnfold) {\n"
119       << "    gSystem->AddIncludePath(Form(\"-I%s/src\",rooUnfold));\n"
120       << "    gSystem->AddDynamicPath(Form(\"%s\", rooUnfold));\n"
121       << "  }\n"
122       << "  gSystem->Load(\"libRooUnfold\");\n"
123       << "  const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
124       << "  gROOT->LoadMacro(Form(\"%s/scripts/UnfoldMultDists.C++g\",fwd));\n"
125       << "  UnfoldMultDists(\"bayes\",regP,here,other);\n"
126       << "}\n"
127       << "// EOF" << std::endl;
128     
129     f.close();
130   }
131   void SaveSummarize()
132   {
133     std::ofstream f("Summarize.C");
134     if (!f) { 
135       Error("SaveSummarize", "Failed to open Summarize.C script");
136       return;
137     }
138     f << "// Generated by " << ClassName() << "\n"
139       << "// WHAT is a bit mask of\n"
140       << "//   0x001     Forward\n"
141       << "//   0x002     Central\n"
142       << "//   0x004     Sums\n"
143       << "//   0x008     Results\n"
144       << "//   0x010     Only min-bias (no centrality)\n"
145       << "//   0x020     Landscape\n"
146       << "//   0x040     Pause\n"
147       << "//\n"
148       << "void Summarize(const char* filename=\"forward_multdists.root\",\n"
149       << "               UShort_t what=0xF)\n"
150       << "{\n"
151       << "  const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
152       << "  gROOT->LoadMacro(Form(\"%s/DrawMultDistsSummary.C\",fwd));\n"
153       << "  DrawMultDistsSummary(filename,what);\n"
154       << "}\n"
155       << "// EOF" << std::endl;
156     f.close();
157   }
158   void SaveDraw()
159   {
160     std::ofstream f("Draw.C");
161     if (!f) { 
162       Error("SaveSummarize", "Failed to open Summarize.C script");
163       return;
164     }
165     f << "// Generated by " << ClassName() << "\n"
166       << "// WHAT is a bit mask of\n"
167       << "//   0x001     Forward\n"
168       << "//   0x002     Central\n"
169       << "//   0x004     Sums\n"
170       << "//   0x008     Results\n"
171       << "//   0x010     Only min-bias (no centrality)\n"
172       << "//   0x020     Landscape\n"
173       << "//   0x040     Pause\n"
174       << "//\n"
175       << "void Draw(const char* filename=\"forward_unfolded.root\",\n"
176       << "               UShort_t what=0xF)\n"
177       << "{\n"
178       << "  const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
179       << "  gROOT->LoadMacro(Form(\"%s/DrawUnfoldedSummary.C\",fwd));\n"
180       << "  DrawUnfoldedSummary(filename);\n"
181       << "}\n"
182       << "// EOF" << std::endl;
183     f.close();
184   }
185   void PostShellCode(std::ostream& f)
186   {
187     f << "  echo \"=== Summarizing results ...\"\n"
188       << "  aliroot -l -b -q ${prefix}Summarize.C\n"
189       << "  echo \"=== Unfolding ...\"\n"
190       << "  export ROOUNFOLD=${HOME}/tmp/RooUnfoldMyEdits\n"
191       << "  mc=\n"
192       << "  if test x$dest != x ; then mc=${dest}/forward_multdists.root; fi\n"
193       << "  aliroot -l -b -q ${prefix}Unfold.C\\(\\\"${mc}\\\"\\)\n"
194       << "  aliroot -l -b -q ${prefix}Draw.C\n"
195       << std::endl;
196   }
197 };
198 //
199 // EOF
200 //