Message: problems with energy deposit | Not Logged In (login) |
|
|
Hi all! I'm beginner in Geant4. I have such a problem. I must gather from every initial particle energy deposit in my detector. I do it, as it shown below ------------------------------------------ #include "TrackingAction.hh" #include "G4TrackingManager.hh" #include "G4Track.hh" #include "G4Step.hh" #include "G4UnitsTable.hh" #include "G4String.hh" TrackingAction::TrackingAction() {} void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{ G4double energy,edep; G4String name,volume;
name = aTrack->GetDefinition()->GetParticleName();
energy = aTrack->GetKineticEnergy();
volume = aTrack->GetVolume()->GetName();
edep =aTrack->GetStep()->GetTotalEnergyDeposit();
if ((name=="gamma") && (energy == 1.17*MeV)) { PutIntoSpectr(E_total); E_total=0; }
if((volume=="csi_1") || (volume=="csi_2") || (volume=="csi_3") || (volume=="csi_4")) {E_total=E_total+edep;} } void TrackingAction::PutIntoSpectr(G4double energy) {
FILE *f;
f=fopen("spectr.txt", "w");
fprintf(f,"\n", energy);
fclose(f); } --------------------------------------------------------- But it doesn't works, and it didn't make the file spectr.txt, and when it is making the standard output file, it shows information only for the first initial particle: ---------------------------------------------------------
********************************************************************************************************* * G4Track Information: Particle = gamma, Track ID = 1, Parent ID = 0 *********************************************************************************************************
Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process 0 0 0 400 1.17 0 0 0 expHall_phys initStep --------------------------------------------------------- and at the end it writes "Segmentation fault". where is my mistake. THANKS in Advance hayk gabrielyan |
Inline Depth: |
|
|
Outline Depth: |
|
|
|
Add message: ![]() |
|
to: |
|