45 #include "G4THitsCollection.hh"
60 :fAccumulated_edep(0.), fAccumulated_edep2(0.), fMean_edep(0.),
61 fError_mean_edep(0.), fRelative_error(0.), fElapsed_time(0.),
62 fPrecision_to_reach(0.),fStop_run_if_precision_reached(
true),
63 fNb_evt_modulo_for_convergence_test(5000),
64 fEdep_rmatrix_vs_electron_prim_energy(0),
65 fElectron_current_rmatrix_vs_electron_prim_energy(0),
66 fGamma_current_rmatrix_vs_electron_prim_energy(0),
67 fEdep_rmatrix_vs_gamma_prim_energy(0),
68 fElectron_current_rmatrix_vs_gamma_prim_energy(0),
69 fGamma_current_rmatrix_vs_gamma_prim_energy(0),
70 fEdep_rmatrix_vs_proton_prim_energy(0),
71 fElectron_current_rmatrix_vs_proton_prim_energy(0),
72 fProton_current_rmatrix_vs_proton_prim_energy(0),
73 fGamma_current_rmatrix_vs_proton_prim_energy(0),
75 fPrimSpectrumType(
EXPO),
76 fAlpha_or_E0(.5*
MeV),fAmplitude_prim_spectrum (1.),
77 fEmin_prim_spectrum(1.*
keV),fEmax_prim_spectrum (20.*
MeV),
78 fAdjoint_sim_mode(
true),fNb_evt_per_adj_evt(2)
132 "Normalised Edep[MeV]\terror[MeV]\tcomputing_time[s]"<<std::endl;
138 "Edep per event [MeV]\terror[MeV]\tcomputing_time[s]"
157 G4cout<<
"Results of forward simulation!"<<std::endl;
163 G4cout<<
"Results of reverse/adjoint simulation!"<<std::endl;
194 nb_event =
static_cast<G4int>(n_adj_evt);
246 for (i=0;i<edepCollection->
entries();++i)
247 totEdep+=(*edepCollection)[i]->GetValue()
248 *(*edepCollection)[i]->GetWeight();
258 G4double prim_ekin =std::sqrt(E0*E0+P*P)-E0;
267 for (i=0;i<electronCurrentCollection->
entries();++i) {
268 G4double ekin =(*electronCurrentCollection)[i]->GetValue();
273 for (i=0;i<protonCurrentCollection->
entries();++i) {
274 G4double ekin =(*protonCurrentCollection)[i]->GetValue();
279 for (i=0;i<gammaCurrentCollection->
entries();++i) {
280 G4double ekin =(*gammaCurrentCollection)[i]->GetValue();
316 for (i=0;i<edepCollection->
entries();++i)
317 totEdep+=(*edepCollection)[i]->GetValue()*
318 (*edepCollection)[i]->GetWeight();
326 size_t nb_adj_track =
328 G4double total_normalised_weight = 0.;
332 for (std::size_t j=0;j<nb_adj_track;++j) {
334 G4int pdg_nb =theAdjointSimManager
336 G4double prim_ekin=theAdjointSimManager
338 G4double adj_weight=theAdjointSimManager
349 total_normalised_weight += normalised_weight;
353 G4H1* edep_rmatrix =0;
354 G4H2* electron_current_rmatrix =0;
355 G4H2* gamma_current_rmatrix =0;
356 G4H2* proton_current_rmatrix =0;
360 electron_current_rmatrix =
373 electron_current_rmatrix =
381 ->fill(prim_ekin,totEdep*normalised_weight);
384 edep_rmatrix->fill(prim_ekin,totEdep*adj_weight/
cm2);
389 for (i=0;i<electronCurrentCollection->
entries();++i) {
390 G4double ekin =(*electronCurrentCollection)[i]->GetValue();
393 electron_current_rmatrix->fill(prim_ekin,ekin,weight*adj_weight/
cm2);
395 for (i=0;i<protonCurrentCollection->
entries();++i) {
396 G4double ekin =(*protonCurrentCollection)[i]->GetValue();
399 proton_current_rmatrix->fill(prim_ekin,ekin,weight*adj_weight/
cm2);
401 for (i=0;i<gammaCurrentCollection->
entries();++i) {
402 G4double ekin =(*gammaCurrentCollection)[i]->GetValue();
405 gamma_current_rmatrix->fill(prim_ekin,ekin,weight*adj_weight/
cm2);
411 G4bool new_mean_computed=
false;
413 if (total_normalised_weight>0.){
418 G4double new_mean(0.0), new_error(0.0);
424 if ( new_error >0) new_relative_error = new_error/ new_mean;
426 G4cout<<
"Potential wrong adjoint weight!"<<std::endl;
427 G4cout<<
"The results of this event will not be registered!"
430 G4cout<<
"previous relative error "<< fRelative_error<<std::endl;
431 G4cout<<
"new rejected mean edep [MeV] "<< new_mean<<std::endl;
432 G4cout<<
"new rejected relative error "<< new_relative_error
442 fRelative_error =new_relative_error;
443 new_mean_computed=
true;
448 if (!new_mean_computed){
534 error = factor*std::sqrt(
std::max(zz, 0.)*norm);
557 G4cout<<
"The particle that you did select is not in the candidate "<<
558 "list for primary [e-, gamma, proton]!"<<
G4endl;
563 (std::exp(-Emin/E0)-std::exp(-Emax/E0))/4./
pi;
581 G4cout<<
"The particle that you did select is not in the candidate"<<
582 " list for primary [e-, gamma, proton]!"<<
G4endl;
593 -std::pow(Emin,p))/4./
pi;
627 G4cout <<
"\n---> RMC01AnalysisManager::Book(): cannot open "
643 G4String(
"edep vs e- primary energy"),60,emin,emax,
671 G4String(
"electron RM vs e- primary energy"),60,emin,emax,
677 CreateH2(
G4String(
"Electron_current_rmatrix_vs_electron_prim_energy"),
678 G4String(
"electron current RM vs e- primary energy"),
679 60,emin,emax,60,emin,emax,
683 theHistoManager->
GetH2(idHisto);
687 CreateH2(
G4String(
"Gamma_current_rmatrix_vs_electron_prim_energy"),
688 G4String(
"gamma current RM vs e- primary energy"),
689 60,emin,emax,60,emin,emax,
693 theHistoManager->
GetH2(idHisto);
699 G4String(
"electron RM vs gamma primary energy"),60,emin,emax,
705 CreateH2(
G4String(
"Electron_current_rmatrix_vs_gamma_prim_energy"),
706 G4String(
"electron current RM vs gamma primary energy"),
707 60,emin,emax,60,emin,emax,
711 theHistoManager->
GetH2(idHisto);
715 CreateH2(
G4String(
"Gamma_current_rmatrix_vs_gamma_prim_energy"),
716 G4String(
"gamma current RM vs gamma primary energy"),
717 60,emin,emax,60,emin,emax,
721 theHistoManager->
GetH2(idHisto);
726 G4String(
"electron RM vs proton primary energy"),60,emin,emax,
732 CreateH2(
G4String(
"Electron_current_rmatrix_vs_proton_prim_energy"),
733 G4String(
"electron current RM vs proton primary energy"),
734 60,emin,emax,60,emin,emax,
738 theHistoManager->
GetH2(idHisto);
742 CreateH2(
G4String(
"Gamma_current_rmatrix_vs_proton_prim_energy"),
743 G4String(
"gamma current RM vs proton primary energy"),
744 60,emin,emax,60,emin,emax,
748 theHistoManager->
GetH2(idHisto);
752 CreateH2(
G4String(
"Proton_current_rmatrix_vs_proton_prim_energy"),
753 G4String(
"proton current RM vs proton primary energy"),
754 60,emin,emax,60,emin,emax,
758 theHistoManager->
GetH2(idHisto);
774 theHistoManager->
ScaleH1(ind,scaling_factor);
777 theHistoManager->
ScaleH2(ind,scaling_factor);
779 theHistoManager->
Write();