Hello thank you the both @pcanal and @dilicus
@Dilicus
I tried your modified files, but I got the error
include/AnalysisManager.hh:58:28: error: invalid use of non-static data member ‘AnalysisManager::kMaxTrack’
58 | G4double Z_interaction[kMaxTrack];//<------------- new lines
| ^~~~~~~~~
include/AnalysisManager.hh:46:14: note: declared here
46 | G4double kMaxTrack=200; // I set the max number of second
then, in the .hh I tried to replace G4double Z_interaction[kMaxTrack]
by
G4double Z_interaction[200]
and in .cc //for(int i=0;i<kMaxTrack;i++) {//<------------- new lines
by
for(int i=0;i<200;i++) {/
I don’t get errors during compiling, but when I run I get:
### Run 0 starts.
--> Event 0 starts.
GeSD::Initialize: GeSD GeCollection
### CAUGHT SIGNAL: 11 ### address: 0, signal = SIGSEGV, value = 11, description = segmentation violation. Unknown segmentation fault error: 128.
Backtrace:
[PID=18494, TID=-1][ 0/16]> ./Sim() [0x461149]
[PID=18494, TID=-1][ 1/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4event.so(_ZN14G4EventManager12DoProcessingEP7G4Event+0x6f9) [0x7f0f22e80b89]
[PID=18494, TID=-1][ 2/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4run.so(_ZN12G4RunManager11DoEventLoopEiPKci+0xaf) [0x7f0f2313dc6f]
[PID=18494, TID=-1][ 3/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4run.so(_ZN12G4RunManager6BeamOnEiPKci+0x5e) [0x7f0f2313b8ae]
[PID=18494, TID=-1][ 4/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4run.so(_ZN14G4RunMessenger11SetNewValueEP11G4UIcommand8G4String+0x5a2) [0x7f0f231720c2]
[PID=18494, TID=-1][ 5/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN11G4UIcommand4DoItE8G4String+0x780) [0x7f0f1ec3cf20]
[PID=18494, TID=-1][ 6/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN11G4UImanager12ApplyCommandEPKc+0xdb1) [0x7f0f1ec5b9d1]
[PID=18494, TID=-1][ 7/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN9G4UIbatch11ExecCommandERK8G4String+0x1d) [0x7f0f1ec2cc4d]
[PID=18494, TID=-1][ 8/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN9G4UIbatch12SessionStartEv+0x66) [0x7f0f1ec2dd46]
[PID=18494, TID=-1][ 9/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN11G4UImanager16ExecuteMacroFileEPKc+0x3c) [0x7f0f1ec5d4bc]
[PID=18494, TID=-1][10/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN20G4UIcontrolMessenger11SetNewValueEP11G4UIcommand8G4String+0x23a) [0x7f0f1ec4a28a]
[PID=18494, TID=-1][11/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN11G4UIcommand4DoItE8G4String+0x780) [0x7f0f1ec3cf20]
[PID=18494, TID=-1][12/16]> /nfs/GEANT4/geant4-v11.0.0-install/lib64/libG4intercoms.so(_ZN11G4UImanager12ApplyCommandEPKc+0xdb1) [0x7f0f1ec5b9d1]
[PID=18494, TID=-1][13/16]> ./Sim() [0x419d59]
[PID=18494, TID=-1][14/16]> /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f0f1d5f9b15]
[PID=18494, TID=-1][15/16]> ./Sim() [0x41dd41]
: Segmentation fault (Signal sent by the kernel [(nil)])
I upload here the files, because I had to fix 3-4 typos.
AnalysisManager.cc (9.1 KB)
AnalysisManager.hh (3.1 KB)
@pcanal I also tried as you suggested i.e.
zintvec = fParPos[i].z();
…
tree1->Branch("zint", &zintvec);
and it looks like that it saved the informatio. What is the difference between your simpler and @Dilicus’s more complicated methods?