AliPhysics  1909eaa (1909eaa)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SummaryDrawer.C
Go to the documentation of this file.
1 
10 #ifndef SUMMARYDRAWER_C
11 # define SUMMARYDRAWER_C
12 # ifndef __CINT__
13 # include <THStack.h>
14 # include <TH1.h>
15 # include <TH2.h>
16 # include <TH3.h>
17 # include <TParameter.h>
18 # include <TCanvas.h>
19 # include <TList.h>
20 # include <TFile.h>
21 # include <TError.h>
22 # include <TLatex.h>
23 # include <TLegend.h>
24 # include <TLegendEntry.h>
25 # include <TMath.h>
26 # include <TString.h>
27 # include <TStyle.h>
28 # include <TSystem.h>
29 # include <TProfile.h>
30 # include <TGaxis.h>
31 # include <TPad.h>
32 # include <TRegexp.h>
33 # include <TGraph.h>
34 # include <sstream>
35 # include <iomanip>
36 # else
37 # ifdef __ACLIC__
38 class THStack;
39 class TH1;
40 class TH2;
41 class TH3;
42 class TCollection;
43 class TCanvas;
44 class TVirtualPad;
45 class TPad;
46 class TLatex;
47 class TAxis;
48 # endif
49 # endif
50 
56 {
57 public:
58  enum {
59  kLogx = 0x1,
60  kLogy = 0x2,
61  kLogz = 0x4,
62  kLegend = 0x10,
63  kGridx = 0x100,
64  kGridy = 0x200,
65  kGridz = 0x400,
66  kSilent = 0x800,
67  kNorth = 0x1000,
68  kMiddle = 0x2000,
69  kSouth = 0x3000,
70  kEast = 0x10000,
71  kCenter = 0x20000,
72  kWest = 0x30000
73  };
74  enum {
75  kLandscape = 0x100,
76  kPause = 0x200
77  };
79  : fCanvas(0),
80  fTop(0),
81  fBody(0),
82  fHeader(0),
83  fParName(0),
84  fParVal(0),
85  fPause(false),
86  fLandscape(false),
87  fRingMap(0),
88  fPDF(true),
89  fLastTitle("")
90  {
91  fRingMap = new TVirtualPad*[6];
92  fRingMap[0] = 0;
93  fRingMap[1] = 0;
94  fRingMap[2] = 0;
95  fRingMap[3] = 0;
96  fRingMap[4] = 0;
97  fRingMap[5] = 0;
98  }
99  virtual ~SummaryDrawer() {}
100 
101 protected:
102  //____________________________________________________________________
111  static const Char_t** GetRingNames(Bool_t lower=false)
112  {
113  static const Char_t* lN[]={ "FMD1i", "FMD2i", "FMD2o", "FMD3o", "FMD3i", 0};
114  static const Char_t* uN[]={ "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0};
115  return (lower ? lN : uN);
116  }
117  //____________________________________________________________________
126  static Color_t RingColor(UShort_t d, Char_t r)
127  {
128  return ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue))
129  + ((r == 'I' || r == 'i') ? 2 : -3));
130  }
131  //____________________________________________________________________
132  TLegend* DrawRingLegend(TVirtualPad* p, UInt_t flags)
133  {
134  TLegend* l = MakeLegend(p, flags, false);
135 
136  for (UShort_t i = 0; i < 5; i++) {
137  UShort_t d = (i+1)/2+1;
138  Char_t r = (i/2 == 1) ? 'o' : 'i';
139  TLegendEntry* e = l->AddEntry("dummy", Form("FMD%d%c", d, r), "f");
140  e->SetFillColor(RingColor(d, r));
141  e->SetFillStyle(1001);
142  e->SetLineColor(kBlack);
143  }
144 
145  l->Draw();
146  return l;
147  }
148  //____________________________________________________________________
149  static void SysString(UShort_t sys, TString& str)
150  {
151  str = "?";
152  switch (sys) {
153  case 1: str = "pp"; break;
154  case 2: str = "PbPb"; break;
155  case 3: str = "pPb"; break;
156  case 4: str = "Pbp"; break;
157  }
158  }
159  //____________________________________________________________________
160  static void SNNString(UShort_t sNN, TString& str)
161  {
162  str = "?";
163  if (sNN < 1000) str = Form("%dGeV", sNN);
164  else if (sNN < 3000) str = Form("%4.2fTeV", 0.001*sNN);
165  else str = Form("%dTeV", sNN/1000);
166  }
167  //____________________________________________________________________
174  static void AppendAnd(TString& trg, const TString& what)
175  {
176  if (!trg.IsNull()) trg.Append(" & ");
177  trg.Append(what);
178  }
179  //____________________________________________________________________
180  static void TriggerString(ULong_t trigger, TString& str)
181  {
182  str = "";
186  enum {
188  kInel = 0x0001,
190  kInelGt0 = 0x0002,
192  kNSD = 0x0004,
194  kEmpty = 0x0008,
196  kA = 0x0010,
198  kB = 0x0020,
200  kC = 0x0080,
202  kE = 0x0100,
204  kPileUp = 0x0200,
206  kMCNSD = 0x0400,
208  kOffline = 0x0800,
210  kNClusterGt0 = 0x1000,
212  kV0AND = 0x2000,
214  kSatellite = 0x4000
215  };
216  if ((trigger & kInel) != 0x0) AppendAnd(str, "INEL");
217  if ((trigger & kInelGt0) != 0x0) AppendAnd(str, "INEL>0");
218  if ((trigger & kNSD) != 0x0) AppendAnd(str, "NSD");
219  if ((trigger & kV0AND) != 0x0) AppendAnd(str, "V0AND");
220  if ((trigger & kA) != 0x0) AppendAnd(str, "A");
221  if ((trigger & kB) != 0x0) AppendAnd(str, "B");
222  if ((trigger & kC) != 0x0) AppendAnd(str, "C");
223  if ((trigger & kE) != 0x0) AppendAnd(str, "E");
224  if ((trigger & kMCNSD) != 0x0) AppendAnd(str, "MCNSD");
225  if ((trigger & kNClusterGt0) != 0x0) AppendAnd(str, "NCluster>0");
226  if ((trigger & kSatellite) != 0x0) AppendAnd(str, "Satellite");
227  }
228 
229  //__________________________________________________________________
239  static TObject* GetObject(const TObject* parent,
240  const TString& name,
241  Bool_t verb=true)
242  {
243  if (!parent) {
244  if (verb) Warning("GetObject", "No parent given");
245  return 0;
246  }
247  if (name.IsNull()) {
248  if (verb) Warning("GetObject", "No name specified");
249  return 0;
250  }
251  TObject* o = 0;
252  if (parent->IsA()->InheritsFrom(TCollection::Class())) {
253  const TCollection* p = static_cast<const TCollection*>(parent);
254  o = p->FindObject(name);
255  }
256  else if (parent->IsA()->InheritsFrom(TDirectory::Class())) {
257  const TDirectory* d = static_cast<const TDirectory*>(parent);
258  o = const_cast<TDirectory*>(d)->Get(name);
259  }
260  else
261  Warning("GetObject", "Do not know how to find an object (%s) in "
262  "%s (of class %s)", name.Data(),
263  parent ? parent->GetName() : "?",
264  parent ? parent->ClassName() : "?");
265  if (!o) {
266  if (verb) Warning("GetObject", "Object \"%s\" not found in parent \"%s\"",
267  name.Data(), parent->GetName());
268  return 0;
269  }
270  return o;
271  }
272  //____________________________________________________________________
282  static Bool_t CheckType(const TObject* o,
283  const TClass* cl,
284  const TString& src)
285  {
286  if (!o->IsA()->InheritsFrom(cl)) {
287  Warning("CheckType", "Object \"%s\" retrieved from \"%s\" is not a "
288  "%s but a %s", o->GetName(), src.Data(), cl->GetName(),
289  o->ClassName());
290  return false;
291  }
292  return true;
293  }
294  //__________________________________________________________________
303  template <typename T>
304  static T* DoGetObject(TObject* o, const TObject* p)
305  {
306  if (!o) return 0;
307  if (!CheckType(o, T::Class(), p->GetName())) return 0;
308  return static_cast<T*>(o);
309  }
310  //__________________________________________________________________
320  template <typename T>
321  static Bool_t DoGetParameter(TObject* o, const TObject* p, T& value)
322  {
323  TParameter<T>* r = DoGetObject<TParameter<T> >(o, p);
324  if (!r) return false;
325  // if (r->TestBit(TParameter<T>::kFirst)) value = r->GetVal();
326  // else value = r->GetUniqueID();
327  value = r->GetVal();
328  if (!r->TestBit(BIT(19))) {
329  TObject* oc = GetObject(p, "count", false);
330  if (oc) {
331  TParameter<int>* pc = static_cast<TParameter<int>*>(oc);
332  int cnt = pc->GetVal();
333  value /= cnt;
334  }
335  else
336  value = r->GetUniqueID();
337  }
338  // value = r->GetUniqueID();
339  return true;
340  }
341 
342  //___________________________________________________________________
351  static Bool_t GetParameter(const TObject* c,
352  const TString& name,
353  Short_t& value,
354  Bool_t verb=true)
355  {
356  int v;
357  Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v);
358  value = v;
359  return r;
360  }
361  //___________________________________________________________________
370  static Bool_t GetParameter(const TObject* c,
371  const TString& name,
372  UShort_t& value,
373  Bool_t verb=true)
374  {
375  int v = 0;
376  Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v);
377  value = v;
378  return r;
379  }
380  //___________________________________________________________________
389  static Bool_t GetParameter(const TObject* c,
390  const TString& name,
391  ULong_t& value,
392  Bool_t verb=true)
393  {
394  Long_t v = 0;
395  Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v);
396  value = v;
397  return r;
398  }
399  //_____________________________________________________________________
408  static Bool_t GetParameter(const TObject* c,
409  const TString& name,
410  Int_t& value,
411  Bool_t verb=true)
412  {
413  return DoGetParameter(GetObject(c, name, verb), c, value);
414  }
415  //_____________________________________________________________________
424  static Bool_t GetParameter(const TObject* c,
425  const TString& name,
426  Double_t& value,
427  Bool_t verb=true);
428  //_____________________________________________________________________
437  static Bool_t GetParameter(const TObject* c,
438  const TString& name,
439  Bool_t& value,
440  Bool_t verb=true)
441  {
442  return DoGetParameter(GetObject(c, name, verb), c, value);
443  }
444  //____________________________________________________________________
454  static TCollection* GetCollection(const TObject* parent,
455  const TString& name,
456  Bool_t verb=true)
457  {
458  return DoGetObject<TCollection>(GetObject(parent, name, verb), parent);
459  }
460  //____________________________________________________________________
470  static TH1* GetH1(const TObject* parent,
471  const TString& name,
472  Bool_t verb=true)
473  {
474  return DoGetObject<TH1>(GetObject(parent, name, verb), parent);
475  }
476  //____________________________________________________________________
486  static TH2* GetH2(const TObject* parent,
487  const TString& name,
488  Bool_t verb=true)
489  {
490  return DoGetObject<TH2>(GetObject(parent, name, verb), parent);
491  }
492  //____________________________________________________________________
502  static TH3* GetH3(const TCollection* parent,
503  const TString& name,
504  Bool_t verb=true)
505  {
506  // Info("GetH2", "Getting 2D histogram of %s from %p", name.Data(), c);
507  // --- Find the object -------------------------------------------
508  return DoGetObject<TH3>(GetObject(parent, name, verb), parent);
509  }
510  //__________________________________________________________________
521  static THStack* GetStack(const TObject* parent,
522  const TString& name,
523  const char* sub=0,
524  Bool_t verb=true)
525  {
526  THStack* stack = DoGetObject<THStack>(GetObject(parent,name,verb),parent);
527  if (!stack) return 0;
528  if (sub == 0) return stack;
529 
530  if (stack->GetHists()->GetEntries() <= 0 ||stack->GetMaximum() < 1) {
531  // Info("GetStack", "No entries in %s", name.Data());
532  stack->GetHists()->Delete();
533  const char** ptr = GetRingNames(false);
534  while (*ptr) {
535  TCollection* sc = GetCollection(parent, *ptr, true);
536  if (!sc) { ptr++; continue; }
537 
538  TObject* obj = GetObject(sc, sub);
539  if (!obj) {
540  continue;
541  ptr++;
542  }
543 
544  if (obj->IsA()->InheritsFrom(TH2::Class())) {
545  TH2* h = static_cast<TH2*>(obj);
546  TH1* p = h->ProjectionX(*ptr, 1, h->GetNbinsY(), "e");
547  p->Scale(1., "width");
548  p->SetTitle(*ptr);
549  p->SetDirectory(0);
550  stack->Add(p);
551  }
552  else if (obj->IsA()->InheritsFrom(TH1::Class())) {
553  TH1* hh = static_cast<TH1*>(obj);
554  hh->SetTitle(*ptr);
555  stack->Add(hh);
556  }
557  ptr++;
558  }
559  }
560  // --- Return the collection -------------------------------------
561  return stack;
562  }
563  //____________________________________________________________________
568  void ClearCanvas()
569  {
570  if (fTop) {
571  fTop->Clear();
572  fTop->SetNumber(1);
573  fTop->SetFillColor(kBlue-5);
574  fTop->SetBorderSize(0);
575  fTop->SetBorderMode(0);
576  }
577 
578  fBody->Clear();
579  fBody->SetNumber(2);
580  fBody->SetFillColor(0);
581  fBody->SetFillStyle(0);
582  fBody->SetBorderSize(0);
583  fBody->SetBorderMode(0);
584  fBody->SetTopMargin(0.01);
585  fBody->SetLeftMargin(0.10);
586  fBody->SetRightMargin(0.01);
587  fBody->SetBottomMargin(0.10);
588 
589  fRingMap[0] = 0;
590  fRingMap[1] = 0;
591  fRingMap[2] = 0;
592  fRingMap[3] = 0;
593  fRingMap[4] = 0;
594  fRingMap[5] = 0;
595 
596  fCanvas->cd();
597  }
598  //____________________________________________________________________
609  void CreateCanvas(const TString& pname,
610  Bool_t landscape=false,
611  Bool_t pdf=true,
612  Bool_t useTop=true)
613  {
614  // Info("CreateCanvas", "Creating canvas");
616  fPDF = pdf;
617  Int_t height = 1000;
618  Int_t width = height / TMath::Sqrt(2);
619  if (fLandscape) {
620  Int_t tmp = height;
621  height = width;
622  width = tmp;
623  }
624  fCanvas = new TCanvas("c", pname.Data(), width, height);
625  fCanvas->SetFillColor(0);
626  fCanvas->SetBorderSize(0);
627  fCanvas->SetBorderMode(0);
628  if (fPDF)
629  fCanvas->Print(Form("%s[", pname.Data()),
630  Form("pdf %s", fLandscape ? "Landscape" : ""));
631  fCanvas->SetLeftMargin(.1);
632  fCanvas->SetRightMargin(.05);
633  fCanvas->SetBottomMargin(.1);
634  fCanvas->SetTopMargin(.05);
635 
636  gStyle->SetOptStat(0);
637  gStyle->SetTitleColor(0);
638  gStyle->SetTitleStyle(0);
639  gStyle->SetTitleBorderSize(0);
640  gStyle->SetTitleX(.5);
641  gStyle->SetTitleY(1);
642  gStyle->SetTitleW(.8);
643  gStyle->SetTitleH(.09);
644  gStyle->SetFrameFillColor(kWhite);
645  gStyle->SetFrameBorderSize(1);
646  gStyle->SetFrameBorderMode(1);
647  gStyle->SetPalette(1);
648 
649  Float_t dy = useTop ? .05 : 0;
650  if (useTop) {
651  fTop = new TPad("top", "Top", 0, 1-dy, 1, 1, 0, 0);
652  fTop->SetNumber(1);
653  fTop->SetFillColor(kBlue-5);
654  fTop->SetBorderSize(0);
655  fTop->SetBorderMode(0);
656  fCanvas->cd();
657  fTop->Draw();
658  }
659 
660  fBody = new TPad("body", "Body", 0, 0, 1, 1-dy, 0, 0);
661  fBody->SetNumber(2);
662  fBody->SetFillColor(0);
663  fBody->SetFillStyle(0);
664  fBody->SetBorderSize(0);
665  fBody->SetBorderMode(0);
666  fCanvas->cd();
667  fBody->Draw();
668 
669  fHeader = new TLatex(.5, .5, "Title");
670  fHeader->SetNDC();
671  fHeader->SetTextAlign(22);
672  fHeader->SetTextSize(.7);
673  fHeader->SetTextColor(kWhite);
674  fHeader->SetTextFont(62);
675 
676  Double_t x1 = .1;
677  Double_t x2 = .6;
678  Double_t y = .8;
679  Double_t s = fLandscape ? 0.08 : 0.05;
680  fParName = new TLatex(x1, y, "");
681  fParName->SetTextAlign(13);
682  fParName->SetNDC();
683  fParName->SetTextSize(s);
684  fParName->SetTextFont(62);
685 
686  fParVal = new TLatex(x2, y, "");
687  fParVal->SetTextAlign(13);
688  fParVal->SetNDC();
689  fParVal->SetTextSize(s);
690  fParVal->SetTextFont(42);
691 
692  fCanvas->cd();
693  }
694 
695  //____________________________________________________________________
700  void CloseCanvas()
701  {
702  // Info("CloseCanvas", "Closing canvas");
703  // ClearCanvas();
704  if (fPDF && fCanvas) {
705  // Printf("Closing canvas with last title %s", fLastTitle.Data());
706  fCanvas->Print(Form("%s]", fCanvas->GetTitle()),
707  Form("pdf %s Title:%s",
708  fLandscape ? "Landscape" : "",
709  fLastTitle.Data()));
710  }
711  if (fCanvas)
712  fCanvas->Close();
713  fCanvas = 0;
714  }
715 
716  //__________________________________________________________________
723  void PrintCanvas(const TString& title, Float_t size=.7)
724  {
725  if (fTop) {
726  fTop->cd();
727  fHeader->SetTextSize(size);
728  fHeader->DrawLatex(.5,.5,title);
729  }
730 
731  fCanvas->Modified();
732  fCanvas->Update();
733  fCanvas->cd();
734 
735  if (fPDF) {
736  TString tit;
737  tit.Form("pdf %s Title:%s", fLandscape ? "Landscape" : "",
738  title.Data());
739 
740 #ifdef DEBUG
741  Info("PrintCanvas", "Printing to %s (%s)",
742  fCanvas->GetTitle(), tit.Data());
743 #else
744  gSystem->RedirectOutput("/dev/null");
745 #endif
746  fCanvas->Print(fCanvas->GetTitle(), tit);
747 #ifndef DEBUG
748  gSystem->RedirectOutput(0);
749 #endif
750  fLastTitle = title;
751  Pause();
752 
753  ClearCanvas();
754  }
755  }
756  //__________________________________________________________________
762  void MakeChapter(const TString& title)
763  {
764  fBody->cd();
765 
766  TLatex* ltx = new TLatex(.5, .5, title);
767  ltx->SetNDC();
768  ltx->SetTextAlign(22);
769  ltx->Draw();
770 
771  PrintCanvas(title);
772  }
773  //__________________________________________________________________
786  TObject* DrawInPad(TVirtualPad* c,
787  Int_t padNo,
788  TObject* h,
789  Option_t* opts="",
790  UInt_t flags=0x0,
791  const char* title="")
792  {
793  TVirtualPad* p = c->GetPad(padNo);
794  if (!p) {
795  Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName());
796  return 0;
797  }
798  return DrawInPad(p, h, opts, flags, title);
799  }
809  virtual TObject* DrawObjClone(TObject* o, Option_t* options,
810  const char* title)
811  {
812  if (o->IsA()->InheritsFrom(TH1::Class()))
813  return DrawObjClone(static_cast<TH1*>(o), options, title);
814  else if (o->IsA()->InheritsFrom(THStack::Class()))
815  return DrawObjClone(static_cast<THStack*>(o), options, title);
816  else if (o->IsA()->InheritsFrom(TGraph::Class()))
817  return o->DrawClone(options);
818  else
819  o->Draw(options);
820  return o;
821  }
831  virtual TObject* DrawObjClone(THStack* o, Option_t* options,
832  const char* title)
833  {
834  // THStack* tmp = static_cast<THStack*>(o->Clone());
835  o->Draw(options);
836  if (title && title[0] != '\0') o->GetHistogram()->SetTitle(title);
837  TAxis* xAxis = o->GetXaxis();
838  if (!xAxis) {
839  Warning("DrawObjClone", "No X-axis for drawn stack %s", o->GetName());
840  return o;
841  }
842  TH1* h = 0;
843  Int_t nBins = xAxis->GetNbins();
844  Double_t xMin = xAxis->GetXmin();
845  Double_t xMax = xAxis->GetXmax();
846  TIter next(o->GetHists());
847  while ((h = static_cast<TH1*>(next()))) {
848  TAxis* a = h->GetXaxis();
849  nBins = TMath::Max(nBins, a->GetNbins());
850  xMin = TMath::Min(xMin, a->GetXmin());
851  xMax = TMath::Max(xMax, a->GetXmax());
852  }
853  if (nBins != xAxis->GetNbins() ||
854  xMin != xAxis->GetXmin() ||
855  xMax != xAxis->GetXmax()) {
856  xAxis->Set(nBins, xMin, xMax);
857  o->GetHistogram()->Rebuild();
858  }
859  o->GetHistogram()->SetYTitle(title);
860  return o;
861  }
871  virtual TObject* DrawObjClone(TH1* o, Option_t* options, const char* title)
872  {
873  TH1* tmp = o->DrawCopy(options);
874  if (title && title[0] != '\0') tmp->SetTitle(title);
875  return tmp;
876  }
877  //__________________________________________________________________
878  static void GetLegendPosition(UInt_t flags, TVirtualPad* p,
879  Double_t& x1, Double_t& y1,
880  Double_t& x2, Double_t& y2)
881  {
882  UInt_t horiz = (flags & 0xF0000);
883  UInt_t verti = (flags & 0xF000);
884  Double_t eps = .01;
885  Double_t dY = .4;
886  Double_t dX = .4;
887  Double_t yB = p->GetBottomMargin()+eps;
888  Double_t yT = 1-p->GetTopMargin()-eps;
889  Double_t xL = p->GetLeftMargin()+eps;
890  Double_t xR = 1-p->GetRightMargin()-eps;
891  switch (verti) {
892  case kNorth: y1 = yT-dY; break;
893  case kSouth: y1 = yB; break;
894  case kMiddle: y1 = (yB+yT-dY)/2; break;
895  }
896  y2 = TMath::Min(y1 + dY, yT);
897 
898  switch (horiz) {
899  case kEast: x1 = xL; break;
900  case kWest: x1 = xR-dX; break;
901  case kCenter: x1 = (xL+xR-dX)/2; break;
902  }
903  x2 = TMath::Min(x1 + dX, xR);
904  }
905  //__________________________________________________________________
915  TLegend* MakeLegend(TVirtualPad* p, UInt_t flags, Bool_t autoFill)
916  {
917  Double_t x1 = fParVal->GetX();
918  Double_t y1 = fParVal->GetY();
919  Double_t x2 = 0;
920  Double_t y2 = 0;
921  GetLegendPosition(flags, p, x1, y1, x2, y2);
922 
923  //Printf("Legend at (%f,%f)x(%f,%f)", x1, y1, x2, y2);
924  TLegend* l = 0;
925  p->cd();
926  if (autoFill) l = p->BuildLegend(x1, y1, x2, y2);
927  else l = new TLegend(x1, y1, x2, y2);
928  l->SetFillColor(0);
929  l->SetFillStyle(0);
930  l->SetBorderSize(0);
931 
932  return l;
933  }
934  //__________________________________________________________________
946  TObject* DrawInPad(TVirtualPad* p,
947  TObject* h,
948  Option_t* opts="",
949  UInt_t flags=0x0,
950  const char* title="")
951  {
952  if (!p) {
953  Warning("DrawInPad", "No pad specified");
954  return 0;
955  }
956  p->cd();
957  // Info("DrawInPad", "Drawing in pad %p", p);
958  // fBody->ls();
959  if (flags & kLogx) p->SetLogx();
960  if (flags & kLogy) p->SetLogy();
961  if (flags & kLogz) p->SetLogz();
962  if (flags & kGridx) p->SetGridx();
963  if (flags & kGridy) p->SetGridy();
964  // if (flags & kGridz) p->SetGridz();
965  p->SetFillColor(0);
966  TString o(opts);
967  if (o.Contains("colz", TString::kIgnoreCase))
968  p->SetRightMargin(0.15);
969  if (!h) {
970  if (!(flags & kSilent))
971  Warning("DrawInPad", "Nothing to draw in pad # %s", p->GetName());
972  return 0;
973  }
974  if (o.Contains("text", TString::kIgnoreCase)) {
975  TH1* hh = static_cast<TH1*>(h);
976  hh->SetMaximum(1.1*hh->GetMaximum());
977  hh->SetMarkerSize(2);
978  o.Append("30");
979  }
980  TObject* ret = DrawObjClone(h, o, title);
981 
982  if (flags & kLegend) {
983  MakeLegend(p, flags, true);
984  }
985  p->Modified();
986  p->Update();
987  p->cd();
988 
989  return ret;
990  }
991  //__________________________________________________________________
1002  void DrawTwoInPad(TVirtualPad* c, Int_t padNo, TH1* h1, TH1* h2,
1003  Option_t* opts="", UShort_t flags=0x0)
1004  {
1005  TVirtualPad* p = c->cd(padNo);
1006  if (!p) {
1007  Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName());
1008  return;
1009  }
1010  if (flags & kLogx) p->SetLogx();
1011  if (flags & kLogy) p->SetLogy();
1012  if (flags & kLogz) p->SetLogz();
1013  if (flags & kGridx) p->SetGridx();
1014  if (flags & kGridy) p->SetGridy();
1015  // if (flags & kGridz) p->SetGridz();
1016  p->SetFillColor(0);
1017 
1018  TString o(opts);
1019  o.ToLower();
1020  TString fopts(o);
1021  Bool_t e3 = o.Contains("e3");
1022  if (e3) {
1023  fopts.ReplaceAll("e3", " same");
1024  }
1025 
1026  h1->GetYaxis()->SetLabelSize(0);
1027  h1->GetYaxis()->SetTicks("");
1028  h1->GetYaxis()->SetNdivisions(0);
1029  h1->DrawCopy(o); // First draw with opts
1030  if (e3) h1->DrawCopy(fopts);
1031  p->Update();
1032 
1033  Double_t m1 = 1.05 * h1->GetMaximum();
1034  if (m1 > 0) {
1035  TGaxis* a1 = new TGaxis(p->GetUxmin(), p->GetUymin(),
1036  p->GetUxmin(), p->GetUymax(),
1037  0, m1, 510);
1038  a1->SetLineColor(h1->GetLineColor());
1039  a1->Draw();
1040  }
1041 
1042  o.Append(" same");
1043  Double_t m2 = 1.1 * h2->GetMaximum();
1044  Double_t scale = m2 > 0 ? m1 / m2 : 1;
1045  h2->Scale(scale);
1046  h2->DrawCopy(o);
1047  if (e3) h2->DrawCopy(fopts);
1048 
1049  if (m2 > 0) {
1050  TGaxis* a2 = new TGaxis(p->GetUxmax(), p->GetUymin(),
1051  p->GetUxmax(), p->GetUymax(),
1052  0, m2, 510, "+L");
1053  a2->SetLineColor(h2->GetLineColor());
1054  a2->Draw();
1055  }
1056  if (flags& kLegend) {
1057  MakeLegend(p, flags, true);
1058  }
1059  p->Modified();
1060  p->Update();
1061  p->cd();
1062  }
1063 
1064  //____________________________________________________________________
1074  const TString& name,
1075  const TString& value,
1076  Double_t size=0)
1077  {
1078  Double_t s = fParName->GetTextSize();
1079  Double_t t = fParVal->GetTextSize();
1080  if (name.IsNull() && value.IsNull()) return;
1081  if (size > 0) {
1082  fParName->SetTextSize(size);
1083  fParVal->SetTextSize(size);
1084  }
1085  if (!name.IsNull())
1086  fParName->DrawLatex(fParName->GetX(), y, Form("%s:", name.Data()));
1087  if (!value.IsNull())
1088  fParVal->DrawLatex(fParVal->GetX(), y, value.Data());
1089  if (!name.IsNull())
1090  y -= 1.2 * fParName->GetTextSize();
1091  else if (!value.IsNull())
1092  y -= 1.2 * fParVal->GetTextSize();
1093 
1094  fParName->SetTextSize(s);
1095  fParVal->SetTextSize(t);
1096  }
1097  template <typename T>
1099  TList* list,
1100  const TString& name) {
1101  T value;
1102  if (!GetParameter(list, name, value))
1103  return;
1104  std::stringstream s;
1105  s << std::boolalpha << value;
1106  DrawParameter(y, name, s.str().c_str(), 0);
1107  }
1108 
1109 #ifndef __CINT__
1110  //__________________________________________________________________
1114  struct DividedPad {
1115  TVirtualPad* fParent;
1116  TVirtualPad** fSubs;
1120 
1121  DividedPad(TVirtualPad* p, Bool_t landscape, Int_t nCol, Int_t nRow)
1122  : fParent(p),
1123  fSubs(0),
1124  fLandscape(landscape),
1125  fNCol(landscape ? nRow : nCol),
1126  fNRow(landscape ? nCol : nRow)
1127  {
1128  Int_t nPad = fNCol * fNRow;
1129  fSubs = new TVirtualPad*[nPad];
1130  }
1131  void Divide(Bool_t commonX, Bool_t commonY) {
1132  if ((!commonX && !commonY) || (commonX && commonY)) {
1133  // In case we have no common axis or do have both to be common,
1134  // we directly use the TVirtualPad::Divide member function
1135  fParent->Divide(fNCol, fNRow, commonX ? 0 : 0.01, commonY ? 0 : 0.01);
1136  for (Int_t iPad = 1; iPad <= fNRow*fNCol; iPad++)
1137  fSubs[iPad-1] = fParent->GetPad(iPad);
1138  }
1139  else if (commonX && !commonY) {
1140  // We need to have common X axis, but not common Y axis. We first
1141  // divide the pad in fNCol columns, and then each in to fNRow rows
1142  fParent->Divide(fNCol, 1);
1143  for (Int_t iCol = 1; iCol <= fNCol; iCol++) {
1144  TVirtualPad* q = fParent->GetPad(iCol);
1145 
1146  if (fNRow == 1) {
1147  fSubs[GetIdx(iCol,0)] = q;
1148  continue;
1149  }
1150 
1151  q->Divide(1,fNRow,0,0);
1152  for (Int_t iRow = 1; iRow <= fNRow; iRow++)
1153  fSubs[GetIdx(iCol, iRow)] = q->GetPad(iRow);
1154  }
1155  }
1156  else if (!commonX && commonY) {
1157  // We need to have common Y axis, but not common X axis. We first
1158  // divide the pad in fNRow rows, and then each in to fNCol columns
1159  fParent->Divide(1, fNRow);
1160  for (Int_t iRow = 1; iRow <= fNRow; iRow++) {
1161  TVirtualPad* q = fParent->GetPad(iRow);
1162 
1163  if (fNCol == 1) {
1164  fSubs[GetIdx(0,iRow)] = q;
1165  continue;
1166  }
1167 
1168  q->Divide(fNCol,1,0,0);
1169  for (Int_t iCol = 1; iCol <= fNCol; iCol++)
1170  fSubs[GetIdx(iCol, iRow)] = q->GetPad(iCol);
1171  }
1172  }
1173  }
1174  virtual ~DividedPad() { if (fSubs) delete [] fSubs; }
1182  TVirtualPad* GetPad(Int_t idx) {
1183  if (!fSubs) {
1184  ::Warning("GetPad","No sub-pads");
1185  return 0;
1186  }
1187  if (idx < 0 || idx >= (fNRow*fNCol)) {
1188  ::Warning("GetPad", "Inded %d out of bounds [%d,%d]",
1189  idx, 0, fNRow*fNCol);
1190  return 0;
1191  }
1192  return fSubs[idx];
1193  }
1194  Int_t GetIdx(Int_t iCol, Int_t iRow) const
1195  {
1196  return (iRow-1) * fNCol + iCol;
1197  }
1206  TVirtualPad* GetPad(Int_t iCol, Int_t iRow) {
1207  if (iRow < 0 || iRow > fNRow) return 0;
1208  if (iCol < 0 || iRow > fNCol) return 0;
1209  return GetPad(GetIdx(iCol, iRow));
1210  }
1211  };
1212 #endif
1213 
1214  //__________________________________________________________________
1215  void DivideForRings(Bool_t commonX, Bool_t commonY)
1216  {
1217  //
1218  // Divide canvas for rings
1219  //
1220  if ((!commonX && !commonY) ||
1221  (commonX && commonY)) {
1222  // Portrait:
1223  // +----------+----------+
1224  // | 1: FMD1i | 2: Free |
1225  // +----------+----------+
1226  // | 3: FMD2i | 4: FMD2o |
1227  // +----------+----------+
1228  // | 5: FMD3i | 6: FMD3o |
1229  // +----------+----------+
1230  //
1231  // Landscape:
1232  // +----------+----------+----------+
1233  // | 1: FMD1i | 2: FMD2i | 3: FMD3i |
1234  // +----------+----------+----------+
1235  // | 4: Free | 5: FMD2o | 6: FMD3o |
1236  // +----------+----------+----------+
1237  //
1238  fBody->Divide(fLandscape ? 3 : 2, fLandscape ? 2 : 3,
1239  commonX ? 0 : 0.01, commonY ? 0 : 0.01);
1240  fRingMap[0] = fBody->GetPad(1); // FMD1i;
1241  fRingMap[1] = fBody->GetPad(fLandscape ? 2 : 3); // FMD2i;
1242  fRingMap[2] = fBody->GetPad(fLandscape ? 5 : 4); // FMD2o;
1243  fRingMap[3] = fBody->GetPad(fLandscape ? 3 : 5); // FMD3i;
1244  fRingMap[4] = fBody->GetPad(6); // FMD3o;
1245  fRingMap[5] = fBody->GetPad(fLandscape ? 4 : 2); // Free
1246  }
1247  else if (commonX && !commonY) {
1248  // Divide into two - left/right
1249  // Portrait:
1250  // +----------++----------+
1251  // | 1: FMD1i || 1: Free |
1252  // +----------++----------+
1253  // | 2: FMD2i || 2: FMD2o |
1254  // +----------++----------+
1255  // | 3: FMD3i || 3: FMD3o |
1256  // +----------++----------+
1257  //
1258  // Landscape:
1259  // +----------++----------++----------+
1260  // | 1: FMD1i || 1: FMD2i || 1: FMD3i |
1261  // +----------++----------++----------+
1262  // | 2: Free || 2: FMD2o || 2: FMD3o |
1263  // +----------++----------++----------+
1264  //
1265  fBody->Divide(fLandscape ? 3 : 2, 1);
1266  TVirtualPad* left = fBody->cd(1);
1267  left->Divide(fLandscape ? 2 : 3);
1268  TVirtualPad* middle = fBody->cd(2);
1269  middle->Divide(fLandscape ? 2 : 3);
1270 
1271  Info("left","%p",left); left->ls();
1272  Info("middle","%p",middle); middle->ls();
1273 
1274  fRingMap[0] = left->GetPad(1); // FMD1i;
1275  if (!fLandscape) {
1276  fRingMap[1] = left->GetPad(2); // FMD2i
1277  fRingMap[2] = middle->GetPad(2); // FMD2o
1278  fRingMap[3] = left->GetPad(3); // FMD3i
1279  fRingMap[4] = middle->GetPad(3); // FMD3o
1280  fRingMap[5] = middle->GetPad(1); // Free
1281  }
1282  else {
1283  TVirtualPad* right = fBody->cd(3);
1284  right->Divide(fLandscape ? 2 : 3);
1285  fRingMap[1] = middle->GetPad(1); // FMD2i
1286  fRingMap[2] = middle->GetPad(2); // FMD2o
1287  fRingMap[3] = right->GetPad(1); // FMD3i
1288  fRingMap[4] = right->GetPad(2); // FMD3o
1289  fRingMap[5] = left->GetPad(2); // Free
1290  }
1291  }
1292  else {
1293  // Divide into two - left/right
1294  // Portrait:
1295  // +----------+----------+
1296  // | 1: FMD1i | 2: Free |
1297  // +----------+----------+
1298  // +----------+----------+
1299  // | 1: FMD2i | 2: FMD2o |
1300  // +----------+----------+
1301  // +----------+----------+
1302  // | 1: FMD3i | 2: FMD3o |
1303  // +----------+----------+
1304  //
1305  // Landscape:
1306  // +----------+----------+----------+
1307  // | 1: FMD1i | 2: FMD2i | 3: FMD3i |
1308  // +----------+----------+----------+
1309  // +----------+----------+----------+
1310  // | 1: Free | 2: FMD2o | 3: FMD3o |
1311  // +----------+----------+----------+
1312  //
1313  fBody->Divide(1, fLandscape ? 2 : 3);
1314  TVirtualPad* top = fBody->cd(1);
1315  top->Divide(fLandscape ? 3 : 2);
1316  TVirtualPad* middle = fBody->cd(2);
1317  middle->Divide(fLandscape ? 3 : 2);
1318 
1319  fRingMap[0] = top->GetPad(1); // FMD1i;
1320  if (!fLandscape) {
1321  TVirtualPad* bottom = fBody->cd(2);
1322  bottom->Divide(2);
1323 
1324  fRingMap[1] = middle->GetPad(1); // FMD2i
1325  fRingMap[2] = middle->GetPad(2); // FMD2o
1326  fRingMap[3] = bottom->GetPad(1); // FMD3i
1327  fRingMap[4] = bottom->GetPad(2); // FMD3o
1328  fRingMap[5] = top->GetPad(2); // Free
1329  }
1330  else {
1331  fRingMap[1] = top->GetPad(2); // FMD2i
1332  fRingMap[2] = middle->GetPad(2); // FMD2o
1333  fRingMap[3] = top->GetPad(3); // FMD3i
1334  fRingMap[4] = middle->GetPad(3); // FMD3o
1335  fRingMap[5] = middle->GetPad(1); // Free
1336  }
1337  }
1338  if (fRingMap[0]) fRingMap[0]->SetTitle("FMD1i");
1339  if (fRingMap[1]) fRingMap[1]->SetTitle("FMD2i");
1340  if (fRingMap[2]) fRingMap[2]->SetTitle("FMD2o");
1341  if (fRingMap[3]) fRingMap[3]->SetTitle("FMD3i");
1342  if (fRingMap[4]) fRingMap[4]->SetTitle("FMD3o");
1343  if (fRingMap[5]) fRingMap[5]->SetTitle("Other");
1344  }
1345  //__________________________________________________________________
1346  TVirtualPad* RingPad(UShort_t d, Char_t r) const
1347  {
1348  Int_t idx = 0;
1349  switch (d) {
1350  case 0: idx = 5; break;
1351  case 1: idx = 0; break;
1352  case 2: idx = 1 + ((r == 'I' || r == 'i') ? 0 : 1); break;
1353  case 3: idx = 3 + ((r == 'I' || r == 'i') ? 0 : 1); break;
1354  default: return 0;
1355  }
1356  return fRingMap[idx];
1357  // return fBody->GetPad(no);
1358  }
1359  //__________________________________________________________________
1360  TVirtualPad* RingPad(const char* name) const
1361  {
1362  TString n(name);
1363  Int_t idx = n.Index("FMD");
1364  if (n == kNPOS) return 0;
1365  n.Remove(0, idx+3);
1366  Int_t det = n.Atoi();
1367  n.Remove(0,1);
1368  Char_t rng = n[0];
1369  return RingPad(det, rng);
1370  }
1371  //__________________________________________________________________
1383  Char_t r,
1384  TObject* h,
1385  Option_t* opts="",
1386  UShort_t flags=0x0,
1387  const char* title="")
1388  {
1389  TVirtualPad* p = RingPad(d, r);
1390  if (!p) {
1391  Warning("DrawInRingPad", "No pad found for FMD%d%c", d, r);
1392  return;
1393  }
1394  DrawInPad(p, h, opts, flags, title);
1395  }
1405  void DrawInRingPad(const char* name,
1406  TObject* h,
1407  Option_t* opts="",
1408  UShort_t flags=0x0,
1409  const char* title="")
1410  {
1411  TVirtualPad* p = RingPad(name);
1412  if (!p) {
1413  Warning("DrawInRingPad", "No pad found for \"%s\"", name);
1414  return;
1415  }
1416  DrawInPad(p, h, opts, flags, title);
1417  }
1429  Option_t* opts="",
1430  UShort_t flags=0x0,
1431  const char* title="")
1432  {
1433  if (!h) return;
1434  TVirtualPad* p = RingPad(h->GetName());
1435  if (!p) {
1436  p = RingPad(h->GetTitle());
1437  if (!p) {
1438  Warning("DrawInRingPad", "No pad found for %s/%s",
1439  h->GetName(), h->GetTitle());
1440  return;
1441  }
1442  }
1443  DrawInPad(p, h, opts, flags, title);
1444  }
1445 
1446 
1447  //__________________________________________________________________
1452  void Pause()
1453  {
1454  if (!fPause) return;
1455  // printf("Press space to continue");
1456  fCanvas->WaitPrimitive();
1457  // std::cin.get();
1458  }
1459  static void CompileScript(const TString& name,
1460  const TString& sub,
1461  const TString& check,
1462  Bool_t force)
1463  {
1464  if (!check.IsNull() && gROOT->GetClass(check)) return;
1465 
1466  TString fwd =gSystem->ExpandPathName("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2");
1467  TString macPath(gROOT->GetMacroPath());
1468  TString incPath(gSystem->GetIncludePath());
1469  if (!macPath.Contains(fwd)) macPath.Append(Form(":%s", fwd.Data()));
1470  if (!incPath.Contains(fwd)) gSystem->AddIncludePath(Form("-I%s",
1471  fwd.Data()));
1472  if (!sub.IsNull()) {
1473  TObjArray* subs = sub.Tokenize(": ");
1474  TObject* pSub = 0;
1475  TIter iSub(subs);
1476  while ((pSub = iSub())) {
1477  TString subDir = gSystem->ConcatFileName(fwd, pSub->GetName());
1478  if (!macPath.Contains(subDir))
1479  macPath.Append(Form(":%s", subDir.Data()));
1480  if (!incPath.Contains(subDir))
1481  gSystem->AddIncludePath(Form("-I%s", subDir.Data()));
1482  }
1483  }
1484  gROOT->SetMacroPath(macPath);
1485  gROOT->LoadMacro(Form("%s%s", name.Data(), (force ? "++g" : "+")));
1486  }
1487  //____________________________________________________________________
1488  virtual void DrawEventInspector(TCollection* parent)
1489  {
1490  Info("DrawEventInspector", "Drawing event inspector");
1491  TCollection* c = GetCollection(parent, "fmdEventInspector");
1492  if (!c) return;
1493 
1494  UShort_t sys=0, sNN=0;
1495  Int_t field=0;
1496  ULong_t runNo=0;
1497  Int_t lowFlux=0, nPileUp=0, ipMethod=0;
1498  ULong_t aliRev=0, aliBra=0;
1499  Bool_t v0and=false;
1500  Double_t dPileUp=0.;
1501  Double_t y = .8;
1502 
1503  fBody->cd();
1504 
1505  Double_t save = fParName->GetTextSize();
1506  fParName->SetTextSize(0.03);
1507  fParVal->SetTextSize(0.03);
1508 
1509  GetParameter(c, "sys", sys);
1510  GetParameter(c, "sNN", sNN);
1511  GetParameter(c, "field", field);
1512  GetParameter(c, "runNo", runNo);
1513  GetParameter(c, "lowFlux", lowFlux);
1514  GetParameter(c, "ipMethod", ipMethod, false);
1515  GetParameter(c, "v0and", v0and);
1516  GetParameter(c, "nPileUp", nPileUp);
1517  GetParameter(c, "dPileup", dPileUp);
1518  GetParameter(c, "alirootRev", aliRev);
1519  GetParameter(c, "alirootBranch", aliBra);
1520 
1521  TString tS; SysString(sys, tS); DrawParameter(y, "System", tS);
1522  TString tE; SNNString(sNN, tE); DrawParameter(y, "#sqrt{s_{NN}}", tE);
1523  DrawParameter(y, "L3 B field", Form("%+2dkG", field));
1524  DrawParameter(y, "Run #", Form("%lu", runNo));
1525  DrawParameter(y, "Low flux cut", Form("%d", lowFlux));
1526  TString sIpMeth("unknown");
1527  switch(ipMethod) {
1528  case 0: sIpMeth = "Normal"; break;
1529  case 1: sIpMeth = "pA in 2012"; break;
1530  case 2: sIpMeth = "pA in 2013"; break;
1531  case 3: sIpMeth = "PWG-UD"; break;
1532  case 4: sIpMeth = "Satellite"; break;
1533  }
1534  DrawParameter(y, "Use PWG-UD vertex", sIpMeth);
1535  DrawParameter(y, "Use V0AND for NSD", (v0and ? "yes" : "no"));
1536  DrawParameter(y, "Least # of pile-up vertex", Form("%d", nPileUp));
1537  DrawParameter(y, "Least distance of pile-up vertex",
1538  Form("%fcm", dPileUp));
1539  DrawParameter(y, "AliROOT", Form("%lu/0x%08lx", ULong_t(aliRev),
1540  ULong_t(aliBra)));
1541 
1542  TH1* triggers = GetH1(c, "triggers");
1543  TH1* vertex = GetH1(c, "vertex", false);
1544  Bool_t mc = (vertex != 0);
1545  if (mc) {
1546  Int_t nInelMC = vertex->GetEntries();
1547  Int_t nInel = triggers->GetBinContent(1);
1548  Int_t nNSDMC = triggers->GetBinContent(11);
1549  Int_t nNSD = triggers->GetBinContent(4);
1550  DrawParameter(y,
1551  Form("#varepsilon_{INEL} = #bf{%d/%d}", nInel, nInelMC),
1552  Form("%5.3f", float(nInel)/nInelMC));
1553  DrawParameter(y,
1554  Form("#varepsilon_{NSD} = #bf{%d/%d}", nNSD, nNSDMC),
1555  Form("%5.3f", float(nNSD)/nNSDMC));
1556  }
1557 
1558  PrintCanvas("Event Inspector");
1559  fParName->SetTextSize(save);
1560  fParVal->SetTextSize(save);
1561 
1562  if (fLandscape) fBody->Divide(4,2);
1563  else fBody->Divide(2,4);
1564 
1565  TH1* nEventsTr = GetH1(c, "nEventsTr");
1566  TH1* nEventsTrVtx = GetH1(c, "nEventsTrVtx");
1567  TH1* nEventsAcc = GetH1(c, "nEventsAccepted");
1568  if (nEventsTr) nEventsTr->Rebin(2);
1569  if (nEventsTrVtx) nEventsTrVtx->Rebin(2);
1570  if (vertex) {
1571  // vertex->Rebin(2);
1572  vertex->SetFillColor(kMagenta+2);
1573  }
1574  DrawInPad(fBody, 1, nEventsTr, "", kLogy,
1575  "Events w/trigger, trigger+vertex, accepted");
1576  if (vertex) DrawInPad(fBody, 1, vertex, "same");
1577  DrawInPad(fBody, 1, nEventsTrVtx, "same");
1578  DrawInPad(fBody, 1, nEventsAcc, "same", kLegend);
1579 
1580 
1581  DrawInPad(fBody, 2, GetH2(c, "nEventsAcceptedXY"), "colz", kLogz);
1582  DrawInPad(fBody, 3, triggers, "hist text");
1583  if (GetH1(c, "trgStatus"))
1584  DrawInPad(fBody, 4, GetH1(c, "trgStatus"), "hist text");
1585  else // Old one
1586  DrawInPad(fBody, 4, GetH2(c, "triggerCorr"), "colz", kLogz);
1587  DrawInPad(fBody, 5, GetH1(c, "status"), "hist text");
1588  if (GetH1(c, "vtxStatus"))
1589  DrawInPad(fBody, 6, GetH1(c, "vtxStatus"), "hist text");
1590  else // old
1591  DrawInPad(fBody, 6, GetH1(c, "type"), "hist text");
1592 
1593  TH1* cent = GetH1(c, "cent");
1594  if (cent) {
1595  cent->Scale(1, "width");
1596  DrawInPad(fBody, 7, cent, "", kLogy);
1597  }
1598 
1599  TH1* pileupStatus = GetH1(c, "pileupStatus", false);
1600  if (pileupStatus) DrawInPad(fBody, 8, pileupStatus, "hist text30");
1601  else {
1602  TH2* centQual = GetH2(c, "centVsQuality");
1603  if (centQual) {
1604  centQual->Scale(1, "width");
1605  DrawInPad(fBody, 8, centQual, "colz", kLogz);
1606  }
1607  }
1608 
1609  PrintCanvas("EventInspector - Histograms");
1610 
1611  if (!mc) return; // not MC
1612 
1613  TH1* phiR = GetH1(c, "phiR");
1614  TH1* b = GetH1(c, "b");
1615  TH2* bVsNpart = GetH2(c, "bVsParticipants");
1616  TH2* bVsNbin = GetH2(c, "bVsBinary");
1617  TH2* bVsCent = GetH2(c, "bVsCentrality");
1618  TH2* vzComparison = GetH2(c, "vzComparison");
1619  TH2* centVsNpart = GetH2(c, "centralityVsParticipans");// Spelling!
1620  TH2* centVsNbin = GetH2(c, "centralityVsBinary");
1621 
1622  fBody->Divide(2,3);
1623 
1624  DrawInPad(fBody, 1, phiR);
1625  DrawInPad(fBody, 2, vzComparison, "colz", kLogz);
1626  DrawInPad(fBody, 3, b);
1627 
1628  TProfile* nPartB = bVsNpart->ProfileX("nPartB",1,-1,"s");
1629  TProfile* nBinB = bVsNbin->ProfileX("nBinB",1,-1,"s");
1630  nPartB->SetMarkerColor(kBlue+2);
1631  nPartB->SetMarkerStyle(20);
1632  nPartB->SetLineColor(kBlue+2);
1633  nPartB->SetFillColor(kBlue-10);
1634  nPartB->SetFillStyle(1001);
1635  nPartB->SetMarkerSize(0.7);
1636  nBinB->SetMarkerColor(kRed+2);
1637  nBinB->SetMarkerStyle(21);
1638  nBinB->SetLineColor(kRed+2);
1639  nBinB->SetFillColor(kRed-10);
1640  nBinB->SetMarkerSize(0.7);
1641  nBinB->SetFillStyle(1001);
1642 
1643  DrawTwoInPad(fBody, 4, nPartB, nBinB, "e3 p", kLegend);
1644 
1645  DrawInPad(fBody, 5, bVsCent, "colz", kLogz);
1646 
1647  TProfile* nPartC = centVsNpart->ProfileY("nPartC",1,-1,"s");
1648  TProfile* nBinC = centVsNbin->ProfileY("nBinC",1,-1,"s");
1649  nPartC->SetMarkerColor(kBlue+2);
1650  nPartC->SetMarkerStyle(20);
1651  nPartC->SetLineColor(kBlue+2);
1652  nPartC->SetFillColor(kBlue-10);
1653  nPartC->SetFillStyle(1001);
1654  nPartC->SetMarkerSize(0.7);
1655  nBinC->SetMarkerColor(kRed+2);
1656  nBinC->SetMarkerStyle(21);
1657  nBinC->SetLineColor(kRed+2);
1658  nBinC->SetFillColor(kRed-10);
1659  nBinC->SetMarkerSize(0.7);
1660  nBinC->SetFillStyle(1001);
1661 
1662  DrawTwoInPad(fBody, 6, nPartC, nBinC, "e3 p", kLegend);
1663 
1664  PrintCanvas("EventInspector - Monte-Carlo");
1665  }
1666  //____________________________________________________________________
1667  virtual void DrawESDFixer(TCollection* parent)
1668  {
1669  Info("DrawESDFixer", "Drawing ESD fixer");
1670  TCollection* c = GetCollection(parent, "fmdESDFixer");
1671  if (!c) return;
1672 
1673  Int_t recoFactor = 0;
1674  Bool_t recalcEta = false;
1675  Bool_t invalidIsEmpty = false;
1676 
1677  fBody->cd();
1678 
1679  Double_t save = fParName->GetTextSize();
1680  fParName->SetTextSize(0.05);
1681  fParVal->SetTextSize(0.05);
1682 
1683  fBody->Divide(2,2);
1684  fBody->cd(1);
1685 
1686  Double_t y = .8;
1687  if (GetParameter(c, "recoFactor", recoFactor))
1688  DrawParameter(y, "Noise factor used in reco",
1689  Form("%d (assumed)", recoFactor));
1690  if (GetParameter(c, "recalcEta", recalcEta))
1691  DrawParameter(y, "Recalculate #eta",
1692  Form("%s", (recalcEta ? "yes" : "no")));
1693  if (GetParameter(c, "invalidIsEmpty", invalidIsEmpty))
1694  DrawParameter(y, "Assume invalid strips are empty",
1695  Form("%s", (invalidIsEmpty ? "yes" : "no")));
1696 
1697  TCollection* xd = GetCollection(c, "extraDead");
1698  if (xd)
1699  DrawParameter(y, "# extra dead strips",
1700  Form("%d", xd->GetEntries()));
1701 
1702  DrawInPad(fBody, 2, GetH1(c, "noiseChange"), "", kLogy);
1703  DrawInPad(fBody, 3, GetH1(c, "etaChange"), "", kLogy);
1704  DrawInPad(fBody, 4, GetH1(c, "deadChange"), "", kLogy);
1705 
1706  PrintCanvas("ESD Fixer");
1707  fParName->SetTextSize(save);
1708  fParVal->SetTextSize(save);
1709  }
1710  //____________________________________________________________________
1712  const char* folderName="mcTrackDensity")
1713  {
1714  Info("DrawTrackDensity", "Drawing track density");
1715 
1716  // --- MC --------------------------------------------------------
1717  TCollection* mc = GetCollection(parent, folderName, false);
1718  if (!mc) return; // Not MC
1719 
1720  fBody->Divide(2,3);
1721  DrawInPad(fBody, 1, GetH2(mc, "binFlow"), "colz", kLogz);
1722  DrawInPad(fBody, 2, GetH2(mc, "binFlowEta"), "colz", kLogz);
1723  DrawInPad(fBody, 3, GetH2(mc, "binFlowPhi"), "colz", kLogz);
1724  DrawInPad(fBody, 4, GetH1(mc, "nRefs"), "", kLogy,
1725  "# of references");
1726  DrawInPad(fBody, 4, GetH1(mc, "clusterRefs", false), "same");
1727  DrawInPad(fBody, 4, GetH1(mc, "clusterSize", false), "same");
1728  DrawInPad(fBody, 4, GetH1(mc, "nClusters", false), "same", kLegend);
1729  DrawInPad(fBody, 5, GetH2(mc, "clusterVsRefs", false),"colz", kLogz);
1730 
1731  PrintCanvas("Track density");
1732  }
1733  //__________________________________________________________________
1734  TCanvas* fCanvas; // Our canvas
1735  TPad* fTop; // Top part
1736  TPad* fBody; // Body part
1737  TLatex* fHeader; // Header text
1738  TLatex* fParName; // Parameter name
1739  TLatex* fParVal; // Parameter value
1740  Bool_t fPause; // Whether to pause after drawing a canvas
1741  Bool_t fLandscape; // Landscape or Portrait orientation
1742  TVirtualPad** fRingMap;
1745 };
1746 #if 0
1747 template <>
1748 inline Bool_t
1749 SummaryDrawer::DoGetParameter<Double_t>(TObject* o, const TObject* p,
1750  Double_t& value)
1751 {
1752  TParameter<Double_t>* r = DoGetObject<TParameter<Double_t>(o, p);
1753  UInt_t i = o->GetUniqueID();
1754  Float_t v = *reinterpret_cast<Float_t*>(&i);
1755  value = v;
1756  return true;
1757 }
1758 #endif
1759 inline Bool_t
1761  const TString& name,
1762  Double_t& value,
1763  Bool_t verb)
1764 
1765 {
1766  return DoGetParameter(GetObject(c, name, verb), c, value);
1767 }
1768 
1769 #endif
1770 //
1771 // EOF
1772 //
1773 
TObject * DrawInPad(TVirtualPad *p, TObject *h, Option_t *opts="", UInt_t flags=0x0, const char *title="")
TLatex * fHeader
return jsonbuilder str().c_str()
TLatex * fParName
double Double_t
Definition: External.C:58
static Bool_t GetParameter(const TObject *c, const TString &name, Int_t &value, Bool_t verb=true)
TVirtualPad * RingPad(const char *name) const
const char * title
Definition: MakeQAPdf.C:26
static TH1 * GetH1(const TObject *parent, const TString &name, Bool_t verb=true)
Definition: External.C:244
static TH2 * GetH2(const TObject *parent, const TString &name, Bool_t verb=true)
TString fLastTitle
void DrawInRingPad(UShort_t d, Char_t r, TObject *h, Option_t *opts="", UShort_t flags=0x0, const char *title="")
void DrawInRingPad(const char *name, TObject *h, Option_t *opts="", UShort_t flags=0x0, const char *title="")
void Divide(Bool_t commonX, Bool_t commonY)
void DrawTrackDensity(TCollection *parent, const char *folderName="mcTrackDensity")
TSystem * gSystem
char Char_t
Definition: External.C:18
static Bool_t DoGetParameter(TObject *o, const TObject *p, T &value)
TList * list
TLegend * DrawRingLegend(TVirtualPad *p, UInt_t flags)
static void TriggerString(ULong_t trigger, TString &str)
TCanvas * c
Definition: TestFitELoss.C:172
static Bool_t CheckType(const TObject *o, const TClass *cl, const TString &src)
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
TVirtualPad ** fRingMap
static Bool_t GetParameter(const TObject *c, const TString &name, Bool_t &value, Bool_t verb=true)
void MakeChapter(const TString &title)
static void SysString(UShort_t sys, TString &str)
static TH3 * GetH3(const TCollection *parent, const TString &name, Bool_t verb=true)
static void GetLegendPosition(UInt_t flags, TVirtualPad *p, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
TCanvas * fCanvas
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
virtual ~SummaryDrawer()
Definition: SummaryDrawer.C:99
static Bool_t GetParameter(const TObject *c, const TString &name, Short_t &value, Bool_t verb=true)
static Bool_t GetParameter(const TObject *c, const TString &name, ULong_t &value, Bool_t verb=true)
TVirtualPad * GetPad(Int_t idx)
TVirtualPad * GetPad(Int_t iCol, Int_t iRow)
static TObject * GetObject(const TObject *parent, const TString &name, Bool_t verb=true)
unsigned long ULong_t
Definition: External.C:38
void CreateCanvas(const TString &pname, Bool_t landscape=false, Bool_t pdf=true, Bool_t useTop=true)
TLegend * MakeLegend(TVirtualPad *p, UInt_t flags, Bool_t autoFill)
void DrawParameter(Double_t &y, const TString &name, const TString &value, Double_t size=0)
virtual TObject * DrawObjClone(THStack *o, Option_t *options, const char *title)
short Short_t
Definition: External.C:23
static const Char_t ** GetRingNames(Bool_t lower=false)
void PrintCanvas(const TString &title, Float_t size=.7)
const char * fwd
Int_t GetIdx(Int_t iCol, Int_t iRow) const
static void AppendAnd(TString &trg, const TString &what)
static void SNNString(UShort_t sNN, TString &str)
void CloseCanvas()
virtual void DrawEventInspector(TCollection *parent)
void DivideForRings(Bool_t commonX, Bool_t commonY)
TLatex * fParVal
Definition: External.C:220
static void CompileScript(const TString &name, const TString &sub, const TString &check, Bool_t force)
static Bool_t GetParameter(const TObject *c, const TString &name, UShort_t &value, Bool_t verb=true)
DividedPad(TVirtualPad *p, Bool_t landscape, Int_t nCol, Int_t nRow)
void DrawTParameter(Double_t &y, TList *list, const TString &name)
virtual TObject * DrawObjClone(TObject *o, Option_t *options, const char *title)
unsigned short UShort_t
Definition: External.C:28
void DrawTwoInPad(TVirtualPad *c, Int_t padNo, TH1 *h1, TH1 *h2, Option_t *opts="", UShort_t flags=0x0)
const char Option_t
Definition: External.C:48
bool landscape
Definition: DrawAnaELoss.C:32
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
void DrawInRingPad(TObject *h, Option_t *opts="", UShort_t flags=0x0, const char *title="")
virtual void DrawESDFixer(TCollection *parent)
virtual TObject * DrawObjClone(TH1 *o, Option_t *options, const char *title)
TVirtualPad * RingPad(UShort_t d, Char_t r) const
static T * DoGetObject(TObject *o, const TObject *p)
static TCollection * GetCollection(const TObject *parent, const TString &name, Bool_t verb=true)
Definition: External.C:196
static Color_t RingColor(UShort_t d, Char_t r)
void ClearCanvas()
static THStack * GetStack(const TObject *parent, const TString &name, const char *sub=0, Bool_t verb=true)