16 #include <AliESDFMD.h>
27 #include <TProfile2D.h>
28 #include <TObjArray.h>
48 fMergeMethod(kStraightMean),
49 fFiducialMethod(kByCut),
56 DGUARD(
fDebug, 3,
"Default CTOR of AliFMDHistCollector");
61 :
TNamed(
"fmdHistCollector", title),
69 fMergeMethod(kStraightMean),
70 fFiducialMethod(kByCut),
77 DGUARD(
fDebug, 3,
"Named CTOR of AliFMDHistCollector: %s", title);
82 fNCutBins(o.fNCutBins),
83 fCorrectionCut(o.fCorrectionCut),
86 fSumRings(o.fSumRings),
87 fCoverage(o.fCoverage),
89 fMergeMethod(o.fMergeMethod),
90 fFiducialMethod(o.fFiducialMethod),
91 fSkipFMDRings(o.fSkipFMDRings),
92 fBgAndHitMaps(o.fBgAndHitMaps),
95 fDoByCent(o.fDoByCent)
120 if (&o ==
this)
return *
this;
121 TNamed::operator=(o);
143 const TAxis& etaAxis)
151 DGUARD(
fDebug, 1,
"Initialization of AliFMDHistCollector");
156 etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(),
161 fSumRings->GetYaxis()->SetBinLabel(1,
"FMD1i");
162 fSumRings->GetYaxis()->SetBinLabel(2,
"FMD2i");
163 fSumRings->GetYaxis()->SetBinLabel(3,
"FMD2o");
164 fSumRings->GetYaxis()->SetBinLabel(4,
"FMD3i");
165 fSumRings->GetYaxis()->SetBinLabel(5,
"FMD3o");
169 etaAxis.GetNbins(),etaAxis.GetXmin(),etaAxis.GetXmax(),
170 vtxAxis.GetNbins(),vtxAxis.GetXmin(),vtxAxis.GetXmax());
177 fSkipped =
new TH1D(
"skipped",
"Rings skipped", 5, 1, 6);
182 fSkipped->GetXaxis()->SetBinLabel(1,
"FMD1i");
183 fSkipped->GetXaxis()->SetBinLabel(2,
"FMD2i");
184 fSkipped->GetXaxis()->SetBinLabel(3,
"FMD2o");
185 fSkipped->GetXaxis()->SetBinLabel(4,
"FMD3i");
186 fSkipped->GetXaxis()->SetBinLabel(5,
"FMD3o");
199 fVtxList->SetName(
"histCollectorVtxBins");
203 for (
UShort_t iVz = 1; iVz <= nVz; iVz++) {
204 Double_t vMin = vtxAxis.GetBinLowEdge(iVz);
205 Double_t vMax = vtxAxis.GetBinUpEdge(iVz);
217 fByCent->SetName(
"byCentrality");
224 for (
Int_t i = 0; i < 5; i++) {
229 TH3* h =
new TH3D(Form(
"FMD%d%c", d, r),
230 Form(
"dN/d#eta per centrality for FMD%d%c", d, r),
231 etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(),
232 nCent, minCent, maxCent, 1, 0, 1);
233 h->SetXTitle(
"#eta");
234 h->SetYTitle(
"Centrality [%]");
235 h->SetZTitle(
"dN/d#eta");
238 h->SetMarkerStyle(20);
266 if (2 * c < bg->GetBinContent(ie+1,ip) ||
267 2 * c < bg->GetBinContent(ie-1,ip))
return false;
270 AliErrorClass(
"No fiducal cut method defined");
285 DGUARD(
fDebug, 1,
"Define output of AliFMDHistCollector");
288 fList->SetName(GetName());
297 UShort_t q = (r ==
'I' || r ==
'i' ? 0 : 1);
301 return (t & skips) == t;
320 case 1: idx = 0;
break;
321 case 2: idx = 1 + (r ==
'I' || r ==
'i' ? 0 : 1);
break;
322 case 3: idx = 3 + (r ==
'I' || r ==
'i' ? 0 : 1);
break;
341 case 0: d = 1; r =
'I';
break;
342 case 1: d = 2; r =
'I';
break;
343 case 2: d = 2; r =
'O';
break;
344 case 3: d = 3; r =
'I';
break;
345 case 4: d = 3; r =
'O';
break;
356 if (ivtx < 1 || ivtx >
fVtxList->GetEntriesFast())
return 0;
367 if (ivtx < 1 || ivtx >
fVtxList->GetEntriesFast())
return 0;
413 re = TMath::Sqrt(oe*oe+(e*e)/4);
424 re = TMath::Sqrt(oe*oe + e*e)/2;
442 re = TMath::Sqrt(1 / sw);
457 re = TMath::Sqrt(oe * oe + e * e);
460 AliErrorClass(
"No method for defining content of overlapping bins defined");
486 DGUARD(
fDebug, 1,
"Collect final histogram of AliFMDHistCollector");
492 if (!bin)
return false;
500 #define PF(N,V,...) \
501 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
502 #define PFB(N,FLAG) \
504 AliForwardUtil::PrintName(N); \
505 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
507 #define PFV(N,VALUE) \
509 AliForwardUtil::PrintName(N); \
510 std::cout << (VALUE) << std::endl; } while(false)
528 case kSum: merge =
"straight sum";
break;
534 gROOT->IncreaseDirLevel();
538 PFV(
"Merge method", merge);
541 gROOT->DecreaseDirLevel();
545 for (
Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] =
' ';
546 ind[gROOT->GetDirLevel()] =
'\0';
548 std::cout << ind <<
"Bin ranges:\n" << ind <<
" rings | Range ";
550 for (
Int_t iIdx = 0; iIdx < 5; iIdx++) {
554 std::cout << ind <<
" | FMD" << d << r <<
" ";
556 std::cout <<
'\n' << ind <<
" /vz_bin |-----------";
557 for (
Int_t iIdx = 0; iIdx < 5; iIdx++)
558 std::cout <<
"-+--------";
559 std::cout << std::endl;
561 for (
UShort_t iVz = 1; iVz <= nVz; iVz++) {
564 std::cout <<
" " << std::right << std::setw(6) << iVz <<
" | "
565 << std::setw(3) << bin->
fLow <<
" - " << std::left
566 << std::setw(3) << bin->
fHigh <<
" ";
567 for (
Int_t iIdx = 0; iIdx < 5; iIdx++) {
570 std::cout <<
" | " << std::setw(3) << first <<
"-"
571 << std::setw(3) << last;
573 std::cout << std::endl;
575 gROOT->DecreaseDirLevel();
597 fFirstBin(o.fFirstBin),
598 fLastBin(o.fLastBin),
606 if (&o ==
this)
return *
this;
620 return Form(
"%c%03d_%c%03d",
621 (fLow >= 0 ?
'p' :
'm'),
Int_t(TMath::Abs(fLow)),
622 (fHigh >= 0 ?
'p' :
'm'),
Int_t(TMath::Abs(fHigh)));
631 const TAxis& etaAxis,
636 if (doHitMaps || storeSecMap) {
638 out->SetName(GetName());
644 fHitMap->Init(etaAxis);
651 for (
Int_t iIdx = 0; iIdx < 5; iIdx++) {
661 Int_t nEta = bg->GetNbinsX();
662 Int_t first = nEta+1;
666 for (
Int_t ie = 1; ie <= nEta; ie++) {
670 for (
Int_t ip = 1; ip <= bg->GetNbinsY(); ip++) {
678 first = TMath::Min(ie, first);
679 last = TMath::Max(ie, last);
682 fFirstBin[iIdx] = first;
683 fLastBin[iIdx] = last;
686 TH2* h = fHitMap->Get(d, r);
688 h->SetName(Form(
"hitMapFMD%d%c", d, r));
695 obg =
static_cast<TH2D*
>(bg->Clone(Form(
"secMapFMD%d%c", d, r)));
696 obg->SetDirectory(0);
702 Double_t old = coverage->GetBinContent(ie, fIndex);
703 coverage->SetBinContent(ie, fIndex, old+1);
705 for (
Int_t ip = 1; ip <= bg->GetNbinsY(); ip++) {
706 obg->SetBinContent(ie, ip, bg->GetBinContent(ie, ip));
707 obg->SetBinError(ie, ip, bg->GetBinError(ie, ip));
730 if (idx < 0 || idx >= fFirstBin.GetSize())
return;
740 GetFirstAndLast(idx, first , last);
748 GetFirstAndLast(idx, first , last);
752 #define PRINT_OVERFLOW(D,R,T,H) do { \
753 printf("Content of FMD%d%c overflow %s rebinning", D, R, T); \
755 for (Int_t ix = 1; ix <= t->GetNbinsX(); ix++) { \
756 Double_t c = t->GetBinContent(ix, t->GetNbinsY()+1); \
757 if (c <= 1e-9) continue; \
758 if ((i % 10) == 0) printf("\n "); \
759 printf("%3d: %5.2f ", ix, c); \
782 Char_t r = (q == 0 ?
'I' :
'O');
783 Int_t i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1));
793 TH2D* t =
static_cast<TH2D*
>(h->Clone(Form(
"FMD%d%c_tmp",d,r)));
798 GetFirstAndLast(d, r, first, last);
801 Int_t nY = t->GetNbinsY();
802 Int_t nX = t->GetNbinsX();
803 for (
Int_t iPhi = 0; iPhi <= nY+1; iPhi++) {
805 for (
Int_t iEta = 1; iEta < first; iEta++) {
806 t->SetBinContent(iEta,iPhi,0);
807 t->SetBinError(iEta,iPhi,0);
809 for (
Int_t iEta = last+1; iEta <= nX; iEta++) {
810 t->SetBinContent(iEta,iPhi,0);
811 t->SetBinError(iEta,iPhi,0);
815 for (
Int_t iEta = first; iEta <= last; iEta++)
816 t->SetBinContent(iEta,0,1);
818 for (
Int_t iEta = first; iEta <= last; iEta++)
819 t->SetBinContent(iEta,nY+1,1);
829 if (fHitMap && !eta2phi) fHitMap->Get(d, r)->Add(t);
833 TH3* dNdetaCent =
static_cast<TH3*
>(byCent->At(i-1));
834 if (cent >= 0 && dNdetaCent) {
835 Int_t iCent = dNdetaCent->GetYaxis()->FindBin(cent);
837 if (iCent > 0 && iCent <= dNdetaCent->GetNbinsY()) {
839 TH1* proj =
static_cast<TH1*
>(t->ProjectionX(
"tmp", 1, nY));
840 proj->SetDirectory(0);
841 for (
Int_t iEta = 1; iEta <= nX; iEta++) {
842 Double_t v1 = proj->GetBinContent(iEta);
843 Double_t e1 = proj->GetBinError(iEta);
844 Double_t v2 = dNdetaCent->GetBinContent(iEta, iCent, 1);
845 Double_t e2 = dNdetaCent->GetBinError(iEta, iCent, 1);
846 dNdetaCent->SetBinContent(iEta,iCent,1, v1+v2);
847 dNdetaCent->SetBinError(iEta,iCent,1, TMath::Sqrt(e1*e1+e2*e2));
850 Double_t uF = t->GetBinContent(iEta, 0);
851 Double_t oF = t->GetBinContent(iEta, nY+1);
853 Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 0);
854 dNdetaCent->SetBinContent(iEta, iCent, 0, old + uF);
857 Double_t old = dNdetaCent->GetBinContent(iEta, iCent, 2);
858 dNdetaCent->SetBinContent(iEta, iCent, 2, old + oF);
877 for (
Int_t iEta = first; iEta <= last; iEta++) {
880 Int_t overlap = GetOverlap(d,r,iEta);
885 if (m !=
kSum && overlap >= 0) {
890 if ((r ==
'o' || r ==
'O') &&
891 (overlap == 0 || overlap == 1 || overlap == 3))
895 else if ((r ==
'i' || r ==
'I') && (overlap == 2 || overlap == 4))
904 if ((r ==
'i' || r ==
'I') && (overlap == 2 || overlap == 4))
907 else if ((r ==
'O' || r ==
'o') &&
908 (overlap == 0 || overlap == 1 || overlap == 3))
917 Float_t ooc = out.GetBinContent(iEta,0);
918 out.SetBinContent(iEta, 0, ooc + fac);
921 Float_t oop = out.GetBinContent(iEta,nY+1);
922 Float_t nop = t->GetBinContent(iEta,nY+1);
924 Info(
"",
"etaBin=%3d Setting phi acceptance to %f(%f+%f)=%f",
925 iEta, fac, oop, nop, fac*(oop+nop));
927 out.SetBinContent(iEta, nY+1, fac * nop + oop);
930 for (
Int_t iPhi = 1; iPhi <= nY; iPhi++) {
931 Double_t c = t->GetBinContent(iEta,iPhi);
932 Double_t e = t->GetBinError(iEta,iPhi);
933 Double_t ee = t->GetXaxis()->GetBinCenter(iEta);
934 sumRings->Fill(ee, i, c);
938 if (fac <= 0 || c <= 0 || e <= 0)
continue;
943 if (overlap < 0 || fac >= 1) {
944 out.SetBinContent(iEta,iPhi,c);
945 out.SetBinError(iEta,iPhi,e);
950 Double_t oc = out.GetBinContent(iEta,iPhi);
951 Double_t oe = out.GetBinError(iEta,iPhi);
955 out.SetBinContent(iEta,iPhi, rc);
956 out.SetBinError(iEta,iPhi, re);
986 if (bin <= GetLast(2,
'I')) other =
GetIdx(2,
'I');
988 else if (d == 2 && r ==
'I') {
989 if (bin <= GetLast(2,
'O')) other =
GetIdx(2,
'O');
990 else if (bin >= GetFirst(1,
'I')) other =
GetIdx(1,
'I');
992 else if (d == 2 && r ==
'O') {
993 if (bin >= GetFirst(2,
'I')) other =
GetIdx(2,
'I');
995 else if (d == 3 && r ==
'O') {
996 if (bin <= GetLast(3,
'I')) other =
GetIdx(3,
'I');
998 else if (d == 3 && r ==
'I') {
999 if (bin >= GetFirst(3,
'O')) other =
GetIdx(3,
'O');
VtxBin & operator=(const VtxBin &o)
virtual ~AliFMDHistCollector()
Int_t GetLast(Int_t idx) const
AliForwardUtil::Histos * fHitMap
TH2D * GetCorrection(UShort_t d, Char_t r, Double_t v) const
void SetupForData(TH2 *coverage, UShort_t skip, FiducialMethod fiducial, Double_t cut, TList *l, const TAxis &etaAxis, Bool_t doHitMap, Bool_t storeSecMap)
TList * fByCent
Per-vertex list.
Int_t GetFirst(Int_t idx) const
static Color_t RingColor(UShort_t d, Char_t r)
Int_t GetOverlap(UShort_t d, Char_t r, Int_t bin) const
const Char_t * GetName() const
virtual void CreateOutputObjects(TList *dir)
virtual Bool_t Collect(const AliForwardUtil::Histos &hists, AliForwardUtil::Histos &sums, UShort_t vtxBin, TH2D &out, Double_t cent=-1.0, Bool_t eta2phi=false, Bool_t add=true)
Bool_t Collect(const AliForwardUtil::Histos &hists, AliForwardUtil::Histos &sums, TH2D &out, TH2D *sumRings, TH1D *skipped, Double_t cent, MergeMethod m, UShort_t skips, TList *byCent, Bool_t eta2phi, Bool_t add)
void GetFirstAndLast(UShort_t d, UShort_t r, Int_t &first, Int_t &last) const
void Print(Option_t *option="") const
static void MergeBins(MergeMethod m, Double_t c, Double_t e, Double_t oc, Double_t oe, Double_t &rc, Double_t &re)
AliFMDHistCollector & operator=(const AliFMDHistCollector &)
#define DGUARD(L, N, F,...)
static void PrintTask(const TObject &o)
TH2D * Get(UShort_t d, Char_t r) const
static TObject * MakeParameter(const char *name, UShort_t value)
VtxBin(Int_t index=0, Double_t minIpZ=999, Double_t maxIpZ=-999, Int_t nCut=0)
static void GetDetRing(Int_t idx, UShort_t &d, Char_t &r)
VtxBin * GetVtxBin(Int_t ivtx)
static Int_t GetIdx(UShort_t d, Char_t r)
static Bool_t CheckCorrection(FiducialMethod m, Double_t cut, const TH2D *bg, Int_t ie, Int_t ip)
const AliFMDCorrSecondaryMap * GetSecondaryMap() const
virtual void SetupForData(const TAxis &vtxAxis, const TAxis &etaAxis)
static Bool_t CheckSkip(UShort_t d, Char_t r, UShort_t skips)
static AliForwardCorrectionManager & Instance()
FiducialMethod fFiducialMethod