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);
264 Printf(
"Calling call-back for %5.1f-%5.1f%%", low, high);
266 Printf(
"Got call back return %p", obj);
268 Printf(
"Now adding %s (%s)to centrality list",
269 obj->GetName(), obj->ClassName());
275 TObject* first = (*callback)();
296 fCentAll->SetXTitle(
"Centrality [%]");
308 fCentAcc->SetTitle(
"Accepted centralities");
316 Printf(
"End of create outputs");
331 Int_t maxNPart = 2*210;
332 Int_t maxNBin = 7*210;
337 maxNPart, 0, maxNPart);
341 maxNBin, 0, maxNBin);
342 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
350 maxNPart, 0, maxNPart);
354 maxNBin, 0, maxNBin);
355 fCentB =
new TH2D(
"centB",
"Centrality vs. b",
370 fCentB->SetYTitle(
"b [fm]");
377 if (!centHist)
return;;
379 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
380 centHist->GetXaxis()->GetNbins(),
381 centHist->GetXaxis()->GetXmin(),
382 centHist->GetXaxis()->GetXmax(),
386 fCentMult =
new TH2D(
"centMult",
"Event multiplicity vs. centrality",
387 centHist->GetXaxis()->GetNbins(),
388 centHist->GetXaxis()->GetXmin(),
389 centHist->GetXaxis()->GetXmax(),
421 if (cent < 0 || cent > 999) {
422 Warning(
"FillDiagnostics",
423 "Centrality is unreasonable: %f -> %f",mult, cent);
428 if (ret-1 == n && cent ==
fCentAxis->GetXmax())
430 if (ret < 1 || ret > n) {
431 Warning(
"ProcessHeader",
"Centrality %f -> %f -> bin # %d",
438 if (ret == n) cent -= 0.001;
455 Warning(
"CentObject",
"No centrality objects defined");
460 Warning(
"CentObject",
"Bin # %2d out of range [%2d,%2d]",
468 if (bin <= 0 || bin >
fCentList->GetEntries()) {
470 Warning(
"CentObject",
"Bin # %2d out of range [%2d,%2d]",
476 Warning(
"CentObject",
"No centrality object defined for bin %d", bin);
479 if (cls && !o->IsA()->InheritsFrom(cls)) {
480 Warning(
"CentObject",
"Centrality object %s is not a %s, but a %s",
481 o->GetName(), cls->GetName(), o->ClassName());
524 TObject* o = output->FindObject(name);
526 Warning(
"GetOutputObject",
"Object %s not found in output", name);
530 if (cls && !o->IsA()->InheritsFrom(cls)) {
531 Warning(
"GetOutputObject",
"Object %s from output is not a %s, but a %s",
532 o->GetName(), cls->GetName(), o->ClassName());
543 TProfile* p = (projX ?
544 h->ProfileX(Form(
"%sMean", name)) :
545 h->ProfileY(Form(
"%sMean", name)));
566 Warning(
"Finalize",
"Missing stack and histograms");
569 Info(
"Terminate",
"Accepted %d/%d=%6.2f%% events",
573 if (!callback)
return true;
577 THStack*
stack =
new THStack(
"all",
"All");
579 TObjLink* link = hists->FirstLink();
586 TObject* o = link->GetObject();
594 printf(
"%9d events in bin %s ...", m, o->GetTitle());
597 TObjLink* tmp = link->Next();
606 TH1* h = (*callback)(o,m);
608 Printf(
" processed [%2d->%2d]", bin, cnt);
614 TH1* h =
static_cast<TH1*
>(o);
615 Int_t n = h->GetBinContent(0);
616 h->SetBinContent(0,0);
617 printf(
"%9d (%9d) events in bin %s ...", n, m, o->GetTitle());
620 TObjLink* tmp = link->Next();
630 h->Scale(1. / n,
"width");
638 Printf(
"ana/acc/all: %9lld/%9lld/%9lld [%6.2f%%/%6.2f%%]",
639 sum, total, all,
float(100*sum)/total,
float(100*total)/all);
641 Printf(
" %3d -> %3d", i,
fMapping[i]);
647 Printf(
" Axis: %d", nBins);
648 if (nBins < 2)
return;
650 for (
Int_t i = 1; i <= nBins; i++)
651 printf(
"%5.1f-",
fCentAxis->GetBinLowEdge(i));
652 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)