62 G4StepPoint* PreStep = aStep->GetPreStepPoint();
63 G4StepPoint* PostStep = aStep->GetPostStepPoint();
65 G4double PreStepX =PreStep->GetPosition().x();
66 G4double PreStepY =PreStep->GetPosition().y();
67 G4double PreStepZ =PreStep->GetPosition().z();
68 G4double parentID =aStep->GetTrack()->GetParentID();
69 G4double trackID =aStep->GetTrack()->GetTrackID();
71 G4double PostStepX =PostStep->GetPosition().x();
72 G4double PostStepY =PostStep->GetPosition().y();
73 G4double PostStepZ =PostStep->GetPosition().z();
90 namePost = volumePost->
GetName();
95 G4double eKin = aStep -> GetPreStepPoint() -> GetKineticEnergy();
96 G4double PosX = aStep->GetTrack()->GetPosition().x();
97 G4double PosY = aStep->GetTrack()->GetPosition().y();
98 G4double PosZ = aStep->GetTrack()->GetPosition().z();
100 G4String volume= aStep->GetTrack()->GetVolume()->GetName();
101 G4Track* theTrack = aStep->GetTrack();
103 if((namePre==
"collimator")||(namePre==
"PhysicExternalMagnet_1Down")||(namePre==
"PhysicExternalMagnet_1")||(namePre==
"PhysicMagnet_1Right")||(namePre==
"PhysicMagnet_1Left")||(namePre==
"PhysicExternalMagnet_2")||(namePre==
"PhysicExternalMagnet_2Down")||(namePre==
"PhysicMagnet_2Right")||(namePre==
"PhysicMagnet_2Left")||(namePre==
"PhysicExternalMagnet_3")||(namePre==
"PhysicExternalMagnet_3Down")||(namePre==
"PhysicMagnet_3Right")||(namePre==
"PhysicMagnet_3Left")||(namePre==
"PhysicExternalMagnet_4")||(namePre==
"PhysicExternalMagnet_4Down")||(namePre==
"physQuadChamberWall")||(namePre==
"PhysicMagnet_4Right")||(namePre==
"PhysicMagnet_4Left")||(namePre==
"ExternalChamber")||(namePre==
"collimatorFinal")||(namePre==
"ExternalSlit")||(namePre==
"PhysFourthQuad")||(namePre==
"PhysThirdQuad")||(namePre==
"PhysSecondQuad")||(namePre==
"PhysFirstQuad"))
105 theTrack -> SetTrackStatus(fKillTrackAndSecondaries);
130 if((aStep->GetTrack()->GetVolume()->GetName()==
"PVirtualMag") && aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-")
133 WriteDataIn << eKin <<
'\t' <<
" " 134 << eventNum <<
'\t' <<
" " 135 << PosX <<
'\t' <<
" " 136 << PosY <<
'\t' <<
" " 137 << PosZ <<
'\t' <<
" " 155 if ((namePre==
"PhysicEntranceWindow") &&
156 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary))
159 WriteDataIn << eKin <<
'\t' <<
" " 160 << eventNum <<
'\t' <<
" " 161 << PreStepX <<
'\t' <<
" " 162 << PreStepY <<
'\t' <<
" " 163 << PreStepZ <<
'\t' <<
" " 164 << parentID <<
'\t' <<
" " 165 << trackID <<
'\t' <<
" " 172 if ((namePre==
"PhysicCup") && (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary))
176 WriteDataBack << eKin <<
'\t' <<
" " 177 << eventNum <<
'\t' <<
" " 178 << PreStepX <<
'\t' <<
" " 179 << PreStepY <<
'\t' <<
" " 180 << PreStepZ <<
'\t' <<
" " 181 << parentID <<
'\t' <<
" " 182 << trackID <<
'\t' <<
" " 191 if (((namePost==
"PhysicVirtualWindow") && (namePre!=
"PhysicVirtualWindow")) &&
192 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary))
195 if ((PostStepX - PreStepX)>0)
204 std::ofstream WriteDataIn(
"DatiFCWindowIn.out",
std::ios::app);
205 WriteDataIn << eKin <<
'\t' <<
" " 206 << eventNum <<
'\t' <<
" " 207 << PostStepX <<
'\t' <<
" " 208 << PostStepY <<
'\t' <<
" " 209 << PostStepZ <<
'\t' <<
" " 213 << parentID <<
'\t' <<
" " 214 << trackID <<
'\t' <<
" " 224 std::ofstream WriteDataBack(
"DatiFCWindowBack.out",
std::ios::app);
225 WriteDataBack << eKin <<
'\t' <<
" " 226 << eventNum <<
'\t' <<
" " 227 << PostStepX <<
'\t' <<
" " 228 << PostStepY <<
'\t' <<
" " 229 << PostStepZ <<
'\t' <<
" " 230 << parentID <<
'\t' <<
" " 231 << trackID <<
'\t' <<
" " 268 if (((namePost==
"PhysicVirtualWindow") && (namePre!=
"PhysicVirtualWindow")) &&
269 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"proton"))
282 std::ofstream WriteData(
"DatiFCAfterWindowProton.out",
std::ios::app);
283 WriteData << eKin <<
'\t' <<
" " 284 << eventNum <<
'\t' <<
" " 285 << PostStepX <<
'\t' <<
" " 286 << PostStepY <<
'\t' <<
" " 287 << PostStepZ <<
'\t' <<
" " 288 << parentID <<
'\t' <<
" " 289 << trackID <<
'\t' <<
" " 300 if ((namePre==
"PhysicGuardRing") &&
301 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
304 if ((PostStepX - PreStepX)>0)
308 std::ofstream WriteDataIn(
"DatiFCGuardRingIn.out",
std::ios::app);
309 WriteDataIn << eKin <<
'\t' <<
" " 310 << eventNum <<
'\t' <<
" " 311 << PreStepX <<
'\t' <<
" " 312 << PreStepY <<
'\t' <<
" " 313 << PreStepZ <<
'\t' <<
" " 314 << parentID <<
'\t' <<
" " 323 std::ofstream WriteDataBack(
"DatiFCGuardRingBack.out",
std::ios::app);
324 WriteDataBack << eKin <<
'\t' <<
" " 325 << eventNum <<
'\t' <<
" " 326 << PreStepX <<
'\t' <<
" " 327 << PreStepY <<
'\t' <<
" " 328 << PreStepZ <<
'\t' <<
" " 329 << parentID <<
'\t' <<
" " 337 if (((namePost==
"PhysicVirtualMiddle") && (namePre!=
"PhysicVirtualMiddle")) &&
338 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary))
341 if ((PostStepX - PreStepX)>0)
347 std::ofstream WriteMDataIn(
"DatiFCMiddleIn.out",
std::ios::app);
348 WriteMDataIn << eKin <<
'\t' <<
" " 349 << eventNum <<
'\t' <<
" " 350 << PostStepX <<
'\t' <<
" " 351 << PostStepY <<
'\t' <<
" " 352 << PostStepZ <<
'\t' <<
" " 353 << parentID <<
'\t' <<
" " 354 << trackID <<
'\t' <<
" " 362 std::ofstream WriteMDataBack(
"DatiFCMiddleBack.out",
std::ios::app);
363 WriteMDataBack << eKin <<
'\t' <<
" " 364 << eventNum <<
'\t' <<
" " 365 << PostStepX <<
'\t' <<
" " 366 << PostStepY <<
'\t' <<
" " 367 << PostStepZ <<
'\t' <<
" " 368 << parentID <<
'\t' <<
" " 369 << trackID <<
'\t' <<
" " 377 if (((namePost==
"PhysicVirtualBottom") && (namePre!=
"PhysicVirtualBottom")) &&
378 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
381 if ((PostStepX - PreStepX)>0)
384 std::ofstream WriteDataIn(
"DatiFCBottomIn.out",
std::ios::app);
385 WriteDataIn << eKin <<
'\t' <<
" " 386 << eventNum <<
'\t' <<
" " 387 << PostStepX <<
'\t' <<
" " 388 << PostStepY <<
'\t' <<
" " 389 << PostStepZ <<
'\t' <<
" " 390 << parentID <<
'\t' <<
" " 391 << trackID <<
'\t' <<
" " 401 std::ofstream WriteDataBack(
"DatiFCBottomBack.out",
std::ios::app);
402 WriteDataBack << eKin <<
'\t' <<
" " 403 << eventNum <<
'\t' <<
" " 404 << PostStepX <<
'\t' <<
" " 405 << PostStepY <<
'\t' <<
" " 406 << PostStepZ <<
'\t' <<
" " 410 << parentID <<
'\t' <<
" " 411 << trackID <<
'\t' <<
" " 422 if (((namePost==
"PhysicCup") && (namePre!=
"PhysicCup")) &&
423 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"proton") && (PreStep->GetStepStatus() == fGeomBoundary))
427 Carica << eKin <<
'\t' <<
" " 428 << eventNum <<
'\t' <<
" " 429 << PostStepX <<
'\t' <<
" " 430 << PostStepY <<
'\t' <<
" " 431 << PostStepZ <<
'\t' <<
" " 432 << parentID <<
'\t' <<
" " 433 << trackID <<
'\t' <<
" " 440 if (((namePost==
"PhysicFaradayCupBottom") && (namePre!=
"PhysicFaradayCupBottom"))&&
441 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"proton") && (PreStep->GetStepStatus() == fGeomBoundary))
444 std::ofstream CaricaLatFC(
"CaricaRaccoltaLatFC.out",
std::ios::app);
445 CaricaLatFC << eKin <<
'\t' <<
" " 446 << eventNum <<
'\t' <<
" " 447 << PostStepX <<
'\t' <<
" " 448 << PostStepY <<
'\t' <<
" " 449 << PostStepZ <<
'\t' <<
" " 450 << parentID <<
'\t' <<
" " 451 << trackID <<
'\t' <<
" " 459 if (((namePre==
"PhysicFaradayCupBottom") || (namePre==
"PhysicCup")) && ((aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary)))
462 if ((PostStepX - PreStepX)>0)
465 std::ofstream WriteDataIn(
"DatiFCConeBottomCupIn.out",
std::ios::app);
466 WriteDataIn << eKin <<
'\t' <<
" " 467 << eventNum <<
'\t' <<
" " 468 << PreStepX <<
'\t' <<
" " 469 << PreStepY <<
'\t' <<
" " 470 << PreStepZ <<
'\t' <<
" " 471 << parentID <<
'\t' <<
" " 481 std::ofstream WriteDataBack(
"DatiFCConeBottomCupBack.out",
std::ios::app);
482 WriteDataBack << eKin <<
'\t' <<
" " 483 << eventNum <<
'\t' <<
" " 484 << PreStepX <<
'\t' <<
" " 485 << PreStepY <<
'\t' <<
" " 486 << PreStepZ <<
'\t' <<
" " 487 << parentID <<
'\t' <<
" " 496 if ((namePre==
"PhysicVirtualOverBottom") &&
497 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
500 if ((PostStepX - PreStepX)>0)
506 std::ofstream WriteDataIn(
"DatiFCOverBottomIn.out",
std::ios::app);
507 WriteDataIn << eKin <<
'\t' <<
" " 508 << eventNum <<
'\t' <<
" " 509 << PreStepX <<
'\t' <<
" " 510 << PreStepY <<
'\t' <<
" " 511 << PreStepZ <<
'\t' <<
" " 512 << parentID <<
'\t' <<
" " 513 << trackID <<
'\t' <<
" " 523 std::ofstream WriteDataBack(
"DatiFCOverBottomBack.out",
std::ios::app);
524 WriteDataBack << eKin <<
'\t' <<
" " 525 << eventNum <<
'\t' <<
" " 526 << PreStepX <<
'\t' <<
" " 527 << PreStepY <<
'\t' <<
" " 528 << PreStepZ <<
'\t' <<
" " 529 << parentID <<
'\t' <<
" " 530 << trackID <<
'\t' <<
" " 542 if (((namePost==
"PhysicVirtualLateral") && (namePre!=
"PhysicVirtualLateral"))&&
543 (aStep->GetTrack()->GetDefinition()->GetParticleName() ==
"e-") && (PreStep->GetStepStatus() == fGeomBoundary))
547 std::ofstream WriteDataIn(
"DatiFCLateral.out",
std::ios::app);
548 WriteDataIn << eKin <<
'\t' <<
" " 549 << eventNum <<
'\t' <<
" " 550 << PostStepX <<
'\t' <<
" " 551 << PostStepY <<
'\t' <<
" " 552 << PostStepZ <<
'\t' <<
" " 553 << parentID <<
'\t' <<
" " 554 << trackID <<
'\t' <<
" " 562 if( aStep->GetTrack()->GetVolume()->GetName() ==
"NewDetectorPhys"){
563 #ifdef G4ANALYSIS_USE_ROOT 565 G4double secondaryParticleKineticEnergy = aStep->GetTrack()->GetKineticEnergy();
568 if(particleType ==
"nucleus") {
571 G4double posX = aStep->GetTrack()->GetPosition().x() /
cm;
572 G4double posY = aStep->GetTrack()->GetPosition().y() /
cm;
573 G4double posZ = aStep->GetTrack()->GetPosition().z() /
cm;
577 analysisMgr->FillFragmentTuple(A, Z, energy, posX, posY, posZ);
578 }
else if(particleName ==
"proton") {
579 G4double posX = aStep->GetTrack()->GetPosition().x() /
cm ;
580 G4double posY = aStep->GetTrack()->GetPosition().y() /
cm ;
581 G4double posZ = aStep->GetTrack()->GetPosition().z() /
cm ;
582 G4double energy = secondaryParticleKineticEnergy *
MeV;
586 G4String secondaryParticleName = def -> GetParticleName();
591 if(secondaryParticleName ==
"proton") {
592 analysis->hydrogenEnergy(secondaryParticleKineticEnergy / MeV);
594 if(secondaryParticleName ==
"deuteron") {
595 analysis->hydrogenEnergy((secondaryParticleKineticEnergy/2) / MeV);
597 if(secondaryParticleName ==
"triton") {
598 analysis->hydrogenEnergy((secondaryParticleKineticEnergy/3) / MeV);
600 if(secondaryParticleName ==
"alpha") {
601 analysis->heliumEnergy((secondaryParticleKineticEnergy/4) / MeV);
603 if(secondaryParticleName ==
"He3"){
604 analysis->heliumEnergy((secondaryParticleKineticEnergy/3) / MeV);
608 aStep->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries);
613 if ((aStep -> GetTrack() -> GetTrackID() == 1) &&
614 (aStep -> GetTrack() -> GetVolume() -> GetName() ==
"PhantomPhys") &&
615 (aStep -> GetPostStepPoint() -> GetProcessDefinedStep() != NULL))
617 G4String process = aStep -> GetPostStepPoint() ->
618 GetProcessDefinedStep() -> GetProcessName();
620 if ((process ==
"Transportation") || (process ==
"StepLimiter")) {;}
623 if ((process ==
"msc") || (process ==
"hLowEIoni") || (process ==
"hIoni"))
631 if ( (process !=
"LElastic") && (process !=
"ProtonInelastic") && (process !=
"hElastic") )
632 G4cout <<
"Warning! Unknown proton process: "<< process <<
G4endl;
645 G4TrackVector* fSecondary = steppingManager -> GetfSecondary();
647 for(
size_t lp1=0;lp1<(*fSecondary).size(); lp1++)
649 G4String volumeName = (*fSecondary)[lp1] -> GetVolume() -> GetName();
651 if (volumeName ==
"phantomPhys")
653 #ifdef G4ANALYSIS_USE_ROOT 654 G4String secondaryParticleName = (*fSecondary)[lp1]->GetDefinition() -> GetParticleName();
655 G4double secondaryParticleKineticEnergy = (*fSecondary)[lp1] -> GetKineticEnergy();
659 if (secondaryParticleName ==
"e-")
660 analysis -> electronEnergyDistribution(secondaryParticleKineticEnergy/MeV);
662 if (secondaryParticleName ==
"gamma")
663 analysis -> gammaEnergyDistribution(secondaryParticleKineticEnergy/MeV);
665 if (secondaryParticleName ==
"deuteron")
666 analysis -> deuteronEnergyDistribution(secondaryParticleKineticEnergy/MeV);
668 if (secondaryParticleName ==
"triton")
669 analysis -> tritonEnergyDistribution(secondaryParticleKineticEnergy/MeV);
671 if (secondaryParticleName ==
"alpha")
672 analysis -> alphaEnergyDistribution(secondaryParticleKineticEnergy/MeV);
674 G4double z = (*fSecondary)[lp1]-> GetDynamicParticle() -> GetDefinition() -> GetPDGCharge();
677 G4int a = (*fSecondary)[lp1]-> GetDynamicParticle() -> GetDefinition() -> GetBaryonNumber();
678 G4int electronOccupancy = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetTotalOccupancy();
682 analysis -> genericIonInformation(a, z, electronOccupancy, secondaryParticleKineticEnergy/MeV);
static HadrontherapyAnalysisManager * GetInstance()
G4int GetBaryonNumber() const
const G4String & GetParticleType() const
HadrontherapyRunAction * runAction
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
G4SteppingManager * fpSteppingManager
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
static G4RunManager * GetRunManager()
const G4String & GetName() const
G4double GetPDGCharge() const