2 # include "SummaryDrawer.C"
3 # include "AliFMDCorrAcceptance.h"
4 # include "AliFMDCorrSecondaryMap.h"
5 # include "AliFMDCorrELossFit.h"
6 # include "AliForwardUtil.h"
7 # include "AliForwardCorrectionManager.h"
15 class AliFMDCorrAcceptance;
16 class AliFMDCorrSecondaryMap;
17 class AliFMDCorrELossFit;
21 class CorrDrawer : public SummaryDrawer
31 fELossExtra = "forward_eloss.root";
35 * Destructor. Closes the PDF
42 * Create output file name
44 * @param out Output file name on return
45 * @param prefix Prefix of the file name
47 static void MakeFileName(TString& out,
48 const TString& prefix)
50 * @param runNo Run Number
51 * @param sys Collision system
52 * @param sNN Center of mass energy
53 * @param field L3 Field
54 * @param mc Simulations or not
55 * @param sat Satellite interactions or not
63 out = TString::Format("forward_%s.pdf", prefix.Data());
65 out = TString::Format("%s_run%09lu_%s_%04dGeV_%c%dkG_%s_%s.pdf",
69 sys == 3 ? "pPb" : "unknown"), sNN,
70 (field >= 0 ? 'p' : 'm'), TMath::Abs(field),
72 (sat ? "satellite" : "nominal"));
76 * Draw corrections using the correction manager to get them
78 * @param what What to draw
79 * @param runNo Run Number
80 * @param sys Collision system
81 * @param sNN Center of mass energy
82 * @param field L3 Field
83 * @param mc Simulations or not
84 * @param sat Satellite interactions or not
85 * @param options Options
86 * @param local Local database file
88 void Run(const Char_t* what,
98 Run(AliForwardCorrectionManager::ParseFields(what),
99 runNo, AliForwardUtil::ParseCollisionSystem(sys),
100 sNN, field, mc, sat, options, local);
102 void AppendName(TString& what, UShort_t which)
104 if (!what.IsNull()) what.Append("_");
106 case AliForwardCorrectionManager::kSecondaryMap:
107 what.Append("secondary"); break;
108 case AliForwardCorrectionManager::kAcceptance:
109 what.Append("acceptance"); break;
110 case AliForwardCorrectionManager::kELossFits:
111 what.Append("elossfits"); break;
113 what.Append("unknown"); break;
117 * Draw corrections using the correction manager to get them
119 * @param what What to draw
120 * @param runNo Run Number
121 * @param sys Collision system
122 * @param sNN Center of mass energy
123 * @param field L3 Field
124 * @param mc Simulations or not
125 * @param sat Satellite interactions or not
126 * @param local Local database file
128 void Run(UShort_t what,
135 Option_t* /*options*/="",
136 const char* local="")
138 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
143 if (what & AliForwardCorrectionManager::kSecondaryMap) {
144 flags |= AliForwardCorrectionManager::kSecondaryMap;
145 if (local) mgr.SetSecondaryMapPath(local);
146 AppendName(name, AliForwardCorrectionManager::kSecondaryMap);
148 if (what & AliForwardCorrectionManager::kAcceptance) {
149 flags |= AliForwardCorrectionManager::kAcceptance;
150 if (local) mgr.SetAcceptancePath(local);
151 AppendName(name, AliForwardCorrectionManager::kAcceptance);
153 if (what & AliForwardCorrectionManager::kELossFits) {
154 flags |= AliForwardCorrectionManager::kELossFits;
155 if (local) mgr.SetELossFitsPath(local);
156 AppendName(name, AliForwardCorrectionManager::kELossFits);
158 if (what & AliForwardCorrectionManager::kVertexBias)
159 Warning("CorrDrawer","Vertex bias not implemented yet");
160 if (what & AliForwardCorrectionManager::kDoubleHit)
161 Warning("CorrDrawer","Double hit not implemented yet");
162 if (what & AliForwardCorrectionManager::kMergingEfficiency)
163 Warning("CorrDrawer","Merging efficiency not implemented yet");
165 if (!mgr.Init(runNo, sys, sNN, field, mc, sat, flags, true)) {
166 Error("CorrDrawer", "Failed to initialize for flags=0x%02x"
167 "run=%lu, sys=%hu, sNN=%hu, field=%hd, mc=%d, sat=%d",
168 flags, runNo, sys, sNN, field, mc, sat);
173 MakeFileName(out, name); // , runNo, sys, sNN, field, mc, sat);
178 DrawParameter(y, "Run #", Form("%lu", runNo));
179 DrawParameter(y, "System", AliForwardUtil::CollisionSystemString(sys));
180 DrawParameter(y, "#sqrt{s_{NN}}",
181 AliForwardUtil::CenterOfMassEnergyString(sNN));
182 DrawParameter(y, "L3 field", AliForwardUtil::MagneticFieldString(field));
183 DrawParameter(y, "Simulation", Form("%s", mc ? "yes" : "no"));
184 DrawParameter(y, "Satellite", Form("%s", sat ? "yes" : "no"));
185 PrintCanvas("Title");
187 if (what & AliForwardCorrectionManager::kSecondaryMap) {
188 const AliFMDCorrSecondaryMap* sec = mgr.GetSecondaryMap();
190 Warning("CorrDrawer","No secondary map available");
194 if (what & AliForwardCorrectionManager::kAcceptance) {
195 const AliFMDCorrAcceptance* acc = mgr.GetAcceptance();
197 Warning("CorrDrawer","No acceptance available");
201 if (what & AliForwardCorrectionManager::kELossFits) {
202 const AliFMDCorrELossFit* fit = mgr.GetELossFit();
204 Warning("CorrDrawer","No energy loss fits available");
213 * @param o Object to draw
215 virtual void Draw(const TObject* o)
218 Warning("CorrDrawer", "Don't know how to draw a %s object",
222 * Draw a single plot of the mean acceptance correction
224 * @param acc Acceptance correction
226 virtual void Draw(const AliFMDCorrAcceptance* acc) { Summarize(acc, false); }
228 * Draw a single plot of the mean secondary correction
230 * @param sec Secondary correction
232 virtual void Draw(const AliFMDCorrSecondaryMap* sec) { Summarize(sec, false);}
234 * Draw a single plot summarizing the energy loss fits
236 * @param fits Energy loss fits
238 virtual void Draw(const AliFMDCorrELossFit* fits) { Summarize(fits, false); }
240 * A generalized entry to the summarization functions
242 * @param what What to show - only one field
243 * @param runNo Run number
245 * @param sNN Center of mass energy in GeV
246 * @param field L3 magnetic field
247 * @param mc Simulation flag
248 * @param sat Satellite interaction flag
249 * @param options Options
250 * @param local Local storage
252 virtual void Summarize(const TString& what,
259 Option_t* options="",
260 const char* local="")
262 Summarize(AliForwardCorrectionManager::ParseFields(what),
263 runNo, AliForwardUtil::ParseCollisionSystem(sys),
264 sNN, field, mc, sat, options, local);
267 * A generalized entry to the summarization functions
269 * @param what What to show - only one field
270 * @param runNo Run number
272 * @param sNN Center of mass energy in GeV
273 * @param field L3 magnetic field
274 * @param mc Simulation flag
275 * @param sat Satellite interaction flag
276 * @param local Local storage
278 virtual void Summarize(UShort_t what,
285 Option_t* /*options*/="",
286 const char* local="")
288 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
290 if (local) mgr.SetPrefix(gSystem->DirName(local));
293 if (what & AliForwardCorrectionManager::kSecondaryMap)
294 flag = AliForwardCorrectionManager::kSecondaryMap;
295 if (what & AliForwardCorrectionManager::kAcceptance)
296 flag = AliForwardCorrectionManager::kAcceptance;
297 if (what & AliForwardCorrectionManager::kELossFits)
298 flag = AliForwardCorrectionManager::kELossFits;
299 if (what & AliForwardCorrectionManager::kVertexBias)
300 Warning("CorrDrawer","Vertex bias not implemented yet");
301 if (what & AliForwardCorrectionManager::kDoubleHit)
302 Warning("CorrDrawer","Double hit not implemented yet");
303 if (what & AliForwardCorrectionManager::kMergingEfficiency)
304 Warning("CorrDrawer","Merging efficiency not implemented yet");
306 Warning("CorrDrawer", "Nothing to draw");
310 if (!mgr.Init(runNo, sys, sNN, field, mc, sat, flag, true)) {
311 Error("CorrDrawer", "Failed to initialize for flags=0x%02x "
312 "run=%lu, sys=%hu, sNN=%hu, field=%hd, mc=%d, sat=%d",
313 flag, runNo, sys, sNN, field, mc, sat);
318 if (flag == AliForwardCorrectionManager::kSecondaryMap)
319 prefix = "secondarymap";
320 else if (flag == AliForwardCorrectionManager::kAcceptance)
321 prefix = "acceptance";
322 else if (flag == AliForwardCorrectionManager::kELossFits)
323 prefix = "elossfits";
327 MakeFileName(out, prefix); // , runNo, sys, sNN, field, mc, sat);
332 DrawParameter(y, "Run #", Form("%lu", runNo));
333 DrawParameter(y, "System", AliForwardUtil::CollisionSystemString(sys));
334 DrawParameter(y, "#sqrt{s_{NN}}",
335 AliForwardUtil::CenterOfMassEnergyString(sys));
336 DrawParameter(y, "L3 field", AliForwardUtil::MagneticFieldString(field));
337 DrawParameter(y, "Simulation", Form("%s", mc ? "yes" : "no"));
338 DrawParameter(y, "Satellite", Form("%s", sat ? "yes" : "no"));
339 PrintCanvas("Title");
341 if (flag == AliForwardCorrectionManager::kSecondaryMap) {
342 const AliFMDCorrSecondaryMap* sec = mgr.GetSecondaryMap();
344 Warning("CorrDrawer","No secondary map available");
348 else if (flag == AliForwardCorrectionManager::kAcceptance) {
349 const AliFMDCorrAcceptance* acc = mgr.GetAcceptance();
351 Warning("CorrDrawer","No acceptance available");
355 if (flag == AliForwardCorrectionManager::kELossFits) {
356 const AliFMDCorrELossFit* fit = mgr.GetELossFit();
358 Warning("CorrDrawer","No energy loss fits available");
367 * @param o Object to draw
368 * @param pdf Not used
370 virtual void Summarize(const TObject* o, Bool_t pdf=true)
373 Warning("CorrDrawer", "Don't know how to draw a %s object (PDF: %s)",
374 o->ClassName(), pdf ? "yes" : "no");
377 * Draw a single summary plot or multiple plots of the acceptance
378 * correction. A new Canvas is created for this.
380 * @param acc Acceptance correction
381 * @param pdf If true, do multiple plots. Otherwise a single summary plot
383 virtual void Summarize(const AliFMDCorrAcceptance* acc, Bool_t pdf=true)
385 CreateCanvas("acceptance.pdf", false, pdf);
387 if (pdf) CloseCanvas();
390 * Draw a single summary plot multiple plots of the secondary
391 * correction. A new canvas is created for this.
393 * @param sec Secondary correction
394 * @param pdf If true, do multiple plots. Otherwise a single summary plot
396 virtual void Summarize(const AliFMDCorrSecondaryMap* sec, Bool_t pdf=true)
398 CreateCanvas("secondarymap.pdf", false, pdf);
400 if (pdf) CloseCanvas();
403 * Draw a single summary plot multiple plots of the energy loss
404 * fits. A new canvas is created for this.
406 * @param fits Energy loss fits
407 * @param pdf If true, do multiple plots. Otherwise a single summary plot
409 virtual void Summarize(const AliFMDCorrELossFit* fits, Bool_t pdf=true)
411 CreateCanvas("elossfits.pdf", false, pdf);
413 if (pdf) CloseCanvas();
416 static void Summarize(const TString& what = TString(""),
418 const TString& output = TString("forward_eloss.root"),
419 const TString& local = TString("fmd_corrections.root"),
420 Option_t* options= "")
422 Summarize(AliForwardCorrectionManager::ParseFields(what), mc,
423 output, local, options);
425 static void Summarize(UShort_t what,
427 const TString& output = "forward_eloss.root",
428 const TString& local = "fmd_corrections.root",
429 Option_t* options= "")
431 TFile* fout = TFile::Open(output, "READ");
433 Warning("SummarizeELoss", "Energy loss task output %s not found",
437 TCollection* forward = GetCollection(fout, "ForwardELossSums");
438 if (!forward) return;
440 TCollection* eventInsp = GetCollection(forward, "fmdEventInspector");
441 if (!eventInsp) return;
443 UShort_t sys = 0, sNN = 0;
447 if (!GetParameter(eventInsp, "sys", sys)) return;
448 if (!GetParameter(eventInsp, "sNN", sNN)) return;
449 if (!GetParameter(eventInsp, "field", field)) return;
450 if (!GetParameter(eventInsp, "satellite", satellite)) return;
451 if (!GetParameter(eventInsp, "runNo", runNo)) return;
453 CorrDrawer* drawer = new CorrDrawer;
454 drawer->Run(what, runNo, sys, sNN, field, mc, satellite,
461 * @param o Object to summarize
463 virtual void DrawIt(const TObject* o)
466 Warning("CorrDrawer", "Don't know how to summarize a %s object",
470 * Draw the acceptance correction
472 * @param corr Correction
473 * @param details If true, make a multipage PDF, otherwise plot the mean.
475 virtual void DrawIt(const AliFMDCorrAcceptance* corr, Bool_t details=true)
477 if (!corr || !fCanvas) return;
479 // --- Get vertex axis ---------------------------------------------
480 const TAxis& vtxAxis = corr->GetVertexAxis();
481 Int_t nVtx = vtxAxis.GetNbins();
483 // --- Create stacks for summaries ---------------------------------
484 TObjArray* stacks = CreateVtxStacks(vtxAxis);
485 TObjArray* stacks2 = (corr->HasOverflow() && details
486 ? CreateVtxStacks(vtxAxis) : 0);
488 //__________________________________________________________________
489 // Create a title page
492 TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle());
493 ll->SetTextAlign(22);
494 ll->SetTextSize(0.03);
498 TLatex* l = new TLatex(.5,.8, "");
500 l->SetTextSize(0.03);
503 l->DrawLatex(0.2, 0.70, "Acceptance due to dead channels");
505 l->DrawLatex(0.5, 0.55, "c_{v,r}(#eta,#phi) = #frac{"
506 "#sum active strips #in (#eta,#phi)}{"
507 "#sum strips #in (#eta,#phi)}");
509 PrintCanvas("Acceptance");
512 // --- Loop over vertex ------------------------------------------
513 for (UShort_t v=1; v <= nVtx; v++) {
514 Double_t vzMin = vtxAxis.GetBinLowEdge(v);
515 Double_t vzMax = vtxAxis.GetBinUpEdge(v);
517 if (details) DivideForRings(true, true);
519 // --- Loop over detectors -------------------------------------
520 for (UShort_t d = 1; d <= 3; d++) {
521 UShort_t nQ = (d == 1 ? 1 : 2);
522 for (UShort_t q = 0; q < nQ; q++) {
523 Char_t r = (q == 0 ? 'I' : 'O');
525 TH2* h2 = corr->GetCorrection(d, r, v);
527 Warning("DrawCorrAcc", "No correction for FMD%d%c, v=%d", d, r, v);
532 if (details) DrawInRingPad(d, r, h2, "colz");
534 Int_t nY = h2->GetNbinsY();
535 TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
538 hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
539 hh->SetLineColor(AliForwardUtil::RingColor(d, r));
540 hh->SetFillColor(AliForwardUtil::RingColor(d, r));
541 hh->SetFillStyle(3001);
543 THStack* stack = static_cast<THStack*>(stacks->At(v-1));
545 Error("", "No stack at v=%d", v-1);
551 Warning("", "No phi acceptance defined");
554 stack = static_cast<THStack*>(stacks2->At(v-1));
556 Error("", "No stack at v=%d", v-1);
559 TH1* hp = corr->GetPhiAcceptance(d, r, v);
561 Error("", "No phi acceptance at v=%d", v-1);
565 hp->SetMarkerColor(AliForwardUtil::RingColor(d, r));
566 hp->SetLineColor(AliForwardUtil::RingColor(d, r));
567 hp->SetFillColor(AliForwardUtil::RingColor(d, r));
568 hp->SetFillStyle(3001);
569 // Info("", "Adding phi acceptance plot %d", Int_t(hp->GetEntries()));
575 PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax));
577 if (DrawVtxStacks(stacks2, 1.2)) {
578 PrintCanvas("#phi acceptance");
580 if (DrawVtxStacks(stacks, 1.2)) {
581 PrintCanvas("#LTacceptance#GT");
585 * Draw the secondary correction
587 * @param corr Correction
588 * @param details If true, make a multipage PDF, otherwise plot the mean.
590 virtual void DrawIt(const AliFMDCorrSecondaryMap* corr, bool details)
592 if (!corr || !fCanvas) return;
594 const TAxis& vtxAxis = corr->GetVertexAxis();
595 Int_t nVtx = vtxAxis.GetNbins();
596 TObjArray* stacks = CreateVtxStacks(vtxAxis);
598 //__________________________________________________________________
599 // Create a title page
602 TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle());
603 ll->SetTextAlign(22);
604 ll->SetTextSize(0.03);
608 TLatex* l = new TLatex(.5,.8, "");
610 l->SetTextSize(0.03);
613 l->DrawLatex(0.2, 0.70, "Secondary map");
615 l->DrawLatex(0.5, 0.60, "c_{v,r}(#eta,#phi)=#frac{"
616 "#sum N_{ch,primary,i}(#eta,#phi)}{"
617 "#sum N_{ch,FMD,i}(#eta,#phi)}");
619 l->DrawLatex(0.2, 0.50, "N: Number of events");
620 l->DrawLatex(0.2, 0.45, "N_{ch,primary,i}(#eta,#phi): Number of charged, "
621 "primary particles in (#eta,#phi) bin");
622 l->DrawLatex(0.2, 0.40, "N_{ch,primary,i}(#eta,#phi): Number of charged, "
623 "particles that hit the FMD in (#eta,#phi) bin");
624 l->DrawLatex(0.2, 0.35, "All quantities determined in MC");
626 PrintCanvas("Secondary maps");
629 // --- Loop over vertex ------------------------------------------
630 for (UShort_t v=1; v <= nVtx; v++) {
631 Double_t vzMin = vtxAxis.GetBinLowEdge(v);
632 Double_t vzMax = vtxAxis.GetBinUpEdge(v);
634 if (details) DivideForRings(true, true);
636 // --- Loop over detectors -------------------------------------
637 for (UShort_t d = 1; d <= 3; d++) {
638 UShort_t nQ = (d == 1 ? 1 : 2);
639 for (UShort_t q = 0; q < nQ; q++) {
640 Char_t r = (q == 0 ? 'I' : 'O');
642 TH2* h2 = corr->GetCorrection(d, r, v);
644 Warning("DrawCorrSec", "No correction for FMD%d%c, v=%d", d, r, v);
648 if (details) DrawInRingPad(d, r, h2, "colz");
650 Int_t nY = h2->GetNbinsY();
651 TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
654 hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
655 hh->SetLineColor(AliForwardUtil::RingColor(d, r));
656 hh->SetFillColor(AliForwardUtil::RingColor(d, r));
657 hh->SetFillStyle(3001);
659 THStack* stack = static_cast<THStack*>(stacks->At(v-1));
661 Error("", "No stack at v=%d", v-1);
668 PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax));
670 if (DrawVtxStacks(stacks, 3.5)) {
671 PrintCanvas("#LTsecondary map#GT");
675 * Draw the energy loss fits correction
677 * @param corr Correction
678 * @param details If true, make a multipage PDF,
679 * otherwise plot the parameters.
681 virtual void DrawIt(const AliFMDCorrELossFit* corr, bool details)
683 if (!corr || !fCanvas) return;
685 AliFMDCorrELossFit* fits = const_cast<AliFMDCorrELossFit*>(corr);
691 TDirectory* savDir = gDirectory;
692 if (!gSystem->AccessPathName(fELossExtra.Data())) {
693 hists = TFile::Open(fELossExtra, "READ");
694 // Info("", "Opened forward_eloss.root -> %p", hists);
697 TList* fr = static_cast<TList*>(hists->Get("ForwardELossResults"));
698 // Info("", "Got forward results -> %p", fr);
700 fitter = static_cast<TList*>(fr->FindObject("fmdEnergyFitter"));
701 // Info("", "Got fitter -> %p", fitter);
707 TLatex* ll = new TLatex(.5,.8, "ESD #rightarrow #Delta-fits"
708 /* fCanvas->GetTitle() */);
709 ll->SetTextAlign(22);
710 ll->SetTextSize(0.05);
714 TLatex* l = new TLatex(.5,.8, "");
716 l->SetTextSize(0.03);
719 l->DrawLatex(0.2, 0.70, "1^{st} page is a summary of fit parameters");
720 l->DrawLatex(0.2, 0.67, "2^{nd} page is a summary of relative errors");
721 l->DrawLatex(0.2, 0.64, "Subsequent pages shows the fitted functions");
722 l->DrawLatex(0.3, 0.60, "Black line is the full fitted function");
723 l->DrawLatex(0.3, 0.57, "Coloured lines are the individual N-mip comp.");
724 //l->DrawLatex(0.3, 0.54, "Full drawn lines correspond to used components");
725 //l->DrawLatex(0.3, 0.51, "Dashed lines correspond to ignored components");
726 l->DrawLatex(0.2, 0.54, "Each component has the form");
727 l->DrawLatex(0.3, 0.49, "f_{n}(x; #Delta, #xi, #sigma') = "
728 "#int_{-#infty}^{+#infty}d#Delta' "
729 "landau(x; #Delta', #xi)gaus(#Delta'; #Delta, #sigma')");
730 l->DrawLatex(0.2, 0.44, "The full function is given by");
731 l->DrawLatex(0.3, 0.41, "f_{N}(x; #Delta, #xi, #sigma', #bf{a}) = "
732 "C #sum_{i=1}^{N} a_{i} "
733 "f_{i}(x; #Delta_{i}, #xi_{i}, #sigma_{i}')");
734 l->DrawLatex(0.3, 0.35, "#Delta_{i} = i (#Delta_{1} + #xi_{1} log(i))");
735 l->DrawLatex(0.3, 0.32, "#xi_{i} = i #xi_{1}");
736 l->DrawLatex(0.3, 0.29, "#sigma_{i} = #sqrt{i} #sigma_{1}");
737 l->DrawLatex(0.3, 0.26, "#sigma_{n} #dot{=} 0");
738 l->DrawLatex(0.3, 0.23, "#sigma_{i}'^{2} = #sigma^{2}_{n} + #sigma_{i}^{2}");
739 l->DrawLatex(0.3, 0.20, "a_{1} #dot{=} 1");
740 l->DrawLatex(0.3, 0.15, Form("Least quality: %d", fMinQuality));
742 TObject* refit = fitter->FindObject("refitted");
743 if (refit) l->DrawLatex(0.3, .10, "Refitted distributions");
745 PrintCanvas("Energy loss fits");
750 PrintCanvas("Fit overview");
751 if (!details) return;
753 //__________________________________________________________________
754 // Draw relative parameter errors
756 fits->Draw("relative");
757 PrintCanvas("Relative parameter errors");
759 //__________________________________________________________________
760 // Draw all fits individually
761 for (UShort_t d=1; d<=3; d++) {
762 UShort_t nQ = (d == 1 ? 1 : 2);
763 for (UShort_t q = 0; q < nQ; q++) {
764 Char_t r = (q == 0 ? 'I' : 'O');
768 // Info("", "Fitter: %s", fitter->GetName());
770 static_cast<TList*>(fitter->FindObject(Form("FMD%d%c",d,r)));
771 // Info("", "Got detector list -> %p", dl);
773 // Info("", "Detector list: %s", dl->GetName());
774 dists = static_cast<TList*>(dl->FindObject("EDists"));
775 // Info("", "Got distributions -> %p", dists);
776 resis = static_cast<TList*>(dl->FindObject("residuals"));
780 printf("FMD%d%c ", d, r);
782 TObjArray* ra = fits->GetRingArray(d, r);
784 DrawELossFits(d, r, ra, dists, resis);
789 * CINT does too much when optimizing on a loop, so we take this out
790 * to force CINT to not optimize the third nested loop.
794 * @param ra Ring array
795 * @param dists Distributions (optional)
796 * @param resis Residuals (optional)
798 void DrawELossFits(UShort_t d, Char_t r, TObjArray* ra,
799 TList* dists, TList* resis)
802 AliFMDCorrELossFit::ELossFit* fit = 0;
806 while ((fit = static_cast<AliFMDCorrELossFit::ELossFit*>(next()))) {
808 Bool_t last = j == nPad-1;
809 if (j == 0) DivideForRings(true, true);
812 TVirtualPad* drawPad = fBody->GetPad(j+1);
815 // Info("", "Distributions: %s", dists->GetName());
816 TString hName(Form("FMD%d%c_etabin%03d", d,r,fit->GetBin()));
817 TH1* dist = static_cast<TH1*>(dists->FindObject(hName));
819 if (resis) resi = static_cast<TH1*>(resis->FindObject(hName));
820 // Info("", "Got histogram -> %p", dist);
822 Bool_t err = resi->GetUniqueID() <= 1;
825 resi->SetYTitle("#chi^{2}_{bin}=(h-f)^{2}/#delta^{2}h");
826 for (Int_t k=1; k<=resi->GetNbinsX(); k++) {
827 Double_t c = resi->GetBinContent(k);
828 Double_t e = resi->GetBinError(k);
829 if (e <= 0) continue;
832 resi->SetBinContent(k, c);
833 resi->SetBinError(k, 0);
836 drawPad->Divide(1,2,0,0);
837 DrawInPad(drawPad, 2, resi, "HIST", kGridx);
839 Double_t red = fit->GetNu() > 0 ? fit->GetChi2() / fit->GetNu() : 0;
842 TLine* l = new TLine(resi->GetXaxis()->GetXmin(), red,
843 resi->GetXaxis()->GetXmax(), red);
847 TLatex* cltx = new TLatex(0.5, 0.5,
848 Form("#chi^{2}/#nu=%6.2f", red));
850 cltx->SetTextAlign(22);
851 cltx->SetTextFont(42);
852 cltx->SetTextSize(0.07);
854 cltx->DrawLatex(0.5,0.4,Form("%g", dist->GetEntries()));
858 // Info("", "Histogram: %s", dist->GetName());
859 DrawInPad(drawPad, subPad, dist, "HIST E", (subPad * kGridx) + kLogy);
864 DrawInPad(drawPad, subPad, fit,
865 Form("comp good values legend %s", (same ? "same" : "")),
867 if (fit->GetQuality() < fMinQuality) {
868 TLatex* ltx = new TLatex(.2, .2, "NOT USED");
870 ltx->SetTextFont(62);
871 ltx->SetTextColor(kRed+1);
872 ltx->SetTextAngle(30);
873 ltx->SetTextSize(0.2);
874 DrawInPad(fBody, j+1, ltx, "", 0);
879 // DrawInPad(fBody, j+1, fit, "comp good values legend", kLogy);
883 PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1));
888 PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1));
893 * Create an array of per-vertex bin stacks
895 * @param vtxAxis Vertex axis
897 * @return Array of stacks
899 TObjArray* CreateVtxStacks(const TAxis& vtxAxis)
901 // --- Create stacks for summaries ---------------------------------
902 Int_t nVtx = vtxAxis.GetNbins();
903 TObjArray* stacks = new TObjArray(nVtx);
904 for (UShort_t v = 1; v <= nVtx; v++) {
905 THStack* stack = new THStack(Form("vtx%02d", v),
906 Form("%+5.1f<v_{z}<%+5.1f",
907 vtxAxis.GetBinLowEdge(v),
908 vtxAxis.GetBinUpEdge(v)));
909 stacks->AddAt(stack, v-1);
914 * Draw the vertex stacks in the canvas
916 * @param stacks Stacks to draw
917 * @param max Possible maximum of the stacks
919 * @return true on success
921 Bool_t DrawVtxStacks(TObjArray* stacks, Double_t max=-1)
923 if (!stacks) return false;
924 // --- Make summary page -------------------------------------------
925 Int_t nVtx = 10; // stacks->GetEntries();
927 fBody->Divide(3, (nVtx+2)/3, 0, 0);
929 for (UShort_t v = 1; v <= nVtx; v++) {
932 if (ipad == 1 || ipad == 12) ipad++;
934 THStack* stack = static_cast<THStack*>(stacks->At(v-1));
936 Error("", "No stack at v=%d", v-1);
939 TVirtualPad* pad = fBody->cd(ipad);
941 Error("", "No pad at %d", ipad);
944 pad->SetFillColor(kWhite);
946 if (max > 0) stack->SetMaximum(max);
947 stack->Draw("nostack hist");