Message: Re: How to give different names to the copies of Physical volume Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: How to give different names to the copies of Physical volume 

Forum: Geometry
Re: Question How to give different names to the copies of Physical volume (Amit Kumar)
Date: 05 May, 2015
From: Michael H. Kelsey <Michael H. Kelsey>

On Tue, 05 May 2015 16:17:00 GMT, Amit Kumar wrote:
> I want to give different names to same logical volumes physically placed
> at ten different places and I want to use them in steppingAction. Please
> let me know whether following lines are appropriate to serve my purpose.
> 
> 1. Following lines are added to DetectorConstruction class
> 
> for (G4int i=0; i<10; i++) {
> new G4PVPlacement(0, G4ThreeVector(0,0,Z), LogicBox,
>                         "physBox[i]",worldVolume,false,i, 0); 
> }

This won't do what you think. Strings in quotes are literal. If you _really_ want to do this (and you really, really do not!), then you need to use stringstream operations to insert the value of i into a string. Please do a search for "std::stringstream" to find guidance on how to use this common C++ feature.

HOWEVER!  As C. Mos already said, you don't need to do this at all.  Use a single name string for all of these placements, and distinguish them by directly using the copy number.   You're already setting the copy number above with the ",i," argument to placement, so it will be available to you in your SteppingAction.
                               --  Michael Kelsey

 Add Message Add Message
to: "Re: How to give different names to the copies of Physical volume"

 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 ]