Message: kinetic energy achievement in an air SD? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question kinetic energy achievement in an air SD? 

Forum: Event and Track Management
Date: 16 Oct, 2012
From: Julien Zhu <Julien Zhu>

Hi guys,
    I hope to get the kinetic eneryies of the photon particles. I construct a score and use track, however there is nothing to achieve in the output. please could you help me what the errors are? thanks a lot.

VoxelScoring::VoxelScoring(G4String name)
  :G4VSensitiveDetector( name )
{
	kinEnergy = new G4double [];
}

VoxelScoring::~VoxelScoring()
{
	 delete kinEnergy;
}

// // Initialize //

G4int num_particle=1000;

void VoxelScoring::Initialize( G4HCofThisEvent* ) {

//   Zero the arrays at the beginning of each primary
  for(G4int i=1;i<num_particle;i++){
   kinEnergy[i]=0;
  }
	;
}

//
// Process hits
//
G4int counter=1;
G4bool VoxelScoring::ProcessHits( G4Step *step, G4TouchableHistory * )
{
	   //achieve the ID of particles
 G4Track *track=step->GetTrack();
G4int track_mon=track->GetParentID();
if(track_mon==0)
{
G4int trackID=track->GetTrackID();
G4StepPoint *point1=step->GetPreStepPoint();
// get the pointer when the particles arrive the boundary of SD
if (point1->GetStepStatus()==fGeomBoundary)
{
	for (i=1;i<num_particle;i++)
	{kinEnergy[i]=track->GetKineticEnergy();
	counter++;
}
    return true;
}
}
}

// // EndOfEvent //

void VoxelScoring::EndOfEvent( G4HCofThisEvent* ) {

  //                                                                      
  // Pass the measured energy to RunAction                             
  //                                                                      
  RunAction* myRunAction = (RunAction*)(G4RunManager::GetRunManager()->GetUserRunAction());

  myRunAction-> kinetic_total(kinEnergy);

}

in RunAction.cc

void RunAction::kinetic_total(G4double kinEnergy[])

{;}

void RunAction::EndOfRunAction(const G4Run* )

{

	//

	ofstream outFile("Results.dat");
		for (G4int i=1;i<num_particle;i++)
	{
			outFile << kinEnergy[i]<<" ";
	}	

	outFile.close();

}

 Add Message Add Message
to: "kinetic energy achievement in an air SD?"

 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 ]