258 if ( !
m_config.activationFileName.empty() ) {
263 m_maps.m_rz_tid .resize(0);
264 m_maps.m_rz_eion.resize(0);
265 m_maps.m_rz_niel.resize(0);
266 m_maps.m_rz_h20 .resize(0);
267 m_maps.m_rz_neut.resize(0);
268 m_maps.m_rz_chad.resize(0);
270 m_maps.m_full_rz_tid .resize(0);
271 m_maps.m_full_rz_eion.resize(0);
272 m_maps.m_full_rz_niel.resize(0);
273 m_maps.m_full_rz_h20 .resize(0);
274 m_maps.m_full_rz_neut.resize(0);
275 m_maps.m_full_rz_chad.resize(0);
277 m_maps.m_3d_tid .resize(0);
278 m_maps.m_3d_eion.resize(0);
279 m_maps.m_3d_niel.resize(0);
280 m_maps.m_3d_h20 .resize(0);
281 m_maps.m_3d_neut.resize(0);
282 m_maps.m_3d_chad.resize(0);
284 m_maps.m_rz_tid_time .resize(0);
285 m_maps.m_rz_ht_time .resize(0);
286 m_maps.m_full_rz_tid_time .resize(0);
287 m_maps.m_full_rz_ht_time .resize(0);
289 m_maps.m_rz_element .resize(0);
290 m_maps.m_full_rz_element .resize(0);
292 m_maps.m_rz_neut_spec .resize(0);
293 m_maps.m_full_rz_neut_spec.resize(0);
294 m_maps.m_rz_gamm_spec .resize(0);
295 m_maps.m_full_rz_gamm_spec.resize(0);
296 m_maps.m_rz_elec_spec .resize(0);
297 m_maps.m_full_rz_elec_spec.resize(0);
298 m_maps.m_rz_muon_spec .resize(0);
299 m_maps.m_full_rz_muon_spec.resize(0);
300 m_maps.m_rz_pion_spec .resize(0);
301 m_maps.m_full_rz_pion_spec.resize(0);
302 m_maps.m_rz_prot_spec .resize(0);
303 m_maps.m_full_rz_prot_spec.resize(0);
304 m_maps.m_rz_rest_spec .resize(0);
305 m_maps.m_full_rz_rest_spec.resize(0);
307 m_maps.m_theta_full_rz_neut_spec .resize(0);
308 m_maps.m_theta_full_rz_gamm_spec .resize(0);
309 m_maps.m_theta_full_rz_elec_spec .resize(0);
310 m_maps.m_theta_full_rz_muon_spec .resize(0);
311 m_maps.m_theta_full_rz_pion_spec .resize(0);
312 m_maps.m_theta_full_rz_prot_spec .resize(0);
313 m_maps.m_theta_full_rz_rchgd_spec.resize(0);
314 m_maps.m_theta_full_rz_rneut_spec.resize(0);
318 m_maps.m_rz_vol .resize(0);
319 m_maps.m_rz_norm.resize(0);
320 m_maps.m_full_rz_vol .resize(0);
321 m_maps.m_full_rz_norm.resize(0);
322 m_maps.m_3d_vol .resize(0);
323 m_maps.m_3d_norm.resize(0);
409 m_tgpSiA =
new TGraph(fpSiA.c_str());
411 m_tgpSiB =
new TGraph(fpSiB.c_str());
413 m_tgnSiA =
new TGraph(fnSiA.c_str());
415 m_tgnSiB =
new TGraph(fnSiB.c_str());
417 m_tgnSiC =
new TGraph(fnSiC.c_str());
419 m_tgpiSi =
new TGraph(fpiSi.c_str());
421 m_tgeSi =
new TGraph(feSi.c_str());
439 m_tgHn =
new TGraph(fHn.c_str() ,
"%lg %*lg %*lg %*lg %*lg %*lg %lg");
441 m_tgHg =
new TGraph(fHg.c_str() ,
"%lg %*lg %*lg %*lg %*lg %*lg %lg");
443 m_tgHp =
new TGraph(fHp.c_str() ,
"%lg %*lg %*lg %*lg %*lg %*lg %lg");
445 m_tgHem =
new TGraph(fHem.c_str(),
"%lg %*lg %*lg %lg");
447 m_tgHep =
new TGraph(fHep.c_str(),
"%lg %*lg %*lg %lg");
449 m_tgHmm =
new TGraph(fHmm.c_str(),
"%lg %*lg %*lg %lg");
451 m_tgHmp =
new TGraph(fHmp.c_str(),
"%lg %*lg %*lg %lg");
453 m_tgHpm =
new TGraph(fHpm.c_str(),
"%lg %*lg %*lg %lg");
455 m_tgHpp =
new TGraph(fHpp.c_str(),
"%lg %*lg %*lg %lg");
457 m_tgHa =
new TGraph(fHa.c_str() ,
"%lg %*lg %*lg %lg");
462 bool goodMaterial(
false);
472 for (
unsigned int i=0;i<
m_config.materials.size();i++) {
473 if (
m_config.materials[i].compare(aStep->GetTrack()->GetMaterial()->GetName()) == 0) {
482 const std::vector<const G4Track*>* tv = aStep->GetSecondaryInCurrentStep();
487 for (
unsigned int is=0;is<tv->size();is++) {
489 const G4ParticleDefinition * pd = (*tv)[is]->GetParticleDefinition ();
490 if ( pd == G4Triton::Definition() || ( pd->GetParticleTable()->GetIonTable()->IsIon(pd) && !pd->GetPDGStable() ) ) {
491 G4String svname(
"unknown");
492 G4String svmaterial(
"unknown");
493 if ( (*tv)[is]->GetVolume() ) {
494 svname = (*tv)[is]->GetVolume()->GetName();
495 if ( (*tv)[is]->GetVolume()->GetLogicalVolume() ) {
496 if ( (*tv)[is]->GetVolume()->GetLogicalVolume()->GetMaterial() ) {
497 svmaterial = (*tv)[is]->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName();
503 <<
" Proc.: " << (*tv)[is]->GetCreatorProcess()->GetProcessType() <<
" Mother: ";
505 m_activationFile << aStep->GetTrack()->GetDefinition()->GetParticleName() <<
" (x,y,z,t): (";
527 if (aStep->GetTrack()->GetDefinition()==G4Gamma::Definition()){
529 }
else if (aStep->GetTrack()->GetDefinition()==G4Proton::Definition()){
531 }
else if (aStep->GetTrack()->GetDefinition()==G4PionPlus::Definition() ||
532 aStep->GetTrack()->GetDefinition()==G4PionMinus::Definition()){
534 }
else if(aStep->GetTrack()->GetDefinition()==G4MuonPlus::Definition() ||
535 aStep->GetTrack()->GetDefinition()==G4MuonMinus::Definition()){
537 }
else if(aStep->GetTrack()->GetDefinition()==G4Electron::Definition() ||
538 aStep->GetTrack()->GetDefinition()==G4Positron::Definition()){
539 if (aStep->GetTrack()->GetKineticEnergy()>0.5){
544 }
else if(aStep->GetTrack()->GetDefinition()==G4Neutron::Definition()){
545 if (aStep->GetTrack()->GetKineticEnergy()>10.){
550 }
else if (aStep->GetTrack()->GetDefinition()==G4KaonPlus::Definition() ||
551 aStep->GetTrack()->GetDefinition()==G4KaonMinus::Definition() ||
552 aStep->GetTrack()->GetDefinition()==G4KaonZeroShort::Definition() ||
553 aStep->GetTrack()->GetDefinition()==G4KaonZeroLong::Definition() ||
554 aStep->GetTrack()->GetDefinition()==G4KaonZero::Definition() ||
555 aStep->GetTrack()->GetDefinition()==G4AntiKaonZero::Definition() ||
556 aStep->GetTrack()->GetDefinition()==G4PionZero::Definition()){
559 }
else if (aStep->GetTrack()->GetDefinition()==G4AntiProton::Definition() ||
560 aStep->GetTrack()->GetDefinition()==G4AntiNeutron::Definition() ||
561 aStep->GetTrack()->GetDefinition()==G4Lambda::Definition() ||
562 aStep->GetTrack()->GetDefinition()==G4AntiLambda::Definition() ||
563 aStep->GetTrack()->GetDefinition()==G4SigmaPlus::Definition() ||
564 aStep->GetTrack()->GetDefinition()==G4AntiSigmaPlus::Definition() ||
565 aStep->GetTrack()->GetDefinition()==G4SigmaMinus::Definition() ||
566 aStep->GetTrack()->GetDefinition()==G4AntiSigmaMinus::Definition() ||
567 aStep->GetTrack()->GetDefinition()==G4SigmaZero::Definition() ||
568 aStep->GetTrack()->GetDefinition()==G4AntiSigmaZero::Definition() ||
569 aStep->GetTrack()->GetDefinition()==G4XiMinus::Definition() ||
570 aStep->GetTrack()->GetDefinition()==G4AntiXiMinus::Definition() ||
571 aStep->GetTrack()->GetDefinition()==G4XiZero::Definition() ||
572 aStep->GetTrack()->GetDefinition()==G4AntiXiZero::Definition() ||
573 aStep->GetTrack()->GetDefinition()==G4OmegaMinus::Definition() ||
574 aStep->GetTrack()->GetDefinition()==G4AntiOmegaMinus::Definition() ||
575 aStep->GetTrack()->GetDefinition()==G4Alpha::Definition() ||
576 aStep->GetTrack()->GetDefinition()==G4Deuteron::Definition() ||
577 aStep->GetTrack()->GetDefinition()==G4Triton::Definition() ||
578 aStep->GetTrack()->GetDefinition()==G4He3::Definition()){
581 }
else if (aStep->GetTrack()->GetDefinition()==G4Geantino::Definition()) {
583 }
else if (!aStep->GetTrack()->GetDefinition()->GetPDGCharge())
return;
585 if ( pdgid == 10 && aStep->GetTrack()->GetKineticEnergy() > 10 ) {
587 if ( aStep->GetTrack()->GetDefinition()->GetAtomicNumber() > 1 ) {
594 if ( pdgid == 0 || pdgid == 3 ||
595 pdgid == 1 || pdgid == 2 || pdgid == 4 || pdgid == 5 || pdgid == 6 || pdgid == 7 || pdgid == 8 || pdgid == 9 ||
596 aStep->GetTotalEnergyDeposit() > 0 || pdgid == 999) {
598 double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
600 double absq = std::fabs(
charge);
602 double rho = aStep->GetTrack()->GetMaterial()->GetDensity()/CLHEP::g*CLHEP::cm3;
604 const G4Material * theMaterial = aStep->GetTrack()->GetMaterial();
607 G4StepPoint* pre_step_point = aStep->GetPreStepPoint();
608 G4StepPoint* post_step_point = aStep->GetPostStepPoint();
609 const G4ThreeVector& startPoint = pre_step_point->GetPosition();
610 const G4ThreeVector& endPoint = post_step_point->GetPosition();
611 G4ThreeVector p = (startPoint + endPoint) * 0.5;
614 if (
m_config.posYOnly && p.y() < 0 )
return;
616 double timeOfFlight = (pre_step_point->GetGlobalTime() +
617 post_step_point->GetGlobalTime()) * 0.5;
620 double deltatime = (timeOfFlight - p.mag()/CLHEP::c_light)/CLHEP::s;
624 double logt = (deltatime<0?
m_config.logTMin-1:log10(deltatime));
627 double x0 = aStep->GetPreStepPoint()->GetPosition().x()*0.1;
628 double x1 = aStep->GetPostStepPoint()->GetPosition().x()*0.1;
629 double y0 = aStep->GetPreStepPoint()->GetPosition().y()*0.1;
630 double y1 = aStep->GetPostStepPoint()->GetPosition().y()*0.1;
631 double z0 = aStep->GetPreStepPoint()->GetPosition().z()*0.1;
632 double z1 = aStep->GetPostStepPoint()->GetPosition().z()*0.1;
634 double l = sqrt(
pow(x1-x0,2)+
pow(y1-y0,2)+
pow(z1-z0,2));
637 unsigned int nStep = l/dl0+1;
638 double dx = (x1-x0)/nStep;
639 double dy = (y1-y0)/nStep;
640 double dz = (z1-z0)/nStep;
645 double eKin = aStep->GetTrack()->GetKineticEnergy();
646 double theta = aStep->GetTrack()->GetMomentumDirection().theta()*180./
M_PI;
650 double dphi = (aStep->GetTrack()->GetMomentumDirection().
phi()-p.phi())*180./
M_PI;
651 while ( dphi > 360 ) dphi -= 360.;
652 while ( dphi < 0 ) dphi += 360.;
656 if ( pdgid == 1 || pdgid == 9 ) {
675 else if ( pdgid == 2 || pdgid == 8 ) {
688 else if ( pdgid == 6 || pdgid == 7 ) {
695 else if ( eKin < 800 ) {
702 else if ( pdgid == 4 || pdgid == 5 ) {
715 else if ( pdgid == 0 ) {
720 else if ( pdgid == 3 ) {
731 double dE_TOT = aStep->GetTotalEnergyDeposit()/nStep;
732 double dE_NIEL = aStep->GetNonIonizingEnergyDeposit()/nStep;
733 double dE_ION = dE_TOT-dE_NIEL;
734 double dH_T = 1e-12*wHt;
736 for(
unsigned int i=0;i<nStep;i++) {
738 double subpos = G4UniformRand();
739 double abszorz = z0+dz*(i+subpos);
741 if (
m_config.zMinFull >= 0 ) abszorz = std::fabs(abszorz);
743 double rr = sqrt(
pow(x0+dx*(i+subpos),2)+
744 pow(y0+dy*(i+subpos),2));
745 double pphi = atan2(y0+dy*(i+subpos),x0+dx*(i+subpos))*180/
M_PI;
750 int vBinZoomSpecn = -1;
751 int vBinFullSpecn = -1;
752 int vBinZoomSpeco = -1;
753 int vBinFullSpeco = -1;
754 int vBinZoomTime = -1;
755 int vBinFullTime = -1;
756 int vBinThetaFullSpecn = -1;
757 int vBinThetaFullSpeco = -1;
773 (pdgid == 6 || pdgid == 7)) {
779 pdgid != 6 && pdgid != 7) {
800 (pdgid == 6 || pdgid == 7)) {
806 int idph = dphi/360.*
m_config.nBinsdphi;
813 pdgid != 6 && pdgid != 7) {
819 int idph = dphi/360.*
m_config.nBinsdphi;
836 double phi_mapped = pphi;
838 if (phi_mapped < 0) {
839 phi_mapped = 360 + phi_mapped;
842 int iphi = phi_mapped/
m_config.phiMaxZoom;
843 phi_mapped -= iphi*
m_config.phiMaxZoom;
847 else if (
m_config.phiMinZoom < pphi &&
855 if ( goodMaterial && vBinZoom >=0 ) {
856 if ( pdgid == 999 ) {
857 m_maps.m_rz_tid [vBinZoom] +=
rr*dl;
858 m_maps.m_rz_eion[vBinZoom] += rho*
rr*dl;
859 for (
size_t ie=0;ie<theMaterial->GetNumberOfElements();ie++ ) {
860 const G4Element * theElement = theMaterial->GetElement (ie);
861 const double mFrac = theMaterial->GetFractionVector()[ie];
862 const int zElem = theElement->GetZ();
870 m_maps.m_rz_tid [vBinZoom] += dE_ION/rho;
871 m_maps.m_rz_eion[vBinZoom] += dE_ION;
872 for (
size_t ie=0;ie<theMaterial->GetNumberOfElements();ie++ ) {
873 const G4Element * theElement = theMaterial->GetElement (ie);
874 const double mFrac = theMaterial->GetFractionVector()[ie];
875 const int zElem = theElement->GetZ();
883 if ( goodMaterial && vBinZoomTime >=0 ) {
884 m_maps.m_rz_tid_time[vBinZoomTime] += dE_ION/rho;
886 m_maps.m_rz_ht_time[vBinZoomTime] += dH_T*dl;
889 if ( goodMaterial && vBinFull >=0 ) {
890 if ( pdgid == 999 ) {
891 m_maps.m_full_rz_tid [vBinFull] +=
rr*dl;
892 m_maps.m_full_rz_eion[vBinFull] += rho*
rr*dl;
893 for (
size_t ie=0;ie<theMaterial->GetNumberOfElements();ie++ ) {
894 const G4Element * theElement = theMaterial->GetElement (ie);
895 const double mFrac = theMaterial->GetFractionVector()[ie];
896 const int zElem = theElement->GetZ();
904 m_maps.m_full_rz_tid [vBinFull] += dE_ION/rho;
905 m_maps.m_full_rz_eion[vBinFull] += dE_ION;
906 for (
size_t ie=0;ie<theMaterial->GetNumberOfElements();ie++ ) {
907 const G4Element * theElement = theMaterial->GetElement (ie);
908 const double mFrac = theMaterial->GetFractionVector()[ie];
909 const int zElem = theElement->GetZ();
917 if ( goodMaterial && vBinFullTime >=0 ) {
918 m_maps.m_full_rz_tid_time[vBinFullTime] += dE_ION/rho;
920 m_maps.m_full_rz_ht_time[vBinFullTime] += dH_T*dl;
923 if ( goodMaterial && vBin3d >=0 ) {
924 if ( pdgid == 999 ) {
926 m_maps.m_3d_eion[vBin3d] += rho*
rr*dl;
929 m_maps.m_3d_tid [vBin3d] += dE_ION/rho;
930 m_maps.m_3d_eion[vBin3d] += dE_ION;
934 if ( goodMaterial && (pdgid == 1 || pdgid == 2 || pdgid == 4 || pdgid == 5 || pdgid == 6 || pdgid == 7 || pdgid == 8 || pdgid == 9 )) {
937 if ( vBinZoom >=0 ) {
938 m_maps.m_rz_niel [vBinZoom] += weight*dl;
940 if ( vBinFull >=0 ) {
941 m_maps.m_full_rz_niel [vBinFull] += weight*dl;
944 m_maps.m_3d_niel [vBin3d] += weight*dl;
948 if ( eKin > 20 && (pdgid == 1 || pdgid == 2 || pdgid == 6 || pdgid == 7 || pdgid == 8 || pdgid == 9) ) {
949 if ( vBinZoom >=0 ) {
950 m_maps.m_rz_h20 [vBinZoom] += dl;
952 if ( vBinFull >=0 ) {
953 m_maps.m_full_rz_h20 [vBinFull] += dl;
956 m_maps.m_3d_h20 [vBin3d] += dl;
960 if ( eKin > 0.1 && (pdgid == 6 || pdgid == 7 ) ) {
961 if ( vBinZoom >=0 ) {
962 m_maps.m_rz_neut [vBinZoom] += dl;
964 if ( vBinFull >=0 ) {
965 m_maps.m_full_rz_neut [vBinFull] += dl;
968 m_maps.m_3d_neut [vBin3d] += dl;
972 if ( absq > 0 && (pdgid == 1 || pdgid == 2 || pdgid == 8 || pdgid == 9 ) ) {
973 if ( vBinZoom >=0 ) {
974 m_maps.m_rz_chad [vBinZoom] += dl;
976 if ( vBinFull >=0 ) {
977 m_maps.m_full_rz_chad [vBinFull] += dl;
980 m_maps.m_3d_chad [vBin3d] += dl;
984 if ( pdgid == 6 || pdgid == 7 ) {
985 if ( vBinZoomSpecn >=0 ) {
986 m_maps.m_rz_neut_spec [vBinZoomSpecn] += dl;
988 if ( vBinFullSpecn >=0 ) {
989 m_maps.m_full_rz_neut_spec [vBinFullSpecn] += dl;
991 if ( vBinThetaFullSpecn >=0 ) {
992 m_maps.m_theta_full_rz_neut_spec [vBinThetaFullSpecn] += dl;
997 if ( goodMaterial && (pdgid < 6 || pdgid > 7 )){
999 if ( vBinZoomSpeco >=0 ) {
1001 m_maps.m_rz_gamm_spec [vBinZoomSpeco] += dl;
1003 else if ( pdgid == 1 ) {
1004 m_maps.m_rz_prot_spec [vBinZoomSpeco] += dl;
1006 else if ( pdgid == 2 ) {
1007 m_maps.m_rz_pion_spec [vBinZoomSpeco] += dl;
1009 else if ( pdgid == 3 ) {
1010 m_maps.m_rz_muon_spec [vBinZoomSpeco] += dl;
1012 else if ( pdgid == 4 || pdgid == 5 ) {
1013 m_maps.m_rz_elec_spec [vBinZoomSpeco] += dl;
1016 m_maps.m_rz_rest_spec [vBinZoomSpeco] += dl;
1019 if ( vBinFullSpeco >=0 ) {
1021 m_maps.m_full_rz_gamm_spec [vBinFullSpeco] += dl;
1023 else if ( pdgid == 1 ) {
1024 m_maps.m_full_rz_prot_spec [vBinFullSpeco] += dl;
1026 else if ( pdgid == 2 ) {
1027 m_maps.m_full_rz_pion_spec [vBinFullSpeco] += dl;
1029 else if ( pdgid == 3 ) {
1030 m_maps.m_full_rz_muon_spec [vBinFullSpeco] += dl;
1032 else if ( pdgid == 4 || pdgid == 5 ) {
1033 m_maps.m_full_rz_elec_spec [vBinFullSpeco] += dl;
1036 m_maps.m_full_rz_rest_spec [vBinFullSpeco] += dl;
1039 if ( vBinThetaFullSpeco >=0 ) {
1041 m_maps.m_theta_full_rz_gamm_spec [vBinThetaFullSpeco] += dl;
1043 else if ( pdgid == 1 ) {
1044 m_maps.m_theta_full_rz_prot_spec [vBinThetaFullSpeco] += dl;
1046 else if ( pdgid == 2 ) {
1047 m_maps.m_theta_full_rz_pion_spec [vBinThetaFullSpeco] += dl;
1049 else if ( pdgid == 3 ) {
1050 m_maps.m_theta_full_rz_muon_spec [vBinThetaFullSpeco] += dl;
1052 else if ( pdgid == 4 || pdgid == 5 ) {
1053 m_maps.m_theta_full_rz_elec_spec [vBinThetaFullSpeco] += dl;
1057 m_maps.m_theta_full_rz_rchgd_spec [vBinThetaFullSpeco] += dl;
1060 m_maps.m_theta_full_rz_rneut_spec [vBinThetaFullSpeco] += dl;
1068 if ( (eKin > 1 && (pdgid == 6 || pdgid == 7)) || pdgid == 999) {
1082 if ( vBinZoom >=0 ) {
1083 m_maps.m_rz_norm[vBinZoom] +=
rr*dl;
1085 if ( vBinFull >=0 ) {
1086 m_maps.m_full_rz_norm[vBinFull] +=
rr*dl;
1091 if ( goodMaterial ) {
1095 if ( vBinZoom >=0 ) {
1096 m_maps.m_rz_vol [vBinZoom] +=
rr*dl;
1098 if ( vBinFull >=0 ) {
1099 m_maps.m_full_rz_vol [vBinFull] +=
rr*dl;