#include "DetectorConstruction.hh" #include "GePD.hh" #include "GeDD.hh" #include "GeSD.hh" #include "SourceNo138_139_140.hh" #include "SourceNo110_114.hh" #include "SourceHolder20210510A.hh" #include "SourceHolder20210510B.hh" #include "Chamber20nep.hh" #include "Collimator20nep.hh" #include "CuShieldForGeDD20nep.hh" #include "CuShieldForGePD20nep.hh" #include "OuterPbShield20nep.hh" #include "Materials.hh" #include "G4SDManager.hh" #include "G4RunManager.hh" #include "G4VSensitiveDetector.hh" #include "G4Box.hh" #include "G4LogicalVolume.hh" #include "G4ThreeVector.hh" #include "G4PVPlacement.hh" #include "globals.hh" #include "G4SystemOfUnits.hh" #include "G4VisAttributes.hh" #include "G4UserLimits.hh" #include "DetectorConstructionMessenger.hh" #include "BOptrMultiParticleChangeCrossSection.hh" DetectorConstruction::DetectorConstruction():G4VUserDetectorConstruction(), fScoringVolume(0) { detectorConstructionMessenger = new DetectorConstructionMessenger(this); materials = Materials::GetInstance(); AGePD = GePD::GetInstance(); AGeDD = GeDD::GetInstance(); } DetectorConstruction::~DetectorConstruction() { delete detectorConstructionMessenger; } G4VPhysicalVolume* DetectorConstruction::Construct() { materials->CreateMaterials(); auto WorldSol = new G4Box("WorldSol",50*m,50*m,50*m); auto WorldLog = new G4LogicalVolume(WorldSol,materials->GetMaterial("G4_Galactic"),"WorldLog",0,0,0); auto WorldPhys = new G4PVPlacement(0,G4ThreeVector(),WorldLog,"WorldPhys",0,0,0); auto WorldVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); WorldVisAtt->SetVisibility(false); WorldLog->SetVisAttributes(WorldVisAtt); if(Physics == "S") { if(SourceHolder == "A") { // SourceNo138_139_140 for 60Co and 137Cs auto rotSource = new G4RotationMatrix(); rotSource->rotateX(90*deg); auto ASource = new SourceNo138_139_140(); auto ASourceLog = ASource->Construct(); auto ASourcePhys = new G4PVPlacement(rotSource,SourcePos,ASourceLog,"ASourcePhys",WorldLog,0,0); // SourceHolder20210510A auto rotSourceHolder = new G4RotationMatrix(); rotSourceHolder->rotateY(180*deg); auto ASourceHolder = new SourceHolder20210510A(); auto ASourceHolderLog = ASourceHolder->Construct(); auto ASourceHolderPhys = new G4PVPlacement(rotSourceHolder,SourcePos+G4ThreeVector(0,ASourceHolder->GetThickness()-ASource->GetThickness(),ASourceHolder->GetLength()-ASource->GetDiameter()),ASourceHolderLog,"ASourceHolderPhys",WorldLog,0,0); } else if(SourceHolder == "B") { // SourceNo110_114 for 133Ba auto rotSource = new G4RotationMatrix(); rotSource->rotateX(90*deg); auto ASource = new SourceNo110_114(); auto ASourceLog = ASource->Construct(); auto ASourcePhys = new G4PVPlacement(rotSource,SourcePos,ASourceLog,"ASourcePhys",WorldLog,0,0); // SourceHolder20210510B auto rotSourceHolder = new G4RotationMatrix(); rotSourceHolder->rotateY(180*deg); auto ASourceHolder = new SourceHolder20210510B(); auto ASourceHolderLog = ASourceHolder->Construct(); auto ASourceHolderPhys = new G4PVPlacement(rotSourceHolder,SourcePos+G4ThreeVector(0,ASourceHolder->GetThickness()-ASource->GetThickness(),ASourceHolder->GetLength()-ASource->GetDiameter()),ASourceHolderLog,"ASourceHolderPhys",WorldLog,0,0); } } // Collimator auto ACollimator20nep = new Collimator20nep(); auto ACollimator20nepAssembly = ACollimator20nep->Construct(); // Chamber auto AChamber20nep = new Chamber20nep(); auto AChamber20nepLog = AChamber20nep->Construct(); // Chamber placement auto AChamber20nepPhys = new G4PVPlacement(0,G4ThreeVector(0,0,AChamber20nep->GetLength()-ACollimator20nep->GetLength()-ACollimator20nep->GetLength2()),AChamber20nepLog,"AChamber20nepPhys",WorldLog,0,0); // Collimator placement auto rotColl = new G4RotationMatrix(); rotColl->rotateX(0*deg); G4ThreeVector tr(0,0,-ACollimator20nep->GetLength()); ACollimator20nepAssembly->MakeImprint(WorldLog,tr,rotColl); // CuShieldForGeDD auto rotCuShDD = new G4RotationMatrix(); rotCuShDD->rotateX(90*deg); auto ACuShieldForGeDD20nep = new CuShieldForGeDD20nep(); auto ACuShieldForGeDD20nepLog = ACuShieldForGeDD20nep->Construct(); auto ACuShieldForGeDD20nepPhys = new G4PVPlacement(0,AChamber20nepPhys->GetTranslation()+G4ThreeVector(0,AChamber20nep->GetHeight()/2+ACuShieldForGeDD20nep->GetHeight()/2+6*mm,-AChamber20nep->GetLength2()/2+ACuShieldForGeDD20nep->GetLength()/2),ACuShieldForGeDD20nepLog,"ACuShieldForGeDD20nepPhys",WorldLog,0,0); // OuterPbShield auto AnOuterPbShield20nep = new OuterPbShield20nep(); auto AnOuterPbShield20nepLog = AnOuterPbShield20nep->Construct(); auto AnOuterPbShield20nepPhys = new G4PVPlacement(0,AChamber20nepPhys->GetTranslation(),AnOuterPbShield20nepLog,"AnOuterPbShield20nepPhys",WorldLog,0,0); //auto AnOuterPbShield20nepPhys = new G4PVPlacement(0,G4ThreeVector(0,0,0),AnOuterPbShield20nepLog,"AnOuterPbShield20nepPhys",WorldLog,0,0); // CuShieldForGePD auto rotCuShPD = new G4RotationMatrix(); rotCuShPD->rotateX(90*deg); auto ACuShieldForGePD20nep = new CuShieldForGePD20nep(); auto ACuShieldForGePD20nepLog = ACuShieldForGePD20nep->Construct(); auto ACuShieldForGePD20nepPhys = new G4PVPlacement(rotCuShPD,AnOuterPbShield20nepPhys->GetTranslation()+G4ThreeVector(0,-AChamber20nep->GetHeight()/2-ACuShieldForGePD20nep->GetLength()/2-5*mm,-AChamber20nep->GetLength2()/2+184*mm),ACuShieldForGePD20nepLog,"ACuShieldForGePD20nepPhys",WorldLog,0,0); // GePD auto AGePDLog = AGePD->Construct(); G4RotationMatrix* rotGePD = new G4RotationMatrix(); rotGePD->rotateX(90*deg); auto AGePDPhys = new G4PVPlacement(rotGePD,GePDPos,AGePDLog,"AGePDPhys",WorldLog,0,0); // GeDD auto AGeDDLog = AGeDD->Construct(); G4RotationMatrix* rotGeDD = new G4RotationMatrix(); rotGeDD->rotateX(-90*deg); auto AGeDDPhys = new G4PVPlacement(rotGeDD,GeDDPos,AGeDDLog,"AGeDDPhys",WorldLog,0,1); G4SDManager* SDman = G4SDManager::GetSDMpointer(); G4String GeSDname = "/GeSD"; GeSD* AGeSD = new GeSD(GeSDname); SDman->AddNewDetector(AGeSD); GetSensitiveDetector(AGePDPhys)->SetSensitiveDetector(AGeSD); GetSensitiveDetector(AGeDDPhys)->SetSensitiveDetector(AGeSD); auto StepLimit = new G4UserLimits(MaxStep); AChamber20nep->GetTargetLog()->SetUserLimits(StepLimit); /* BOptrMultiParticleChangeCrossSection* biasingOperator = new BOptrMultiParticleChangeCrossSection(); biasingOperator->AddParticle("deuteron"); biasingOperator->AttachTo(ATargetLog); */ //------------------------------------------------------------------ G4cout << G4endl << "The materials defined are : " << G4endl << G4endl; G4cout << *(G4Material::GetMaterialTable()) << G4endl; fScoringVolume = AChamber20nepLog; DumpGeometricalTree(WorldPhys); return WorldPhys; } void DetectorConstruction::DumpGeometricalTree(G4VPhysicalVolume* aVolume,G4int depth) { for(int isp=0;ispGetName() << "[" << aVolume->GetCopyNo() << "] " << aVolume->GetLogicalVolume()->GetName() << " " << aVolume->GetLogicalVolume()->GetNoDaughters() << " " << aVolume->GetLogicalVolume()->GetMaterial()->GetName(); if(aVolume->GetLogicalVolume()->GetSensitiveDetector()) { G4cout << " " << aVolume->GetLogicalVolume()->GetSensitiveDetector() ->GetFullPathName(); } G4cout << G4endl; for(int i=0;iGetLogicalVolume()->GetNoDaughters();i++) { DumpGeometricalTree(aVolume->GetLogicalVolume()->GetDaughter(i),depth+1); } } G4LogicalVolume* DetectorConstruction::GetSensitiveDetector(G4VPhysicalVolume* aVolume,G4int depth) { for(int isp=0;ispGetName() << "[" << aVolume->GetCopyNo() << "] " << aVolume->GetLogicalVolume()->GetName() << " " << aVolume->GetLogicalVolume()->GetNoDaughters() << " " << aVolume->GetLogicalVolume()->GetMaterial()->GetName(); G4cout << G4endl; */ if(aVolume->GetName()=="gePhys") { //G4cout << "Sensitive volume found: " << aVolume->GetName() << G4endl; SensitiveLogicalVolume = aVolume->GetLogicalVolume(); break; } for(int i=0;iGetLogicalVolume()->GetNoDaughters();i++) { GetSensitiveDetector(aVolume->GetLogicalVolume()->GetDaughter(i),depth+1); } return SensitiveLogicalVolume; } G4ThreeVector DetectorConstruction::GetSourcePos() { return SourcePos/mm; } G4String DetectorConstruction::GetPhysics() { return Physics; } G4String DetectorConstruction::GetSourceHolder() { return SourceHolder; }