Message: Usage of memory in a sensitive detector Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Usage of memory in a sensitive detector 

Forum: Run Management
Date: 29 Nov, 2010
From: Mario <Mario>

Hi folks,

I simulate a scintillator with wavelength shifting fibers in the scintillator itself. I have three different sensitive detectors: - The logical volume of the scintillator - The logical volume of the fibers - and the logical volume of a detector outside of the scintillator.

My scintillator gets passed by a Muon- with 1 GeV. The scintillation yield is 500 / MeV

So there are ~2000 optical photons produced in scintillator and fiber.

My problem is:

For about 200 events my simulation uses more than 1 GB memory. When I deactivate the sensitive detector of the fibers it remains at ~ 50 MB.

I do not know if this behavior is normal or i have a memory leak.

I have some questions about the code (which is copied from example N02):

- What does this codeblock do?:

  static G4int HCID = -1;
  if(HCID<0)
  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
  HCE->AddHitsCollection( HCID, FiberCollection );

- Should I use somewhere in the code a delete - command? And where? When I try, I get segmentation faults...

I hope someone can help me.

Following the code of my sensitive detector:

scintillatorFiberSD::scintillatorFiberSD(G4String name)
:G4VSensitiveDetector(name)
{
  G4String HCname;
  collectionName.insert(HCname="FiberCollection");

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

scintillatorFiberSD::~scintillatorFiberSD(){ }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void scintillatorFiberSD::Initialize(G4HCofThisEvent* HCE)
{
  FiberCollection = new scintillatorFiberHitsCollection
                          (SensitiveDetectorName,collectionName[0]);
  static G4int HCID = -1;
  if(HCID<0)
  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
  HCE->AddHitsCollection( HCID, FiberCollection );
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4bool scintillatorFiberSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
	scintillatorFiberHit* newHit = new scintillatorFiberHit();
	// Only reading hits where OpWLS-Photons are produced
	if(aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "OpWLS" ){
	newHit->SetTrackID  (aStep->GetTrack()->GetTrackID());
        newHit->SetPos      (aStep->GetPostStepPoint()->GetPosition());
        newHit->SetProcessName(aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName());
	FiberCollection->insert( newHit );
}

  return true;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void scintillatorFiberSD::EndOfEvent(G4HCofThisEvent*)
{
	     G4int NbHits = FiberCollection->entries();
	     if (NbHits != 0){photoInFiberProdRoot->Fill(NbHits);}  //Fill of my histogram
}   

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

1 Idea: Re: Usage of memory in a sensitive detector   (Neoh - 29 Nov, 2010)
2 None: Re: Usage of memory in a sensitive detector   (Marc Verderi - 29 Nov, 2010)
1 Agree: Re: Usage of memory in a sensitive detector   (Mario - 29 Nov, 2010)
3 None: Re: Usage of memory in a sensitive detector   (Marc Verderi - 29 Nov, 2010)
4 None: Re: Usage of memory in a sensitive detector   (Marc Verderi - 29 Nov, 2010)
 Add Message Add Message
to: "Usage of memory in a sensitive detector"

 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 ]