AliPhysics  5eaf189 (5eaf189)
Extract.C
Go to the documentation of this file.
1 //====================================================================
11 {
12  Double_t c = (c1+c2) / 2;
13  if (c < 5) return 0;
14  else if (c < 10) return 1;
15  else if (c < 20) return 2;
16  else if (c < 30) return 3;
17  else if (c < 40) return 4;
18  else if (c < 50) return 5;
19  else if (c < 60) return 6;
20  else if (c < 70) return 7;
21  else if (c < 80) return 8;
22  else if (c < 90) return 9;
23  return 10;
24 }
25 
26 //____________________________________________________________________
35 static Color_t PbPbColor(Double_t c1, Double_t c2)
36 {
37  const Color_t cc[] = { kMagenta+2,
38  kBlue+2,
39  kAzure-1, // 10,
40  kCyan+2,
41  kGreen+1,
42  kSpring+5,//+10,
43  kYellow+1,
44  kOrange+5,//+10,
45  kRed+1,
46  kPink+5,//+10,
47  kBlack };
48  Int_t bin = PbPbBin(c1,c2);
49  return cc[bin];
50 }
51 
52 //====================================================================
64 {
65  return sMin + TMath::Power(x/xMax, 2)*(sMax-sMin);
66 }
77 {
78  return SysEval(x, sMin, sMax, 80);
79 }
90 {
91  return SysEval(x, sMin, sMax, 2);
92 }
103 void MakeGSE(std::ostream& o, const TH1* h,
104  Double_t c1, Double_t c2, Bool_t reweigh, Double_t fac=1)
105 {
106  // These are correlated
107  Double_t bgMid = CSysEval(c2, 100*0.02, 100*0.002);
108  Double_t cSys = CSysEval(c2, 100*0.005, 100*0.075);
109  Double_t strMid = 100*0.005;
110  Double_t strFwd = 100*0.05;
111  Double_t pidMid = 100*0;
112  Double_t pidFwd = 100*0.01;
113  // Double_t bgSys = (1-c1/100)*(2-0.2) + 0.2;
114  // Double_t cSys = TMath::Power(c1/100,2)*(7.5-0.5) + 0.5;
115 
116  o << "*dataset:\n"
117  << "*dscomment: The pseudo-rapidity density of charged particle\n"
118  << "*reackey: PB PB --> CHARGED X\n"
119  << "*obskey: DN/DETARAP\n"
120  << "*qual: CENTRALITY IN PCT : " << c1 << " TO " << c2 << "\n"
121  << "*qual: SQRT(S)/NUCLEON IN GEV : 5023\n";
122  if (!reweigh) {
123  o << "*dserror: " << strMid << " PCT : Weak decays\n"
124  << "*dserror: " << pidMid << " PCT : Particle composition\n"
125  << "*dserror: " << bgMid << " PCT : Background subtraction\n";
126  }
127  o << "*dserror: 1 PCT : pT extrapolation\n"
128  << "*dserror: " << cSys << " PCT : Centrality\n"
129  << "*xheader: ETARAP\n"
130  << "*yheader: DN/DETARAP\n"
131  << "*data: x : y" << std::endl;
132  // Define points
133  TAxis* xa = h->GetXaxis();
134  for (Int_t i = 0; i < h->GetNbinsX(); i++) {
135  Int_t j = i+1;
136  Double_t cc = h->GetBinContent(j)*fac;
137  Double_t x = h->GetXaxis()->GetBinCenter(j);
138  Double_t ex = h->GetXaxis()->GetBinWidth(j)/2;
139  Double_t xo = TMath::Abs(x)+ex;
140  if (cc < 1e-8) continue;
141  o << " " << xa->GetBinLowEdge(j) << " TO " << xa->GetBinUpEdge(j)
142  << "; " << cc << " +-" << h->GetBinError(j)
143  << " (DSYS=" << 0.01+0.01*TMath::Power(xo/2,2) << " PCT:Acceptance";
144  if (reweigh) {
145  Double_t bg = EtaSysEval(xo, bgMid, 3*bgMid);
146  Double_t pid = EtaSysEval(xo, pidMid, pidFwd);
147  Double_t str = EtaSysEval(xo, strMid, strFwd);
148  o << ",DSYS=" << bg << " PCT:Background subtraction"
149  << ",DSYS=" << pid << " PCT:Particle composition"
150  << ",DSYS=" << str << " PCT:Weak decay";
151 
152  }
153  o << ");"
154  << std::endl;
155  }
156  o << "*dataend:\n" << std::endl;
157 }
166 {
167  Double_t eMin = +10000;
168  Double_t eMax = -10000;
169  GraphSysErr* g = static_cast<GraphSysErr*>(o);
170  for (Int_t i = 0; i < g->GetN(); i++) {
171  Double_t eyl, eyh;
172  Double_t y = g->GetYandError(i, true, false, true, false, eyl, eyh);
173  Double_t ey = TMath::Max(eyl,eyh)/y;
174  eMin = TMath::Min(ey, eMin);
175  eMax = TMath::Max(ey, eMax);
176  }
177  Printf("%4.1f - %4.1f%%: Least: %6.2f%%, Largest %6.2f%%",
178  c1, c2, eMin*100, eMax*100);
179 }
180 
188 void
189 Extract(const char* filename="dndneta.pbpb502.20151124.root",
190  const char* outname="TRACKLETS_5023_PbPb.input",
191  Bool_t reweigh=false)
192 {
193  if (filename == 0) return;
194  TFile* file = TFile::Open(filename, "READ");
195  TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray"));
196  // Now count number of bins
197  Int_t nBins = 0;
198  TIter next(arr);
199  TObject* obj = 0;
200  while ((obj = next())) {
201  if (TString(obj->GetName()).Contains("DataCorrSignal"))
202  nBins++;
203  }
204  Info("ExtractdNdeta", "Defining %d centrality bins", nBins);
205  TArrayD c(nBins+1);
206  if (nBins == 5) {
207  c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80;
208  }
209  else if (nBins >= 9) {
210  c[0] = 0; c[1] = 5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40;
211  c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80;
212  if (nBins >= 10) c[10] = 90;
213  if (nBins >= 11) c[11] = 100;
214  }
215 
216  THStack* all = new THStack("all","all");
217  std::ofstream out(outname);
218  std::ostream& o = out; // std::cout;
219  // std::ostream& o = std::cout;
220 
221  o << "*author: SHAHOYAN : 2015\n"
222  << "*title: Full centrality dependence of the charged "
223  << "particle pseudo-rapidity density over the widest "
224  << "possible pseudo-rapidity range in Pb-Pb collisions "
225  << "at 5.02 TeV\n"
226  << "*detector: TRACKLETS\n"
227  << "*experiment: CERN-LHC-TRACKLETS\n"
228  << "*comment: CERN-LHC: We present the charged particle pseudo-rapidity "
229  << "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon "
230  "= 5.02 over the widest possible pseudo-rapidity and centrality range "
231  << "possible.\n" << std::endl;
232 
233  for (Int_t i = 0; i < nBins; i++) {
234  TString hName = Form("bin%d_DataCorrSignal_PbPb",i);
235  TH1* h = static_cast<TH1*>(arr->FindObject(hName));
236  if (!h) {
237  hName.ReplaceAll("PbPb", "PBPB");
238  h = static_cast<TH1*>(arr->FindObject(hName));
239  if (!h) {
240  Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i);
241  arr->Print();
242  continue;
243  }
244  }
245 
246  Color_t col = PbPbColor(c[i], c[i+1]);
247  h->SetLineColor(col);
248  h->SetMarkerColor(col);
249  h->SetFillColor(col);
250  all->Add(h);
251  Info("","Making GSE for %0d%% to %3d%% (%d)",
252  Int_t(c[i]), Int_t(c[i+1]), col);
253 
254  MakeGSE(o, h, c[i], c[i+1], reweigh);
255  }
256  // all->Draw("nostack");
257  o << "*E" << std::endl;
258  out.close();
259 
260  TCanvas* can = new TCanvas("c","C", 1600, 800);
261  can->SetRightMargin(0.2);
262  can->SetTopMargin(0.01);
263 
264  TLegend* cl = new TLegend(1-can->GetRightMargin(),
265  can->GetBottomMargin(),.99,
266  1-can->GetTopMargin());
267  cl->SetFillStyle(0);
268  cl->SetBorderSize(0);
269 
270  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+");
271  TList* ll = GraphSysErr::Import(outname);
272  // ll->ls();
273 
274  TIter next(ll);
275  TObject* obj = 0;
276  Bool_t first = true;
277  TH1* frame = 0;
278  Double_t min=100000, max=0;
279  Int_t i = 0;
280  while ((obj = next())) {
281  if (c[i+1] > 80) break;
282  GraphSysErr* g = static_cast<GraphSysErr*>(obj);
283  Color_t col = PbPbColor(c[i], c[i+1]);
284  TLegendEntry* e = cl->AddEntry("", Form("%4.1f-%4.1f%%", c[i], c[i+1]),
285  "F");
286  e->SetFillColor(col);
287  e->SetFillStyle(1001);
288  g->SetLineColor(col);
289  g->SetMarkerColor(col);
290  g->SetFillColor(col);
291  // g->Print("qual");
294  g->SetSumLineColor(col);
295  g->SetSumFillColor(col);
297  g->SetCommonSumLineColor(col);
298  g->SetCommonSumFillColor(col);
299  g->SetName(Form("tracklets%03dd%02d_%03dd%02d",
300  Int_t(c[i]), Int_t(c[i]*100) % 100,
301  Int_t(c[i+1]), Int_t(c[i+1]*100) % 100));
302  g->SetTitle(Form("%4.1f - %4.1f%%", c[i], c[i+1]));
303  if (first) g->Draw("combine stat quad axis xbase=2.5");
304  else g->Draw("combine stat quad xbase=2.5");
305  if (!frame)
306  frame = g->GetMulti()->GetHistogram();
307  first = false;
308  Double_t mn, mx;
309  g->GetMinMax("combine stat quad", mn, mx);
310  FindLeastLargest(g, c[i], c[i+1]);
311  min = TMath::Min(min, mn);
312  max = TMath::Max(max, mx);
313  i++;
314  }
315  frame->SetMinimum(min*.9);
316  frame->SetMaximum(max*1.1);
317  cl->Draw();
318 
319  TFile* outFile = TFile::Open(Form("PbPb5023midRapidity%s.root",
320  reweigh ? "Reweighed" : "Normal"),
321  "RECREATE");
322  ll->Write("container",TObject::kSingleKey);
323  outFile->Write();
324 
325  can->SaveAs(Form("PbPb5023midRapidity%s.png",
326  reweigh ? "Reweighed" : "Normal"));
327 }
328 //
329 // EOF
330 //
const char * filename
Definition: TestFCM.C:1
const Color_t cc[]
Definition: DrawKs.C:1
double Double_t
Definition: External.C:58
void Draw(Option_t *option="")
Definition: GraphSysErr.C:791
void Extract()
Definition: Extract.C:111
Double_t GetYandError(Int_t i, Bool_t cmn, Bool_t stat, Bool_t quad, Bool_t nosqrt, Double_t &eyl, Double_t &eyh) const
Definition: GraphSysErr.C:6612
Double_t EtaSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: Extract.C:89
void SetCommonSumLineColor(Color_t color)
Definition: GraphSysErr.C:4503
TCanvas * c
Definition: TestFitELoss.C:172
void SetCommonSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4491
static TSeqCollection * Import(const TString &fileName)
Definition: GraphSysErr.C:2993
static Int_t PbPbBin(Double_t c1, Double_t c2)
Definition: Extract.C:10
void SetTitle(const char *name)
Definition: GraphSysErr.C:3576
int Int_t
Definition: External.C:63
void GetMinMax(Option_t *option, Double_t &ymin, Double_t &ymax) const
Definition: GraphSysErr.C:3985
void SetDataOption(EDrawOption_t opt)
Definition: GraphSysErr.C:3586
static Color_t PbPbColor(Double_t c1, Double_t c2)
Definition: Extract.C:35
TMultiGraph * GetMulti(Option_t *option="")
Definition: GraphSysErr.C:924
Int_t GetN() const
Definition: GraphSysErr.C:3609
void SetSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4449
void MakeGSE(std::ostream &o, const TH1 *h, Double_t c1, Double_t c2, Bool_t reweigh, Double_t fac=1)
Definition: Extract.C:103
Double_t SysEval(Double_t x, Double_t sMin, Double_t sMax, Double_t xMax)
Definition: Extract.C:63
void FindLeastLargest(TObject *o, Double_t c1, Double_t c2)
Definition: Extract.C:165
TFile * file
TList with histograms for a given trigger.
Double_t CSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: Extract.C:76
void SetSumFillColor(Color_t color)
Definition: GraphSysErr.C:4479
bool Bool_t
Definition: External.C:53
void SetSumLineColor(Color_t color)
Definition: GraphSysErr.C:4461
void SetCommonSumFillColor(Color_t color)
Definition: GraphSysErr.C:4521
Definition: External.C:196