You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
We've migrated all our DAQ (and I guess also DQM?) machines to cc7 which defaults to ROOT v6.X. In this version of ROOT by default TH1::Sumw2() is automatically set, see the TH1 Class Documentation. This causes error bars of some of our histograms to not be set correctly.
Types of issue
Bug report (report an issue with the code)
Feature request (request for change which adds functionality)
Expected Behavior
For a counting experiment (almost all of our scan routines) the error bar should go as sqrt(N) where N is the bin content.
Current Behavior
Due to the differences between ROOT 6.X and 5.34 the TH1::Sumw2() method is automatically called.
Our analysis routines usually use the Int_t TH1::Fill(Double_t x,Double_t w ) method for storing values in the histogram where x and w come from the input TTree object. However this is only being called once per bin so the error bar ends up equalling w e.g. the sum of weights squared is a sum over one number.
Run any anaUltra script on a machine where ROOT is v6.X or higher.
Look at the error bars on the produced plots
Possible Solution (for bugs)
Proposal 1
Call TH1::SetDefaultSumw2(False) at the start of each script. Although this is a static ROOT function and I'm not sure how that will play in python.
If it works this is the simplest fix.
Proposal 2
Use event.indepVar to determine the corresponding bin in the histogram, e.g.
for idx in range(1, Histo.GetNbinsX()+1):
if (Histo.GetBinLowEdge(1) + idx*Histo.GetBinLowEdge(1) ) <= event.indepVar and indepVar < (Histo.GetBinLowEdge(1) + (idx+1)*Histo.GetBinLowEdge(1) ):
Histo.SetBinContent(idx, event.depVar)
Disadvantage is that this is pretty slow...
Proposal 3
Change all TH1 objects to TGraph objects (or inherited classes, e.g. TGraphErrors or TGraphAsymErrors) and use the TGraph::SetPoint(...) method for plotting from the TTree.
If you draw the TGraph object you could then use the TGraph::GetHistogram() method to return a TH1 if it's absolutely necessary.
Context (for feature requests)
This is particularly a problem when we are fitting distributions since the error bars on the data points will be accounted in the fitting and having each point as N +/- N is probably not going to give good fit results.
Your Environment
Version used: I think any commit will have this problem
Shell used: zsh
The text was updated successfully, but these errors were encountered:
Regarding proposal 1: Using r.TH1.SetDefaultSumw2(False) will work in python
EDIT: Actually, the better (more correct) thing to do would also be to explicitly set the errors whenever using a SetBinContent type assignment
I would suggest fixing this by finding the chargeBin as was done in anaUltraScurve.py. To do so you'll need to get the list of bin edges in terms of charge, e.g. replace Y with X:
Brief summary of issue
We've migrated all our DAQ (and I guess also DQM?) machines to cc7 which defaults to ROOT v6.X. In this version of ROOT by default TH1::Sumw2() is automatically set, see the TH1 Class Documentation. This causes error bars of some of our histograms to not be set correctly.
Types of issue
Expected Behavior
For a counting experiment (almost all of our scan routines) the error bar should go as
sqrt(N)
whereN
is the bin content.Current Behavior
Due to the differences between ROOT 6.X and 5.34 the
TH1::Sumw2()
method is automatically called.Our analysis routines usually use the Int_t TH1::Fill(Double_t x,Double_t w ) method for storing values in the histogram where
x
andw
come from the inputTTree
object. However this is only being called once per bin so the error bar ends up equallingw
e.g. the sum of weights squared is a sum over one number.See for example:
Steps to Reproduce (for bugs)
Possible Solution (for bugs)
Proposal 1
Call TH1::SetDefaultSumw2(False) at the start of each script. Although this is a static ROOT function and I'm not sure how that will play in python.
If it works this is the simplest fix.
Proposal 2
Use
event.indepVar
to determine the corresponding bin in the histogram, e.g.Disadvantage is that this is pretty slow...
Proposal 3
Change all
TH1
objects toTGraph
objects (or inherited classes, e.g.TGraphErrors
orTGraphAsymErrors
) and use theTGraph::SetPoint(...)
method for plotting from theTTree
.If you draw the
TGraph
object you could then use theTGraph::GetHistogram()
method to return a TH1 if it's absolutely necessary.Context (for feature requests)
This is particularly a problem when we are fitting distributions since the error bars on the data points will be accounted in the fitting and having each point as
N +/- N
is probably not going to give good fit results.Your Environment
zsh
The text was updated successfully, but these errors were encountered: