Re: Compare TGeoShape

From: Jason Webb <jwebb_at_rcf.rhic.bnl.gov>
Date: Thu, 15 Jul 2010 11:10:44 -0400


Hi Andrei,

Thanks for the reply. I will proceed with my (ugly, error prone, difficult to maintain) work around.

However, I think that you are overestimating the effort it would take to implement this functionality. If TGeoShape stored a dynamic array of parameters then the equality method becomes trivial. Just loop over the two arrays and check equality of elements.

Such an array could be created and filled with modest effort. 20 shapes, averaging 10 parameters per shape. To store these parameters would take approximately 20 x 10 = 200 lines of code. Double for overhead, 400 lines of code. (pcon and pgon being exceptions, but easily handled).

Composite shapes should also be easy to handle. Check that the expressions are the same, and if so, check that each of the named shapes are equal.

Cheers,
Jason

Andrei Gheata wrote:
> Hi Jason,
>
> This comparison is not implemented and not in the plan. The reason is
> that there are ~20 different shapes and this makes the implementation
> effort too big and not scaling with the limited use cases. Besides, this
> cannot be implemented for Boolean composite shapes that can be of
> infinite variety.
>
> Best,
> Andrei
>
> On 07/14/2010 11:03 PM, Jason Webb wrote:

>> Hi ROOTers,
>>
>> Is there a simple way to compare two TGeoShapes to each other?
>> Specifically I am interested in functionality like
>>
>> TGeoShape *shape1 = ...
>> TGeoShape *shape2 = ...
>>
>> if ( shape1->IsEqualTo(shape2) )
>> {
>> std::cout << "same"<<std::endl;
>> }
>>
>> where shape1 and shape2 are any of the TGeo shapes, and the 'IsEqualTo'
>> function would return true if they are of the same class and have the
>> same parameters.
>>
>> Thanks,
>> Jason
>>
Received on Thu Jul 15 2010 - 17:10:51 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 15 2010 - 23:50:01 CEST