Re: [ROOT] 'Draw' with a variable

From: lars ewell (ewell@ewell.rhic.bnl.gov)
Date: Wed Sep 19 2001 - 22:23:42 MEST


Freya,

	Thanks for the prompt response.

|> In real emergencies you can just create a character string with your cut
|> in there.
|> 
|> for example:
|> 
|> 	int somevalue = 5;
|> 	ostringstream mystream; 
|> 	mystream << "run = runlist[" <<  somevalue << "]"  << endl;
|> 	string thestring = mystream.str();	
|> 	ntuple.Draw("run", thestring.c_str() );
|> 
|> I know this works, although it's definitely not the most elegant
|> solution. (It *is* the solution I ended up using)
|> 
|>  if you get a more 'root-minded' response I would appreciate it if you
|> forwarded it to me.

	I got what I would call a 'C-minded' response which was
to use 'sprintf' to write a string to be used as the second
argument of the 'Draw' command.

	It wound up looking something like
	
------------

	char *run = new Char[5];
	char runnum[5] = "123";
	strncpy(run,runnum,4);
	sprintf(runcut,"run==%s",run);
	chain.Draw("histvar",runcut);

----------

	and it worked.  I think very similar to what you propose,
just using something more like C than C++.

	If I hear something more 'root-minded', I will
send it your way.

	Thanks again.

	Best 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