Message: Scoring in G4Tubs Cylinder type Volume Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Scoring in G4Tubs Cylinder type Volume 

Forum: Biasing and Scoring
Date: 24 Jan, 2018
From: Marian Lückhof <Marian Lückhof>

Hello Everyone,

I am new to Geant4 and have a question regarding scoring volumes. I created an example of a photon beam entering a cylinder at one end (front face) and would like to apply a simple scoring task, to count the entering photons on that surface. That brought me to G4PSCylinderSurfaceCurrent.

My detector implementation:

G4VSolid* tubeSolid = new G4Tubs("scoring tube",
		  	  	 0.*cm,
			 	 20.*cm,
				 25.*cm,
				 0.*deg,
				 360.*deg);

fScoreLogical = new G4LogicalVolume(tubeSolid,
		  	  	    air,
				    "tubLog");

new G4PVPlacement(0,				// Rotation of 90 deg
  		  G4ThreeVector(0., 0., 35.*cm),// translation
  		  fScoreLogical,		// its logical volume
  		  "tubePhysical",		// its name
  		  fpWorldLogical,		// mother volume
  		  false,			//
  		  0);				// copy number

G4SDManager* manager = G4SDManager::GetSDMpointer(); G4MultiFunctionalDetector* detector = new G4MultiFunctionalDetector( "MyDetector" );

manager->AddNewDetector( detector ); fScoreLogical->SetSensitiveDetector( detector ); G4PSCylinderSurfaceCurrent * scorer = new G4PSCylinderSurfaceCurrent( "photonScorer", fCurrent_In );

G4SDParticleFilter * photonFilter = new G4SDParticleFilter( "photonFilter" ); photonFilter->add( "gamma" );

scorer->SetFilter( photonFilter ); detector->RegisterPrimitive( scorer );

And I record the event as such:

void BeamTestRun::RecordEvent(const G4Event* anEvent)
{
  numberOfEvent++; 

  // Get the hits collection
  G4HCofThisEvent* eventHitCollection = anEvent->GetHCofThisEvent();

  if ( !eventHitCollection ) {
	  G4cout << " *** Warning: no hits collection!" << G4endl;
	  return;
  }

  // Update our private fMap
  // iter is the iterator, starting at the first element of fMap
  //
  std::map< G4int, G4THitsMap<G4double>* >::iterator iter = fMap.begin();

  // as long as iterator does not reach the end of fMao
  //

  while ( iter != fMap.end() ) {
    G4int id = iter->first;
    G4cout << " * iterating through fMap" << " " << id	<< G4endl;

    // Get the hit collection corresponding to "id"
    //
    G4THitsMap<G4double>* eventHitsMap
		= dynamic_cast< G4THitsMap<G4double>* >( eventHitCollection->GetHC(id) );

    // Expect this to exist
    //
    assert ( 0 != eventHitsMap );
    G4cout << " -------- HitsMap SUMMARY -------- "	<< G4endl;
    eventHitsMap->PrintAllHits();
    G4cout << " -------- --------------- -------- "	<< G4endl;

    // Accumulate event data into our G4THitsMap<G4double> map
    //
    *( iter->second ) += *eventHitsMap;

    iter++;
  }
}

My naive assumption would be, that if a beam of 10 photons hits the front face of the cylinder, the count would be 10, normalized to the surface area. However, it is 0. The HitsMap summary gives 0 entries. Repeating this example with a box as sensitive detector and G4PSFlatSurfaceCurrent, results in the expected outcome of the counter with an entry in the hitsmap.

I hope, that someone can push me into the right direction. Is there something wrong with the setup/readout? Or maybe me understanding of the scorer G4PSCylinderSurfaceCurrent is wrong. Repeated tests with the source inside the cylinder and photons hitting the inner surface (not the front face) also gave a result of 0. If additional code is required to solve this, please ask.

Many thanks in advance!

 Add Message Add Message
to: "Scoring in G4Tubs Cylinder type Volume"

 Subscribe Subscribe

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