Message: Re: Placement of large number of volumes on a sphere Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Placement of large number of volumes on a sphere 

Forum: Geometry
Re: Question Placement of large number of volumes on a sphere
Date: 27 Aug, 2015
From: John Apostolakis <John Apostolakis>

Dear Stefano,

Your application is interesting, and you should be able to obtain good performance as the geometry is of moderate size.

Inspecting your ComputeTransformation method, my colleague Gabriele identified the most likely reason for your problems (large memory use and poor performance): there is an memory in the ComputeTransformation method.

Every time that ComputeTransformation is called it creates (using new) a new G4RotationMatrix object, and that is never deleted.

There are two different solutions 
1) Simplest: create a  G4RotationMatrix for every PMT in an array - similar to what you are doing for the parameters
phi, theta, psi.
    Advantages:      It is very fast to implement
    Disadvantages: Extra memory is requied.
    My expectation is that for your current number of PMTs (20,000) this solution should be adequate.

2) Make sure that there is just one Rotation Matrix object, which is reused.  (One object per thread - if your application is multithreaded.)

    If your application is single-threaded, this is not difficult - the Parameterisation class must simple own an G4RotationMatrix object, which you use (instead of creating one in each call. )
    If your application is multi-threaded this can be rather complex, so I do not recommend it.

Best regards,
John Apostolakis

> where the ComputeTransformation method is defined as
> 
> void PmtParameterisation::ComputeTransformation
> (const G4int copyNo, G4VPhysicalVolume* physVol) const
> {
>  G4ThreeVector origin(px[copyNo],py[copyNo],pz[copyNo]);
>  physVol->SetTranslation(origin);
>  physVol->SetRotation(px[copyNo],py[copyNo],pz[copyNo]);
> 
>  G4RotationMatrix *rot = new G4RotationMatrix();
                                          ^^^^^^
>  rot->set(phi[copyNo]*deg,theta[copyNo]*deg,psi[copyNo]*deg);
>  physVol->SetRotation(rot);
> }

> 
> -------------------------------------------------------------
> Visit this GEANT4 at hypernews.slac.stanford.edu message (to reply or unsubscribe) at: 
> http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/1434.html 

 Add Message Add Message
to: "Re: Placement of large number of volumes on a sphere"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]