List Info

Thread: python ROOT access




python ROOT access
user name
2008-03-02 14:22:38
Hi ROOTers,
could someone with pyROOT configured properly check the
following in python:

(ROOT 5.19/01)

$ python
Python 2.5.2 (r252:60911, Feb 27 2008, 18:32:21)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu1)] on linux2
Type "help", "copyright",
"credits" or "license" for more
information.
>>> import ROOT
>>> combi  = ROOT.TGeoCombiTrans()
>>> matrix = combi.GetRotationMatrix()
>>> print matrix[0]
1.0
>>> matrix[0]=0.99

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library
"/lib/tls/i686/cmov/libthread_db.so.1".
Attaching to program: /proc/8053/exe, process 8053
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d428c0 (LWP 8053)]
[New Thread 0xb521db90 (LWP 8069)]
(no debugging symbols found)...done.

0xb7eef410 in __kernel_vsyscall ()
error detected on stdin
The program is running.  Quit anyway (and detach it)? (y or
n)
[answered Y; input not from terminal]
Detaching from program: /proc/8053/exe, process 8053

>>> combi = ROOT.TGeoRotation()
>>> matrix = combi.GetRotationMatrix()
>>> matrix[0]
1.0
>>> matrix[0]=0.99
>>> print matrix[0]
0.99

In the same time doing quite the same with TGeoRotation
instead works OK.
What's my error then ? Or what's the proper way of feeding a
TGeoCombiTrans
from python with [x,y,z] as translation and
[1,0,0,0,1,0,0,0,1] as
rotation "matrix" ?

Regards
Michal


Re: python ROOT access
country flaguser name
United States
2008-03-02 14:49:56
I see the same result with 5.18 on Mac OS X 10.5.2.

The problem is that PyROOT is letting you violate the method
signature  
of GetRotationMatrix():

const Double_t *TGeoCombiTrans::GetRotationMatrix() const;

You should not assign values using the Double_t pointer
returned by  
the method, as it is declared const.  Assignment worked
anyway for  
TGeoRotation since the method always returns a pointer to an
internal  
buffer in the object.  However, TGeoCombiTrans does this:

const Double_t *TGeoCombiTrans::GetRotationMatrix() const
{
// get the rotation array
    if (!fRotation) return kIdentityMatrix;
    return fRotation->GetRotationMatrix();
}

When it takes the first branch, it returns a pre-defined
constant  
matrix, which for some reason triggers a segfault when you
try to  
modify it.

See the TGeoCombiTrans constructor for the correct way to
instantiate  
it with a given offset and rotation.

On Mar 2, 2008, at 2:22 PM, Michal Dwuznik wrote:

> Hi ROOTers,
> could someone with pyROOT configured properly check the
following in  
> python:
>
> (ROOT 5.19/01)
>
> $ python
> Python 2.5.2 (r252:60911, Feb 27 2008, 18:32:21)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu1)] on linux2
> Type "help", "copyright",
"credits" or "license" for more
information.
>>>> import ROOT
>>>> combi  = ROOT.TGeoCombiTrans()
>>>> matrix = combi.GetRotationMatrix()
>>>> print matrix[0]
> 1.0
>>>> matrix[0]=0.99
>
> *** Break *** segmentation violation
> (no debugging symbols found)
> Using host libthread_db library
"/lib/tls/i686/cmov/libthread_db.so. 
> 1".
> Attaching to program: /proc/8053/exe, process 8053
> [Thread debugging using libthread_db enabled]
> [New Thread 0xb7d428c0 (LWP 8053)]
> [New Thread 0xb521db90 (LWP 8069)]
> (no debugging symbols found)...done.
>
> 0xb7eef410 in __kernel_vsyscall ()
> error detected on stdin
> The program is running.  Quit anyway (and detach it)?
(y or n)
> [answered Y; input not from terminal]
> Detaching from program: /proc/8053/exe, process 8053
>
>>>> combi = ROOT.TGeoRotation()
>>>> matrix = combi.GetRotationMatrix()
>>>> matrix[0]
> 1.0
>>>> matrix[0]=0.99
>>>> print matrix[0]
> 0.99
>
> In the same time doing quite the same with TGeoRotation
instead  
> works OK.
> What's my error then ? Or what's the proper way of
feeding a  
> TGeoCombiTrans
> from python with [x,y,z] as translation and
[1,0,0,0,1,0,0,0,1] as
> rotation "matrix" ?
>
> Regards
> Michal


Re: python ROOT access
user name
2008-03-02 15:01:17
Thank you,

going around via defining

xyz=TGeoTranslation()
rot=TGeoRotation()

modifying those and creating
combi=TGeoCombiTrans()
combi.SetTranslation(xyz)
combi.SetRotation(rot) works as advertised 

Regards
Michal

2008/3/2, Stanley Seibert <volsungphysics.utexas.edu>:
> I see the same result with 5.18 on Mac OS X 10.5.2.
>
>  The problem is that PyROOT is letting you violate the
method signature
>  of GetRotationMatrix():
>
>  const Double_t *TGeoCombiTrans::GetRotationMatrix()
const;
>
>  You should not assign values using the Double_t
pointer returned by
>  the method, as it is declared const.  Assignment
worked anyway for
>  TGeoRotation since the method always returns a pointer
to an internal
>  buffer in the object.  However, TGeoCombiTrans does
this:
>
>  const Double_t *TGeoCombiTrans::GetRotationMatrix()
const
>  {
>  // get the rotation array
>     if (!fRotation) return kIdentityMatrix;
>     return fRotation->GetRotationMatrix();
>  }
>
>  When it takes the first branch, it returns a
pre-defined constant
>  matrix, which for some reason triggers a segfault when
you try to
>  modify it.
>
>  See the TGeoCombiTrans constructor for the correct way
to instantiate
>  it with a given offset and rotation.
>
>
>  On Mar 2, 2008, at 2:22 PM, Michal Dwuznik wrote:
>
>  > Hi ROOTers,
>  > could someone with pyROOT configured properly
check the following in
>  > python:
>  >
>  > (ROOT 5.19/01)
>  >
>  > $ python
>  > Python 2.5.2 (r252:60911, Feb 27 2008, 18:32:21)
>  > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu1)] on linux2
>  > Type "help", "copyright",
"credits" or "license" for more
information.
>  >>>> import ROOT
>  >>>> combi  = ROOT.TGeoCombiTrans()
>  >>>> matrix = combi.GetRotationMatrix()
>  >>>> print matrix[0]
>  > 1.0
>  >>>> matrix[0]=0.99
>  >
>  > *** Break *** segmentation violation
>  > (no debugging symbols found)
>  > Using host libthread_db library
"/lib/tls/i686/cmov/libthread_db.so.
>  > 1".
>  > Attaching to program: /proc/8053/exe, process
8053
>  > [Thread debugging using libthread_db enabled]
>  > [New Thread 0xb7d428c0 (LWP 8053)]
>  > [New Thread 0xb521db90 (LWP 8069)]
>  > (no debugging symbols found)...done.
>  >
>  > 0xb7eef410 in __kernel_vsyscall ()
>  > error detected on stdin
>  > The program is running.  Quit anyway (and detach
it)? (y or n)
>  > [answered Y; input not from terminal]
>  > Detaching from program: /proc/8053/exe, process
8053
>  >
>  >>>> combi = ROOT.TGeoRotation()
>  >>>> matrix = combi.GetRotationMatrix()
>  >>>> matrix[0]
>  > 1.0
>  >>>> matrix[0]=0.99
>  >>>> print matrix[0]
>  > 0.99
>  >
>  > In the same time doing quite the same with
TGeoRotation instead
>  > works OK.
>  > What's my error then ? Or what's the proper way
of feeding a
>  > TGeoCombiTrans
>  > from python with [x,y,z] as translation and
[1,0,0,0,1,0,0,0,1] as
>  > rotation "matrix" ?
>  >
>  > Regards
>  > Michal
>
>


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )