Re: [ROOT] Cut Definition and Command Draw

From: Matthieu Guillo (guillo@jlab.org)
Date: Wed Apr 04 2001 - 17:27:00 MEST


Hi Annalisa,

To answer to your first question, you can use the sprintf function
(C style) or the more elaborated ostrstream object (C++ style). In a
simple case like yours, sprintf seems more appropriate to me.
So you type:

TFile* file = new TFile("strip4_z2.root");
TNtuple* ntuple=(TNtuple*)file->Get("h8;1");
(....) ; // whatever goes there
float zmincut, zmaxcut;
cout << "Give me the zmincut, please " << flush;  // nice way
cin >> zmincut;
cout<< "\nGive me the zmaxcut, right now " << flush;  // rude way
cin >> zmaxcut;

char szCut[80];  // string holder for the cut
sprintf(szCut,"Zpos > %f && Zpos < %f", zmincut, zmaxcut);  // creates the
string for the cut
ntuple->Draw("Iadc1", szCut);

Hope that helps


Matthieu Guillo
University of South Carolina
Thomas Jefferson National Laboratory
Office 71 trailer 16
Phone: 757-269-5551

On Wed, 4 Apr 2001, Annalisa De Caro wrote:

>    Hi rooters,
> thank you at all for you answers to my question... but i think that i was
> not very clear...
> 
> First problem:
> This command lines are in a macro, that (in execution) ask me the value
> for zmincut... then i do not know a priori his value!!! For example:
>    TFile* file = new TFile("strip4_z2.root");
>    TNtuple* ntuple=(TNtuple*)file->Get("h8;1");
> (...)
>    cout<<"Give me the zmincut, please ";
>    cin>>zmincut;
>    ntuple->Draw("Iadc1","Xpos>zmincut");
> 
> 
> Second problem:
> +And an other problem...
> +When the command Draw (ntuple-Draw("Xpos"); or histogram->Draw();)is
> +inside a macro, the histogram is plotted only when the macro is closed.
> +And When the command Draw is inside a macro called by an other main
> +macro, the histogram is plotted only when the main macro is closed. But
> +how can i interact with the histogram (to draw a line where i want, for
> +example), if i do not see him?
> 
> For example:
>    ntuple->Draw("Zpos");
>    cout<<'\n'<<"Give me the zmincut, please ";
>    cin>>zmincut;
>    cout<<'\n'<<"Give me the zmaxcut, please ";
>    cin>>zmaxcut;
>    ntuple->Draw("Iadc1","Zpos>zmincut && Zpos<zmaxcut");
> 
> If i understand, in cuts definition, the cut values can be numeric only!!!
> 
>   Thank you
> 
> 
> *************************************************************************
> *    University of Bologna    |                   |  decaro@bo.infn.it  *
> *     Physics Department      | +39 051  20 91103 |                     *
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> *    University of Salerno    |                   |                     *
> * Physics Sciences Department | +39 089  96 5359  |                     *
> *       (INFN of Napoli)      |                   |                     *
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> *     CERN - EP division      |                   | decaro@mail.cern.ch *
> *        (Bld.29 R019)        | +41  22  76 77767 |                     *
> *************************************************************************
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET