RE: Disable/enable filling an histogram

From: Fine, Valeri <fine_at_bnl.gov>
Date: Tue, 17 Jan 2006 12:01:20 -0500


Hello Legeard,

> Olivier Couet wrote:
>
> >Hello,
> >
> >I am sure my question is stupid, but why don't you simply not fill
the
> >histogram ? ie: do not call TH1:Fill() ?
> >I am sure you have a very good reason to ask this and may be there is
an
> >other way to achieve the same result.
> >
> > Cheers, Olivier
> >
> >
> >
> Yes it is exactly what i want
> but when you have a lot of histograms
> and you want to devalidate the filling on 100 of them
> it is simpler not to change you code and juste tell to wanted
histograms
> to be hang!
>
> Thank you for you interest of my trouble!

ROOT is C++ package and such things are supposed to be resolved via C++ subclassing.
Create your own MyTriggeredHistogram derived from TH1F and overload the Fill method.

  void MyTriggeredHistogram::SetAcive(Bool_t on=kTRUE)   { fActive = on;}

  Int_t MyTriggeredHistogram::Fill(Double_t x){     Int_t bin = -1;
    if (fActive) bin= TH1F::Fill(x);
    return bin;
  }  

>
> Luc
>
> >On Tue, 17 Jan 2006, Legeard Luc wrote:
> >
> >
> >
> >>Hello Rooters
> >>
> >>I'd like know if there a posibility to disable/enable filling an
> histogram
> >>for example :
> >>
> >>we can imaging a such method TH1:Enable(Bool_t boolenable) with
this
> >>behaviour:
> >>
> >>TH1F <http://root.cern.ch/root/html////TH1F.html> *h1 = new TH1F
> >><http://root.cern.ch/root/html////TH1F.html>("h1","h1",10,0,10);
> >>
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
fill
> bin 1
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
fill
> bin 1
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
fill
> bin 2
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
fill
> bin 2
> >>h1->Enable(kFALSE);
> >>
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
no
> action
> >>!
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
no
> action
> >>!
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
no
> action
> >>!
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
no
> action
> >>! h1->Enable(kTRUE);
> >>
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
fill
> bin 1
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(1); //
fill
> bin 1
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
fill
> bin 2
> >>h1->Fill <http://root.cern.ch/root/html///TH1.html#TH1:Fill>(2); //
fill
> bin 2
> >>
> >>
> >>Thanks a lot for your help
> >>
> >>Luc
> >>
> >>
> >>
> >>
> >
> >
> >
>
>
> --
> ------------------------------------------------------------
> - Luc LEGEARD - Tel : 02 31 45 44 36 -
> - GANIL BP 55027 Bd Becquerel - Fax : 02 31 45 47 97 -
> - 14076 CAEN Cedex 5 - mailto:legeard_at_ganil.fr -
> - Web http://www.ganil.fr
Received on Tue Jan 17 2006 - 18:01:46 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:56 MET