Mean of TEfficiency object

Hey there,

I’ve just recently discovered, that there is an object called TEfficiency.
Until now, I have been using histogram pairs and converted them into a single TGraphAsymmerrorrs object to depict efficiencies, so thank you for this feature!

My question is: is it possible to easily calculate mean efficiency using this object?

Is this the most compact code to achieve this functionality?

Note that getting the mean among the “value-axis” seems broken.

TH1* dummy;
dummy -> Multiply(eff -> GetTotalHistogram(), eff -> GetPassedHistogram());
double mean = dummy -> GetMean(1);

What about 2D efficiencies?

Cheers,
Adam Hunyadi

Also, calling Multiply on TH2D objects results weird behaviour. This code:

std::cout << detectorPartROCHits -> GetNcells() << " " << detectorPartROCEfficiencies -> GetNcells() << std::endl;
dummy -> Multiply(detectorPartROCHits, detectorPartROCEfficiencies);
double mean = dummy -> ProjectionX() -> GetMean(2);
std::cout << "mean: " << mean  << std::endl;

outputs:

4440 4440
Error in TH2D::Multiply: Attempt to multiply histograms with different number of bins
mean: 0.000000

HI,

I have not understood your problem. Which Mean do you want, the mean computed by weighting by the efficiency value in each bin or the mean of the efficiency value ?

Lorenzo

Hello Lorenzo,

I am looking for the mean of the efficiencies, so I would like to add weights to every bin depending on the number of entries in that particular bin.

Cheers,
Adam Hunyadi

Hello,

TEfficiency returns the efficiency value in every bin. You can then compute their weighted mean by for example by filling an additional histogram given as input values the efficiency in each bin and their weight.

Lorenzo

Yes, but it’s quite complicated (in terms of both code length and efficiency), especially the error calculation. There “should” be a default function to calculate them while filling the efficiency histograms, shouldn’t it?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.