]>
Commit | Line | Data |
---|---|---|
39fd42ed | 1 | /** |
2 | * @file MakeFMDELossTrain.C | |
3 | * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> | |
4 | * @date Fri Jun 1 13:53:02 2012 | |
5 | * | |
6 | * @brief | |
7 | * | |
8 | * | |
9 | * @ingroup pwglf_forward_trains_specific | |
10 | */ | |
11 | #include "TrainSetup.C" | |
12 | ||
13 | //==================================================================== | |
14 | /** | |
15 | * Analysis train to do energy loss fits | |
16 | * | |
17 | * @ingroup pwglf_forward_trains_specific | |
18 | * @ingroup pwglf_forward_eloss | |
19 | */ | |
20 | class MakeFMDELossTrain : public TrainSetup | |
21 | { | |
22 | public: | |
23 | /** | |
24 | * Constructor. | |
25 | * | |
26 | * @param name Name of train | |
27 | */ | |
28 | MakeFMDELossTrain(const char* name = "FMD Energy Loss") | |
29 | : TrainSetup(name) | |
30 | { | |
31 | fOptions.Add("cent", "Use centrality"); | |
32 | } | |
33 | protected: | |
34 | //------------------------------------------------------------------ | |
35 | /** | |
36 | * Create the analysis manager | |
37 | * | |
38 | * @param name Name of the analysis | |
39 | * | |
40 | * @return Created analysis manager | |
41 | */ | |
42 | virtual AliAnalysisManager* CreateAnalysisManager(const char* name) | |
43 | { | |
44 | AliAnalysisManager* mgr = TrainSetup::CreateAnalysisManager(name); | |
45 | // mgr->SetAutoBranchLoading(false); | |
46 | return mgr; | |
47 | } | |
48 | //__________________________________________________________________ | |
49 | /** | |
50 | * Create the tasks | |
51 | * | |
39fd42ed | 52 | * @param mgr Analysis manager |
53 | */ | |
54 | void CreateTasks(AliAnalysisManager* mgr) | |
55 | { | |
56 | // --- Output file name ------------------------------------------ | |
57 | AliAnalysisManager::SetCommonFileName("forward_eloss.root"); | |
58 | ||
59 | // --- Load libraries/pars --------------------------------------- | |
60 | fHelper->LoadLibrary("PWGLFforward2"); | |
61 | ||
62 | // --- Set load path --------------------------------------------- | |
63 | gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", | |
64 | gROOT->GetMacroPath())); | |
65 | ||
66 | // --- Check if this is MC --------------------------------------- | |
67 | Bool_t mc = mgr->GetMCtruthEventHandler() != 0; | |
68 | Bool_t cent = fOptions.Has("cent"); | |
8449e3e0 | 69 | Int_t verb = fOptions.AsInt("verbose"); |
39fd42ed | 70 | |
71 | // --- Add the task ---------------------------------------------- | |
8449e3e0 | 72 | gROOT->Macro(Form("AddTaskFMDELoss.C(%d,%d,%d)", mc, cent, verb)); |
39fd42ed | 73 | } |
74 | /** | |
75 | * Create entrality selection if enabled | |
76 | * | |
77 | * @param mc Whether this is MC or not | |
78 | * @param mgr Analysis manager | |
79 | */ | |
80 | virtual void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr) | |
81 | { | |
82 | if (!fOptions.Has("cent")) return; | |
83 | ||
84 | const char* name = "CentralitySelection"; | |
85 | gROOT->Macro("AddTaskCentrality.C"); | |
86 | AliCentralitySelectionTask* ctask = | |
87 | dynamic_cast<AliCentralitySelectionTask*>(mgr->GetTask(name)); | |
88 | if (!ctask) return; | |
89 | // ctask->SetPass(fESDPass); | |
90 | if (mc) ctask->SetMCInput(); | |
91 | } | |
92 | /** | |
93 | * Crete output handler - we don't want one here. | |
94 | * | |
95 | * @return 0 | |
96 | */ | |
97 | AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; } | |
98 | ||
99 | //__________________________________________________________________ | |
100 | const char* ClassName() const { return "MakeFMDElossTrain"; } | |
101 | //__________________________________________________________________ | |
102 | /** | |
103 | * Overloaded to create new Extract.C in the output | |
104 | * directory | |
105 | * | |
106 | * @param asShellScript | |
107 | */ | |
108 | void SaveSetup(Bool_t asShellScript) | |
109 | { | |
110 | TrainSetup::SaveSetup(asShellScript); | |
111 | ||
112 | std::ofstream f("Extract.C"); | |
113 | if (!f) { | |
114 | Error("SaveSetup", "Failed to open Extract.C"); | |
115 | return; | |
116 | } | |
117 | f << "// Generated by " << ClassName() << "\n" | |
118 | << "void Extract()\n" | |
119 | << "{\n" | |
120 | << " gROOT->LoadMacro(\"$ALICE_ROOT/PWGLF/FORWARD/analysis2/corrs/ExtractELoss.C\");\n" | |
121 | << " ExtractELoss(\"forward_eloss.root\"," | |
122 | << fHelper->IsMC() << ");\n" | |
123 | << "}\n" | |
124 | << "// EOF" << std::endl; | |
125 | f.close(); | |
126 | } | |
127 | }; | |
128 | ||
129 | // | |
130 | // EOF | |
131 | // |