1 #ifndef FASTCENTHELPER_H
2 #define FASTCENTHELPER_H
13 # include <TProfile.h>
59 if (tokens->GetEntriesFast() > 1)
60 axis = tokens->At(1)->GetName();
111 Info(
"SetCentAxis",
"Setting centrality axis from %s", spec);
114 if (s.IsNull())
return;
115 if (s.EqualTo(
"pbpb") || s.EqualTo(
"aa") || s.EqualTo(
"default")) {
116 Printf(
"Setting centrality axis Pb-Pb");
117 Double_t aa[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
122 if (s.EqualTo(
"ppb") || s.EqualTo(
"pbp") ||
123 s.EqualTo(
"pa") || s.EqualTo(
"ap")) {
124 Printf(
"Setting centrality axis p-Pb/Pb-p");
125 Double_t pa[] = { 0, 5, 10, 20, 40, 60, 80, 100 };
130 if (s.EqualTo(
"pp")) {
131 Printf(
"Setting centrality axis pp");
132 Double_t pp[] = { 0, 0.01, 0.1, 1, 5, 10, 15, 20, 30, 40, 50, 70, 100 };
139 Int_t nTokens = tokens->GetEntriesFast();
141 for (
Int_t i = 0; i < nTokens; i++) {
142 TObjString* token =
static_cast<TObjString*
>(tokens->At(i));
143 TString& edge = token->String();
144 edges[i] = edge.Atof();
159 Int_t nCol = gStyle->GetNumberOfColors();
160 Int_t icol = TMath::Min(nCol-1,
int(fc * nCol + .5));
161 Int_t col = gStyle->GetColorPalette(icol);
175 return Form(
"h%03dd%02d_%03dd%02d",
198 if (iLow == 0)
return " 0";
199 else return Form(
"%2d+", iLow);
201 return Form(
"%2d-%2d", iLow+1, iHigh);
203 return Form(
"%6.2f-%6.2f%%", low, high);
217 Printf(
"Base level, setting names on %p", o);
218 if (o->IsA()->InheritsFrom(TNamed::Class())) {
224 if (o->IsA()->InheritsFrom(TCollection::Class())) {
225 Printf(
"Got a collection, will loop on that");
231 while ((oo = next()))
ModHist(oo, low, high, lvl+1);
235 if (o->IsA()->InheritsFrom(TH1::Class())) {
236 Printf(
"Got a histogram, will modify that");
237 TH1* h =
static_cast<TH1*
>(o);
238 h->SetLineColor(col);
240 h->SetMarkerColor(col);
241 h->SetMarkerStyle(24);
242 h->SetFillColor(kWhite);
263 Printf(
"Calling call-back for %5.1f-%5.1f%%", low, high);
265 Printf(
"Got call back return %p", obj);
267 Printf(
"Now adding %s (%s)to centrality list",
268 obj->GetName(), obj->ClassName());
273 TObject* first = (*callback)();
294 fCentAll->SetXTitle(
"Centrality [%]");
306 fCentAcc->SetTitle(
"Accepted centralities");
314 Printf(
"End of create outputs");
329 Int_t maxNPart = 2*210;
330 Int_t maxNBin = 7*210;
335 maxNPart, 0, maxNPart);
339 maxNBin, 0, maxNBin);
340 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
348 maxNPart, 0, maxNPart);
352 maxNBin, 0, maxNBin);
353 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
368 fCentB->SetYTitle(
"b [fm]");
375 if (!centHist)
return;;
377 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
378 centHist->GetXaxis()->GetNbins(),
379 centHist->GetXaxis()->GetXmin(),
380 centHist->GetXaxis()->GetXmax(),
384 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
385 centHist->GetXaxis()->GetNbins(),
386 centHist->GetXaxis()->GetXmin(),
387 centHist->GetXaxis()->GetXmax(),
419 if (cent < 0 || cent > 999) {
420 Warning(
"FillDiagnostics",
421 "Centrality is unreasonable: %f -> %f",mult, cent);
426 if (ret-1 == n && cent ==
fCentAxis->GetXmax())
428 if (ret < 1 || ret > n) {
429 Warning(
"ProcessHeader",
"Centrality %f -> %f -> bin # %d",
436 if (ret == n) cent -= 0.001;
453 Warning(
"CentObject",
"No centrality objects defined");
458 Warning(
"CentObject",
"Bin # %2d out of range [%2d,%2d]",
466 if (bin <= 0 || bin >
fCentList->GetEntries()) {
468 Warning(
"CentObject",
"Bin # %2d out of range [%2d,%2d]",
474 Warning(
"CentObject",
"No centrality object defined for bin %d", bin);
477 if (cls && !o->IsA()->InheritsFrom(cls)) {
478 Warning(
"CentObject",
"Centrality object %s is not a %s, but a %s",
479 o->GetName(), cls->GetName(), o->ClassName());
522 TObject* o = output->FindObject(name);
524 Warning(
"GetOutputObject",
"Object %s not found in output", name);
528 if (cls && !o->IsA()->InheritsFrom(cls)) {
529 Warning(
"GetOutputObject",
"Object %s from output is not a %s, but a %s",
530 o->GetName(), cls->GetName(), o->ClassName());
541 TProfile* p = (projX ?
542 h->ProfileX(Form(
"%sMean", name)) :
543 h->ProfileY(Form(
"%sMean", name)));
564 Warning(
"Finalize",
"Missing stack and histograms");
567 Info(
"Terminate",
"Accepted %d/%d=%6.2f%% events",
573 THStack*
stack =
new THStack(
"all",
"All");
575 TObjLink* link = hists->FirstLink();
582 TObject* o = link->GetObject();
590 printf(
"%9d events in bin %s ...", m, o->GetTitle());
593 TObjLink* tmp = link->Next();
602 TH1* h = (*callback)(o,m);
604 Printf(
" processed [%2d->%2d]", bin, cnt);
610 TH1* h =
static_cast<TH1*
>(o);
611 Int_t n = h->GetBinContent(0);
612 h->SetBinContent(0,0);
613 printf(
"%9d (%9d) events in bin %s ...", n, m, o->GetTitle());
616 TObjLink* tmp = link->Next();
626 h->Scale(1. / n,
"width");
633 Printf(
"ana/acc/all: %9lld/%9lld/%9lld [%6.2f%%/%6.2f%%]",
634 sum, total, all,
float(100*sum)/total,
float(100*total)/all);
637 Printf(
" %3d -> %3d", i,
fMapping[i]);
643 Printf(
" Axis: %d", nBins);
644 if (nBins < 2)
return;
646 for (
Int_t i = 1; i <= nBins; i++)
647 printf(
"%5.1f-",
fCentAxis->GetBinLowEdge(i));
648 Printf(
"%5.1f%%",
fCentAxis->GetBinUpEdge(nBins));
void SetCentAxis(const char *spec)
TObject * GetOutputObject(TCollection *output, const char *name, TClass *cls)
Bool_t Finalize(TCollection *output, Long_t minEvents, TH1 *(*callback)(TObject *, Int_t))
void SetCentAxis(Int_t n, Double_t *edges)
TH1 * CentHist(Int_t bin) const
TH2 * Get2DDiag(TCollection *output, const char *name, Bool_t projX)
virtual const char * HistName(Double_t low, Double_t high) const
virtual const char * HistTitle(Double_t low, Double_t high) const
virtual const char * HistName(Int_t i) const
void SetCentAxis(Int_t n, Double_t low, Double_t high)
TObject * CentObject(Int_t bin, TClass *cls=0) const
FastCentHelper(const char *method)
Int_t GetCentralityColor(Double_t, Double_t high) const
void CreateHistos(TCollection *output, TObject *(*callback)())
void ModHist(TObject *o, Double_t low, Double_t high, Int_t lvl=0)
TCollection * CentCollection(Int_t bin) const
void Print(Option_t *option="") const
void CreateDiagnostics(TCollection *output, TH1 *centHist)
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)