AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliTrackletdNdeta.C
Go to the documentation of this file.
1 
11 #ifndef ALITRACKLETDNDETA_H
12 #define ALITRACKLETDNDETA_H
13 #include <AliTrackletAODUtils.C>
14 #ifndef __CINT__
15 #include <THStack.h>
16 #include <TFile.h>
17 #include <TLatex.h>
18 #include <TCanvas.h>
19 #include <TLegend.h>
20 #include <TError.h>
21 #include <TParameter.h>
22 #include <TMath.h>
23 #include <TLine.h>
24 #include <TLegendEntry.h>
25 #include <TStyle.h>
26 #include <TBrowser.h>
27 #include <TGraphAsymmErrors.h>
28 #include <TProfile.h>
29 #include <TFitResult.h>
30 #include <TF1.h>
31 #include <TSystem.h>
32 #include <TProfile2D.h>
33 #else
34 class TPad;
35 class TLatex;
36 class TObject;
37 class TSeqCollection;
38 class TH1;
39 class TH2;
40 class TF1;
41 class TFitResultPtr;
42 class THStack;
43 class TCanvas;
44 class TVirtualPad;
45 class TFile;
46 class TAxis;
47 class TLegend;
48 class TDirectory;
49 class TProfile2D;
50 #endif
51 
52 //====================================================================
59 {
64  enum {
66  kGeneral = 0x00001,
68  kParameters = 0x00002,
70  kWeights = 0x00004,
72  kdNdetas = 0x00010,
74  kDeltas = 0x00020,
76  kBackgrounds = 0x00040,
78  kAlphas = 0x00080,
80  kPDF = 0x01000,
81  kPNG = 0x01000,
83  kPause = 0x02000,
85  kLandscape = 0x04000,
87  kAltMarker = 0x08000,
89  kDefaultViz = 0x30ff
90  };
95  enum {
97  kRealComb = 0x00001,
99  kSimComb = 0x00002,
101  kScaleNone = 0x00010,
103  kScaleFix = 0x00020,
105  kScaleAverage = 0x00040,
107  kScaleFull = 0x00080,
108  kScaleEta = 0x00100,
110  kScaleDouble = 0x00200,
112  kClosure = 0x01000,
114  kDefaultProc = 0x00083
115  };
116  enum {
117  kTopBackground = kAzure-8
118  };
119  //==================================================================
121  TCanvas* fCanvas;
123  TPad* fTop;
125  TPad* fBody;
135  TLatex* fHeader;
160  void ClearCanvas();
166  void CreateCanvas(const TString& outputName);
171  void CloseCanvas();
179  void PrintCanvas(const char* title,
180  const char* shortTitle="page",
181  Float_t size=.7);
182  //____________________________________________________________________
193  TLegend* DrawInPad(TVirtualPad* c, Int_t pad, TObject* o, Option_t* opt);
194  /* @} */
195  //____________________________________________________________________
207  TFile* OpenFile(const char* filename);
221  TH1* SetAttr(TH1* h,
222  Color_t color,
223  Style_t marker=20,
224  Double_t size=1.,
225  Style_t fill=0,
226  Style_t line=1,
227  Width_t width=1);
228  /* @} */
229  //____________________________________________________________________
241  void DrawParam(const char* name, Double_t& y, const char* val);
249  void DrawParam(const char* name, Double_t& y, Double_t val);
257  void DrawParam(const char* name, Double_t& y, Int_t val);
265  void DrawParam(const char* name, Double_t& y, Bool_t val);
273  void DrawParams(Container* pars, const char* title, Bool_t comb);
280  void DrawParams(Container* realSums, Container* simSums);
281  /* @} */
282  //____________________________________________________________________
299  THStack* Make2Stack(const char* name,
300  const char* title,
301  Container* realList,
302  Container* simList,
303  Option_t* dataOpt="",
304  Option_t* simOpt="");
311  void DrawGeneral(Container* realList, Container* simList);
317  void DrawWeights(Container* simList);
318  /* @} */
319  //____________________________________________________________________
333  TH1* FindDelta(Container* ress, const char* sub, Bool_t scaled=false);
334  TH1* FindDelta(Container* realList, Container* simList,
335  const char* sub, TH2*& scaleH,
336  Double_t& scale, Double_t& scaleE);
346  TH1* FindSub(Container* ress, const char* sub, const char* name);
353  void DrawDeltas(Container* realList, Container* simList);
360  void DrawScalars(Container* realList, Container* simList);
373  Double_t DrawBackground(TVirtualPad* c,
374  Int_t pad,
375  Container* ress,
376  const char* name,
377  const char** which,
378  const char* pretty);
385  void DrawBackground(Container* realList, Container* simList);
393  TH2* CutAlpha(TH2* alpha);
400  void DrawAlpha(Container* realList, Container* simList);
401  /* @} */
402  //__________________________________________________________________
412  const char* ObsTitle() const { return "d#it{N}_{ch}/d#eta"; }
422  Style_t MS(Int_t what, Bool_t sim, Bool_t alt) const;
423 
434  TH2* GetScaledCombi(TH2* h,
435  Container* realList,
436  Container* simList,
437  TH1*& scale);
447  TH2* GetRealBackground(Container* realList,
448  Container* simList,
449  TH1*& scale);
459  TH2* GetRealSignal(Container* realList,
460  Container* simList,
461  TH1*& scale);
471  TH2* GetSim(Container* simList,
472  const char* name,
473  const char* newName);
550  TF1* DrawdNdeta(Container* realList,
551  Container* simList,
552  Color_t color=kBlack,
553  THStack* stack=0,
554  TDirectory* out=0,
555  Bool_t alt=false);
556  //====================================================================
569  void ProcessBin(Int_t bin,
570  Double_t c1, Double_t c2,
571  Container* realList, Container* simList,
572  THStack* stack=0, TDirectory* out=0,
573  TH1* mid=0);
574  //====================================================================
585  void Run(UInt_t proc = kDefaultProc,
586  UInt_t viz = kDefaultViz,
587  UShort_t maxBins = 9,
588  const char* dataName = "data.root",
589  const char* simName = "sim.root",
590  const char* output = 0);
601  void Run(const char* proc,
602  const char* viz,
603  const char* dataName = "data.root",
604  const char* simName = "sim.root",
605  const char* output = 0,
606  UShort_t maxBins = 9);
607 
608 };
609 
610 
611 //____________________________________________________________________
614  fCanvas(0),
615  fTop(0),
616  fBody(0),
617  fViz(0),
618  fProc(0),
619  fLastTitle(""),
620  fLastBin(""),
621  fHeader(0),
622  fDeltaCut(0),
623  fTailDelta(0),
624  fMaxDelta(0),
625  fCombinatoricsScale(1.3),
626  fAlphaMin(0),
627  fAlphaMax(2.5)
628 {}
629 //====================================================================
630 namespace {
631  struct SuppressGuard
632  {
633  Int_t save = 0;
634  SuppressGuard(Int_t lvl=2000)
635  {
636  save = gErrorIgnoreLevel;
637  gErrorIgnoreLevel = lvl;
638  }
640  {
641  gErrorIgnoreLevel = save;
642  }
643  };
644 }
645 
646 //____________________________________________________________________
648 {
649  fTop->Clear();
650  fTop->SetNumber(1);
651  fTop->SetFillColor(kTopBackground);
652  fTop->SetFillStyle(1001);
653  fTop->SetBorderSize(0);
654  fTop->SetBorderMode(0);
655 
656  fBody->Clear();
657  fBody->SetNumber(2);
658  fBody->SetFillColor(0);
659  fBody->SetFillStyle(0);
660  fBody->SetBorderSize(0);
661  fBody->SetBorderMode(0);
662  fBody->SetTopMargin(0.01);
663  fBody->SetRightMargin(0.01);
664  fBody->SetBottomMargin(0.10);
665  fBody->SetLeftMargin(0.10);
666  fBody->SetTicks();
667 
668  fCanvas->cd();
669 }
670 //____________________________________________________________________
672 {
673  gStyle->SetOptStat(0);
674  gStyle->SetOptTitle(0);
675 
676  Int_t h = 1000;
677  Int_t w = h / TMath::Sqrt(2);
678  if (fViz & kLandscape) {
679  Int_t t = h;
680  h = w;
681  w = t;
682  }
683 
684  fCanvas = new TCanvas("c",outputName,w,h);
685  fCanvas->SetFillColor(0);
686  fCanvas->SetBorderSize(0);
687  fCanvas->SetBorderMode(0);
688 
689  if (fViz & kPDF) {
690  SuppressGuard g;
691  fCanvas->Print(Form("%s.pdf[", outputName.Data()),
692  Form("pdf %s", (fViz & kLandscape) ? "Landscape" : ""));
693  }
694  if (fViz & kPNG) {
695  gSystem->mkdir(outputName.Data(),1);
696  }
697  fCanvas->SetLeftMargin (0.10);
698  fCanvas->SetRightMargin (0.05);
699  fCanvas->SetTopMargin (0.05);
700  fCanvas->SetBottomMargin(0.10);
701 
702  Float_t dy = 0.05;
703  fTop = new TPad("top","Top",0,1-dy,1,1,0,0);
704  // fTop->SetNumber(1);
705  // fTop->SetFillColor(kTopBackground);
706  // fTop->SetBorderSize(0);
707  // fTop->SetBorderMode(0);
708  fCanvas->cd();
709  fTop->Draw();
710 
711  fBody = new TPad("body","Body",0,0,1,1-dy,0,0);
712  fBody->SetNumber(2);
713  // fBody->SetFillColor(0);
714  // fBody->SetFillStyle(0);
715  // fBody->SetBorderSize(0);
716  // fBody->SetBorderMode(0);
717  fCanvas->cd();
718  fBody->Draw();
719 
720  ClearCanvas();
721 
722  fHeader = new TLatex(.5, .5, "Title");
723  fHeader->SetNDC();
724  fHeader->SetTextAlign(22);
725  // fHeader->SetTextColor(kWhite);
726  fHeader->SetTextFont(62);
727  fHeader->SetTextSize(0.7);
728 
729  fCanvas->cd();
730 }
731 //____________________________________________________________________
733 {
734  if ((fViz & kPDF) && fCanvas) {
735  SuppressGuard g;
736  fCanvas->Print(Form("%s.pdf]", fCanvas->GetTitle()),
737  Form("pdf %s Title:%s",
738  (fViz & kLandscape) ? "Landscape" : "",
739  fLastTitle.Data()));
740  Printf("PDF %s written", fCanvas->GetTitle());
741  }
742  if (fCanvas) fCanvas->Close();
743  fCanvas = 0;
744 }
745 
746 //____________________________________________________________________
748  const char* shortTitle,
749  Float_t size)
750 {
751  static Int_t cnt = 0;
752  if (fTop) {
753  fTop->cd();
754  fHeader->SetTextSize(size);
755  fHeader->DrawLatex(.5,.5,title);
756  }
757  fCanvas->Modified();
758  fCanvas->Update();
759  fCanvas->cd();
760 
761  if (fViz & kPDF) {
762  TString tit;
763  tit.Form("pdf %s Title:%s", (fViz & kLandscape) ? "Landscape" : "", title);
764  // Suppress prints
765  SuppressGuard g;
766  fCanvas->Print(Form("%s.pdf", fCanvas->GetTitle()), tit);
767  }
768  if (fViz & kPNG) {
769  SuppressGuard g;
770  fCanvas->Print(Form("%s/%03d_%s.png", fCanvas->GetTitle(), shortTitle));
771  }
772  fLastTitle = title;
773  if (fViz & kPause) fCanvas->WaitPrimitive();
774 }
775 //====================================================================
777 {
778  TFile* file = TFile::Open(filename, "READ");
779  if (!file) {
780  Warning("OpenFile", "Failed to open \"%s\"", filename);
781  return 0;
782  }
783  return file;
784 }
785 //____________________________________________________________________
787  Color_t color,
788  Style_t marker,
789  Double_t size,
790  Style_t fill,
791  Style_t line,
792  Width_t width)
793 {
794  h->SetMarkerColor(color);
795  h->SetMarkerStyle(marker);
796  h->SetMarkerSize(size);
797  h->SetFillColor(color);
798  h->SetFillStyle(fill);
799  h->SetLineColor(color);
800  h->SetLineStyle(line);
801  h->SetLineWidth(width);
802  h->GetXaxis()->SetNdivisions(210);
803  h->GetYaxis()->SetNdivisions(210);
804 }
805 
806 //____________________________________________________________________
807 TLegend* AliTrackletdNdeta::DrawInPad(TVirtualPad* c,
808  Int_t pad,
809  TObject* o,
810  Option_t* opt)
811 {
812  if (!o) {
813  // Warning("", "Nothing to draw in pad %d", pad);
814  return 0;
815  }
816  TLegend* l = 0;
817  TVirtualPad* p = c->cd(pad);
818  TString option(opt);
819  option.ToLower();
820  if (option.Contains("logx")) { p->SetLogx(); option.ReplaceAll("logx",""); }
821  if (option.Contains("logy")) { p->SetLogy(); option.ReplaceAll("logy",""); }
822  if (option.Contains("logz")) { p->SetLogz(); option.ReplaceAll("logz",""); }
823  if (option.Contains("grid")) { p->SetGridx(); p->SetGridy();
824  option.ReplaceAll("grid",""); }
825  Int_t leg = 0;
826  if (option.Contains("leg2")) { leg = 2; option.ReplaceAll("leg2",""); }
827  if (option.Contains("leg")) { leg = 1; option.ReplaceAll("leg",""); }
828  o->Draw(opt);
829  if (leg) {
830  l = p->BuildLegend(0.5, 0.73, .98, .98);
831  l->SetNColumns(leg);
832  TObject* frame = 0;
833  TIter next(l->GetListOfPrimitives());
834  TLegendEntry* ent = 0;
835  while ((ent = static_cast<TLegendEntry*>(next()))) {
836  if (TString(ent->GetLabel()).EqualTo("frame")) frame = ent;
837  }
838  if (frame) l->GetListOfPrimitives()->Remove(frame);
839  // l->GetListOfPrimitives()->Print();
840  }
841  p->Modified();
842  // p->Update();
843  // p->cd();
844  return l;
845 }
846 //====================================================================
847 void AliTrackletdNdeta::DrawParam(const char* name,
848  Double_t& y,
849  const char* val)
850 {
851  TLatex* ln = new TLatex(.49, y, name);
852  ln->SetTextAlign(31);
853  ln->SetTextSize(0.02/gPad->GetHNDC());
854  ln->SetNDC();
855  ln->Draw();
856  TLatex* lv = new TLatex(.51, y, val);
857  lv->SetTextAlign(11);
858  lv->SetTextSize(0.02/gPad->GetHNDC());
859  lv->SetNDC();
860  lv->Draw();
861  y -= 0.025/gPad->GetHNDC();
862 }
863 //____________________________________________________________________
864 void AliTrackletdNdeta::DrawParam(const char* name,
865  Double_t& y,
866  Double_t val)
867 {
868  DrawParam(name, y, Form("%f", val));
869 }
870 //____________________________________________________________________
871 void AliTrackletdNdeta::DrawParam(const char* name,
872  Double_t& y,
873  Int_t val)
874 {
875  DrawParam(name, y, Form("%d", val));
876 }
877 //____________________________________________________________________
878 void AliTrackletdNdeta::DrawParam(const char* name,
879  Double_t& y,
880  Bool_t val)
881 {
882  DrawParam(name, y, val ? "yes" : "no");
883 }
884 //____________________________________________________________________
886  const char* title,
887  Bool_t comb)
888 {
889  // c->Clear();
890  Double_t y = .9;
891  TLatex* latex = new TLatex(.5, y, title);
892  latex->SetTextAlign(21);
893  latex->SetTextSize(0.023/gPad->GetHNDC());
894  latex->SetNDC();
895  latex->Draw();
896  y -= 0.028/gPad->GetHNDC();
897  if (!pars) return;
898  DrawParam("#delta#phi shift", y, GetD(pars, "DPhiShift"));
899  DrawParam("Shifted #delta#phi cut",y, GetD(pars, "ShiftedDPhiCut"));
900  DrawParam("#Delta cut", y, GetD(pars, "DeltaCut"));
901  DrawParam("max#Delta", y, GetD(pars, "MaxDelta"));
902  DrawParam("min#Delta_{tail}", y, GetD(pars,"TailDelta"));
903  DrawParam("abs.min#it{c}", y, GetD(pars,"AbsMinCent"));
904  y -= 0.045;
905  DrawParam("Background method", y, comb ? "Combinatorics" : "Injected");
906 }
907 //____________________________________________________________________
909 {
910  ClearCanvas();
911  fBody->Divide(1,3,0,0);
912 
913  Double_t yr = .1;
914  TVirtualPad* p1 = fBody->GetPad(1); p1->SetPad(0,1-yr,1,1);
915  TVirtualPad* p2 = fBody->GetPad(2); p2->SetPad(0,(1-yr)/2,1,1-yr);
916  TVirtualPad* p3 = fBody->GetPad(3); p3->SetPad(0,0,1,(1-yr)/2);
917 
918  // Post-processing stuff
919  fBody->cd(1);
920  Double_t y = .80;
921  TLatex* latex = new TLatex(.5, y, "Post-processing");
922  latex->SetTextAlign(21);
923  latex->SetTextSize(0.023/p1->GetHNDC());
924  latex->SetNDC();
925  latex->Draw();
926  y -= 0.028/p1->GetHNDC();
927  TString scaleM("none");
928  if (fProc & kScaleNone) scaleM = "none";
929  else if (fProc & kScaleFix) scaleM.Form("%4.2f", fCombinatoricsScale);
930  else if (fProc & kScaleAverage) scaleM = "average";
931  else if (fProc & kScaleFull) scaleM = "full";
932  if (fProc & kScaleDouble) scaleM.Append(" (double)");
933  DrawParam("Scaling of comb. bg.", y, scaleM);
934  DrawParam("min#alpha", y, fAlphaMin);
935  DrawParam("max#alpha", y, fAlphaMax);
936 
937  // From tasks
938  fBody->cd(2);
939  DrawParams(GetC(realSums, "parameters"), "Real data", (fProc & kRealComb));
940  fBody->cd(3);
941  DrawParams(GetC(simSums, "parameters"), "Simulated data",(fProc & kSimComb));
942  PrintCanvas("Parameters", "parameters");
943 }
944 //____________________________________________________________________
945 void ModLegend(TVirtualPad* p, TLegend* l,
946  Double_t x1, Double_t y1,
947  Double_t x2, Double_t y2)
948 {
949  Double_t px1 = p->GetX1();
950  Double_t px2 = p->GetX2();
951  Double_t py1 = p->GetY1();
952  Double_t py2 = p->GetY2();
953  l->SetX1(px1+(px2-px1)*x1);
954  l->SetX2(px1+(px2-px1)*x2);
955  l->SetY1(py1+(py2-py1)*y1);
956  l->SetY2(py1+(py2-py1)*y2);
957  p->Modified();
958 }
959 //====================================================================
960 THStack* AliTrackletdNdeta::Make2Stack(const char* name,
961  const char* title,
962  Container* realList,
963  Container* simList,
964  Option_t* realOpt,
965  Option_t* simOpt)
966 {
967  TString nme(name);
968  THStack* stack = new THStack(name, title);
969  TH1* real = CopyH1(realList, name, Form("real%s",name));
970  TH1* sim = CopyH1(simList, name, Form("sim%s",name));
971  real->SetMarkerStyle(20);
972  sim ->SetMarkerStyle(24);
973  real->SetFillStyle(3004);
974  sim ->SetFillStyle(3005);
975  real->SetBarWidth(0.4);
976  sim ->SetBarWidth(0.4);
977  real->SetBarOffset(0.1);
978  sim ->SetBarOffset(0.5);
979  TString dtit(real->GetTitle());
980  if (dtit.Contains("\\")) dtit.Form("%s\\hbox{ - real}", real->GetTitle());
981  else dtit.Form("%s - real", real->GetTitle());
982  real->SetTitle(dtit);
983  TString stit(sim->GetTitle());
984  if (stit.Contains("\\")) stit.Form("%s\\hbox{ - sim.}", sim->GetTitle());
985  else stit.Form("%s - sim.", sim->GetTitle());
986  sim->SetTitle(stit);
987  stack->Add(real, realOpt);
988  stack->Add(sim, simOpt);
989  return stack;
990 }
991 
992 //____________________________________________________________________
994  Container* simList)
995 {
996  THStack* ipz = Make2Stack("ipz", "IP_{#it{z}}", realList,simList);
997  THStack* cent = Make2Stack("cent", "Centrality [%]", realList,simList);
998  THStack* status = Make2Stack("status","Task status", realList,simList,
999  "B text90", "B text90");
1000  THStack* centTr = Make2Stack("centTracklets", "#LTtracklets#GT",
1001  realList, simList, "E", "E");
1002  ClearCanvas();
1003  fBody->Divide(1,3);
1004  for (Int_t i = 1; i <= 3; i++) {
1005  if (i < 3) fBody->GetPad(i)->SetRightMargin(0.01);
1006  fBody->GetPad(i)->SetTopMargin(0.01);
1007  }
1008  TLegend* l = 0;
1009  TVirtualPad* q = fBody->GetPad(1);
1010  q->Divide(2,1);
1011  l = DrawInPad(q,1,ipz, "nostack leg");
1012  ModLegend(q->GetPad(1),l,.4,.1,.75,.4);
1013  l = DrawInPad(q,2,cent, "nostack leg");
1014  ModLegend(q->GetPad(2),l,.6,.1,.99,.4);
1015  q = fBody->GetPad(2);
1016  q->Divide(2,1);
1017  l = DrawInPad(q,1,status, "nostack hist text90 leg");
1018  ModLegend(q->GetPad(1),l,.5,.7,.99,.99);
1019  l = DrawInPad(q,2,centTr, "nostack leg");
1020  ModLegend(q->GetPad(2),l,.5,.7,.99,.99);
1021 
1022  TH2* real = GetH2(realList, "etaPhi");
1023  TH2* sim = GetH2(simList, "etaPhi");
1024  if (sim) {
1025  sim->SetMarkerColor(kBlack);
1026  sim->SetMarkerStyle(0);
1027  sim->SetMarkerSize(1);
1028  sim->SetLineColor(kBlack);
1029  sim->SetFillColor(kBlack);
1030  sim->SetFillStyle(0);
1031  sim->SetName("simEtaPhi");
1032  }
1033  DrawInPad(fBody, 3, real, "colz");
1034  DrawInPad(fBody, 3, sim, "box same");
1035 
1036  PrintCanvas("General information", "general");
1037 }
1038 
1039 namespace {
1040  void SetCentColors(THStack* s)
1041  {
1042  if (!s->GetHists()) return;
1043 
1044  const Color_t cc[] = { kMagenta+2, // 0
1045  kBlue+2, // 1
1046  kAzure-1, // 2 // 10,
1047  kCyan+2, // 3
1048  kGreen+1, // 4
1049  kSpring+5, // 5 //+10,
1050  kYellow+1, // 6
1051  kOrange+5, // 7 //+10,
1052  kRed+1, // 8
1053  kPink+5, // 9 //+10,
1054  kBlack }; // 10
1055  TIter next(s->GetHists());
1056  TH1* h = 0;
1057  Int_t i = 0;
1058  Double_t min = +10000;
1059  Double_t max = -10000;
1060  while ((h = static_cast<TH1*>(next()))) {
1061  Color_t c = cc[i % 10];
1062  h->SetMarkerColor(c);
1063  h->SetFillColor(c);
1064  h->SetLineColor(c);
1065  h->SetMarkerStyle(20+(i%4));
1066  min = TMath::Min(h->GetMinimum(), min);
1067  max = TMath::Max(h->GetMaximum(), max);
1068  i++;
1069  }
1070  s->SetMinimum(min*.9);
1071  s->SetMaximum(max*1.1);
1072  }
1073  THStack* GetPdgStack(AliTrackletAODUtils::Container* w, const char* name)
1074  {
1076  if (!c) return 0;
1077 
1078  THStack* s = new THStack(name, "");
1079  TH1* h = 0;
1080  TIter n(c);
1081  while ((h = static_cast<TH1*>(n()))) s->Add(h);
1082 
1083  return s;
1084  }
1085 }
1086 //____________________________________________________________________
1088 {
1089  Container* w = GetC(simList,"weights", false);
1090  if (!w) return;
1091 
1092  ClearCanvas();
1093  fBody->Divide(1,3);
1094 
1095  THStack* ef = new THStack(GetP2(simList,"etaWeight"),"x","effWeights","");
1096  THStack* pt = new THStack(GetH2(w, "centPt"), "y","pt","");
1097  THStack* ab = GetPdgStack(w, "abundance");
1098  THStack* st = GetPdgStack(w, "strangeness");
1099  SetCentColors(ef);
1100  SetCentColors(pt);
1101  SetCentColors(ab);
1102  SetCentColors(st);
1103 
1104  DrawInPad(fBody, 1, ef, "nostack");
1105  DrawInPad(fBody, 2, pt, "nostack");
1106 
1107  TVirtualPad* p3 = fBody->GetPad(3);
1108  p3->Divide(2,1);
1109 
1110  DrawInPad(p3, 1, ab, "nostack leg");
1111  DrawInPad(p3, 2, st, "nostack leg");
1112 
1113  PrintCanvas("Simulation weights", "weights");
1114 }
1115 
1116 //====================================================================
1118  const char* sub,
1119  const char* name)
1120 {
1121  if (!ress) return 0;
1122  TObjArray* tokens = TString(sub).Tokenize("/");
1123  Container* subCont = ress;
1124  TIter next(tokens);
1125  TObjString* dir = 0;
1126  while ((dir = static_cast<TObjString*>(next()))) {
1127  subCont = GetC(ress, dir->GetName());
1128  if (!subCont) break;
1129  }
1130  TH1* ret = 0;
1131  if (subCont) ret = GetH1(subCont, name);
1132  tokens->Delete();
1133  return ret;
1134 }
1135 //____________________________________________________________________
1137  const char* sub,
1138  Bool_t scaled)
1139 {
1140  if (!ress) return 0;
1141 
1142  Container* subCont = GetC(ress, sub);
1143  if (!subCont) return 0;
1144 
1145  TH1* h = CopyH1(subCont, scaled ? "scaledDelta" : "delta");
1146  if (!h) return 0;
1147 
1148  return h;
1149 }
1150 //____________________________________________________________________
1152  Container* simList,
1153  const char* sub,
1154  TH2*& scaleH,
1155  Double_t& scale,
1156  Double_t& scaleE)
1157 {
1158  if (!realList || !simList) return 0;
1159 
1160  Container* simSub = GetC(simList, sub);
1161  if (!simSub) return 0;
1162 
1163  TH3* h = GetH3(simSub, "etaDeltaIPz");
1164  if (!h) return 0;
1165  if (!scaleH) {
1166  Info("", "Scaled histogram not found, making it");
1167  Container* realSub = GetC(realList, sub);
1168  if (!realSub) return 0;
1169 
1170  Double_t realV = GetD(realSub, "deltaTail");
1171  Double_t realE = GetD(realSub, "deltaTailError");
1172  Double_t simV = GetD(simSub, "deltaTail");
1173  Double_t simE = GetD(simSub, "deltaTailError");
1174  scale = RatioE(realV,realE,simV,simE,scaleE);
1175  Info("", "integrated scalar: %5.3f +/- %5.3f", scale, scaleE);
1176 
1177  scaleH = CopyH2(realSub, "etaIPzDeltaTail");
1178  scaleH->SetDirectory(0);
1179  scaleH->SetName("scale");
1180  scaleH->SetZTitle("k_{I,#eta,IP_{#it{z}}}");
1181  scaleH->SetTitle(Form("%5.3f#times#eta,IP_{#it{z}} scalar",scale));
1182  scaleH->Divide(GetH2(simSub, "etaIPzDeltaTail"));
1183  }
1184  Printf("Scaling %s/%s by %s - %5.3f", h->GetName(), h->GetTitle(),
1185  scaleH->GetName(), scale);
1186 #if 0
1187  TH3* scaled = ScaleDelta(h, scaleH);
1188  TH2* etaDelta = ProjectEtaDelta(scaled);
1189  TH1* ret = ProjectDelta(etaDelta);
1190 #else
1191  TH1* ret = CopyH1(simSub, "delta", "scaledDelta");
1192  Scale(ret, scale, scaleE);
1193 #endif
1194  ret->SetName("scaledDelta");
1195  ret->SetTitle(Form("%5.3f#times%s", scale, h->GetTitle()));
1196  return ret;
1197 }
1198 //____________________________________________________________________
1200 {
1201 
1202  ClearCanvas();
1203  fBody->Divide(1,3,0,0);
1204  fBody->GetPad(1)->SetRightMargin(0.01);
1205  fBody->GetPad(2)->SetRightMargin(0.01);
1206  fBody->GetPad(3)->SetRightMargin(0.01);
1207 
1208 
1209  TH1* rm = 0;
1210  TH1* ri = 0;
1211  TH1* sm = 0;
1212  TH1* si = 0;
1213  TH1* sc = 0;
1214  TH1* sp = 0;
1215  TH1* st = 0;
1216  THStack* orig = new THStack("orig", "#Delta");
1217  orig->Add(rm = FindDelta(realList, "measured", false));
1218  orig->Add(sm = FindDelta(simList, "measured", false));
1219  orig->Add(ri = FindDelta(realList, "injected", false));
1220  orig->Add(si = FindDelta(simList, "injected", false));
1221  orig->Add(sc = FindDelta(simList, "combinatorics", false));
1222  orig->Add(sp = FindDelta(simList, "primaries", false));
1223  orig->Add(st = FindDelta(simList, "secondaries", false));
1224  if (rm) { SetAttr(rm, kRed+2, 20, 1); }
1225  if (ri) { SetAttr(ri, kOrange+2, 21, 1); }
1226  if (sm) { SetAttr(sm, kRed+2, 24, 1.3); }
1227  if (si) { SetAttr(si, kOrange+2, 25, 1.3); }
1228  if (sc) { SetAttr(sc, kGreen+2, 26); }
1229  if (sp) { SetAttr(sp, kMagenta+2, 30); }
1230  if (st) { SetAttr(st, kMagenta+2, 31); }
1231 
1232  Double_t scale = 0, scaleE = 0;
1233  TH2* scaleH = 0;
1234  THStack* scaled = new THStack("scaled", "#Delta (scaled)");
1235  scaled->Add(rm = FindDelta(realList, "measured", false));
1236  scaled->Add(sm = FindDelta(realList, simList, "measured",
1237  scaleH, scale, scaleE));
1238  scaled->Add(ri = FindDelta(realList, "injected", true));
1239 #if 0
1240  TH3* si3 =
1241  ScaleDelta(GetH3(GetC(simList,"injected"),"scaledEtaDeltaIPz"), scaleH);
1242  si3->SetTitle(Form("%5.3f#times%s",scale,si3->GetTitle()));
1243  scaled->Add(si = ProjectDelta(ProjectEtaDelta(si3)));
1244 #else
1245  scaled->Add(si = FindDelta(simList, "injected", true));
1246  if (si) {
1247  Scale(si, scale, scaleE);
1248  si->SetTitle(Form("%5.3f#times%s",scale,si->GetTitle()));
1249  }
1250 #endif
1251  scaled->Add(sc = FindDelta(realList, simList, "combinatorics",
1252  scaleH, scale, scaleE));
1253  scaled->Add(sp = FindDelta(realList, simList, "primaries",
1254  scaleH, scale, scaleE));
1255  scaled->Add(st = FindDelta(realList, simList, "secondaries",
1256  scaleH, scale, scaleE));
1257  if (rm) { SetAttr(rm, kRed+2, 20, 1); }
1258  if (ri) { SetAttr(ri, kOrange+2, 21, 1); }
1259  if (sm) { SetAttr(sm, kRed+2, 24, 1.3); }
1260  if (si) { SetAttr(si, kOrange+2, 25, 1.3); }
1261  if (sc) { SetAttr(sc, kGreen+2, 26); }
1262  if (sp) { SetAttr(sp, kMagenta+2, 30); }
1263  if (st) { SetAttr(st, kMagenta+2, 31); }
1264 
1265  Double_t max = /*5*/1.2*orig->GetMaximum("nostack");
1266  TH1* templ = FindDelta(realList, "measured", false);
1267  TH2* frame = new TH2D("frame","",
1268  templ->GetNbinsX(),
1269  templ->GetXaxis()->GetXmin(),
1270  templ->GetXaxis()->GetXmax(),
1271  500, 0.001, max);
1272  frame->SetXTitle(templ->GetXaxis()->GetTitle());
1273  frame->SetYTitle(templ->GetYaxis()->GetTitle());
1274  frame->SetStats(0);
1275  frame->SetDirectory(0);
1276  TLine* cuts = new TLine(fDeltaCut, 0.001, fDeltaCut, .99*max);
1277  cuts->SetLineColor(kGreen+1);
1278  frame->GetListOfFunctions()->Add(cuts);
1279  TLine* cutt = new TLine(fTailDelta, 0.001, fTailDelta, .99*max);
1280  cutt->SetLineColor(kRed+1);
1281  frame->GetListOfFunctions()->Add(cutt);
1282 
1283  TLegend* l = 0;
1284  TH1* f1 = static_cast<TH1*>(frame->Clone());
1285  f1->SetDirectory(0);
1286  DrawInPad(fBody, 1, f1, "axis logx logy grid");
1287  l = DrawInPad(fBody, 1, orig, "nostack same leg2");
1288  ModLegend(fBody->GetPad(1), l,
1289  fBody->GetPad(1)->GetLeftMargin(),
1290  fBody->GetPad(1)->GetBottomMargin(),
1291  .6, .35);
1292 
1293 
1294  TH1* f2 = static_cast<TH1*>(frame->Clone());
1295  f2->SetDirectory(0);
1296  DrawInPad(fBody, 2, f2, "axis logx logy grid");
1297  l = DrawInPad(fBody, 2, scaled, "nostack same leg2");
1298  ModLegend(fBody->GetPad(2), l,
1299  fBody->GetPad(2)->GetLeftMargin(),
1300  fBody->GetPad(2)->GetBottomMargin(),
1301  .6, .45);
1302 
1303  THStack* ratios = new THStack("ratios","");
1304  TH1* jm = static_cast<TH1*>(sm->Clone("rm"));
1305  jm->Divide(rm);
1306  jm->SetDirectory(0);
1307  jm->SetTitle(Form("%s / %s", sm->GetTitle(), rm->GetTitle()));
1308  ratios->Add(jm);
1309  TH1* ji = static_cast<TH1*>(si->Clone("sic"));
1310  ji->Divide(sc);
1311  ji->SetDirectory(0);
1312  ji->SetTitle(Form("%s / %s", si->GetTitle(), sc->GetTitle()));
1313  ratios->Add(ji);
1314  TH1* ki = static_cast<TH1*>(ri->Clone("ric"));
1315  ki->Divide(sc);
1316  ki->SetDirectory(0);
1317  ki->SetTitle(Form("%s / %s", ri->GetTitle(), sc->GetTitle()));
1318  ratios->Add(ki);
1319  l = DrawInPad(fBody, 3, ratios, "nostack logx grid leg");
1320  ModLegend(fBody->GetPad(3), l,
1321  fBody->GetPad(3)->GetLeftMargin(),
1322  fBody->GetPad(3)->GetBottomMargin(),
1323  .6, .45);
1324 
1325  PrintCanvas(Form("%s - #Delta", fLastBin.Data()),
1326  Form("%s_delta", realList->GetName()));
1327 
1328  if ((fProc & kScaleFull|kScaleAverage) == 0) return;
1329 
1330  DrawScalars(realList, simList);
1331 }
1332 
1333 //____________________________________________________________________
1335 {
1336 
1337  ClearCanvas();
1338 
1339  Container* realInjected = GetC(realList, "injected");
1340  Container* simInjected = GetC(simList, "injected");
1341  Container* realMeasured = GetC(realList, "measured");
1342  Container* simMeasured = GetC(simList, "measured");
1343  TH1* realIPz = GetH1(realList, "ipz");
1344  TH1* simIPz = GetH1(simList, "ipz");
1345  TH2* real2D = GetH2(realMeasured, "etaDelta");
1346  TH2* sim2D = GetH2(simMeasured, "etaDelta");
1347  TH1* realD = 0;
1348  TH1* simD = 0;
1349  TH1* scale = 0;
1350  if (fProc & kScaleFull) {
1351  TH2* realIE = GetH2(realMeasured, "etaIPzDeltaTail");
1352  TH2* simIE = GetH2(simMeasured, "etaIPzDeltaTail");
1353  TH2* scaleIE = static_cast<TH2*>(realIE->Clone("scaleIE"));
1354  scaleIE->Divide(simIE);
1355  scaleIE->SetDirectory(0);
1356  scale = AverageOverIPz(scaleIE, "scale", 1, 0, 0);
1357  realD = realIE ->ProjectionX("realD");
1358  simD = simIE ->ProjectionX("simD");
1359  realD->SetDirectory(0);
1360  simD ->SetDirectory(0);
1361  }
1362  else {
1363  if (fProc & kScaleEta) {
1364  if (!(fProc & kScaleDouble)) {
1365  realD = GetH1(realMeasured, "etaDeltaTail");
1366  simD = GetH1(simMeasured, "etaDeltaTail");
1367  }
1368  else {
1369  realD = GetH1(realInjected, "etaDeltaTailRatio");
1370  simD = GetH1(simInjected, "etaDeltaTailRatio");
1371  }
1372  }
1373  else {
1374  Double_t realV = 1, realE = 0, simV = 1, simE = 0;
1375  if (fProc & kScaleAverage) {
1376  if (!(fProc & kScaleDouble)) {
1377  realV = GetD(realMeasured, "deltaTail");
1378  realE = GetD(realMeasured, "deltaTailError");
1379  simV = GetD(simMeasured, "deltaTail");
1380  simE = GetD(simMeasured, "deltaTailError");
1381  }
1382  else {
1383  realV = GetD(realInjected, "deltaTailRatio");
1384  realE = GetD(realInjected, "deltaTailRatioError");
1385  simV = GetD(simInjected, "deltaTailRatio");
1386  simE = GetD(simInjected, "deltaTailRatioError");
1387  }
1388  }
1389  else if (fProc & kScaleFix)
1390  realV = fCombinatoricsScale;
1391 
1392  realD = Make1D(0, "realD", "Integral of tail", kBlack, 23,
1393  *real2D->GetXaxis());
1394  simD = Make1D(0, "simD", "Integral of tail", kBlack, 23,
1395  *sim2D->GetXaxis());
1396  for (Int_t i = 1; i <= realD->GetNbinsX(); i++) {
1397  realD->SetBinContent(i, realV);
1398  realD->SetBinError (i, realE);
1399  simD ->SetBinContent(i, simV);
1400  simD ->SetBinError (i, simE);
1401  }
1402  }
1403  scale = static_cast<TH1*>(realD->Clone("scale"));
1404  scale->Divide(simD);
1405  scale->SetFillStyle(0);
1406  }
1407  if (!realD || !simD) {
1408  Warning("DrawScalars",
1409  "Real (%p) or simulated (%p) distribution not found",
1410  realD, simD);
1411  return;
1412  }
1413 
1414  fBody->Divide(1,2);
1415  TVirtualPad* top = fBody->GetPad(1);
1416  top->SetRightMargin(0.01);
1417  top->SetTopMargin(0.01);
1418  top->Divide(2,1,0,0);
1419  DrawInPad(top, 1, real2D, "logy logz colz");
1420  DrawInPad(top, 2, sim2D, "logy logz colz");
1421 
1422  TVirtualPad* bot = fBody->GetPad(2);
1423  bot->SetRightMargin(0.01);
1424  bot->SetTopMargin(0.01);
1425  bot->Divide(1,2,0,0);
1426  bot->GetPad(1)->SetRightMargin(0.01);
1427  bot->GetPad(2)->SetRightMargin(0.01);
1428  THStack* ints = new THStack("ints","");
1429  ints->Add(realD);
1430  ints->Add(simD);
1431  realD->SetMarkerStyle(20);
1432  simD ->SetMarkerStyle(24);
1433  realD->SetMarkerSize(1.5);
1434  simD ->SetMarkerSize(1.8);
1435  realD->SetMarkerColor(kRed+2);
1436  simD ->SetMarkerColor(kGreen+2);
1437  realD->SetLineColor(kRed+2);
1438  simD ->SetLineColor(kGreen+2);
1439  realD->SetFillStyle(0);
1440  simD ->SetFillStyle(0);
1441  // realD->SetTitle("#int d#Delta d#it{N}/d#Delta - Real");
1442  // simD ->SetTitle("#int d#Delta d#it{N}/d#Delta - Sim.");
1443  TLegend* l = DrawInPad(bot, 1, ints, "nostack grid leg");
1444 
1445  TF1* ff = new TF1("ff", "pol0");
1446  ff->SetLineColor(kBlue+2);
1447  ff->SetLineStyle(2);
1448  scale->Fit(ff, "Q0");
1449  scale->SetTitle(Form("#LTk#GT = %5.2f #pm %5.2f",
1450  ff->GetParameter(0), ff->GetParError(0)));
1451  // delete ff;
1452  DrawInPad(bot,2,scale,"grid");
1453 
1454  ModLegend(bot->GetPad(1),l,.4,.1,.75,.4);
1455 
1456  PrintCanvas(Form("%s - #it{k}", fLastBin.Data()),
1457  Form("%s_scalar", realList->GetName()));
1458 }
1459 
1460 //____________________________________________________________________
1462  Int_t pad,
1463  Container* ress,
1464  const char* name,
1465  const char** what,
1466  const char* pretty)
1467 {
1468  SuppressGuard g(kError);
1469  Container* sc = GetC(ress, name);
1470  TObjArray* hists = new TObjArray(10);
1471  Int_t nHists = 0;
1472  const char** ptr = what;
1473  Double_t max = 0;
1474  while (*ptr) {
1475  TH2* h = CopyH2(sc, *ptr);
1476  if (h) {
1477  hists->AddAt(h, nHists);
1478  h->SetMinimum(0);
1479  TString nme(h->GetName());
1480  if (nme.EqualTo("beta")) h->SetMaximum(.7);
1481  if (nme.EqualTo("etaIPz") || nme.EqualTo("signal")) {
1482  max = TMath::Max(h->GetMaximum(), max);
1483  }
1484  }
1485  nHists++;
1486  ptr++;
1487  }
1488  TVirtualPad* q = c->cd(pad);
1489  q->SetRightMargin(0.10);
1490  q->Divide(nHists,1,0,0);
1491  for (Int_t i = 0; i < nHists; i++) {
1492  TH1* h = static_cast<TH1*>(hists->At(i));
1493  if (!h) continue;
1494  TString nme(h->GetName());
1495  if (!nme.EqualTo("beta") && !nme.EqualTo("etaIPzScale"))
1496  h->SetMaximum(max);
1497  DrawInPad(q,i+1,h,"colz");
1498  }
1499  TVirtualPad* r = q->GetPad(nHists);
1500  r->SetRightMargin(0.12);
1501  r->SetPad(r->GetXlowNDC(), r->GetYlowNDC(),
1502  .99, r->GetYlowNDC()+r->GetHNDC());
1503 
1504  TLatex* ltx = new TLatex(.01,.5, pretty);
1505  ltx->SetNDC();
1506  ltx->SetTextFont(62);
1507  ltx->SetTextAngle(90);
1508  ltx->SetTextAlign(23);
1509  ltx->SetTextSize(0.07);
1510  DrawInPad(q,1,ltx,"");
1511 
1512  return max;
1513 }
1514 //____________________________________________________________________
1516  Container* simList)
1517 {
1518  ClearCanvas();
1519 
1520  const char* what[] = { "etaIPz",
1521  "etaIPzDeltaTail",
1522  "beta",
1523  "background",
1524  "signal",
1525  "etaIPzScale",
1526  0 };
1527  fBody->SetLeftMargin(0.2);
1528  fBody->SetTopMargin(0.10);
1529  fBody->Divide(1,3,0,0);
1530  Double_t max = 0;
1531  max = TMath::Max(max, DrawBackground(fBody, 1, realList,
1532  "injected", what, "Injected - Real"));
1533  max = TMath::Max(max, DrawBackground(fBody, 2, simList,
1534  "injected", what, "Injected - Sim."));
1535  max = TMath::Max(max, DrawBackground(fBody, 3, simList,
1536  "combinatorics", what, "MC Labels"));
1537  Int_t i = 0;
1538  for (i = 1; i <= 4; i++) {
1539  TVirtualPad* p = fBody->GetPad(i);
1540  if (!p) continue;
1541  for (Int_t j = 1; j <= 4; j++) {
1542  TVirtualPad* q = p->GetPad(j);
1543  TH1* h = static_cast<TH1*>(q->FindObject("raw"));
1544  if (h) {
1545  h->SetMaximum(max);
1546  continue;
1547  }
1548  h = static_cast<TH1*>(q->FindObject("bg"));
1549  if (h) h->SetMaximum(max/5);
1550  h = static_cast<TH1*>(q->FindObject("bgEta"));
1551  if (h) h->SetMaximum(max/5);
1552  }
1553  }
1554  Int_t nCol = 6;
1555  const char* headings[] = { "#it{I}, #it{I}', #it{C}'",
1556  "#scale[0.7]{#int}#Delta",
1557  "#beta",
1558  "#it{B}",
1559  "#it{S}",
1560  "#it{k}",
1561  0 };
1562  const char** ptr = headings;
1563  i = 0;
1564  while (*ptr) {
1565  TLatex* head = new TLatex(fBody->GetRightMargin()+
1566  (1-fBody->GetRightMargin())/nCol*(i+.5),
1567  .99, *ptr);
1568  head->SetNDC();
1569  head->SetTextAlign(23);
1570  head->SetTextFont(62);
1571  head->SetTextSize(0.02);
1572  DrawInPad(fBody, 0, head, "");
1573  ptr++;
1574  i++;
1575  }
1576  PrintCanvas(Form("%s - backgrounds", fLastBin.Data()),
1577  Form("%s_background", realList->GetName()));
1578 }
1579 //____________________________________________________________________
1580 void PrintH(TH2* h, Int_t prec=2)
1581 {
1582  Printf("Content of %s - %s", h->GetName(), h->GetTitle());
1583  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
1584  printf("%3d: ", i);
1585  for (Int_t j = 1; j <= h->GetNbinsY(); j++) {
1586  Double_t c = h->GetBinContent(i,j);
1587  Double_t e = h->GetBinError (i,j);
1588  if (TMath::IsNaN(c) || TMath::IsNaN(e))
1589  printf("*** NAN ***");
1590  else
1591  printf("%.*f+/-%.*f ", prec, c, prec, e);
1592  }
1593  printf("\n");
1594  }
1595 }
1596 //____________________________________________________________________
1598 {
1599  TH2* r = static_cast<TH2*>(h->Clone("fiducial"));
1600  r->SetDirectory(0);
1601  r->Reset();
1602  r->SetTitle("Fiducial cut");
1603  for (Int_t i = 1; i <= r->GetNbinsX(); i++) {
1604  for (Int_t j = 1; j <= r->GetNbinsY(); j++) {
1605  Double_t c = h->GetBinContent(i,j);
1606  if (c <= fAlphaMin || c > fAlphaMax) continue;
1607  r->SetBinContent(i,j,1);
1608  r->SetBinError (i,j,0);
1609  }
1610  }
1611  // PrintH(h, 1);
1612  // PrintH(r, 0);
1613  return r;
1614 }
1615 
1616 //____________________________________________________________________
1618 {
1619  ClearCanvas();
1620 
1621  fBody->SetLeftMargin(0.2);
1622  fBody->SetRightMargin(0.01);
1623  fBody->SetTopMargin(0.01);
1624  fBody->Divide(1,2,0,0);
1625  TH2* alphaInj = CopyH2(GetC(simList, "injected"), "alpha");
1626  TH2* alphaComb = CopyH2(GetC(simList, "combinatorics"), "alpha");
1627  if (alphaInj) {
1628  alphaInj ->SetMinimum(fAlphaMin);
1629  alphaInj ->SetMaximum(fAlphaMax);
1630  }
1631  if (alphaComb) {
1632  alphaComb ->SetMinimum(fAlphaMin);
1633  alphaComb ->SetMaximum(fAlphaMax);
1634  }
1635  fBody->GetPad(1)->SetRightMargin(0.15);
1636  fBody->GetPad(2)->SetRightMargin(0.15);
1637  DrawInPad(fBody, 1, alphaInj, "colz");
1638  DrawInPad(fBody, 2, alphaComb, "colz");
1639 
1640  TLatex* ltx = new TLatex(.01,.5, "Injection");
1641  ltx->SetNDC();
1642  ltx->SetTextFont(62);
1643  ltx->SetTextAngle(90);
1644  ltx->SetTextAlign(23);
1645  ltx->SetTextSize(0.07);
1646  DrawInPad(fBody,1,ltx,"");
1647 
1648  ltx = new TLatex(.01,.5, "Combinatorics");
1649  ltx->SetNDC();
1650  ltx->SetTextFont(62);
1651  ltx->SetTextAngle(90);
1652  ltx->SetTextAlign(23);
1653  ltx->SetTextSize(0.07);
1654  DrawInPad(fBody,2,ltx,"");
1655 
1656  PrintCanvas(Form("%s - #alpha", fLastBin.Data()),
1657  Form("%s_alpha", realList->GetName()));
1658 }
1659 //____________________________________________________________________
1660 Style_t AliTrackletdNdeta::MS(Int_t what, Bool_t sim, Bool_t alt) const
1661 {
1662  if (!alt) {
1663  switch (what) {
1664  case 0: /* dndeta */ return (sim ? 24 : 20); // cirlce
1665  case 1: /* M */ return (sim ? 24 : 20); // circle
1666  case 2: /* B */ return (sim ? 25 : 21); // square
1667  case 3: /* S */ return (sim ? 26 : 22); // up-triangle
1668  default: return (sim ? 5 : 2); //
1669  }
1670  }
1671  switch (what) {
1672  case 0: /* dndeta */ return (sim ? 25 : 21); // square
1673  case 1: /* M */ return (sim ? 28 : 34); // cross
1674  case 2: /* B */ return (sim ? 27 : 33); // diamond
1675  case 3: /* S */ return (sim ? 30 : 29); // star
1676  }
1677  return (sim ? 5 : 2); //
1678 }
1679 
1680 //____________________________________________________________________
1682  Container* realList,
1683  Container* simList,
1684  TH1*& scale)
1685 {
1686 
1687  if (!scale) {
1688  Container* realInjected = GetC(realList, "injected");
1689  Container* simInjected = GetC(simList, "injected");
1690  Container* realMeasured = GetC(realList, "measured");
1691  Container* simMeasured = GetC(simList, "measured");
1692  if (fProc & kScaleFull) {
1693  TH2* realD = 0;
1694  TH2* simD = 0;
1695  if (!(fProc & kScaleDouble)) {
1696  realD = GetH2(realMeasured, "etaIPzDeltaTail");
1697  simD = GetH2(simMeasured, "etaIPzDeltaTail");
1698  }
1699  else {
1700  }
1701  if (!realD || !simD) {
1702  Warning("GetCombiScale",
1703  "Real (%p) or simulated (%p) distribution not found",
1704  realD, simD);
1705  return 0;
1706  }
1707  TH2* tmp2 = static_cast<TH2*>(realD->Clone("scale"));
1708  tmp2->Divide(simD);
1709  scale = tmp2;
1710  TH1* tmp = AverageOverIPz(tmp2, "tmp", 1, 0, 0);
1711  TF1* ff = new TF1("ff", "pol0");
1712  tmp->Fit(ff, "QN0");
1713  scale->SetTitle(Form("#LTk#GT = %5.2f #pm %5.2f",
1714  ff->GetParameter(0), ff->GetParError(0)));
1715  delete ff;
1716  delete tmp;
1717  }
1718  else if (fProc & kScaleEta) {
1719  TH1* realD = 0;
1720  TH1* simD = 0;
1721  if (!(fProc & kScaleDouble)) {
1722  realD = GetH1(realMeasured, "etaDeltaTail");
1723  simD = GetH1(simMeasured, "etaDeltaTail");
1724  }
1725  else {
1726  realD = GetH1(realInjected, "etaDeltaTailRatio");
1727  simD = GetH1(simInjected, "etaDeltaTailRatio");
1728  }
1729  if (!realD || !simD) {
1730  Warning("GetCombiScale",
1731  "Real (%p) or simulated (%p) distribution not found",
1732  realD, simD);
1733  return 0;
1734  }
1735  scale = static_cast<TH1*>(realD->Clone("scale"));
1736  scale->Divide(simD);
1737  scale->SetFillStyle(0);
1738  TF1* ff = new TF1("ff", "pol0");
1739  scale->Fit(ff, "QN0");
1740  scale->SetTitle(Form("#LTk#GT = %5.2f #pm %5.2f",
1741  ff->GetParameter(0), ff->GetParError(0)));
1742  delete ff;
1743 
1744  }
1745  else {
1746  Double_t s = 1, sE = 0;
1747  if (fProc & kScaleAverage) {
1748  Double_t realV, realE, simV, simE;
1749  if (!(fProc & kScaleDouble)) {
1750  realV = GetD(realMeasured, "deltaTail");
1751  realE = GetD(realMeasured, "deltaTailError");
1752  simV = GetD(simMeasured, "deltaTail");
1753  simE = GetD(simMeasured, "deltaTailError");
1754  }
1755  else {
1756  realV = GetD(realInjected, "deltaTailRatio");
1757  realE = GetD(realInjected, "deltaTailRatioError");
1758  simV = GetD(simInjected, "deltaTailRatio");
1759  simE = GetD(simInjected, "deltaTailRatioError");
1760  }
1761  s = RatioE(realV,realE,simV,simE,sE);
1762  }
1763  else if (fProc & kScaleFix) {
1764  s = fCombinatoricsScale;
1765  sE = 0;
1766  }
1767  else if (fProc & kScaleNone) {
1768  s = 1;
1769  sE - 0;
1770  }
1771  scale = Make1D(0, "scale",
1772  Form("k = %5.2f #pm %5.2f", s, sE),
1773  kBlack, 23, *h->GetXaxis());
1774  for (Int_t i = 1; i <= scale->GetNbinsX(); i++) {
1775  scale->SetBinContent(i, s);
1776  scale->SetBinError (i, sE);
1777  }
1778  }
1779  scale->SetDirectory(0);
1780  }
1781  Info("GetScaledCombi",
1782  "Scaling combinatorial background %s with %dD k %s",
1783  h->GetTitle(), scale->GetDimension(), scale->GetTitle());
1784  if (scale->GetDimension() == 2)
1785  h->Multiply(scale);
1786  else
1787  Scale(h, scale);
1788  return h;
1789 }
1790 
1791 
1792 //____________________________________________________________________
1794  Container* simList,
1795  TH1*& scale)
1796 {
1797  if (!(fProc & kRealComb)) {
1798  // Just return background from injection - possibly scaled by eta
1799  // dependent ratio of tails.
1800  Container* realInjected = GetC(realList, "injected");
1801  return CopyH2(realInjected,
1802  (fProc & kScaleAverage) ?
1803  "background" : "backgroundEta",
1804  "realBg");
1805  }
1806  TH2* ret = CopyH2(GetC(simList, "combinatorics"), "background", "realBg");
1807  return GetScaledCombi(ret, realList, simList, scale);
1808 }
1809 //____________________________________________________________________
1811  Container* simList,
1812  TH1*& scale)
1813 {
1814  Container* simInjected = GetC(simList, "injected");
1815 
1816  if (!(fProc & kRealComb)) {
1817  // Just return background from injection - possibly scaled by eta
1818  // dependent ratio of tails.
1819  Container* realInjected = GetC(realList, "injected");
1820  return CopyH2(realInjected,
1821  !(fProc & kScaleFull) ? "signal" : "signalEta",
1822  "realSignal");
1823  }
1824  Container* simComb = GetC(simList, "combinatorics");
1825  TH2* beta = CopyH2(simComb, "beta");
1826  GetScaledCombi(beta, realList, simList, scale);
1827 
1828  TH2* one = CopyH2(simComb, "beta", "one");
1829  one->Reset();
1830  for (Int_t i = 1; i <= one->GetNbinsX(); i++)
1831  for (Int_t j = 1; j <= one->GetNbinsY(); j++)
1832  one->SetBinContent(i,j,1);
1833  // Subtract k times beta
1834  one->Add(beta,-1);
1835  // Multiply on to the measured distribution
1836  TH2* realSig = CopyH2(GetC(realList, "measured"), "etaIPz", "realSig");
1837  realSig->SetMarkerStyle(beta->GetMarkerStyle());
1838  realSig->Multiply(one);
1839  return realSig;
1840 }
1841 //____________________________________________________________________
1843  const char* name,
1844  const char* newName)
1845 {
1846  Bool_t simComb = fProc & kSimComb;
1847  Container* cont = GetC(simList,
1848  (simComb ? "combinatorics" : "injected"));
1849  TString find;
1850  if (simComb || !(fProc & kScaleFull))
1851  find = name;
1852  else
1853  find.Format("%sEta", name);
1854  return CopyH2(cont, find, newName);
1855 }
1856 
1857 //____________________________________________________________________
1859  Container* simList,
1860  Color_t color,
1861  THStack* stack,
1862  TDirectory* out,
1863  Bool_t alt)
1864 {
1865  Bool_t realComb = fProc & kRealComb;
1866  Bool_t simComb = fProc & kSimComb;
1867  Container* realData = GetC(realList, "measured");
1868  Container* simData = GetC(simList, "measured");
1869  Container* simCombC = GetC(simList, "combinatorics");
1870  Container* simBgC = simComb ? simCombC : GetC(simList, "injected");
1871  Container* realBgC = realComb ? simCombC : GetC(realList, "injected");
1872 
1873 
1874  TH1* scale = 0;
1875  TH2* realMeas = CopyH2(realData, "etaIPz", "realMeas");
1876  TH1* realIPz = CopyH1(realList, "ipz", "realIPz");
1877  TH2* realBg = GetRealBackground(realList, simList, scale);
1878  TH2* realSig = GetRealSignal (realList, simList, scale);
1879  if (!realMeas || !realSig || !realBg || !realIPz) {
1880  Warning("DrawdNdeta", "One or more real data histograms missing: "
1881  "meas=%p sig=%p bg=%p ipz=%p", realMeas, realSig, realBg, realIPz);
1882  return 0;
1883  }
1884  if (realBg ->GetMarkerStyle() == 30) realBg ->SetMarkerStyle(29);
1885  if (realBg ->GetMarkerStyle() == 27) realBg ->SetMarkerStyle(33);
1886  if (realSig->GetMarkerStyle() == 30) realSig->SetMarkerStyle(29);
1887  if (realSig->GetMarkerStyle() == 27) realSig->SetMarkerStyle(33);
1888 
1889  TH2* simMeas = CopyH2(simData, "etaIPz", "simMeas");
1890  TH1* simIPz = CopyH1(simList, "ipz", "simIPz");
1891  TH2* simBg = GetSim(simList, "background", "simBg");
1892  TH2* simSig = GetSim(simList, "signal", "simSig");
1893  TH2* alpha = GetSim(simList, "alpha", "alpha");
1894  TH2* fiducial = CutAlpha(alpha);
1895  if (!simMeas || !simSig || !simBg || !simIPz || !alpha) {
1896  Warning("DrawdNdeta", "One or more simuluated data histograms missing: "
1897  "meas=%p sig=%p bg=%p ipz=%p alpha=%p",
1898  simMeas, simSig, simBg, simIPz, alpha);
1899  return 0;
1900  }
1901  alpha->Multiply(fiducial);
1902  TH2* trueGen = CopyH2(GetC(simList, "generated"), "etaIPz", "trueGen");
1903  TH1* trueIPz = CopyH1(simList, "ipz", "trueIPz");
1904  if (!trueGen || !trueIPz) {
1905  Warning("DrawdNdeta", "One or more generator data histograms missing: "
1906  "gen=%p ipz=%p", trueGen, trueIPz);
1907  return 0;
1908  }
1909 
1910  realMeas->SetTitle("Measured (real)");
1911  realBg ->SetTitle("Background (real)");
1912  realSig ->SetTitle("Signal (real)");
1913  realIPz ->SetTitle("IP_{z} (real)");
1914  simMeas ->SetTitle("Measured (simulated)");
1915  simBg ->SetTitle("Background (simulated)");
1916  simSig ->SetTitle("Signal (simulated)");
1917  simIPz ->SetTitle("IP_{z} (simulated)");
1918  trueGen ->SetTitle("Generated");
1919  trueIPz ->SetTitle("IP_{z} (generated)");
1920 
1921  // Create result as alpha times real signal
1922  TH2* result = static_cast<TH2*>(realSig->Clone("result"));
1923  result->SetTitle("Result");
1924  result->SetDirectory(0);
1925  result->Multiply(alpha);
1926 
1927  UShort_t mode = 1;
1928  // Calculate the primary dN/deta
1929  TH1* truth = AverageOverIPz(trueGen, "truth", mode, trueIPz, 0);
1930  truth->SetYTitle(ObsTitle());
1931  SetAttr(truth, color, MS(0,true,alt), 1.5, 0, 7, 1);
1932 
1933  // Calculate the real dN/deta
1934  TH1* dndeta = AverageOverIPz(result, "dndeta", mode, realIPz, 0);
1935  dndeta->SetYTitle(ObsTitle());
1936  SetAttr(dndeta, color, MS(0,false,alt), 1.2, 0, 1, 1);
1937 
1938  // Multiply histograms by fiducial cut
1939  realMeas->Multiply(fiducial);
1940  simMeas ->Multiply(fiducial);
1941  realSig ->Multiply(fiducial);
1942  simSig ->Multiply(fiducial);
1943  realBg ->Multiply(fiducial);
1944  simBg ->Multiply(fiducial);
1945  realSig ->Multiply(fiducial);
1946  simSig ->Multiply(fiducial);
1947  // Get some step histograms. Note, we use the result histogram to
1948  // select which bins we project so that we get the used sub-sample.
1949  TH1* realAvgMeas = AverageOverIPz(realMeas,"realAvgMeas",mode,realIPz,result);
1950  TH1* realAvgSig = AverageOverIPz(realSig, "realAvgSig", mode,realIPz,result);
1951  TH1* realAvgBg = AverageOverIPz(realBg, "realAvgBg", mode,realIPz,result);
1952  TH1* simAvgMeas = AverageOverIPz(simMeas, "simAvgMeas", mode,simIPz, result);
1953  TH1* simAvgSig = AverageOverIPz(simSig, "simAvgSig", mode,simIPz, result);
1954  TH1* simAvgBg = AverageOverIPz(simBg, "simAvgBg", mode,simIPz, result);
1955  SetAttr(realAvgMeas,realAvgMeas->GetMarkerColor(), MS(1,false,alt));
1956  SetAttr(realAvgSig, realAvgSig ->GetMarkerColor(), MS(2,false,alt));
1957  SetAttr(realAvgBg, realAvgSig ->GetMarkerColor(), MS(3,false,alt));
1958  SetAttr(simAvgMeas, simAvgSig ->GetMarkerColor(), MS(1,true, alt));
1959  SetAttr(simAvgSig, simAvgSig ->GetMarkerColor(), MS(2,true, alt));
1960  SetAttr(simAvgBg, simAvgBg ->GetMarkerColor(), MS(3,true, alt));
1961  realAvgMeas->SetYTitle("#LT M#GT");
1962  realAvgSig ->SetYTitle("#LT S#GT");
1963  realAvgBg ->SetYTitle("#LT B#GT");
1964  simAvgMeas ->SetYTitle("#LT M'#GT");
1965  simAvgSig ->SetYTitle("#LT S'#GT");
1966  simAvgBg ->SetYTitle("#LT B'#GT");
1967 
1968  // Put everything together
1969  THStack* summary = new THStack("summary", dndeta->GetYaxis()->GetTitle());
1970  summary->Add(dndeta, "e2");
1971  summary->Add(truth, "e");
1972  summary->Add(realAvgMeas);
1973  summary->Add(simAvgMeas);
1974  summary->Add(realAvgSig);
1975  summary->Add(simAvgSig);
1976  summary->Add(realAvgBg);
1977  summary->Add(simAvgBg);
1978  if (scale) {
1979  if (scale->GetDimension() == 1) summary->Add(scale);
1980  else {
1981  TH1* tmp = AverageOverIPz(static_cast<TH2*>(scale), "scale",1,0,result);
1982  summary->Add(tmp);
1983  }
1984  }
1985 
1986 
1987  ClearCanvas();
1988  fBody->SetLeftMargin(0.15);
1989  TLegend* l = DrawInPad(fBody, 0, summary, "nostack leg2 grid");
1990  summary->GetHistogram()->SetXTitle("#eta");
1991  summary->GetHistogram()->SetYTitle(ObsTitle());
1992  summary->GetHistogram()->GetYaxis()->SetTitleOffset(1.7);
1993  fBody->Modified();
1994  fBody->Update();
1995  fBody->cd();
1996  l->SetName("legend");
1997  l->SetFillStyle(0);
1998  l->SetBorderSize(0);
1999  ModLegend(fBody, l, fBody->GetLeftMargin(), .7, .99, .99);
2000  Double_t lim = .5;
2001  TF1* f = new TF1("ff", "pol0", -lim, lim);
2002  TFitResultPtr r = dndeta->Fit(f, "N0QSR", "", -lim, lim);
2003  // r->Print();
2004  TLatex* ltx = new TLatex(fBody->GetLeftMargin()+
2005  (1-fBody->GetLeftMargin()-fBody->GetRightMargin())/2,
2006  .3,
2007  Form("%s|_{|#eta|<%3.1f}"
2008  "=%6.1f#pm%6.1f (#chi^{2}/#nu=%5.2f)",
2009  ObsTitle(), lim, r->Parameter(0),
2010  r->ParError(0), r->Chi2()/r->Ndf()));
2011  ltx->SetTextAlign(22);
2012  ltx->SetNDC();
2013  ltx->SetTextFont(42);
2014  ltx->SetTextSize(0.035);
2015  ltx->Draw();
2016  printf("%6.1f +/- %6.1f (%5.2f)",
2017  r->Parameter(0), r->ParError(0), r->Chi2()/r->Ndf());
2018  summary->GetHistogram()->GetListOfFunctions()->Add(l);
2019  summary->GetHistogram()->GetListOfFunctions()->Add(ltx);
2020 
2021  fBody->Modified();
2022  if (summary->GetHistogram()->GetMinimum() < 1)
2023  summary->SetMinimum(1);
2024  summary->SetMaximum(1.5*summary->GetMaximum("nostack"));
2025 
2026  if (stack) {
2027  dndeta->SetTitle(fLastBin);
2028  stack->Add(dndeta, "e2");
2029  stack->Add(truth, "e");
2030  }
2031 
2032  if (out) {
2033  out->cd();
2034  result ->Write();
2035  dndeta ->Write();
2036  summary ->Write();
2037  f ->Write();
2038  if (scale) scale->Write();
2039 
2040  TDirectory* details = out->mkdir("details");
2041  details->cd();
2042  realMeas->Write();
2043  realBg ->Write();
2044  realSig ->Write();
2045  simMeas ->Write();
2046  simBg ->Write();
2047  simSig ->Write();
2048  trueGen ->Write();
2049  alpha ->Write();
2050  fiducial->Write();
2051  GetH1(realData, "delta") ->Write("realDataDelta");
2052  GetH1(GetC(realList, "injected"), "delta")->Write("realInjDelta");
2053  GetH1(simData, "delta") ->Write("simDataDelta");
2054  GetH1(GetC(simList, "injected"), "delta") ->Write("simInjDelta");
2055 
2056  TDirectory* averages = out->mkdir("averages");
2057  averages->cd();
2058  realAvgMeas ->Write();
2059  realAvgSig ->Write();
2060  realAvgBg ->Write();
2061  simAvgMeas ->Write();
2062  simAvgSig ->Write();
2063  simAvgBg ->Write();
2064  truth ->Write();
2065  realIPz ->Write();
2066  simIPz ->Write();
2067  trueIPz ->Write();
2068  }
2069  PrintCanvas(Form("%s - %s", fLastBin.Data(),ObsTitle()),
2070  Form("%s_summary", realList->GetName()));
2071 
2072  return f;
2073 }
2074 //____________________________________________________________________
2076  Double_t c1, Double_t c2,
2077  Container* realList, Container* simList,
2078  THStack* stack, TDirectory* out,
2079  TH1* mid)
2080 {
2081  fLastBin.Form("%5.1f%% - %5.1f%%", c1, c2);
2082  printf("Centrality bin %5.1f%% - %5.1f%%: ", c1, c2);
2083  TString name;
2084  name.Form("cent%03dd%02d_%03dd%02d",
2085  Int_t(c1), Int_t(c1*100)%100,
2086  Int_t(c2), Int_t(c2*100)%100);
2087  Container* realListBin = GetC(realList, name);
2088  Container* simListBin = GetC(simList, name);
2089  if (!realListBin || !simListBin) {
2090  Warning("PostBin", "Missing bin for %5.1f%% - %5.1f%% (%s): %p %p",
2091  c1, c2, name.Data(), realListBin, simListBin);
2092  return;
2093  }
2094  const Color_t cc[] = { kMagenta+2, // 0
2095  kBlue+2, // 1
2096  kAzure-1, // 2 // 10,
2097  kCyan+2, // 3
2098  kGreen+1, // 4
2099  kSpring+5, // 5 //+10,
2100  kYellow+1, // 6
2101  kOrange+5, // 7 //+10,
2102  kRed+1, // 8
2103  kPink+5, // 9 //+10,
2104  kBlack }; // 10
2105  Color_t color = (bin <= 0 ? cc[10] : cc[(bin-1)%11]);
2106  TDirectory* binOut = 0;
2107  Bool_t alt = (fViz & kAltMarker);
2108  if (out) binOut = out->mkdir(name);
2109 
2110  TF1* f = 0;
2111  if (fViz & kDeltas) DrawDeltas (realListBin, simListBin);
2112  if (fViz & kBackgrounds) DrawBackground(realListBin, simListBin);
2113  if (fViz & kAlphas) DrawAlpha (realListBin, simListBin);
2114  if (fViz & kdNdetas) f = DrawdNdeta(realListBin, simListBin,
2115  color, stack, binOut, alt);
2116  if (f && mid && bin > 0) {
2117  mid->SetBinContent(bin, f->GetParameter(0));
2118  mid->SetBinError (bin, f->GetParError (0));
2119  }
2120  printf(" done \n");
2121 }
2122 //====================================================================
2123 void AliTrackletdNdeta::Run(const char* sproc,
2124  const char* sviz,
2125  const char* dataName,
2126  const char* simName,
2127  const char* outName,
2128  UShort_t maxBins)
2129 {
2130  UInt_t proc = 0;
2131  UInt_t viz = 0;
2132  TString p(sproc);
2133  TString v(sviz);
2134  if (v.Contains("lan")) viz |= kLandscape;
2135  if (v.Contains("pdf")) viz |= kPDF;
2136  if (v.Contains("pau")) viz |= kPause;
2137  if (v.Contains("gen")) viz |= kGeneral;
2138  if (v.Contains("v.i")) viz |= kWeights;
2139  if (v.Contains("par")) viz |= kParameters;
2140  if (v.Contains("alt")) viz |= kAltMarker;
2141  if (v.Contains("del")) viz |= kDeltas;
2142  if (v.Contains("bak")) viz |= kBackgrounds;
2143  if (v.Contains("alp")) viz |= kAlphas;
2144  if (v.Contains("dnd")) viz |= kdNdetas;
2145 
2146  if (p.Contains("non")) proc |= kScaleNone;
2147  if (p.Contains("fix")) proc |= kScaleFix;
2148  if (p.Contains("avg")) proc |= kScaleAverage;
2149  if (p.Contains("ful")) proc |= kScaleFull;
2150  if (p.Contains("dou")) proc |= kScaleDouble;
2151  if (p.Contains("clo")) proc |= kClosure;
2152  if (p.Contains("com")) proc |= (kRealComb | kSimComb);
2153 
2154  Run(proc, viz, maxBins, dataName, simName, outName);
2155 }
2157  UInt_t viz,
2158  UShort_t maxBins,
2159  const char* dataName,
2160  const char* simName,
2161  const char* outName)
2162 {
2163  fProc = proc;
2164  fViz = viz;
2165  TFile* dataFile = 0;
2166  TFile* simFile = 0;
2167  Printf("***************************************************\n"
2168  " Data file: %s\n"
2169  " Simulation file: %s\n"
2170  " Output file: %s\n",
2171  dataName, simName, outName);
2172 
2173  if (!(dataFile = OpenFile(dataName))) return;
2174  if (!(simFile = OpenFile(simName))) return;
2175 
2176  const char* base = "MidRapidity";
2177  Container* realSums = GetC(dataFile, Form("%sSums", base));
2178  Container* realRess = GetC(dataFile, Form("%sResults", base));
2179  Container* simSums = GetC(simFile, Form("%sMCSums", base));
2180  Container* simRess = GetC(simFile, Form("%sMCResults", base));
2181  if (!realSums || !realRess) {
2182  realSums = GetC(dataFile, Form("%sMCSums", base));
2183  realRess = GetC(dataFile, Form("%sMCResults", base));
2184  if (realSums && realRess)
2185  Warning("Run","\n"
2186  "*********************************************\n"
2187  "* Testing MC vs. MC: *\n"
2188  "* 'Data' file: %23s *\n"
2189  "* Simulation file: %23s *\n"
2190  "*********************************************\n",
2191  dataName, simName);
2192  }
2193  if (!realSums || !realRess || !simSums || !simRess) return;
2194 
2195  Container* params = GetC(realSums, "parameters");
2196  fDeltaCut = GetD(params, "DeltaCut");
2197  fTailDelta = GetD(params, "TailDelta");
2198  fMaxDelta = GetD(params, "MaxDelta");
2199 
2200  TString outBase(outName);
2201  if (outBase.IsNull()) outBase.Form("MiddNdeta_0x%04x", fProc);
2202  if (outBase.EndsWith(".root")) outBase.ReplaceAll(".root", "");
2203 
2204  CreateCanvas(outBase.Data());
2205  if (fViz & kGeneral) DrawGeneral(realRess, simRess);
2206  if (fViz & kWeights) DrawWeights(simRess);
2207  if (fViz & kParameters) DrawParams(realSums, simSums);
2208 
2209  TH1* realCent = CopyH1(realSums, "cent", "realCent");
2210  TH1* simCent = CopyH1(simSums, "cent", "simCent");
2211  TH1* realIPz = GetH1(realSums, "ipz");
2212  TH1* simIPz = GetH1(simSums, "ipz");
2213 
2214  if (!CheckConsistency(realCent, simCent)) {
2215  Warning("Post", "Centrality bins are incompatible, giving up");
2216  return;
2217  }
2218  if (!CheckConsistency(realIPz, simIPz)) {
2219  Warning("Post", "Centrality bins are incompatible, giving up");
2220  return;
2221  }
2222  if (fProc & kClosure) realRess = simRess;
2223 
2224  THStack* stack = new THStack("all", ObsTitle());
2225  // Draw "min-bias" bin
2226  ProcessBin(0, 0, 100, realRess, simRess, stack);
2227 
2228  TFile* out = TFile::Open(Form("%s.root", outBase.Data()), "RECREATE");
2229  TH1* mid = Make1D(0,"mid",Form("%s|_{|#eta|<0.5}", ObsTitle()),
2230  kBlack, 20, *(realCent->GetXaxis()));
2231  mid->SetDirectory(out);
2232  mid->SetXTitle("Centrality [%]");
2233  mid->SetYTitle(mid->GetTitle());
2234  realCent->Write();
2235  simCent ->Write();
2236  for (Int_t i = 1; i <= realCent->GetNbinsX() && i <= maxBins ; i++) {
2237  Double_t c1 = realCent->GetXaxis()->GetBinLowEdge(i);
2238  Double_t c2 = realCent->GetXaxis()->GetBinUpEdge (i);
2239 
2240  ProcessBin(i, c1, c2, realRess, simRess, stack, out, mid);
2241  }
2242  ClearCanvas();
2243  DrawInPad(fBody,0,mid,"E");
2244  PrintCanvas(mid->GetTitle(),"mid");
2245 
2246  if (stack->GetHists() && stack->GetHists()->GetEntries() > 0) {
2247  ClearCanvas();
2248  DrawInPad(fBody, 0, stack, "nostack grid e2");
2249  if (stack->GetHistogram()->GetMinimum() < 1)
2250  stack->SetMinimum(1);
2251  out->cd();
2252  stack->Write();
2253  TFile* res = 0;
2254  {
2255  SuppressGuard g(kFatal);
2256  res = TFile::Open("result.root","READ");
2257  }
2258  if (res) {
2259  THStack* other = GetHS(res, "result");
2260  if (other)
2261  DrawInPad(fBody, 0, other, "nostack same");
2262  out->cd();
2263  other->Write();
2264  }
2265  PrintCanvas(ObsTitle(),"result");
2266  }
2267  Printf("Results stored in %s", out->GetName());
2268  out->Write();
2269  CloseCanvas();
2270 }
2271 
2272 #endif
2273 // Local Variables:
2274 // mode: C++
2275 // End:
2276 
Int_t color[]
void DrawGeneral(Container *realList, Container *simList)
const char * filename
Definition: TestFCM.C:1
TLegend * DrawInPad(TVirtualPad *c, Int_t pad, TObject *o, Option_t *opt)
const Color_t cc[]
Definition: DrawKs.C:1
double Double_t
Definition: External.C:58
Style_t MS(Int_t what, Bool_t sim, Bool_t alt) const
const char * title
Definition: MakeQAPdf.C:26
TH2 * CutAlpha(TH2 *alpha)
Definition: External.C:244
void DrawAlpha(Container *realList, Container *simList)
void DrawParams(Container *pars, const char *title, Bool_t comb)
TSystem * gSystem
static TH1 * GetH1(Container *parent, const char *name, Bool_t verb=true)
static TH3 * ScaleDelta(TH3 *h, TH2 *scale)
TCanvas * c
Definition: TestFitELoss.C:172
void PrintCanvas(const char *title, const char *shortTitle="page", Float_t size=.7)
static TH2 * ProjectEtaDelta(TH3 *h)
static TH1 * AverageOverIPz(TH2 *h, const char *name, UShort_t mode, TH1 *ipz, TH2 *mask=0, Bool_t verb=true)
static TH1 * ProjectDelta(TH2 *h)
TH2 * GetRealSignal(Container *realList, Container *simList, TH1 *&scale)
static Double_t GetD(Container *parent, const char *name, Double_t def=-1, Bool_t verb=true)
static Bool_t CheckConsistency(const TH1 *h1, const TH1 *h2)
Double_t DrawBackground(TVirtualPad *c, Int_t pad, Container *ress, const char *name, const char **which, const char *pretty)
static TH1 * Scale(TH1 *h, Double_t x, Double_t xe)
void PrintH(TH2 *h, Int_t prec=2)
Utilities for midrapidity analysis.
TH1 * FindSub(Container *ress, const char *sub, const char *name)
TH1 * FindDelta(Container *ress, const char *sub, Bool_t scaled=false)
int Int_t
Definition: External.C:63
static TProfile2D * GetP2(Container *parent, const char *name, Bool_t verb=true)
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
void ModLegend(TVirtualPad *p, TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: External.C:228
TFile * OpenFile(const char *filename)
void DrawParam(const char *name, Double_t &y, const char *val)
const char * ObsTitle() const
TH2 * GetRealBackground(Container *realList, Container *simList, TH1 *&scale)
static TH2 * CopyH2(Container *parent, const char *name, const char *newName=0, Bool_t verb=true)
Int_t mode
Definition: anaM.C:40
static TH1 * CopyH1(Container *parent, const char *name, const char *newName=0, Bool_t verb=true)
static TH3 * GetH3(Container *parent, const char *name, Bool_t verb=true)
static Double_t RatioE(Double_t n, Double_t en, Double_t d, Double_t ed, Double_t &er)
static TH2 * GetH2(Container *parent, const char *name, Bool_t verb=true)
void Run(UInt_t proc=kDefaultProc, UInt_t viz=kDefaultViz, UShort_t maxBins=9, const char *dataName="data.root", const char *simName="sim.root", const char *output=0)
TH2 * GetScaledCombi(TH2 *h, Container *realList, Container *simList, TH1 *&scale)
SuppressGuard(Int_t lvl=2000)
Definition: ChainBuilder.C:43
TF1 * DrawdNdeta(Container *realList, Container *simList, Color_t color=kBlack, THStack *stack=0, TDirectory *out=0, Bool_t alt=false)
static THStack * GetHS(Container *parent, const char *name, Bool_t verb=true)
Definition: External.C:220
void DrawWeights(Container *simList)
TFile * file
static Container * GetC(Container *parent, const char *name, Bool_t verb=true)
TH1 * SetAttr(TH1 *h, Color_t color, Style_t marker=20, Double_t size=1., Style_t fill=0, Style_t line=1, Width_t width=1)
unsigned short UShort_t
Definition: External.C:28
TList * ef
Definition: TestFitELoss.C:145
const char Option_t
Definition: External.C:48
TH2 * GetSim(Container *simList, const char *name, const char *newName)
void DrawScalars(Container *realList, Container *simList)
bool Bool_t
Definition: External.C:53
THStack * Make2Stack(const char *name, const char *title, Container *realList, Container *simList, Option_t *dataOpt="", Option_t *simOpt="")
static TH1 * Make1D(Container *c, const TString &name, const TString &title, Color_t color, Style_t style, const TAxis &xAxis)
void CreateCanvas(const TString &outputName)
Definition: External.C:196
void DrawDeltas(Container *realList, Container *simList)
void ProcessBin(Int_t bin, Double_t c1, Double_t c2, Container *realList, Container *simList, THStack *stack=0, TDirectory *out=0, TH1 *mid=0)