3 #include "TProfile2D.h"
11 sprintf(name,
"%s_proj",prof2d->GetName());
12 res =
new TH1D(name,prof2d->GetTitle(),prof2d->GetNbinsY(),prof2d->GetYaxis()->GetXmin(),prof2d->GetYaxis()->GetXmax());
15 for(
int iy=1;iy<prof2d->GetNbinsY()+1;++iy) {
19 for(
int ix=1;ix<prof2d->GetNbinsX()+1;++ix) {
20 const int ibin = prof2d->GetBin(ix,iy);
21 sum += prof2d->GetBinContent(ibin)*prof2d->GetBinEntries(ibin);
22 sumsq += prof2d->GetBinError(ibin)*prof2d->GetBinError(ibin)*prof2d->GetBinEntries(ibin)*prof2d->GetBinEntries(ibin)+
23 prof2d->GetBinContent(ibin)*prof2d->GetBinContent(ibin)*prof2d->GetBinEntries(ibin);
24 nevt += prof2d->GetBinEntries(ibin);
26 double mean = nevt==0 ? 0: sum/nevt;
27 double meansq = nevt==0 ? 0: sumsq/nevt;
28 double err = meansq >= mean*mean ?
sqrt(meansq-mean*mean) : 0;
29 err = nevt==0 ? 0 : err/
sqrt(nevt);
30 res->SetBinContent(iy,mean);
31 res->SetBinError(iy,err);
44 sprintf(name,
"%s_proj",prof2d->GetName());
45 res =
new TH1D(name,prof2d->GetTitle(),prof2d->GetNbinsX(),prof2d->GetXaxis()->GetXmin(),prof2d->GetXaxis()->GetXmax());
48 for(
int ix=1;ix<prof2d->GetNbinsX()+1;++ix) {
52 for(
int iy=1;iy<prof2d->GetNbinsY()+1;++iy) {
53 const int ibin = prof2d->GetBin(ix,iy);
54 sum += prof2d->GetBinContent(ibin)*prof2d->GetBinEntries(ibin);
55 sumsq += prof2d->GetBinError(ibin)*prof2d->GetBinError(ibin)*prof2d->GetBinEntries(ibin)*prof2d->GetBinEntries(ibin)+
56 prof2d->GetBinContent(ibin)*prof2d->GetBinContent(ibin)*prof2d->GetBinEntries(ibin);
57 nevt += prof2d->GetBinEntries(ibin);
59 double mean = nevt==0 ? 0: sum/nevt;
60 double meansq = nevt==0 ? 0: sumsq/nevt;
61 double err = meansq >= mean*mean ?
sqrt(meansq-mean*mean) : 0;
62 err = nevt==0 ? 0 : err/
sqrt(nevt);
63 res->SetBinContent(ix,mean);
64 res->SetBinError(ix,err);
TH1D * projectProfile2DAlongY(TProfile2D *prof2d)
TH1D * projectProfile2DAlongX(TProfile2D *prof2d)