My code does not work while I try to use Rebin with variable bin size.
There is no error but the rebinned histogram is not drawn.
Could you please help to correct it.
root [0]
Processing NA.C...
In file included from input_line_9:1:
/Users/couet/Downloads/NA.C:21:2: error: use of undeclared identifier 'Read_Simulation'
Read_Simulation("Run0001.root","hExI0to36TSC_",20,"","");
^
ROOT 5.34/32 (v5-34-32@v5-34-32, Jun 23 2015, 17:58:02 on win32)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing NA.C…
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
root [1]
Now i get more details with the very recent ROOT version
root [0]
Processing NA.C...
Warning in <TH1D::Rebin>: Bin edge 1 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 2 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 3 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 4 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 5 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 6 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 7 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 8 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 9 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 10 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 11 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 12 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1]
Your main function is calling a sub-function you have not declared at the beginning of the file. Either you declare it or you write the called function before the main function.
When I run it with the latest ROOT version I get the following messages:
$ root NA.C
------------------------------------------------------------
| Welcome to ROOT 6.19/01 https://root.cern |
| (c) 1995-2019, The ROOT Team |
| Built for macosx64 on Jun 28 2019, 07:44:41 |
| From heads/master@v6-19-01-295-g30065525ce |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0]
Processing NA.C...
Warning in <TH1D::Rebin>: Bin edge 1 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 2 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 3 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 4 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 5 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 6 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 7 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 8 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 9 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 10 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 11 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Warning in <TH1D::Rebin>: Bin edge 12 of rebinned histogram does not much any bin edges of the old histogram. Result can be inconsistent
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
Read_Simulation must be defined before used as couet pointed out
h1new, h1rebin need SetDirectory(0) otherwise they go out of
scope when macro terminates (TFile f was current dir)
more serious:
Rebin works only correctly if the new bin edges coincide with an
edge in the original hist (bins can’t be divided)
The best you can do refill a new histogram taking the
bin centers and contents of the original. (see att macro)
The right thing to do would to fill new histogram at the
time you fill the originals when you still have the exact
values
Cheers
Otto
PS: for the maintainer of TH1:
The word “much” in
"histogram does not much any bin edges "
should be “match” I guess