Re: 2D TEfficiency

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Tue, 4 Jan 2011 11:09:36 +0100


See http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=11858

On Dec 22, 2010, at 9:36 AM, Simone Bifani wrote:

> Dear ROOTers,
>
> I am trying to use the TEfficiency class (ROOT 5.28.00) to parametrize a trigger efficiency as a function of two variables
>
> Unfortunately there is no TEfficiency TH2 constructor such as
>
> TEfficiency(const TH2& passed, const TH2& total)
>
> but I managed to use
>
> TEfficiency(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup)
>
>
> Suppose hNL1 is the TH2D histogram corresponding to the "passed" events and hDL1 to the "total" ones, I tried the following:
>
> TEfficiency *tEL1 = new TEfficiency("tEL1", "", hNL1->GetNbinsX(), hNL1->GetXaxis()->GetXmin(), hNL1->GetXaxis()->GetXmax(), hNL1->GetNbinsY(), hNL1->GetYaxis()->GetXmin(), hNL1->GetYaxis()->GetXmax());
> for (Int_t i = 1; i <= hNL1->GetNbinsX(); ++i) {
> for (Int_t j = 1; j <= hNL1->GetNbinsY(); ++j) {
> tEL1->GetPassedHistogram()->SetBinContent(i, j, hNL1->GetBinContent(i, j));
> tEL1->GetTotalHistogram()->SetBinContent(i, j, hDL1->GetBinContent(i, j));
> }
> }
>
> While using CINT everything is fine, if I try to compile this lines I get the following error
>
> error: passing 'const TH1' as 'this' argument of 'virtual void TH1::SetBinContent(Int_t, Int_t, Double_t)' discards qualifiers
>
> which as far as I can understand is due to the fact that GetPassedHistogram() and GetTotalHistogram() return a const object that I cannot modify
>
>
> My first question is how can I solve this problem? How can I easily create a 2D TEfficiency starting from two TH2D histos?
>
> Next, why there is no 2D TEfficiency constructor?
> Moreover, even if the TEfficiency class as it is now can be used to create 2D and 3D objects, why there is only a GetEfficiency(Int_t bin) method and not GetEfficiency(Int_t binx, Int_t biny) and GetEfficiency(Int_t binx, Int_t biny, Int_t binz) ones as well? I know I can use GetBin(Int_t binx, Int_t biny, Int_t binz) to retrieve the global bin number and this is working, but it would be handier
>
> Last question, as I mentioned earlier when using CINT the lines I wrote are working but when I draw the 2D TEfficiency object as tEL1->Draw("colz") X and Y axis doesn't correspond to the created ones according to hNL1 but both ranges goes from 0 to 1
> How is that possible?
>
>
> Thanks,
> s.
>
>
> <simone_bifani.vcf>
Received on Tue Jan 04 2011 - 11:10:13 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 04 2011 - 17:50:01 CET