Fill multiple histograms with different functions and automatic binning. 
Illustrates merging with the power-of-two autobin algorithm
 
 OBJ: TStatistic   min   Mean = -0.18015 +- 0.08447    RMS = 0.26711     Count = 10     Min = -0.59373    Max = 0.24225
 OBJ: TStatistic   max   Mean = 6.178 +- 0.08377    RMS = 0.26491     Count = 10     Min = 5.8673   Max = 6.6579
 OBJ: TStatistic   dif   Mean = 6.3581 +- 0.151     RMS = 0.4774   Count = 10     Min = 5.7113   Max = 7.0745
 OBJ: TStatistic   mean     Mean = 3.0156 +- 0.01042   RMS = 0.032951    Count = 10     Min = 2.97     Max = 3.0729
 OBJ: TStatistic   rms   Mean = 0.99878 +- 0.008687    RMS = 0.02747     Count = 10     Min = 0.95965     Max = 1.0375
 ent: 10010
TH1.Print Name  = myh0, Entries= 10010, Total sum= 10008
TH1.Print Name  = myhref, Entries= 10010, Total sum= 9993
   
 
TF1 *gam = 
new TF1(
"gam", 
"1/(1+0.1*x*0.1*x)", -100., 100.);
 
TF1 *gam1 = 
new TF1(
"gam", 
"1/(1+0.1*x*0.1*x)", -1., .25);
 
TF1 *iga = 
new TF1(
"inv gam", 
"1.-1/(1+0.1*x*0.1*x)", -100., 100.);
 
TF1 *iga1 = 
new TF1(
"inv gam", 
"1.-1/(1+0.1*x*0.1*x)", -.5, 1.);
 
 
void fillhistosauto2p(
unsigned opt = 1, 
unsigned n = 1001)
 
{
 
 
 
   
   auto href = 
new TH1D(
"myhref", 
"current", 50, 0., -1.);
 
   href->SetBuffer(bsize);
 
   
   auto href2 = 
new TH1D(
"myhref", 
"Auto P2, sequential", 50, 0., -1.);
 
   href2->SetBuffer(bsize);
 
 
 
   for (
UInt_t j = 0; j < nh; ++j) {
 
      auto hw = 
new TH1D(hname.
Data(), 
"Auto P2, merged", nbins, 0., -1.);
 
      hw->SetBuffer(bsize);
 
 
         switch (opt) {
         case 1: xx = rndm.Gaus(3, 1); break;
         case 2: xx = rndm.Rndm() * 100. - 50.; break;
         default: xx = rndm.Gaus(0, 1);
         }
 
         if (buffering) {
            if (xx > xma)
               xma = xx;
            if (xx < xmi)
               xmi = xx;
            xw.Fill(xx);
         }
         hw->Fill(xx);
         href->Fill(xx);
         href2->Fill(xx);
         if (!hw->GetBuffer()) {
            
         }
      }
 
   }
 
 
      return;
 
 
   if (
gROOT->GetListOfCanvases()->FindObject(
"c3"))
 
      delete gROOT->GetListOfCanvases()->FindObject(
"c3");
 
 
   href2->StatOverflows();
 
   href->StatOverflows();
   std::cout << 
" ent: " << h0->
GetEntries() << 
"\n";
 
   href->Print();
 
   delete hlist;
   delete href;
   delete href2;
   delete h0;
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
 
R__EXTERN TStyle * gStyle
 
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
 
virtual Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr)
Return a random number following this function shape.
 
1-D histogram with a double per channel (see TH1 documentation)}
 
static void StatOverflows(Bool_t flag=kTRUE)
if flag=kTRUE, underflows and overflows are used by the Fill functions in the computation of statisti...
 
@ kAutoBinPTwo
different than 1.
 
void Print(Option_t *option="") const override
Print some global quantities for this histogram.
 
virtual Double_t GetEntries() const
Return the current number of entries.
 
virtual Long64_t Merge(TCollection *list)
 
void Add(TObject *obj) override
 
TObject * Remove(TObject *obj) override
Remove object from the list.
 
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
 
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
Random number generator class based on M.
 
Statistical variable, defined by its mean and variance (RMS).
 
const char * Data() const
 
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
 
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
 
- Date
 - November 2017 
 
- Author
 - Gerardo Ganis 
 
Definition in file fillhistosauto2p.C.