Re: [ROOT] 'Draw' with a variable

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Sep 19 2001 - 22:11:34 MEST


Hi Lars,

I suggest the following conservative solution:
       int runlist[3] = {1,2,3}; 
       char cut[20];
       for (i = 0; i < 3 ; i++) {
         sprintf(cut,"run == %d",runlist[i]);
         ntuple.Draw("run",cut);
       }

Note the "==" instead of "=" !

Rene Brun

On Mon, 17 Sep 2001, lars ewell wrote:

> To Whom it May Concern,
> 
> 	I have been attempting to use the "Draw" command within a
> macro that references a variable I have defined in the macro.
> Although this seems like it should be straightforward, I have 
> had little success.
> 
> 	For example, I have a list of runs that I want to
> loop over.  In my ROOT ntuple, there is defined a 'run'
> variable.  In my macro then, I want to check that 'run'
> variable matches a number on my run list.
> 
> 	The code looks something like this;
> 
> 	.
> 	. 
> 	int runlist[3] = {1,2,3};
> 	for (i = 0; i < 3 ; i++) {
> 	   ntuple.Draw("run", "run = runlist[i]";
> 	 }
> 	.
> 	.
> 	.
> 
> 
> 	If I use the number '1' in place of 'runlist[i]', of
> course it works fine.  However, I want to use a *variable* and not 
> a number.  I have attempted to use variation of the 'TCut' command 
> in place of the selection and different placements of the double 
> quotes but have not been able to succeed.  In addition, I have looked
> over the TTree page (http://root.cern.ch/root/html/TTree.html) but
> was not able to see this problem addressed.
> 
> 	Any advice?
> 
> 	Thanks in advance.
> 
> 	regards,
> 
> 	Lars
> 	
> -- 
> ______________________________________
>  Lars Ewell 
>  Brookhaven National Laboratory
>  PHENIX Group
>  Physics Dept. 510C
>  Upton, NY 11973  
>  
>  ewell@bnl.gov
>  Phone (631)344-7070
>  FAX   (631)344-3253
>  www   http://www.phenix.bnl.gov/~ewell
> _____________________________________
> 
> 



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