Message: Segmentation Fault on G4HCofThisEvent::GetHC Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Segmentation Fault on G4HCofThisEvent::GetHC 

Forum: Hits, Digitization and Pileup
Date: Jan 14, 06:10
From: Juliana Cristina Martins <Juliana Cristina Martins>

Dear all,

I am having some problems in implementing a Sensitive Detector in my model, to create a Phase Space containing informatin of all particles crossing its surface. I get a Segmentation Fault coming from G4HCofThisEvent::GetHC:

Thread 1 "DetectorLinac" received signal SIGSEGV, Segmentation fault. 0x000000000043b753 in G4HCofThisEvent::GetHC (this=0x1ade710, i=222670581) at /software/opt/xenial/x86_64/geant4/10.01.p02/include/Geant4/G4HCofThisEvent.hh:67 67 { return (*HC)[i]; }

If I run more tThe output before the segmentation fault is this:

In DicomSourceSurfaceSD::ProcessHits
UserInfo: In phase space
UserInfo: Crossed Phase Space at prestep: (-0.3097670078277588 , 720.005 , 0) at posttep: (-0.3097670078277588 , 719.995 , 0) with index = 0	, PDG 0
   44    -0.31      450        0      5.54        0      270       580       World Transportation
   45    -0.31   -2e+03        0      5.54        0 2.45e+03  3.03e+03  OutOfWorld Transportation

So as far as I can understand, the particle hits my sensitive detector, it gets the information I asked for, but there is some problem when ProcessHits is called. Here is the code for my sensitive detector (relevant parts):

void Synergy_DetectorConstruction::ConstructPhaseSpace(){

//------------------------------ phase space -----------------------------------------

  G4double PS1box_halfx= 3.0 *cm;
  G4double PS1box_halfy= 5.0 *um;
  G4double PS1box_halfz= 3.0 *cm;

  G4Box * PS1_box = new G4Box("PS1_box", PS1box_halfx,PS1box_halfy, S1box_halfz);

  G4LogicalVolume * PS1_log = new G4LogicalVolume(PS1_box,Vacuum_window_material,
  								"PS1_log");

  PS1_phys = new G4PVPlacement(0,
  		  	  G4ThreeVector(0.0,-28.0*cm/*0.09*cm*/, 0.0*cm),
  		  	  PS1_log,
  		  	  "PS1_phys",
  		  	  LogicalTreatmentHead,
  		  	  true,
  		  	  0);

  /***Sensitive Detector ***/

  if (fInitialized) {
  	G4SDManager* SDMan = G4SDManager::GetSDMpointer();
	G4String name = "ScoringSurface";
	G4String phspfile_prefix = "PhaseSpace";
	DicomSourceSurfaceSD* pSurfaceSD = new DicomSourceSurfaceSD(name,phspfile_prefix);
	SDMan->AddNewDetector(pSurfaceSD);
	PS1_log->SetSensitiveDetector(pSurfaceSD);
	G4cout << "\n *********constructing the SENSITIVE DETECTOR********\n "<<G4endl;
	  }

  fInitialized = true;
    G4VisAttributes* PS1_logVisAtt = new G4VisAttributes(G4Colour::Red());
    PS1_logVisAtt->SetVisibility(true);
    //PS1_logVisAtt->SetForceSolid(true);
    //PS1_logVisAtt->SetForceWireframe(true);
    PS1_log->SetVisAttributes(PS1_logVisAtt);

  PS1_phys = new G4PVPlacement(0,
		  	  G4ThreeVector(0.0,-28.0*cm, 0.0*cm),
		  	  PS1_log,
		  	  "PS1_phys",
		  	  LogicalTreatmentHead,
		  	  true,
		  	  0);

  G4cout << "\n *********constructing the phase Space*******n "<<G4endl;

}

G4bool DicomSourceSurfaceSD::ProcessHits(G4Step* aStep, G4TouchableHistory*ROhist) {

	G4cout << "In DicomSourceSurfaceSD::ProcessHits" << G4endl;

	const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
	const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
	G4cout << "UserInfo: In phase space" << G4endl;
	if (preStepPoint->GetStepStatus()!=fGeomBoundary)
		return false;

	pPhspData->SetPDG((G4int)aStep->GetTrack()->GetParticleDefinition()->GetPDGEncoding(),index);
	pPhspData->SetEnergy((G4float)postStepPoint->GetKineticEnergy()/MeV,index);
	pPhspData->SetPosX((G4float)postStepPoint->GetPosition().x()/mm,index);
	pPhspData->SetPosY((G4float)postStepPoint->GetPosition().y()/mm,index);
	pPhspData->SetPosZ((G4float)postStepPoint->GetPosition().z()/mm,index);
	pPhspData->SetDirX((G4float)postStepPoint->GetMomentumDirection().x(),index);
	pPhspData->SetDirY((G4float)postStepPoint->GetMomentumDirection().y(),index);
	pPhspData->SetDirZ((G4float)postStepPoint->GetMomentumDirection().z(),index);

	G4cout << "UserInfo: Crossed Phase Space at prestep: ("
		<< preStepPoint->GetPosition().x()/mm << " , " << preStepPoint->GetPosition().y()/mm << " , " << preStepPoint->GetPosition().z()/mm
		<< ") at posttep: (" << postStepPoint->GetPosition().x()/mm << " , " <<  postStepPoint->GetPosition().y()/mm << " , " << postStepPoint->GetPosition().z()/mm
		<< ") with index = " << index << "	, PDG " << aStep->GetTrack()->GetParticleDefinition()->GetPDGEncoding() << G4endl;

	index++;

	if (index==size)
	  {
		pPhspData->WritePhspDataToFile(phspFileName,index);
		index=0;
		G4cout << "****** INDEX == SIZE ******" << G4endl;
	  }
	return true;
}

Does anyone have a clue why is there a problem coming from G4HCofThisEvent::GetHC? A colleague of mine suggested it is related to the fact that my geometry is updated between 2 runs...

Thank you in advance, Juliana

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

1 None: Re: Segmentation Fault on G4HCofThisEvent::GetHC   (Makoto Asai - Mar 18, 09:40)
 Add Message Add Message
to: "Segmentation Fault on G4HCofThisEvent::GetHC"

 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 ]