AliPhysics  5403132 (5403132)
CorrDrawer.C
Go to the documentation of this file.
1 #ifndef __CINT__
2 # include "SummaryDrawer.C"
3 # include "AliFMDCorrAcceptance.h"
4 # include "AliFMDCorrSecondaryMap.h"
5 # include "AliFMDCorrELossFit.h"
6 # include "AliFMDCorrNoiseGain.h"
7 # include "AliForwardUtil.h"
9 # include "AliLog.h"
10 # include <TString.h>
11 # include <TError.h>
12 #else
13 class SummaryDrawer;
14 class TObject;
15 // class TAxis;
18 class AliFMDCorrELossFit;
20 #include <TString.h>
21 #endif
22 
23 class CorrDrawer : public SummaryDrawer
24 {
25 public:
32  {
33  fELossExtra = ""; // forward_eloss.root";
35  }
40  {
41  CloseCanvas();
42  }
49  static void MakeFileName(TString& out,
50  const TString& prefix)
51  {
52  out = TString::Format("forward_%s.pdf", prefix.Data());
53  }
54 
63  void Run(const Char_t* what,
64  const Char_t* extra,
65  Option_t* options="",
66  const Char_t* local="")
67  {
69  extra, options, local);
70  }
79  void Run(UShort_t what,
80  const Char_t* extra,
81  Option_t* options="",
82  const Char_t* local="")
83  {
84  fELossExtra = extra;
85  ULong_t runNo = 0;
86  UShort_t sys = 0;
87  UShort_t sNN = 0;
88  Short_t fld = 0;
89  Bool_t mc = false;
90  Bool_t sat = false;
91  if (!GetInformation(runNo, sys, sNN, fld, mc, sat)) return;
92 
93  Run(what, runNo, sys, sNN, fld, mc, sat, options, local);
94  }
95 
109  void Run(const Char_t* what,
110  ULong_t runNo,
111  const Char_t* sys,
112  UShort_t sNN,
113  UShort_t field,
114  Bool_t mc=false,
115  Bool_t sat=false,
116  Option_t* options="",
117  const char* local="")
118  {
121  sNN, field, mc, sat, options, local);
122  }
136  void Run(UShort_t what,
137  ULong_t runNo,
138  UShort_t sys,
139  UShort_t sNN,
140  UShort_t field,
141  Bool_t mc=false,
142  Bool_t sat=false,
143  Option_t* options="",
144  const char* local="")
145  {
147  mgr.SetDebug(true);
148 
149  // Set local prefix
150  if (local) mgr.SetPrefix(gSystem->DirName(local));
151 
152  // Get output file name
153  TString name;
155  AppendName(name, AliForwardCorrectionManager::kSecondaryMap);
157  AppendName(name, AliForwardCorrectionManager::kAcceptance);
159  AppendName(name, AliForwardCorrectionManager::kELossFits);
161  AppendName(name, AliForwardCorrectionManager::kNoiseGain);
163  Warning("CorrDrawer","Vertex bias not implemented yet");
165  Warning("CorrDrawer","Double hit not implemented yet");
167  Warning("CorrDrawer","Merging efficiency not implemented yet");
168 
169  // Filter the ones we can handle
170  UShort_t flags = what & (AliForwardCorrectionManager::kELossFits|
171  AliForwardCorrectionManager::kAcceptance|
172  AliForwardCorrectionManager::kSecondaryMap|
174  if (!mgr.Init(runNo, sys, sNN, field, mc, sat, flags, true)) {
175  Error("CorrDrawer", "Failed to initialize for flags=0x%02x"
176  "run=%lu, sys=%hu, sNN=%hu, field=%hd, mc=%d, sat=%d",
177  flags, runNo, sys, sNN, field, mc, sat);
178  return;
179  }
180 
181  TString out;
182  MakeFileName(out, name); // , runNo, sys, sNN, field, mc, sat);
183 
184  TString opts(options);
185  opts.ToUpper();
186  Bool_t landscape = opts.Contains("LANDSCAPE");
187  Bool_t few = opts.Contains("FEW");
188  Bool_t details = !opts.Contains("SINGLE");
189  if (opts.Contains("PORTRAIT")) landscape = false;
190  CreateCanvas(out, landscape);
191 
192 
193  fBody->cd();
194  if (details) {
195  Double_t y = .8;
196  DrawParameter(y, "Run #", Form("%lu", runNo));
198  DrawParameter(y, "#sqrt{s_{NN}}",
200  DrawParameter(y, "L3 field", AliForwardUtil::MagneticFieldString(field));
201  DrawParameter(y, "Simulation", Form("%s", mc ? "yes" : "no"));
202  DrawParameter(y, "Satellite", Form("%s", sat ? "yes" : "no"));
203  PrintCanvas("Title");
204  }
205 
206  if (what & AliForwardCorrectionManager::kSecondaryMap)
207  DrawIt(mgr.GetSecondaryMap(), details);
208  if (what & AliForwardCorrectionManager::kAcceptance)
209  DrawIt(mgr.GetAcceptance(), details);
210  if (what & AliForwardCorrectionManager::kELossFits)
211  DrawIt(mgr.GetELossFit(), details, few);
212  if (what & AliForwardCorrectionManager::kNoiseGain)
213  DrawIt(mgr.GetNoiseGain(), details);
214 
215  // Done
216  CloseCanvas();
217  }
223  virtual void Draw(const TObject* o)
224  {
225  if (!o) return;
226  Warning("CorrDrawer", "Don't know how to draw a %s object",
227  o->ClassName());
228  }
234  virtual void Draw(const AliFMDCorrAcceptance* acc) { Summarize(acc, false); }
240  virtual void Draw(const AliFMDCorrSecondaryMap* sec) { Summarize(sec, false);}
246  virtual void Draw(const AliFMDCorrELossFit* fits) { Summarize(fits, false); }
262  virtual void Summarize(const TString& what,
263  ULong_t runNo,
264  const Char_t* sys,
265  UShort_t sNN,
266  Short_t field,
267  Bool_t mc=false,
268  Bool_t sat=false,
269  Option_t* options="",
270  const char* local="")
271  {
274  sNN, field, mc, sat, options, local);
275  }
291  virtual void Summarize(UShort_t what,
292  ULong_t runNo,
293  UShort_t sys,
294  UShort_t sNN,
295  Short_t field,
296  Bool_t mc=false,
297  Bool_t sat=false,
298  Option_t* options="",
299  const char* local="")
300  {
301  Run(what, runNo, sys, sNN, field, mc, sat, options, local);
302  }
309  virtual void Summarize(const TObject* o, Bool_t pdf=true)
310  {
311  if (!o) return;
312  Warning("CorrDrawer", "Don't know how to draw a %s object (PDF: %s)",
313  o->ClassName(), pdf ? "yes" : "no");
314  }
322  virtual void Summarize(const AliFMDCorrAcceptance* acc, Bool_t pdf=true)
323  {
324  CreateCanvas(CanvasName("acceptance.pdf"), false, pdf);
325  DrawIt(acc, pdf);
326  if (pdf) CloseCanvas();
327  }
335  virtual void Summarize(const AliFMDCorrSecondaryMap* sec, Bool_t pdf=true)
336  {
337  CreateCanvas(CanvasName("secondarymap.pdf"), false, pdf);
338  DrawIt(sec, pdf);
339  if (pdf) CloseCanvas();
340  }
348  virtual void Summarize(const AliFMDCorrNoiseGain* corr, Bool_t pdf=true)
349  {
350  CreateCanvas(CanvasName("noisegain.pdf"), true, pdf);
351  DrawIt(corr, pdf);
352  if (pdf) CloseCanvas();
353  }
361  virtual void Summarize(const AliFMDCorrELossFit* fits, Bool_t pdf=true)
362  {
363  CreateCanvas(CanvasName("elossfits.pdf"), true, pdf);
364  DrawIt(fits, pdf);
365  if (pdf) CloseCanvas();
366  }
378  static void Summarize(const TString& what = "",
379  Bool_t /*mc*/ = false,
380  const TString& output = "",
381  const TString& local = "fmd_corrections.root",
382  Option_t* options= "")
383  {
384  CorrDrawer* drawer = new CorrDrawer;
386  output, local, options);
387  }
399  static void Summarize(UShort_t what,
400  Bool_t /*mc*/ = false,
401  const TString& output = "",
402  const TString& local = "fmd_corrections.root",
403  Option_t* options= "")
404  {
405  CorrDrawer* drawer = new CorrDrawer;
406  drawer->Run(what, output, options, local);
407  }
408 protected:
415  void AppendName(TString& what, UShort_t which)
416  {
417  if (!what.IsNull()) what.Append("_");
418  switch (which) {
420  what.Append("secondary"); break;
422  what.Append("acceptance"); break;
424  what.Append("elossfits"); break;
426  what.Append("noisegain"); break;
427  default:
428  what.Append("unknown"); break;
429  }
430  }
431 
444  virtual Bool_t GetInformation(ULong_t& runNo,
445  UShort_t& sys,
446  UShort_t& sNN,
447  Short_t& fld,
448  Bool_t& mc,
449  Bool_t& sat)
450  {
451  TFile* fout = TFile::Open(fELossExtra, "READ");
452  if (!fout) {
453  Warning("SummarizeELoss", "Correction task output \"%s\" not found",
454  fELossExtra.Data());
455  return false;
456  }
457  Bool_t ret = false;
458  try {
459  TCollection* forward = GetCollection(fout, "ForwardELossSums");
460  if (!forward) {
461  forward = GetCollection(fout, "forwardQAResults");
462  if (!forward) throw false;
463  }
464 
465  TCollection* eventInsp = GetCollection(forward, "fmdEventInspector");
466  if (!eventInsp) throw false;
467 
468  if (!GetParameter(eventInsp, "sys", sys)) throw false;
469  if (!GetParameter(eventInsp, "sNN", sNN)) throw false;
470  if (!GetParameter(eventInsp, "field", fld)) throw false;
471  if (!GetParameter(eventInsp, "satellite", sat)) throw false;
472  if (!GetParameter(eventInsp, "runNo", runNo)) throw false;
473  if (!GetParameter(eventInsp, "mc", mc)) throw false;
474 
475  ret = true;
476  }
477  catch (bool e) {
478  ret = e;
479  }
480  if (fout) fout->Close();
481  return ret;
482  }
491  virtual TString CanvasName(const char* def)
492  {
493  TString canName(def);
494  if (!fELossExtra.IsNull()) {
495  canName = gSystem->BaseName(fELossExtra.Data());
496  canName.ReplaceAll(".root", ".pdf");
497  }
498  return canName;
499  }
505  virtual void DrawIt(const TObject* o)
506  {
507  if (!o) return;
508  Warning("CorrDrawer", "Don't know how to summarize a %s object",
509  o->ClassName());
510  }
517  virtual void DrawIt(const AliFMDCorrAcceptance* corr, Bool_t details=true)
518  {
519  if (!corr) {
520  Warning("CorrDrawer","No acceptance available");
521  return;
522  }
523 
524  if (!fCanvas) {
525  Warning("CorrDrawer", "No canvas");
526  return;
527  }
528 
529  // --- Get vertex axis ---------------------------------------------
530  const TAxis& vtxAxis = corr->GetVertexAxis();
531  Int_t nVtx = vtxAxis.GetNbins();
532 
533  // --- Create stacks for summaries ---------------------------------
534  TObjArray* stacks = CreateVtxStacks(vtxAxis);
535  TObjArray* stacks2 = (corr->HasOverflow() && details
536  ? CreateVtxStacks(vtxAxis) : 0);
537 
538  //__________________________________________________________________
539  // Create a title page
540  if (details) {
541  fBody->cd();
542  TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle());
543  ll->SetTextAlign(22);
544  ll->SetTextSize(0.03);
545  ll->SetNDC();
546  ll->Draw();
547 
548  TLatex* l = new TLatex(.5,.8, "");
549  l->SetNDC();
550  l->SetTextSize(0.03);
551  l->SetTextFont(132);
552  l->SetTextAlign(12);
553  l->DrawLatex(0.2, 0.70, "Acceptance due to dead channels");
554  l->SetTextAlign(22);
555  l->DrawLatex(0.5, 0.55, "c_{v,r}(#eta,#phi) = #frac{"
556  "#sum active strips #in (#eta,#phi)}{"
557  "#sum strips #in (#eta,#phi)}");
558 
559  PrintCanvas("Acceptance");
560  }
561 
562  // --- Loop over vertex ------------------------------------------
563  for (UShort_t v=1; v <= nVtx; v++) {
564  Double_t vzMin = vtxAxis.GetBinLowEdge(v);
565  Double_t vzMax = vtxAxis.GetBinUpEdge(v);
566 
567  if (details) DivideForRings(true, true);
568 
569  // --- Loop over detectors -------------------------------------
570  for (UShort_t d = 1; d <= 3; d++) {
571  UShort_t nQ = (d == 1 ? 1 : 2);
572  for (UShort_t q = 0; q < nQ; q++) {
573  Char_t r = (q == 0 ? 'I' : 'O');
574 
575  TH2* h2 = corr->GetCorrection(d, r, v);
576  if (!h2) {
577  Warning("DrawCorrAcc", "No correction for FMD%d%c, v=%d", d, r, v);
578  corr->ls();
579  continue;
580  }
581 
582  if (details) DrawInRingPad(d, r, h2, "colz");
583 
584  Int_t nY = h2->GetNbinsY();
585  TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
586  hh->Scale(1. / nY);
587  hh->SetDirectory(0);
588  hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
589  hh->SetLineColor(AliForwardUtil::RingColor(d, r));
590  hh->SetFillColor(AliForwardUtil::RingColor(d, r));
591  hh->SetFillStyle(3001);
592 
593  THStack* stack = static_cast<THStack*>(stacks->At(v-1));
594  if (!stack) {
595  Error("", "No stack at v=%d", v-1);
596  continue;
597  }
598  stack->Add(hh);
599 
600  if (!stacks2) {
601  Warning("", "No phi acceptance defined");
602  continue;
603  }
604  stack = static_cast<THStack*>(stacks2->At(v-1));
605  if (!stack) {
606  Error("", "No stack at v=%d", v-1);
607  continue;
608  }
609  TH1* hp = corr->GetPhiAcceptance(d, r, v);
610  if (!hp) {
611  Error("", "No phi acceptance at v=%d", v-1);
612  continue;
613  }
614  hp->SetDirectory(0);
615  hp->SetMarkerColor(AliForwardUtil::RingColor(d, r));
616  hp->SetLineColor(AliForwardUtil::RingColor(d, r));
617  hp->SetFillColor(AliForwardUtil::RingColor(d, r));
618  hp->SetFillStyle(3001);
619  // Info("", "Adding phi acceptance plot %d", Int_t(hp->GetEntries()));
620  stack->Add(hp);
621 
622  }
623  }
624  if (details)
625  PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax));
626  }
627  if (DrawVtxStacks(stacks2, 1.2)) {
628  PrintCanvas("#phi acceptance");
629  }
630  if (DrawVtxStacks(stacks, 1.2)) {
631  PrintCanvas("#LTacceptance#GT");
632  }
633  }
640  virtual void DrawIt(const AliFMDCorrSecondaryMap* corr, bool details)
641  {
642  if (!corr) {
643  Warning("CorrDrawer","No secondary map available");
644  return;
645  }
646 
647  if (!fCanvas) {
648  Warning("CorrDrawer", "No canvas");
649  return;
650  }
651 
652  const TAxis& vtxAxis = corr->GetVertexAxis();
653  Int_t nVtx = vtxAxis.GetNbins();
654  TObjArray* stacks = CreateVtxStacks(vtxAxis);
655 
656  //__________________________________________________________________
657  // Create a title page
658  if (details) {
659  fBody->cd();
660  TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle());
661  ll->SetTextAlign(22);
662  ll->SetTextSize(0.03);
663  ll->SetNDC();
664  ll->Draw();
665 
666  TLatex* l = new TLatex(.5,.8, "");
667  l->SetNDC();
668  l->SetTextSize(0.03);
669  l->SetTextFont(132);
670  l->SetTextAlign(12);
671  l->DrawLatex(0.2, 0.70, "Secondary map");
672  l->SetTextAlign(22);
673  l->DrawLatex(0.5, 0.60, "c_{v,r}(#eta,#phi)=#frac{"
674  "#sum N_{ch,primary,i}(#eta,#phi)}{"
675  "#sum N_{ch,FMD,i}(#eta,#phi)}");
676  l->SetTextAlign(12);
677  l->DrawLatex(0.2, 0.50, "N: Number of events");
678  l->DrawLatex(0.2, 0.45, "N_{ch,primary,i}(#eta,#phi): Number of charged, "
679  "primary particles in (#eta,#phi) bin");
680  l->DrawLatex(0.2, 0.40, "N_{ch,primary,i}(#eta,#phi): Number of charged, "
681  "particles that hit the FMD in (#eta,#phi) bin");
682  l->DrawLatex(0.2, 0.35, "All quantities determined in MC");
683 
684  PrintCanvas("Secondary maps");
685  }
686 
687  // --- Loop over vertex ------------------------------------------
688  for (UShort_t v=1; v <= nVtx; v++) {
689  Double_t vzMin = vtxAxis.GetBinLowEdge(v);
690  Double_t vzMax = vtxAxis.GetBinUpEdge(v);
691 
692  if (details) DivideForRings(true, true);
693 
694  // --- Loop over detectors -------------------------------------
695  for (UShort_t d = 1; d <= 3; d++) {
696  UShort_t nQ = (d == 1 ? 1 : 2);
697  for (UShort_t q = 0; q < nQ; q++) {
698  Char_t r = (q == 0 ? 'I' : 'O');
699 
700  TH2* h2 = corr->GetCorrection(d, r, v);
701  if (!h2) {
702  Warning("DrawCorrSec", "No correction for FMD%d%c, v=%d", d, r, v);
703  continue;
704  }
705 
706  if (details) DrawInRingPad(d, r, h2, "colz");
707 
708  Int_t nY = h2->GetNbinsY();
709  TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
710  hh->Scale(1. / nY);
711  hh->SetDirectory(0);
712  hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
713  hh->SetLineColor(AliForwardUtil::RingColor(d, r));
714  hh->SetFillColor(AliForwardUtil::RingColor(d, r));
715  hh->SetFillStyle(3001);
716 
717  THStack* stack = static_cast<THStack*>(stacks->At(v-1));
718  if (!stack) {
719  Error("", "No stack at v=%d", v-1);
720  continue;
721  }
722  stack->Add(hh);
723  }
724  }
725  if (details)
726  PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax));
727  }
728  if (DrawVtxStacks(stacks, 3.5)) {
729  PrintCanvas("#LTsecondary map#GT");
730  }
731  }
732  virtual void DrawIt(const AliFMDCorrNoiseGain* corr, bool /*details*/)
733  {
734  if (!corr) {
735  Warning("CorrDrawer","No noise-gain correction available");
736  return;
737  }
738 
739  if (!fCanvas) {
740  Warning("CorrDrawer", "No canvas");
741  return;
742  }
743 
744  DivideForRings(false,false);
745 
746  for (UShort_t d = 1; d <= 3; d++) {
747  UShort_t nQ = d == 1 ? 1 : 2;
748  for (UShort_t q = 0; q < nQ; q++) {
749  Char_t r = q == 0 ? 'I' : 'O';
750  UShort_t nS = q == 0 ? 20 : 40;
751  UShort_t nT = q == 0 ? 512 : 256;
752 
753  TH2* h = new TH2D(Form("fmd%d%c", d, r),
754  Form("FMD%d%c", d, r),
755  nT, -.5, nT-.5, nS, -.5, nS-.5);
756  h->SetDirectory(0);
757  h->SetXTitle("Strip");
758  h->SetYTitle("Sector");
759 
760  for (UShort_t s = 0; s < nS; s++) {
761  for (UShort_t t = 0; t < nT; t++) {
762  Float_t c = corr->Get(d,r,s,t);
763  h->Fill(t,s,c);
764  }
765  }
766  h->GetZaxis()->SetRangeUser(0,0.05);
767  DrawInRingPad(d,r,h,"COLZ");
768  }
769  }
770  PrintCanvas("Noise correction");
771  }
780  virtual void DrawIt(const AliFMDCorrELossFit* corr, bool details,
781  bool few=true)
782  {
783  if (!corr) {
784  Warning("CorrDrawer","No energy loss fits available");
785  return;
786  }
787 
788  if (!fCanvas) {
789  Warning("CorrDrawer", "No canvas");
790  return;
791  }
792 
793  AliFMDCorrELossFit* fits = const_cast<AliFMDCorrELossFit*>(corr);
794  fits->CacheBins(8);
795  fits->Print("C");
796  TList* fitter = 0;
797  if (details) {
798  TFile* hists = 0;
799  TDirectory* savDir = gDirectory;
800  if (!gSystem->AccessPathName(fELossExtra.Data())) {
801  hists = TFile::Open(fELossExtra, "READ");
802  Info("", "Opened %s -> %p", fELossExtra.Data(), hists);
803  }
804  else
805  Warning("", "Couldn't open %s", fELossExtra.Data());
806  if (hists) {
807  TList* fr = static_cast<TList*>(hists->Get("ForwardELossResults"));
808  if (!fr)
809  fr = static_cast<TList*>(hists->Get("forwardQAResults"));
810  // Info("", "Got forward results -> %p", fr);
811  if (fr) {
812  fitter = static_cast<TList*>(fr->FindObject("fmdEnergyFitter"));
813  // Info("", "Got fitter -> %p", fitter);
814  // fr->ls();
815  DrawEventInspector(fr);
816  }
817  hists->Close();
818  savDir->cd();
819  }
820  fBody->cd();
821  TLatex* ll = new TLatex(.5,.9, "ESD #rightarrow #Delta-fits"
822  /* fCanvas->GetTitle() */);
823  ll->SetTextAlign(22);
824  ll->SetTextSize(0.05);
825  ll->SetNDC();
826  ll->Draw();
827 
828  const Double_t fontSize = 0.03;
829 #define DL(X,Y,T) do { l->DrawLatex(X,Y,T); Y -= fontSize; } while (false)
830  TLatex* l = new TLatex(.5,.8, "");
831  l->SetNDC();
832  l->SetTextSize(fontSize);
833  l->SetTextFont(132);
834  l->SetTextAlign(12);
835  Double_t y = 0.80;
836  Double_t x = 0.20;
837  Double_t z = 0.30;
838  DL(x,y,"1^{st} page is a summary of fit parameters");
839  DL(x,y,"2^{nd} page is a summary of relative errors");
840  DL(x,y,"Subsequent pages shows the fitted functions");
841  y -= 0.01;
842  DL(z,y,"Black line is the full fitted function");
843  DL(z,y,"Coloured lines are the individual N-mip comp.");
844  DL(x,y,"Each component has the form");
845  y -= 0.02;
846  DL(z,y,"f_{n}(x; #Delta, #xi, #sigma') = "
847  "#int_{-#infty}^{+#infty}dx' "
848  "landau(x'; #Delta, #xi)gaus(x'; x, #sigma')");
849  y -= 0.02;
850  DL(x,y,"The full function is given by");
851  y -= 0.02;
852  DL(z,y,"f_{N}(x; #Delta, #xi, #sigma', #bf{a}) = "
853  "C #sum_{i=1}^{N} a_{i} "
854  "f_{i}(x; #Delta_{i}, #xi_{i}, #sigma_{i}')");
855  y -= 0.03;
856  DL(z,y,"#Delta_{i} = i (#Delta_{1} + #xi_{1} log(i)) +#delta_{i}");
857  DL(z,y,"#xi_{i} = i #xi_{1}");
858  DL(z,y,"#sigma_{i} = #sqrt{i} #sigma_{1}");
859  DL(z,y,"#sigma_{n} #dot{=} 0");
860  DL(z,y,"#sigma_{i}'^{2} = #sigma^{2}_{n} + #sigma_{i}^{2}");
861  DL(z,y,"#delta_{i} = c#sigmau/(1+1/i)^{pu#sqrt{u}}");
862  DL(z,y,"u = #sigma/#xi");
863  DL(z,y,"a_{1} #dot{=} 1");
864  y -= 0.02;
865  DL(z,y,Form("Least quality: %d", fMinQuality));
866  y -= 0.02;
867  if (fitter) {
868  TObject* refit = fitter->FindObject("refitted");
869  if (refit) DL(z,y, "Refitted distributions");//.10
870  }
871  PrintCanvas("Energy loss fits");
872  }
873 
874  if (details && fitter) {
875  // Draw parameter from the fitter
876  fBody->cd();
877  Double_t y = 0.90;
878  Double_t s = fParName->GetTextSize();
879  Double_t t = fParVal->GetTextSize();
880  fParName->SetTextSize(0.04);
881  fParVal->SetTextSize(0.04);
882  DrawTParameter<double>(y, fitter, "lowCut");
883  DrawTParameter<int> (y, fitter, "nParticles");
884  DrawTParameter<int> (y, fitter, "minEntries");
885  DrawTParameter<int> (y, fitter, "subtractBins");
886  DrawTParameter<bool> (y, fitter, "doFits");
887  DrawTParameter<double>(y, fitter, "maxE");
888  DrawTParameter<int> (y, fitter, "nEbins");
889  DrawTParameter<bool> (y, fitter, "increasingBins");
890  DrawTParameter<double>(y, fitter, "maxRelPerError");
891  DrawTParameter<double>(y, fitter, "maxChi2PerNDF");
892  DrawTParameter<double>(y, fitter, "minWeight");
893  DrawTParameter<double>(y, fitter, "regCut");
894  DrawParameter(y,"Use #delta#Delta(#sigma/#xi)",
895  Form("%s",
896  fits->TestBit(AliFMDCorrELossFit::kHasShift)
897  ? "yes" : "no"));
898  PrintCanvas("Fitter settings");
899  fParName->SetTextSize(s);
900  fParVal->SetTextSize(t);
901  }
902 
903  fBody->cd();
904  fits->Draw("error good");
905  PrintCanvas("Fit overview");
906  if (!details) return;
907 
908  //__________________________________________________________________
909  // Draw relative parameter errors
910  fBody->cd();
911  fits->Draw("relative good");
912  PrintCanvas("Relative parameter errors");
913 
914  //__________________________________________________________________
915  // Draw all fits individually
916  for (UShort_t d=1; d<=3; d++) {
917  UShort_t nQ = (d == 1 ? 1 : 2);
918  for (UShort_t q = 0; q < nQ; q++) {
919  Char_t r = (q == 0 ? 'I' : 'O');
920  TList* dists = 0;
921  TList* resis = 0;
922  if (fitter) {
923  // Info("", "Fitter: %s", fitter->GetName());
924  TList* dl =
925  static_cast<TList*>(fitter->FindObject(Form("FMD%d%c",d,r)));
926  // Info("", "Got detector list -> %p", dl);
927  if (dl) {
928  // Info("", "Detector list: %s", dl->GetName());
929  dists = static_cast<TList*>(dl->FindObject("elossDists"));
930  // Info("", "Got distributions -> %p", dists);
931  resis = static_cast<TList*>(dl->FindObject("elossResiduals"));
932  // Info("", "Got residuals -> %p", resis);
933  }
934  }
935 
936  printf("FMD%d%c ", d, r);
937  ClearCanvas();
938  TObjArray* ra = fits->GetRingArray(d, r);
939  if (!ra) continue;
940  DrawELossFits(d, r, ra, dists, resis, few);
941  }
942  }
943  }
956  TList* dists, TList* resis, bool few)
957  {
958  Int_t nRow = 3;
959  Int_t nCol = (few ? 1 : 2);
960  Int_t nPad = nRow * nCol;
962  TIter next(ra);
963  Int_t i = 0;
964  Int_t j = 0;
965  DividedPad divided(fBody, fLandscape, nCol, nRow);
966  while ((fit = static_cast<AliFMDCorrELossFit::ELossFit*>(next()))) {
967  j = i % nPad;
968  Bool_t last = j == nPad-1;
969  if (j == 0) divided.Divide(true, true);
970 
971  Bool_t same = false;
972  TVirtualPad* drawPad = divided.GetPad(j); // fBody->GetPad(j+1);
973  Int_t subPad = 0;
974  // fBody->ls();
975  // Info("", "Now in sub-pad %d of %d: %p", j, nPad, drawPad);
976  // Info("", "Pad %s", drawPad->GetName());
977  if (dists) {
978  // Info("", "Distributions: %s", dists->GetName());
979  TString hName(Form("FMD%d%c_etabin%03d", d,r,fit->GetBin()));
980  TH1* dist = static_cast<TH1*>(dists->FindObject(hName));
981  TH1* resi = 0;
982  if (resis) resi = static_cast<TH1*>(resis->FindObject(hName));
983  // Info("", "Got histogram -> %p", dist);
984  if (resi) {
985  Bool_t err = resi->GetUniqueID() <= 1;
986  drawPad->SetGridx();
987  if (err) {
988  resi->SetYTitle("#chi^{2}_{bin}=(h-f)^{2}/#delta^{2}h");
989  for (Int_t k=1; k<=resi->GetNbinsX(); k++) {
990  Double_t c = resi->GetBinContent(k);
991  Double_t e = resi->GetBinError(k);
992  if (e <= 0) continue;
993  c *= c;
994  c /= (e*e);
995  resi->SetBinContent(k, c);
996  resi->SetBinError(k, 0);
997  }
998  }
999  drawPad->Divide(1,2,0,0);
1000  DrawInPad(drawPad, 2, resi, "HIST", kGridx);
1001  subPad = 1;
1002  Double_t red = fit->GetNu() > 0 ? fit->GetChi2() / fit->GetNu() : 0;
1003  if (red > 0) {
1004  drawPad->cd(2);
1005  TLine* l = new TLine(resi->GetXaxis()->GetXmin(), red,
1006  resi->GetXaxis()->GetXmax(), red);
1007  l->SetLineWidth(2);
1008  l->SetLineStyle(2);
1009  l->Draw();
1010  TLatex* cltx = new TLatex(0.5, 0.5,
1011  Form("#chi^{2}/#nu=%6.2f", red));
1012  cltx->SetNDC();
1013  cltx->SetTextAlign(22);
1014  cltx->SetTextFont(42);
1015  cltx->SetTextSize(0.07);
1016  cltx->Draw();
1017  cltx->DrawLatex(0.5,0.4,Form("%g", dist->GetEntries()));
1018  }
1019  }
1020  if (dist) {
1021  // Info("", "Histogram: %s", dist->GetName());
1022  dist->SetFillStyle(3001);
1023  dist->SetMarkerStyle(0);
1024  DrawInPad(drawPad, subPad, dist, "HIST E", (subPad * kGridx) + kLogy);
1025  same = true;
1026  }
1027  }
1028  // if (same)
1029  DrawInPad(drawPad, subPad, fit,
1030  Form("comp good values legend peak %s", (same ? "same" : "")),
1031  kLogy);
1032  if (fit->GetQuality() < fMinQuality) {
1033  TLatex* ltx = new TLatex(.2, .2, "NOT USED");
1034  ltx->SetNDC();
1035  ltx->SetTextFont(62);
1036  ltx->SetTextColor(kRed+1);
1037  ltx->SetTextAngle(30);
1038  ltx->SetTextSize(0.2);
1039  DrawInPad(fBody, j+1, ltx, "", 0);
1040  // ltx->Draw();
1041  }
1042 
1043  // else
1044  // DrawInPad(fBody, j+1, fit, "comp good values legend", kLogy);
1045  printf(".");
1046 
1047  if (last)
1048  PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1));
1049  i++;
1050  }
1051  j = i % nPad;
1052  if (j != 0)
1053  PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1));
1054  printf(" done\n");
1055  }
1056 
1065  {
1066  // --- Create stacks for summaries ---------------------------------
1067  Int_t nVtx = vtxAxis.GetNbins();
1068  TObjArray* stacks = new TObjArray(nVtx);
1069  for (UShort_t v = 1; v <= nVtx; v++) {
1070  THStack* stack = new THStack(Form("vtx%02d", v),
1071  Form("%+5.1f<v_{z}<%+5.1f",
1072  vtxAxis.GetBinLowEdge(v),
1073  vtxAxis.GetBinUpEdge(v)));
1074  stacks->AddAt(stack, v-1);
1075  }
1076  return stacks;
1077  }
1087  {
1088  if (!stacks) return false;
1089  // --- Make summary page -------------------------------------------
1090  Int_t nVtx = stacks->GetEntries();
1091 
1092  fBody->Divide(3, (nVtx+2)/3, 0, 0);
1093  Int_t ipad = 0;
1094  for (UShort_t v = 1; v <= nVtx; v++) {
1095  ipad++;
1096 
1097  if (nVtx == 10 && (ipad == 1 || ipad == 12)) ipad++;
1098 
1099  THStack* stack = static_cast<THStack*>(stacks->At(v-1));
1100  if (!stack) {
1101  Error("", "No stack at v=%d", v-1);
1102  continue;
1103  }
1104  TVirtualPad* pad = fBody->cd(ipad);
1105  if (!pad) {
1106  Error("", "No pad at %d", ipad);
1107  continue;
1108  }
1109  pad->SetFillColor(kWhite);
1110 
1111  if (max > 0) stack->SetMaximum(max);
1112  stack->Draw("nostack hist");
1113  }
1114  return true;
1115  }
1116 
1117 };
1118 
1119 
1120 
1121 //
1122 // EOF
1123 //
TH2D * GetCorrection(UShort_t d, Char_t r, Double_t v) const
virtual void DrawIt(const AliFMDCorrAcceptance *corr, Bool_t details=true)
Definition: CorrDrawer.C:517
TLatex * fParName
double Double_t
Definition: External.C:58
Base class for classes to draw summaries.
static const char * CenterOfMassEnergyString(UShort_t cms)
void ls(Option_t *option="") const
virtual void SetPrefix(const TString &prefix)
void Run(const Char_t *what, ULong_t runNo, const Char_t *sys, UShort_t sNN, UShort_t field, Bool_t mc=false, Bool_t sat=false, Option_t *options="", const char *local="")
Definition: CorrDrawer.C:109
UShort_t fMinQuality
Definition: CorrDrawer.C:27
void DrawInRingPad(UShort_t d, Char_t r, TObject *h, Option_t *opts="", UShort_t flags=0x0, const char *title="")
void Divide(Bool_t commonX, Bool_t commonY)
TSystem * gSystem
TH2D * GetCorrection(UShort_t d, Char_t r, Double_t v) const
char Char_t
Definition: External.C:18
Float_t Get(UShort_t d, Char_t r, UShort_t s, UShort_t t) const
virtual void Draw(const AliFMDCorrELossFit *fits)
Definition: CorrDrawer.C:246
void Print(Option_t *option="R") const
#define DL(X, Y, T)
virtual void Summarize(const AliFMDCorrSecondaryMap *sec, Bool_t pdf=true)
Definition: CorrDrawer.C:335
TCanvas * c
Definition: TestFitELoss.C:172
Bool_t DrawVtxStacks(TObjArray *stacks, Double_t max=-1)
Definition: CorrDrawer.C:1086
void CacheBins(UShort_t minQuality=kDefaultQuality) const
const TAxis & GetVertexAxis() const
AliStack * stack
static void Summarize(const TString &what="", Bool_t=false, const TString &output="", const TString &local="fmd_corrections.root", Option_t *options="")
Definition: CorrDrawer.C:378
virtual void Draw(const TObject *o)
Definition: CorrDrawer.C:223
void DrawELossFits(UShort_t d, Char_t r, TObjArray *ra, TList *dists, TList *resis, bool few)
Definition: CorrDrawer.C:955
TH1D * GetPhiAcceptance(UShort_t d, Char_t r, Double_t v) const
virtual TString CanvasName(const char *def)
Definition: CorrDrawer.C:491
Bool_t Init(ULong_t runNumber, UShort_t collisionSystem, UShort_t cmsNN, Short_t field, Bool_t mc=false, Bool_t satelliteCollisions=false, UInt_t what=kDefault, Bool_t force=false)
void Run(UShort_t what, ULong_t runNo, UShort_t sys, UShort_t sNN, UShort_t field, Bool_t mc=false, Bool_t sat=false, Option_t *options="", const char *local="")
Definition: CorrDrawer.C:136
static const char * MagneticFieldString(Short_t field)
TCanvas * fCanvas
int Int_t
Definition: External.C:63
static Color_t RingColor(UShort_t d, Char_t r)
TObjArray * GetRingArray(UShort_t d, Char_t r) const
float Float_t
Definition: External.C:68
void Run(const Char_t *what, const Char_t *extra, Option_t *options="", const Char_t *local="")
Definition: CorrDrawer.C:63
void AppendName(TString &what, UShort_t which)
Definition: CorrDrawer.C:415
Various utilities used in PWGLF/FORWARD.
virtual void Summarize(const AliFMDCorrNoiseGain *corr, Bool_t pdf=true)
Definition: CorrDrawer.C:348
static Bool_t GetParameter(const TObject *c, const TString &name, Short_t &value, Bool_t verb=true)
Definition: External.C:228
TVirtualPad * GetPad(Int_t idx)
virtual void DrawIt(const AliFMDCorrNoiseGain *corr, bool)
Definition: CorrDrawer.C:732
void Run(UShort_t what, const Char_t *extra, Option_t *options="", const Char_t *local="")
Definition: CorrDrawer.C:79
unsigned long ULong_t
Definition: External.C:38
virtual void SetDebug(Bool_t debug)
TList * fitter
Definition: DrawAnaELoss.C:26
const AliFMDCorrELossFit * GetELossFit() const
const AliFMDCorrNoiseGain * GetNoiseGain() const
void CreateCanvas(const TString &pname, Bool_t landscape=false, Bool_t pdf=true, Bool_t useTop=true)
virtual void DrawIt(const AliFMDCorrSecondaryMap *corr, bool details)
Definition: CorrDrawer.C:640
static void MakeFileName(TString &out, const TString &prefix)
Definition: CorrDrawer.C:49
void DrawParameter(Double_t &y, const TString &name, const TString &value, Double_t size=0)
static UInt_t ParseFields(const TString &what)
short Short_t
Definition: External.C:23
void PrintCanvas(const TString &title, Float_t size=.7)
virtual void Summarize(UShort_t what, ULong_t runNo, UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc=false, Bool_t sat=false, Option_t *options="", const char *local="")
Definition: CorrDrawer.C:291
virtual void Draw(const AliFMDCorrAcceptance *acc)
Definition: CorrDrawer.C:234
virtual void Summarize(const TString &what, ULong_t runNo, const Char_t *sys, UShort_t sNN, Short_t field, Bool_t mc=false, Bool_t sat=false, Option_t *options="", const char *local="")
Definition: CorrDrawer.C:262
const TAxis & GetVertexAxis() const
static UShort_t ParseCollisionSystem(const char *sys)
virtual Bool_t GetInformation(ULong_t &runNo, UShort_t &sys, UShort_t &sNN, Short_t &fld, Bool_t &mc, Bool_t &sat)
Definition: CorrDrawer.C:444
void CloseCanvas()
virtual void DrawEventInspector(TCollection *parent)
void DivideForRings(Bool_t commonX, Bool_t commonY)
TLatex * fParVal
Definition: External.C:220
const AliFMDCorrAcceptance * GetAcceptance() const
virtual void Draw(const AliFMDCorrSecondaryMap *sec)
Definition: CorrDrawer.C:240
static void Summarize(UShort_t what, Bool_t=false, const TString &output="", const TString &local="fmd_corrections.root", Option_t *options="")
Definition: CorrDrawer.C:399
void Draw(Option_t *option="")
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
virtual void DrawIt(const TObject *o)
Definition: CorrDrawer.C:505
TObjArray * CreateVtxStacks(const TAxis &vtxAxis)
Definition: CorrDrawer.C:1064
bool landscape
Definition: DrawAnaELoss.C:32
static const char * CollisionSystemString(UShort_t sys)
virtual void DrawIt(const AliFMDCorrELossFit *corr, bool details, bool few=true)
Definition: CorrDrawer.C:780
TObject * DrawInPad(TVirtualPad *c, Int_t padNo, TObject *h, Option_t *opts="", UInt_t flags=0x0, const char *title="")
bool Bool_t
Definition: External.C:53
TFile * fout
input train file
TString fELossExtra
Definition: CorrDrawer.C:26
const AliFMDCorrSecondaryMap * GetSecondaryMap() const
static TCollection * GetCollection(const TObject *parent, const TString &name, Bool_t verb=true)
virtual void Summarize(const AliFMDCorrELossFit *fits, Bool_t pdf=true)
Definition: CorrDrawer.C:361
virtual void Summarize(const AliFMDCorrAcceptance *acc, Bool_t pdf=true)
Definition: CorrDrawer.C:322
Definition: External.C:196
static AliForwardCorrectionManager & Instance()
virtual void Summarize(const TObject *o, Bool_t pdf=true)
Definition: CorrDrawer.C:309
void ClearCanvas()