Message: Re: How to make each concentric shell sensitive and access information Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: How to make each concentric shell sensitive and access information 

Forum: Geometry
Re: Question How to make each concentric shell sensitive and access information (aimsphere)
Date: 17 Jul, 2010
From: John Apostolakis <John Apostolakis>

A simple way to communicate which shell you are in to the sensitive 
detector is to use the "Copy Number" in the physical volume.

If you give the CopyNumber the value of the index of layers  ( the 
variable "i" in your case ) then it is very simple to use it to record 
the energy deposition or any other observable in the correct layer:

                 physiSphere[i] = new G4PVPlacement(0,               // no rotation
                                                 positionTarget,  // at (x,y,z)
                                                 logicSphere[i],     // its logical volume
                                                 spherePhysNum,        // its name
                                                 logicWorld,      // its mother  volume
                                                 false,           // no boolean operations
                                        =====>    i );              // copy number


Your code for process hits already has the line needed to access this 
copy number -- it is similar for a placement as for a Replica:

         G4int LayerNb = aStep->GetPreStepPoint()->GetTouchableHandle()
                                                ->GetCopyNumber();

By setting the value of the copy number as we did, you will be 
simulating the replica in this respect.

By the way, I think that it is possible to use a replica and slice (a 
sphere) in the spherical R radius "direction".

Best regards,
John Apostolakis

On 7/16/2010 11:51 AM, aimsphere wrote:
> *** Discussion title: Geometry
>
> Dear Geant4 users,
>
> I am trying to simulate a water sphere and the the depth dose profile by creating several layers inside it. Then make each of them sensitive and access the necessary information.
>
> How I am doing is by creating several spherical shells with increasing Rmin and Rmax (starting Rmin = 0). Here is the part of my code:
>
> for (G4int i = 0; i<NbOfLayers; i++){
>
>                  std::string sphereNum = "sphereNum_"; sphereNum += i;
>                  G4Sphere* solidSphere = new G4Sphere(sphereNum,Rmin,Rmax,0.* deg, 360.* deg,0.* deg, 180.* deg);
>
>                  std::string sphereLogNum= "sphereLogNum_"; sphereLogNum += i;
>                  logicSphere[i] = new G4LogicalVolume(solidSphere,H2O,sphereLogNum,0,0,0);
>
>                                                          std::string spherePhysNum= "spherePhysNum_"; spherePhysNum += i;
>                  physiSphere[i] = new G4PVPlacement(0,               // no rotation
>                                                  positionTarget,  // at (x,y,z)
>                                                  logicSphere[i],     // its logical volume
>                                                  spherePhysNum,        // its name
>                                                  logicWorld,      // its mother  volume
>                                                  false,           // no boolean operations
>                                                  0);              // copy number
>
>                                  G4double maxStep = 0.01*mm;
>                  G4UserLimits* stepLimit = new G4UserLimits(maxStep);
>                  logicSphere[i]->SetUserLimits(stepLimit);
>                  Rmin = Rmax;
>                  Rmax = Rmax+deltaRadius;
>          }
>
> Then I make all these shells Sensitive like this:
>
>                 G4SDManager* SDman = G4SDManager::GetSDMpointer();
>                 G4String trackerTargetSDname = "Ex1/TrackerChamberSD";
>                 Ex1TrackerSD* aTrackerSD = new Ex1TrackerSD( trackerTargetSDname , fileName);
>                 SDman->AddNewDetector( aTrackerSD );
>                 for (G4int i = 0; i<NbOfLayers; i++){
>                         logicSphere[i]->SetSensitiveDetector( aTrackerSD );
>                 }
>
> Question1) Can you confirm if this would work? Sorry I am still learning G4 and have not much programming experience.
>
> Question2) I do not know how to get information out of these sensitive shells. I had previously made a cuboid with several layers n used G4Replica to make copies n use the following code to get information out of it.
>
> G4bool Ex1TrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
> {
>          G4double edep = aStep->GetTotalEnergyDeposit();
>          G4double stepLength = aStep ->  GetStepLength();
>          G4double let = edep/stepLength;
>          G4String particleDef = aStep ->  GetTrack()->  GetDefinition() ->  GetParticleName();
>          G4int trackID = aStep->GetTrack()->GetTrackID();
>          G4int LayerNb = aStep->GetPreStepPoint()->GetTouchableHandle()
>                                                 ->GetCopyNumber();
> .........
> }
>
> Since there are so many volumes how can I get information from each? should I write something like to get the number of layers:
> for (int i = 0; i<100; i++){
>   G4int LayerNb += aStep->GetPreStepPoint()->GetTouchableHandle()
>                                                 ->GetCopyNumber(depth = i);
> }
>
> Thank you for helping me out!
>
> -------------------------------------------------------------
> Visit this GEANT4 at hypernews.slac.stanford.edu message (to reply or unsubscribe) at:
> http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/1051.html
>    

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Ok: Re: How to make each concentric shell sensitive and access information   (aimsphere - 19 Jul, 2010)
2 Ok: Re: How to make each concentric shell sensitive and access information   (aimsphere - 19 Jul, 2010)
 Add Message Add Message
to: "Re: How to make each concentric shell sensitive and access information"

 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 ]