AliPhysics  cdeda5a (cdeda5a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Convert.C
Go to the documentation of this file.
1 
2 
3 
4 TList*
5 ConvertOne(const TString& system,
6  UShort_t sNN,
7  const TString& trigger,
8  Bool_t rebin=true)
9 {
10  TString t(trigger);
11  if (t.EqualTo("INEL>0")) t="INELGt0";
12  if (t.EqualTo("NSD")) t="V0AND";
13  TString scr(Form("nosec/%s/%04d/%s/%s.C",
14  system.Data(), sNN, t.Data(), (rebin ? "rebin" : "full")));
15 
16  if (gSystem->AccessPathName(scr.Data())) {
17  Warning("ConvertOne", "Script %s does not exist", scr.Data());
18  return;
19  }
20 
21  THStack* stack = new THStack("", "");
22  gROOT->Macro(Form("%s((THStack*)%p,0,20)", scr.Data(), stack));
23  if (!stack->GetHists()) {
24  Warning("ConvertOne", "Failed to import from %s", scr.Data());
25  return;
26  }
27 
28  SysErrorAdder* adder = 0;
29  if (t.EqualTo("INEL")) adder = new INELAdder(system,sNN);
30  else if (t.EqualTo("INELGt0")) adder = new INELGt0Adder(system,sNN);
31  else if (t.EqualTo("V0AND")) adder = new NSDAdder(system,sNN);
32  else if (t.BeginsWith("CENT")) adder = new CENTAdder(system,sNN,t);
33  else {
34  Error("ConvertOne", "Don't know how to add to %s", t.Data());
35  return;
36  }
37 
38  TList* ret = new TList;
39  ret->SetName(Form("%s_%05d_%s", system.Data(), sNN, t.Data()));
40 
41  TIter next(stack->GetHists());
42  TH1* hist = 0;
43  while ((hist = static_cast<TH1*>(next()))) {
44  TString name(hist->GetName());
45  if (name.Contains("mirror") || name.Contains("SysError")) {
46  // Info("ConvertOne", "Ignoring %s", name.Data());
47  continue;
48  }
49 
50  // Info("ConvertOne", "Converting %s", hist->GetName());
51  hist->SetMarkerColor(kBlack);
52  hist->SetFillColor(kBlack);
53  hist->SetLineColor(kBlack);
54 
55  if (system.EqualTo("pp") && sNN == 8000) {
56  if (t.EqualTo("INEL")) hist->Scale(0.85);
57  if (t.EqualTo("V0AND")) hist->Scale(0.93);
58  }
59 
60  GraphSysErr* gse = adder->Make(hist,0);
61  gse->SetName("data");
62 
63  TString trg = adder->GetTriggerString();
64  if (trg.EqualTo("INEL>0")) trg = "INELGt0";
65  TString dir(Form("out/%s/%05d/%s", system.Data(),
66  sNN, trg.Data()));
67  gSystem->Exec(Form("mkdir -p %s", dir.Data()));
68 
69  TFile* file = TFile::Open(Form("%s/%s.root",
70  dir.Data(),
71  gse->GetKey("detector")),
72  "RECREATE");
73  Info("", "Writing to %s", file->GetPath());
74  gse->Write("data");
75  file->Write();
76  // file->Close();
77  ret->Add(gse);
78  }
79  return ret;
80 }
81 
82 void
83 ConvertAndDraw(const TString& system,
84  UShort_t sNN,
85  const TString& trigger,
86  Bool_t rebin=true)
87 {
88  TList* l = ConvertOne(system, sNN, trigger, rebin);
89  if (!l) return;
90  if (gROOT->IsBatch()) return;
91 
92  TCanvas* c = new TCanvas(l->GetName(), l->GetName());
93  TIter n(l);
94  TObject* o = 0;
95  Bool_t f = true;
96  while ((o = n())) {
97  if (f) {
98  o->Draw("STACK SPLIT QUAD AXIS");
99  GraphSysErr* g = static_cast<GraphSysErr*>(o);
100  TH1* h = g->GetMulti()->GetHistogram();
101  h->SetMaximum(h->GetMaximum()*1.2);
102  h->SetMinimum(0);
103  }
104  else
105  o->Draw("STACK SPLIT QUAD");
106  f = false;
107  }
108 }
109 
110 void
112 {
113  ConvertAndDraw("PbPb", 2760, "CENT");
114 }
115 
116 void
118 {
119  const char* paCents[] = { "V0X", "ZNX", "V0M", "CL1", 0 };
120  const char** ptrCent = paCents;
121  while (*ptrCent) {
122  const char* paSys[] = { "pPb", "Pbp", 0 };
123  const char* paSide[] = { "A", "C", 0 };
124  const char** ptrSys = paSys;
125  const char** ptrSide = paSide;
126  while (*ptrSys) {
127  TString trg(Form("CENT%s", *ptrCent));
128  trg.ReplaceAll("X", *ptrSide);
129 
130  ConvertAndDraw(*ptrSys, 5023, trg);
131 
132  ptrSys++;
133  ptrSide++;
134  }
135  ptrCent++;
136  }
137 }
138 void
140 {
141  UShort_t ppSNN[] = { 900, 2760, 7000, 8000, 0 };
142  UShort_t* ptrSNN = ppSNN;
143  while (*ptrSNN) {
144  const char* ppTrig[] = { "INEL", "INELGt0", "NSD", 0 };
145  const char** ptrTrig = ppTrig;
146 
147  while (*ptrTrig) {
148  ConvertAndDraw("pp", *ptrSNN, *ptrTrig);
149  ptrTrig++;
150  }
151  ptrSNN++;
152  }
153 }
154 
155 void
157 {
158  const char* fwd = ".";
159  gROOT->SetMacroPath(Form("%s:%s/dndeta:%s/gse:%s/scripts",
160  gROOT->GetMacroPath(), fwd, fwd, fwd));
161  gSystem->AddIncludePath(Form("-I%s/dndeta -I%s/gse", fwd,fwd));
162 
163  if (!gROOT->GetClass("GraphSysErr")) gROOT->LoadMacro("GraphSysErr.C+g");
164  if (!gROOT->GetClass("SysErrorAdder"))gROOT->LoadMacro("SysErrorAdder.C+g");
165 
166  gSystem->Exec("rm -rf out");
167  ConvertPbPb();
168  ConvertpPb();
169  ConvertPP();
170 
171 
172  gSystem->Exec("(cd out && tar -czvf ../fwd.tar.gz .)");
173 
174 
175 }
176 
void Convert()
Definition: Convert.C:156
virtual GraphSysErr * Make(TH1 *h, TLegend *l, Double_t eff=1, Bool_t verb=false)
TList * ConvertOne(const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebin=true)
Definition: Convert.C:5
TSystem * gSystem
void ConvertAndDraw(const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebin=true)
Definition: Convert.C:83
TCanvas * c
Definition: TestFitELoss.C:172
void ConvertpPb()
Definition: Convert.C:117
TMultiGraph * GetMulti(Option_t *option="")
Definition: GraphSysErr.C:924
const char * GetKey(const char *key) const
Definition: GraphSysErr.C:4641
void ConvertPbPb()
Definition: Convert.C:111
const char * fwd
TFile * file
Int_t rebin
void ConvertPP()
Definition: Convert.C:139
unsigned short UShort_t
Definition: External.C:28
virtual const char * GetTriggerString() const
Definition: SysErrorAdder.C:56
bool Bool_t
Definition: External.C:53
Definition: External.C:196