1 #ifndef FASTCENTHELPER_H
2 #define FASTCENTHELPER_H
55 if (tokens->GetEntriesFast() > 1)
56 axis = tokens->At(1)->GetName();
107 Info(
"SetCentAxis",
"Setting centrality axis from %s", spec);
110 if (s.IsNull())
return;
111 if (s.EqualTo(
"pbpb") || s.EqualTo(
"aa") || s.EqualTo(
"default")) {
112 Printf(
"Setting centrality axis Pb-Pb");
113 Double_t aa[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
118 if (s.EqualTo(
"ppb") || s.EqualTo(
"pbp") ||
119 s.EqualTo(
"pa") || s.EqualTo(
"ap")) {
120 Printf(
"Setting centrality axis p-Pb/Pb-p");
121 Double_t pa[] = { 0, 5, 10, 20, 40, 60, 80, 100 };
126 if (s.EqualTo(
"pp")) {
127 Printf(
"Setting centrality axis pp");
128 Double_t pp[] = { 0, 0.01, 0.1, 1, 5, 10, 15, 20, 30, 40, 50, 70, 100 };
135 Int_t nTokens = tokens->GetEntriesFast();
137 for (
Int_t i = 0; i < nTokens; i++) {
138 TObjString* token =
static_cast<TObjString*
>(tokens->At(i));
139 TString& edge = token->String();
140 edges[i] = edge.Atof();
155 Int_t nCol = gStyle->GetNumberOfColors();
156 Int_t icol = TMath::Min(nCol-1,
int(fc * nCol + .5));
157 Int_t col = gStyle->GetColorPalette(icol);
171 return Form(
"h%03dd%02d_%03dd%02d",
189 if (iLow == 0)
return " 0";
190 else return Form(
"%2d+", iLow);
192 return Form(
"%2d-%2d", iLow+1, iHigh);
194 return Form(
"%6.2f-%6.2f%%", low, high);
207 h->SetLineColor(col);
209 h->SetMarkerColor(col);
210 h->SetMarkerStyle(24);
211 h->SetFillColor(kWhite);
231 TH1* hist = (*callback)();
239 TH1* first = (*callback)();
244 TH1* last = (*callback)();
259 fCentAll->SetXTitle(
"Centrality [%]");
271 fCentAcc->SetTitle(
"Accepted centralities");
292 Int_t maxNPart = 2*210;
293 Int_t maxNBin = 3*210;
298 maxNPart, 0, maxNPart);
302 maxNBin, 0, maxNBin);
303 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
311 maxNPart, 0, maxNPart);
315 maxNBin, 0, maxNBin);
316 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
331 fCentB->SetYTitle(
"b [fm]");
338 if (!centHist)
return;;
340 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
341 centHist->GetXaxis()->GetNbins(),
342 centHist->GetXaxis()->GetXmin(),
343 centHist->GetXaxis()->GetXmax(),
347 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
348 centHist->GetXaxis()->GetNbins(),
349 centHist->GetXaxis()->GetXmin(),
350 centHist->GetXaxis()->GetXmax(),
382 if (cent < 0 || cent > 999) {
383 Warning(
"FillDiagnostics",
384 "Centrality is unreasonable: %f -> %f",mult, cent);
389 if (ret-1 == n && cent ==
fCentAxis->GetXmax())
391 if (ret < 1 || ret > n) {
392 Warning(
"ProcessHeader",
"Centrality %f -> %f -> bin # %d",
399 if (ret == n) cent -= 0.001;
414 TObject* o = output->FindObject(name);
416 Warning(
"GetOutputObject",
"Object %s not found in output", name);
420 if (cls && !o->IsA()->InheritsFrom(cls)) {
421 Warning(
"GetOutputObject",
"Object %s from output is not a %s, but a %s",
422 o->GetName(), cls->GetName(), o->ClassName());
443 Warning(
"Finalize",
"Missing stack and histograms");
446 Info(
"Terminate",
"Accepted %d/%d=%6.2f%% events",
450 THStack* stack =
new THStack(
"all",
"All");
452 TObjLink* link = hists->FirstLink();
458 TObject* o = link->GetObject();
464 TH1* h =
static_cast<TH1*
>(o);
465 Int_t n = h->GetBinContent(0);
468 h->SetBinContent(0,0);
469 printf(
"%9d (%9d) events in bin %s ...", n, m, o->GetTitle());
472 TObjLink* tmp = link->Next();
482 h->Scale(1. / n,
"width");
488 Printf(
"ana/acc/all: %9lld/%9lld/%9lld [%6.2f%%/%6.2f%%]",
489 sum, total, all,
float(100*sum)/total,
float(100*total)/all);
void SetCentAxis(const char *spec)
void ModHist(TH1 *h, Double_t low, Double_t high)
TObject * GetOutputObject(TCollection *output, const char *name, TClass *cls)
void SetCentAxis(Int_t n, Double_t *edges)
virtual const char * HistName(Double_t low, Double_t high) const
virtual const char * HistTitle(Double_t low, Double_t high) const
void CreateHistos(TCollection *output, TH1D *(*callback)())
void SetCentAxis(Int_t n, Double_t low, Double_t high)
FastCentHelper(const char *method)
Int_t GetCentralityColor(Double_t, Double_t high) const
ClassDef(FastCentHelper, 1)
void CreateDiagnostics(TCollection *output, TH1 *centHist)
Bool_t Finalize(TCollection *output, Long_t minEvents)
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)