]>
Commit | Line | Data |
---|---|---|
8b1c306c | 1 | //____________________________________________________________________ |
970b1a8a | 2 | /** |
3 | * | |
4 | * | |
5 | * @param list | |
6 | * @param low | |
7 | * @param high | |
8 | * @param m | |
9 | * | |
10 | * @return | |
11 | * | |
bd6f5206 | 12 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 13 | */ |
8b1c306c | 14 | Bool_t |
15 | MakeSecMap(TList* list, Double_t low, Double_t high, | |
16 | AliFMDCorrSecondaryMap* m) | |
17 | { | |
18 | // --- Get the list ------------------------------------------------ | |
19 | TString lName(AliForwardMCCorrectionsTask::VtxBin::BinName(low, high)); | |
20 | TList* vl = static_cast<TList*>(list->FindObject(lName)); | |
21 | if (!vl) { | |
22 | Error("MakeSecMap", "List %s not found in %s", | |
23 | lName.Data(), list->GetName()); | |
24 | return false; | |
25 | } | |
26 | ||
27 | // --- Get primary distribution ------------------------------------ | |
28 | const char* primaryName = "primary"; | |
29 | TH2D* primary = static_cast<TH2D*>(vl->FindObject(primaryName)); | |
30 | if (!primary) { | |
31 | Error("MakeSecMap", "Couldn't not find histogram %s in %s", | |
32 | primaryName, lName.Data()); | |
33 | return false; | |
34 | } | |
35 | TH2D* primaryI = static_cast<TH2D*>(primary->Clone("primaryI")); | |
36 | TH2D* primaryO = static_cast<TH2D*>(primary->Clone("primaryO")); | |
37 | primaryI->SetDirectory(0); | |
38 | primaryO->SetDirectory(0); | |
39 | primaryI->RebinY(2); | |
40 | ||
41 | ||
42 | // --- Calculate vertex -------------------------------------------- | |
43 | Double_t vz = (high+low) / 2; | |
44 | ||
45 | // --- Loop over rings --------------------------------------------- | |
46 | for (UShort_t d = 1; d <= 3; d++) { | |
47 | UShort_t nr = (d == 1 ? 1 : 2); | |
48 | for (UShort_t q = 0; q < nr; q++) { | |
49 | Char_t r = (q == 0 ? 'I' : 'O'); | |
50 | ||
51 | const char* ringName = Form("FMD%d%c_cache", d, r); | |
52 | TH2D* ring = static_cast<TH2D*>(vl->FindObject(ringName)); | |
53 | if (!ring) { | |
54 | Error("MakeSecMap", "Didn't find histogram %s in %s", | |
55 | ringName, vl->GetName()); | |
56 | vl->ls(); | |
57 | continue; | |
58 | } | |
59 | ||
60 | TH2D* tmp = static_cast<TH2D*>(ring->Clone("tmp")); | |
61 | TString tmpName = tmp->GetName(); | |
62 | tmpName.ReplaceAll("_cache", ""); | |
63 | tmp->SetName(tmpName); | |
64 | tmp->SetDirectory(0); | |
65 | tmp->Divide(q == 0 ? primaryI : primaryO); | |
66 | ||
67 | ||
68 | m->SetCorrection(d, r, vz, tmp); | |
69 | } | |
70 | } | |
71 | return true; | |
72 | } | |
73 | ||
74 | //____________________________________________________________________ | |
970b1a8a | 75 | /** |
76 | * | |
77 | * | |
78 | * @param filename | |
79 | * @param sys | |
80 | * @param cms | |
81 | * @param field | |
82 | * | |
bd6f5206 | 83 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 84 | */ |
8b1c306c | 85 | void |
86 | MakeCorrSecMap(const char* filename, | |
87 | const char* sys="pp", | |
88 | UShort_t cms=900, | |
89 | Short_t field=+5) | |
90 | { | |
91 | // --- Load code --------------------------------------------------- | |
bd6f5206 | 92 | // gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C"); |
8b1c306c | 93 | |
94 | ||
95 | // --- Get the file ------------------------------------------------ | |
96 | TFile* file = TFile::Open(filename, "READ"); | |
97 | if (!file) { | |
98 | Error("MakeCorrSecMap", "Couldn't open file %s", filename); | |
99 | return; | |
100 | } | |
101 | ||
102 | // --- Get the parent list ----------------------------------------- | |
103 | const char* forwardName = "ForwardSums"; | |
104 | TList* forward = static_cast<TList*>(file->Get(forwardName)); | |
105 | if (!forward) { | |
106 | Error("MakeCorrSecMap", "Couldn't get list %s from %s", | |
107 | forwardName, filename); | |
108 | return; | |
109 | } | |
110 | ||
111 | // --- Get the vertex axis ----------------------------------------- | |
112 | const char* vtxName = "vtxAxis"; | |
113 | TH1* vtxHist = static_cast<TH1*>(forward->FindObject(vtxName)); | |
114 | if (!vtxHist) { | |
115 | Error("MakeCorrSecMap", "Couldn't get histogram %s from %s", | |
116 | vtxName, forwardName); | |
117 | return; | |
118 | } | |
119 | const TAxis& vtxAxis = *(vtxHist->GetXaxis()); | |
120 | ||
121 | // --- Get the vertex axis ----------------------------------------- | |
122 | const char* etaName = "etaAxis"; | |
123 | TH1* etaHist = static_cast<TH1*>(forward->FindObject(etaName)); | |
124 | if (!etaHist) { | |
125 | Error("MakeCorrSecMap", "Couldn't get histogram %s from %s", | |
126 | etaName, forwardName); | |
127 | return; | |
128 | } | |
129 | const TAxis& etaAxis = *(etaHist->GetXaxis()); | |
130 | ||
131 | // --- Fill correction object -------------------------------------- | |
132 | AliFMDCorrSecondaryMap* corr = new AliFMDCorrSecondaryMap; | |
133 | corr->SetVertexAxis(vtxAxis); | |
134 | corr->SetEtaAxis(etaAxis); | |
135 | ||
136 | for (Int_t i = 1; i <= vtxAxis.GetNbins(); i++) { | |
137 | Double_t low = vtxAxis.GetBinLowEdge(i); | |
138 | Double_t high = vtxAxis.GetBinUpEdge(i); | |
139 | ||
140 | MakeSecMap(forward, low, high, corr); | |
141 | } | |
142 | ||
143 | // --- Get output filename and open -------------------------------- | |
144 | UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys); | |
145 | AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance(); | |
146 | TString fname(mgr.GetFileName(AliForwardCorrectionManager::kSecondaryMap, | |
147 | isys, cms, field, false)); | |
148 | TFile* output = TFile::Open(fname.Data(), "RECREATE"); | |
149 | if (!output) { | |
150 | Warning("Run", "Failed to open output file %s", fname.Data()); | |
151 | return kFALSE; | |
152 | } | |
153 | ||
154 | // --- Write to output --------------------------------------------- | |
155 | corr->Write(mgr.GetObjectName(AliForwardCorrectionManager::kSecondaryMap)); | |
156 | output->Write(); | |
157 | output->Close(); | |
158 | Info("Run", "File %s created. It should be copied to %s and stored in SVN", | |
159 | fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kSecondaryMap)); | |
160 | ||
161 | } | |
162 | //____________________________________________________________________ | |
163 | // | |
164 | // EOF | |
165 | // | |
166 |