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