After filling a histogram that is setup for auto-binning, the bin information is not updated until I call TH1::Integral() (see example below). Is this the intended behavior? If so, what is the intended way to update the histogram so the bin information is set.
MINIMAL EXAMPLE:
root [0] TH1F h("h","",25,0,-1)
(TH1F &) Name: h Title: NbinsX: 25
root [1] h.Fill(100)
(int) -2
root [2] h.GetBinLowEdge(26)
(double) -1.0000000
root [3] h.Integral()
(double) 1.0000000
root [4] h.GetBinLowEdge(26)
(double) 101.20000
USE CASE:
I am comparing branches of a TTree by plotting two variables and comparing the histograms. I am not sure beforehand what range is needed for the histogram so I use auto-binning. However, auto-binning will not always give the same bin range when drawing the different TTree branches. So in an initial loop I am drawing the branches and checking the bin range determined by auto-binning. Then I use this information to hard-code the bin range. While doing this I noticed that I couldn’t get the bin edge information without calling Integral() first.
ROOT Version: v6-14-00
Platform: macOS 10.12.6
Compiler: Apple LLVM version 9.0.0 (clang-900.0.39.2)
@Wile_E_Coyote
Thanks for the quick reply. I found that those methods were not working (i.e. always returning 0). I think it may have to do with my TTrees storing user classes.
root [0]
Attaching file new_sample.root as _file0...
(class TFile *) 0x244bb20
root [1] MuonTriggerNt->GetMinimum("muons.pt")
(Double_t) 0.000000e+00
root [2] MuonTriggerNt->GetMaximum("muons.pt")
(Double_t) 0.000000e+00
root [3] MuonTriggerNt->Scan("muons.pt")
***********************************
* Row * Instance * muons.pt *
***********************************
* 0 * 0 * 80.532646 *
* 1 * 0 * 42.845775 *
* 2 * 0 * 54.021347 *
* 3 * 0 * 95.548072 *
.
.
.
I guess we need @pcanal here.
Maybe the output of MuonTriggerNt->Print();
would be helpful.
pcanal
November 15, 2018, 8:18pm
5
The calculation of the edge information is ‘expensive’ so it is delayed. To force the calculation call
h.BufferEmpty();
pcanal
November 15, 2018, 8:20pm
6
That is indeed one of the existing limitation of those routines. Consider using RDataFrame.
@pcanal This limitation is somehow surprising and nowhere described (at least I know of no place where it is mentioned).
Looking at the ROOT output shown in the previous post of @armstro1 , ROOT does not complain about unknown “muons” class and the Scan call shows reasonable values (again, I think MuonTriggerNt->Print();
would be helpful here).
pcanal
November 15, 2018, 9:02pm
8
@Wile_E_Coyote I used the word limitation, I should probably have used the word ‘deficiency’ and indeed we should update the GetMinimum/GetMaximum code and documentation to express this and mention/describe the replacement …
To force the calculation call
h.BufferEmpty();
@pcanal . Thank you. That works for me. I should’ve notice that function mentioned in relation to automatic binning in the TH1 documention .
Here is the printout:
root [0]
Attaching file new_sample.root as _file0...
(class TFile *) 0x2758120
root [1] .ls
TFile** new_sample.root
TFile* new_sample.root
KEY: TTree MuonTriggerNt;1 MuonTriggerNt
KEY: TH1F trig;1 Event-level triggers fired
root [2] MuonTriggerNt->Print()
******************************************************************************
*Tree :MuonTriggerNt: MuonTriggerNt *
*Entries : 250 : Total = 22989204 bytes File Size = 3911253 *
* : : Tree compression factor = 5.88 *
******************************************************************************
*Br 0 :event : TrigNtup::Event *
*Entries : 250 : Total Size= 33656 bytes File Size = 1574 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 21.08 *
*............................................................................*
*Br 1 :muons : vector<TrigNtup::Muon> *
*Entries : 250 : Total Size= 57139 bytes File Size = 29141 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.94 *
*............................................................................*
*Br 2 :mcMuons : vector<TrigNtup::TruthMuon> *
*Entries : 250 : Total Size= 30711 bytes File Size = 12562 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.41 *
*............................................................................*
*Br 3 :mdtChamber : vector<TrigNtup::MdtChamber> *
*Entries : 250 : Total Size= 144880 bytes File Size = 40031 *
*Baskets : 5 : Basket Size= 32000 bytes Compression= 3.61 *
*............................................................................*
*Br 4 :mdtHits : vector<TrigNtup::MdtHit> *
*Entries : 250 : Total Size= 2380988 bytes File Size = 623848 *
*Baskets : 79 : Basket Size= 32000 bytes Compression= 3.81 *
*............................................................................*
*Br 5 :tgcHits : vector<TrigNtup::TgcHit> *
*Entries : 250 : Total Size= 753868 bytes File Size = 140592 *
*Baskets : 26 : Basket Size= 32000 bytes Compression= 5.36 *
*............................................................................*
*Br 6 :rpcHits : vector<TrigNtup::RpcHit> *
*Entries : 250 : Total Size= 652637 bytes File Size = 104413 *
*Baskets : 23 : Basket Size= 32000 bytes Compression= 6.24 *
*............................................................................*
*Br 7 :mdtSegment : vector<TrigNtup::Segment> *
*Entries : 250 : Total Size= 183992 bytes File Size = 86354 *
*Baskets : 6 : Basket Size= 32000 bytes Compression= 2.12 *
*............................................................................*
*Br 8 :cscSegment : vector<TrigNtup::Segment> *
*Entries : 250 : Total Size= 22818 bytes File Size = 10223 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.18 *
*............................................................................*
*Br 9 :tgcCoincidence : vector<TrigNtup::TgcCoincidence> *
*Entries : 250 : Total Size= 4612 bytes File Size = 543 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 7.55 *
*............................................................................*
*Br 10 :muonsRoI : vector<TrigNtup::MuonRoI> *
*Entries : 250 : Total Size= 4582 bytes File Size = 536 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 7.63 *
*............................................................................*
*Br 11 :muCTPi : vector<TrigNtup::MuCTPi> *
*Entries : 250 : Total Size= 4572 bytes File Size = 533 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 7.67 *
*............................................................................*
*Br 12 :tileCells : vector<TrigNtup::TileCell> *
*Entries : 250 : Total Size= 18713564 bytes File Size = 2855819 *
*Baskets : 250 : Basket Size= 32000 bytes Compression= 6.55 *
*............................................................................*
When describing a “replacement”, please keep in mind that many people are stuck with ROOT versions prior to 6.14 (so no RDataFrame).
pcanal
November 15, 2018, 9:11pm
12
So muons is an unsplit collection and GetMaximum only work on things that are split.
system
Closed
November 29, 2018, 9:18pm
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.