[gate-users] Draw method with a selection based on logical operation on strings

GUEZ David dguez at cea.fr
Sun Sep 4 00:40:51 CEST 2005


tim tran a écrit :

> Hi 
>  
> I have just entered the exciting field of detector simulation using GATE.
> I am using ROOT for analysis of Gate.root data. 
>  
> First of all, I like to thank all those who have made it possible for 
> these wonderful software packages to be freely available for 
> researchers all over the world.
>  
> Now, I have a  question about displaying histogram using ROOT.
>  
> The Draw() method provides a very easy way to display a histogram and 
> has a very neat implementation of a selection option.
>  
> e.g.,  Singles->Draw("globalPosX","energy>0.1");  Display those 
> Singles with energy less than 0.1 Mev.
>  
> However, the easy selection method does not seem to extend to string 
> operation. For example, if I want to display the same globalPosX for 
> those Singles that had at least Compton interaction in the SPECThead, 
> I thought the following line might work, it it did not,
>  
>  
>   Singles->Draw("globalPosX","!strcmp(comptVolName,"SPECTHead"));  To 
> display those Singles with a Compton interaction in the SPECThead.
>  
> However, the 'comptVolName' is not recognized by ROOT, while 
> globalPosX is.  
>  
> Can some one point out what was wrong with the above line?
>  
> Is there a correct and similarly easy way to display a variable with 
> logical operation on strings as a selection method?
>  
> I understand that an alternative way is to use the Get Entry() method 
> in a loop. 
>  
> If using GetEntry() is the only way possible to display a histogram 
> when selection is based on comparison of strings, please tell me, so I 
> won't keep looking for an easy way out.
>  
>  
> Thanks in advance.
>  
> Tim
>  
>  
>  
>  
>  
>  
>  
>    
>  
>  
>  
>  
>   
>
>------------------------------------------------------------------------
>
>_______________________________________________
>gate-users mailing list
>gate-users at lphe1pet1.epfl.ch
>http://lphe1pet1.epfl.ch/mailman/listinfo/gate-users
>  
>

Hello,
you could directly use the equality operator in the slection string, but 
you must protect the quotes, so you should use
the command line
Singles->Draw("globalPosX","comptVolName==\"SPECTHead\"")

I'd just like to add a comment, the volume names you entered in the GATE 
macr are automatically suffixed with a '_P' for G4
so, the name you of your volume name is probably SPECTHead_P, leading to 
the command line
Singles->Draw("globalPosX","comptVolName==\"SPECTHead_P\"")

best regards,

       David

-- 
*****************************************************************
*****************************************************************
**  David GUEZ                                                 **
**  ^^^^^^^^^^                                                 **
**                                                             **
**  Service de Physique Nucléaire |                            **
**  CEA Saclay                    | mail :dguez at cea.fr         **
**  DSM/DAPNIA/SPHN               | tel : (+33) 1 69 08 33 68  **
**  91191 Gif sur Yvette Cedex    | fax : (+33) 1 69 08 75 84  **
**  Bat. 703/p. 104               |                            **
**                                                             **
*****************************************************************
*****************************************************************






More information about the Gate-users mailing list