24 h2D.TH2D::Copy(*
this);
26 fBinEntries.Set(fNcells);
27 fBinSumw2.Set(fNcells);
29 for (
int i=0; i<fNcells; i++)
31 if (h2D.GetBinContent(i) && h2D.GetBinError(i))
33 fBinEntries.fArray[i] = 1;
34 fBinSumw2.fArray[i] = fSumw2.fArray[i];
36 fBinEntries.fArray[i] = 0;
37 fBinSumw2.fArray[i] = 0;
44 Int_t nbinsy, Double_t ylow, Double_t yup, std::string options) :
45 TProfile2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup, options.c_str())
47 SetOption(options.c_str());
52 Int_t nbinsy,
const Double_t* ybins, std::string options) :
53 TProfile2D(name.c_str(), title.c_str(), nbinsx, xbins, nbinsy, ybins, options.c_str())
55 SetOption(options.c_str());
61 for (
int iBin=0; iBin<fNcells; ++iBin)
63 double bc = GetBinContent(iBin);
64 double be = GetBinError(iBin);
67 if (!bc && !be)
continue;
69 fBinEntries.fArray[iBin] = val;
77 CheckConsistency((TH1*)
this, (TH1*) &prof2);
79 Error(
"Multiply",
"Attempt to multiply histograms with different number of bins");
82 Warning(
"Multiply",
"Attempt to multiply histograms with different axis limits");
84 Warning(
"Multiply",
"Attempt to multiply histograms with different bin limits");
86 Warning(
"Multiply",
"Attempt to multiply histograms with different labels");
90 for (Int_t i = 0; i < fNcells; ++i) {
91 Double_t c1 = prof2.GetBinContent(i);
98 TProfile *
Profile2D::ProfileX(
const char *name, Int_t firstybin, Int_t lastybin, Option_t *option)
const
115 return DoProfile(
true, name, firstybin, lastybin, option);
137 return DoProfile(
false, name, firstxbin, lastxbin, option);
141 TProfile *
Profile2D::DoProfile(
bool onX,
const char *name, Int_t firstbin, Int_t lastbin, Option_t *option)
const
146 TString opt = option;
148 bool originalRange = opt.Contains(
"o");
150 TString expectedName = ( onX ?
"_pfx" :
"_pfy" );
153 if (pname.IsNull() || name == expectedName)
154 pname = TString(GetName() ) + expectedName;
156 const TAxis& outAxis = ( onX ? fXaxis : fYaxis );
157 const TArrayD *bins = outAxis.GetXbins();
158 Int_t firstOutBin = outAxis.GetFirst();
159 Int_t lastOutBin = outAxis.GetLast();
165 p1 =
new TProfile(pname,GetTitle(), outAxis.GetNbins(), outAxis.GetXmin(), outAxis.GetXmax(), opt );
167 p1 =
new TProfile(pname,GetTitle(), lastOutBin-firstOutBin+1,
168 outAxis.GetBinLowEdge(firstOutBin),outAxis.GetBinUpEdge(lastOutBin), opt);
172 p1 =
new TProfile(pname,GetTitle(),outAxis.GetNbins(),bins->fArray,opt);
174 p1 =
new TProfile(pname,GetTitle(),lastOutBin-firstOutBin+1,&bins->fArray[firstOutBin-1],opt);
178 if (fBinSumw2.fN) p1->Sumw2();
181 TH2D * h2dW = ProjectionXY(
"h2temp-W",
"W");
182 TH2D * h2dN = ProjectionXY(
"h2temp-N",
"B");
184 h2dW->SetDirectory(0); h2dN->SetDirectory(0);
187 TString opt1 = (originalRange) ?
"o" :
"";
188 TH1D * h1W = (onX) ? h2dW->ProjectionX(
"h1temp-W",firstbin,lastbin,opt1) : h2dW->ProjectionY(
"h1temp-W",firstbin,lastbin,opt1);
189 TH1D * h1N = (onX) ? h2dN->ProjectionX(
"h1temp-N",firstbin,lastbin,opt1) : h2dN->ProjectionY(
"h1temp-N",firstbin,lastbin,opt1);
190 h1W->SetDirectory(0); h1N->SetDirectory(0);
197 for (
int i = 0; i < p1->fN ; ++i) {
198 p1->fArray[i] = h1W->GetBinContent(i);
199 p1->GetSumw2()->fArray[i] = h1W->GetSumw2()->fArray[i];
200 p1->SetBinEntries(i, h1N->GetBinContent(i) );
201 if (fBinSumw2.fN) p1->GetBinSumw2()->fArray[i] = h1N->GetSumw2()->fArray[i];
211 p1->SetEntries( p1->GetEffectiveEntries() );
virtual TProfile * DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
ClassImp(Profile2D) Profile2D
TProfile * ProfileY(const char *name="_pfy", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
R__ASSERT(refX!=0 &&refY!=0 &&refZ!=0)
TProfile * ProfileX(const char *name="_pfx", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
Bool_t Multiply(const Profile2D &prof2)
void ResetBinEntries(double val)