Message: SteppingAction and EventAction Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question SteppingAction and EventAction 

Forum: Hits, Digitization and Pileup
Date: 03 Aug, 2010
From: stefania stucci <stefania stucci>

Hi, I need to record the position of the impact point of particles in my sampling calorimeter and the energy deposited of the event. In order to have the total deposit energy for event in the calorimeter I need to loop in EndOfEventAction but this is a problem when I get the information in the UserSteppingAction because I record the wrong energy deposit. I mean the energy does not correspond at the right event.

Thanks very much in advance!

Stefania

Here there are pieces of code from SteppingAction and EventAction:

void SteppingAction::UserSteppingAction(const G4Step* aStep) { #ifdef G4ANALYSIS_USE

  G4Track* theTrack = aStep->GetTrack();
  G4StepPoint* thePrePoint = aStep->GetPreStepPoint();
  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
  G4StepPoint* thePostPoint = aStep->GetPostStepPoint();
  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();

  if( thePostPoint->GetStepStatus()==fGeomBoundary ){
    if( thePostPV ){
      if( (thePostPV->GetName()=="scisxupPhysical"||thePostPV-> GetName() ==    
      "scisxdownPhysical")&&thePrePV->GetName()=="worldPhysical" ) {

	G4double ipX = theTrack->GetPosition().x()/cm; 
	G4double ipY = theTrack->GetPosition().y()/cm;
	G4double Edep =  eventAction->GetEnergyDeposit();
	G4String particleName = aStep->GetTrack()->GetDefinition()->GetParticleName();    
	G4int EvtNb = eventAction->GetEvtNb();
	G4double X0 = eventAction->GetX0(); //cm
	G4double Y0 = eventAction->GetY0(); //cm
	G4double PZ = eventAction->GetPZ(); //MeV

	histoManager->FillHisto(1,ipX);	       
	histoManager->FillHisto(2,ipY);		
	histoManager->FillHisto(3,Edep);

	outFile << EvtNb << "  " << PZ << "  " << X0 << "  " << Y0 << "  " 
		<< particleName << "  " << ipX << "  " << ipY << "  " << Edep << G4endl;      
      }
    }
#endif
}

void EventAction::BeginOfEventAction(const G4Event* evt)
{
  EvtNb = evt->GetEventID();
  X0 = evt->GetPrimaryVertex(0)->GetX0()/cm;
  Y0 = evt->GetPrimaryVertex(0)->GetY0()/cm;

  G4PrimaryParticle* primary = evt->GetPrimaryVertex(0)->GetPrimary(0);
  PZ = primary->GetPz()/MeV;

}

void EventAction::EndOfEventAction(const G4Event* evt)
{
  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
  EmCalorimeterHitsCollection* ECHC1D = 0;
  if(HCE) {
      ECHC1D = (EmCalorimeterHitsCollection*)(HCE->GetHC(ECHCID));
     }

  G4int nEmHits = 0 ; 

  if(ECHC1D)
    {
      nEmHits = ECHC1D->entries();

      G4int iHit=0;
      G4double EDEP=0;

      for(iHit=0; iHit<nEmHits; iHit++){
	TotalEnergyDeposit += (*ECHC1D)[iHit]->GetEdep() ; 
      }
    }
  }  

 Add Message Add Message
to: "SteppingAction and EventAction"

 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 ]