1 #include "SummaryDrawer.C"
4 * Class to draw a summary of the AOD production
7 * - The merged <tt>forward.root</tt> file.
8 * If the file isn't merged, it should still work.
11 * - A PDF file named after the input, but with <tt>.root</tt>
12 * replaced with <tt>pdf</tt>
15 class SummaryMCCorrDrawer : public SummaryDrawer
19 kEventInspector = 0x001,
20 kTrackDensity = 0x002,
33 virtual ~SummaryMCCorrDrawer() {}
35 //__________________________________________________________________
42 void Run(const char* fname, UShort_t what=kNormal)
44 // --- Open the file ---------------------------------------------
45 TString filename(fname);
46 TFile* file = TFile::Open(filename, "READ");
48 Error("Run", "Failed to open \"%s\"", filename.Data());
53 // --- Get top-level collection ----------------------------------
54 fSums = GetCollection(file, "ForwardCorrSums");
57 // --- Make our canvas -------------------------------------------
58 TString pdfName(filename);
59 pdfName.ReplaceAll(".root", ".pdf");
60 CreateCanvas(pdfName, what & 0x100);
62 // --- Possibly make a chapter here ------------------------------
63 if (what & kCentral && GetCollection(file, "CentralCorrSums"))
64 MakeChapter("Forward");
66 // --- Set pause flag --------------------------------------------
69 // --- Do each sub-algorithm -------------------------------------
70 if (what & kEventInspector) DrawEventInspector(fSums);
71 if (what & kTrackDensity) DrawTrackDensity(fSums);
72 if (what & kVertexBins) DrawVertexBins(true);
74 // --- Do the results ----------------------------------------------
75 fResults = GetCollection(file, "ForwardCorrResults");
76 if (!fResults) fResults = fSums; // Old-style
78 if (what & kResults) DrawResults(true);
80 // --- SPD clusters ----------------------------------------------
81 if (what & kCentral) {
82 // --- Get top-level collection --------------------------------
83 fSums = GetCollection(file, "CentralCorrSums");
85 MakeChapter("Central");
86 if (what & kEventInspector) DrawEventInspector(fSums);
87 if (what & kTrackDensity) DrawTrackDensity(fSums);
88 if (what & kVertexBins) DrawVertexBins(false);
91 Warning("", "No CentralCorrSums found");
93 fResults = GetCollection(file, "CentralCorrResults");
94 if (!fResults) fResults = fSums; // Old-style
96 Warning("", "No CentralCorrResults found");
98 if (what & kResults) DrawResults(false);
104 //____________________________________________________________________
105 TCollection* GetVertexList(TCollection* parent, const TAxis& axis, Int_t bin)
107 TString folder = TString::Format("vtx%+05.1f_%+05.1f",
108 axis.GetBinLowEdge(bin),
109 axis.GetBinUpEdge(bin));
110 folder.ReplaceAll(".", "d");
111 folder.ReplaceAll("+", "p");
112 folder.ReplaceAll("-", "m");
114 TCollection* c = GetCollection(parent, folder);
116 Warning("DrawVertexBins", "List %s not found", folder.Data());
120 //____________________________________________________________________
121 void DrawVertexBins(Bool_t forward)
123 Info("DrawVertexBins", "Drawing %s vertex bins",
124 forward ? "Forward" : "Central");
125 TH1* vtxHist = GetH1(fSums, "vtxAxis");
126 if (!vtxHist) return;
128 TAxis* vtxAxis = vtxHist->GetXaxis();
129 for (Int_t i = 1; i <= vtxAxis->GetNbins(); i++) {
130 Info("", "Bin %d", i);
131 TCollection* c = GetVertexList(fSums, *vtxAxis, i);
135 DivideForRings(true, true);
136 for (UShort_t d = 1; d <= 3; d++) {
137 for (UShort_t q = 0; q < (d == 1 ? 1 : 2); q++) {
138 Char_t r = q == 0 ? 'I' : 'O';
139 DrawInRingPad(d,r, GetH2(c, Form("FMD%d%c_cache",d,r)), "colz");
142 DrawInPad(fBody, 2, GetH2(c, "primary"), "colz");
145 fBody->Divide(1,3, 0, 0);
147 DrawInPad(fBody, 1, GetH2(c, "hits"), "colz");
148 DrawInPad(fBody, 2, GetH2(c, "clusters"), "colz");
149 DrawInPad(fBody, 3, GetH2(c, "primary"), "colz");
151 PrintCanvas(Form("%s sums - Vertex bin %+5.1f - %+5.1f",
152 (forward ? "Forward" : "Central"),
153 vtxAxis->GetBinLowEdge(i),
154 vtxAxis->GetBinUpEdge(i)));
157 //____________________________________________________________________
158 void DrawResults(Bool_t forward)
160 Info("DrawVertexBins", "Drawing resulting %s vertex bins",
161 forward ? "Forward" : "Central");
162 TH1* vtxHist = GetH1(fSums, "vtxAxis");
163 if (!vtxHist) return;
165 TAxis* vtxAxis = vtxHist->GetXaxis();
166 for (Int_t i = 1; i <= vtxAxis->GetNbins(); i++) {
167 TCollection* c = GetVertexList(fResults, *vtxAxis, i);
171 DivideForRings(true, true);
172 for (UShort_t d = 1; d <= 3; d++) {
173 for (UShort_t q = 0; q < (d == 1 ? 1 : 2); q++) {
174 Char_t r = q == 0 ? 'I' : 'O';
175 TVirtualPad* p = RingPad(d, r);
178 TH2* h = GetH2(c, Form("FMD%d%c_vtxbin%03d",d,r,i));
179 DrawInPad(p,1, h,"colz");
180 TVirtualPad* pp = p->cd(1);
181 TVirtualPad* ppp = p->cd(2);
182 ppp->SetRightMargin(pp->GetRightMargin());
183 TH1* hh = h->ProjectionX();
184 hh->Scale(1./ h->GetNbinsY());
185 hh->SetFillColor(RingColor(d,r));
186 hh->SetFillStyle(3001);
187 hh->SetTitle(Form("#LT%s#GT", hh->GetTitle()));
188 DrawInPad(p,2, hh, "hist e");
193 fBody->Divide(2,4,0,0);
194 TH2* secMap = GetH2(c, "secMap");
195 TH2* secMapAlt = GetH2(c, "secMapEff");
196 if (!secMapAlt) secMapAlt = GetH2(c, "secMapHit");
197 TH1* acc = GetH1(c, "acc");
198 TH1* accAlt = GetH1(c, "accEff");
199 if (!accAlt) accAlt = GetH1(c, "accHit");
201 TH1* secMapProj = secMap->ProjectionX();
202 secMapProj->Scale(1./ secMap->GetNbinsY());
203 secMapProj->Divide(acc);
204 secMapProj->SetFillColor(kRed+1);
205 secMapProj->SetFillStyle(3001);
206 secMapProj->SetTitle(Form("#LT%s#GT/Acceptance", secMap->GetTitle()));
208 TH1* secMapAltProj = secMapAlt->ProjectionX();
209 secMapAltProj->Scale(1./ secMapAlt->GetNbinsY());
210 secMapAltProj->Divide(accAlt);
211 secMapAltProj->SetFillColor(kBlue+1);
212 secMapAltProj->SetFillStyle(3001);
213 secMapAltProj->SetTitle(Form("#LT%s#GT/Acceptance",
214 secMapAlt->GetTitle()));
216 Double_t secMapMax = TMath::Max(secMap->GetMaximum(),
217 secMapAlt->GetMaximum());
218 secMap->SetMaximum(secMapMax);
219 secMapAlt->SetMaximum(secMapMax);
221 Double_t secMapProjMax = TMath::Max(secMapProj->GetMaximum(),
222 secMapAltProj->GetMaximum());
223 secMapProj->SetMaximum(secMapProjMax);
224 secMapAltProj->SetMaximum(secMapProjMax);
226 acc->SetFillColor(kRed+1);
227 acc->SetFillStyle(3001);
228 accAlt->SetFillColor(kBlue+1);
229 accAlt->SetFillStyle(3001);
231 Double_t accMax = TMath::Max(acc->GetMaximum(),accAlt->GetMaximum());
232 acc->SetMaximum(accMax);
233 accAlt->SetMaximum(accMax);
235 DrawInPad(fBody, 1, secMap, "colz", kGridx);
236 DrawInPad(fBody, 2, secMapAlt, "colz", kGridx);
238 TVirtualPad* p = fBody;
239 TVirtualPad* pp = p->cd(1);
240 TVirtualPad* ppp = p->cd(3);
241 ppp->SetRightMargin(pp->GetRightMargin());
242 DrawInPad(p,3, secMapProj, "hist", kGridx|kGridy);
245 ppp->SetRightMargin(pp->GetRightMargin());
246 DrawInPad(fBody, 5, acc, "", kGridx|kGridy);
249 pp->SetLeftMargin(0.10);
251 ppp->SetRightMargin(pp->GetRightMargin());
252 ppp->SetLeftMargin(0.10);
253 DrawInPad(p,4, secMapAltProj, "hist", kGridx|kGridy);
256 pp->SetLeftMargin(0.10);
258 ppp->SetRightMargin(pp->GetRightMargin());
259 ppp->SetLeftMargin(0.10);
260 DrawInPad(fBody, 6, accAlt, "", kGridx|kGridy);
262 DrawInPad(fBody, 7, GetH2(c, "diagnostics"), "colz");
264 TH2* ratio = static_cast<TH2*>(secMap->Clone("ratio"));
265 ratio->Add(secMapAlt, -1);
266 ratio->Divide(secMapAlt);
267 ratio->SetTitle("Relative difference between maps");
268 ratio->SetZTitle("#frac{S - S_{alt}}{S_{alt}}");
271 pp->SetLeftMargin(0.10);
272 DrawInPad(fBody, 8, ratio, "colz");
274 PrintCanvas(Form("%s results - Vertex bin %+5.1f - %+5.1f",
275 (forward ? "Forward" : "Central"),
276 vtxAxis->GetBinLowEdge(i),
277 vtxAxis->GetBinUpEdge(i)));
281 TCollection* fResults;