// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // /// \file DetectorConstruction.cc /// \brief Implementation of the DetectorConstruction class // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "DetectorConstruction.hh" #include "DetectorMessenger.hh" //#include "ExG4DetectorSD.hh" //#include "G4SDManager.hh" #include "G4Material.hh" #include "G4NistManager.hh" #include "G4Tubs.hh" #include "G4Orb.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4RunManager.hh" #include "G4SubtractionSolid.hh" #include "G4UnionSolid.hh" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" #include "G4UnitsTable.hh" #include "G4RotationMatrix.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() :G4VUserDetectorConstruction(), fTargetMater(0), fLogicTarget(0), fDetectorMater(0), fLogicDetector(0), fWorldMater(0), fPhysiWorld(0), fDetectorMessenger(0), fElectrodeMater(0), fAssemblyMater(0), fDeviceMater(0), fLogicsDs(0), fIsoMater(0) { fTargetLength = 44.*mm; fTargetRadius = 29.75*mm; fDetectorLength = 20*m; fDetectorThickness = 10*m; fWorldLength = std::max(fTargetLength,fDetectorLength); fWorldRadius = fTargetRadius + fDetectorThickness; DefineMaterials(); fDetectorMessenger = new DetectorMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { delete fDetectorMessenger;} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { return ConstructVolumes(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::DefineMaterials() { // build materials // // Liquid argon material G4double a; // mass of a mole; G4double z; // z=mean number of protons; G4double density; // Vacuum fDetectorMater = new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density, kStateGas, 2.73*kelvin, 3.e-18*pascal); G4Element* N = new G4Element("Nitrogen", "N", 7, 14.01*g/mole); G4Element* O = new G4Element("Oxygen", "O", 8, 16.00*g/mole); // G4int ncomponents; G4double fractionmass; G4Material* Air20 = new G4Material("Air", 1.205*mg/cm3, ncomponents=2, kStateGas, 293.*kelvin, 1.*atmosphere); Air20->AddElement(N, fractionmass=0.7); Air20->AddElement(O, fractionmass=0.3); // fWorldMater = Air20; // or use G4 materials data base // G4NistManager* man = G4NistManager::Instance(); G4Material* Ge = man->FindOrBuildMaterial("G4_Ge"); G4Material* Cu = man->FindOrBuildMaterial("G4_Cu"); G4Material* Al = man->FindOrBuildMaterial("G4_Al"); G4Material* Tef = man->FindOrBuildMaterial("G4_TEFLON"); fElectrodeMater = Cu; fAssemblyMater = Al; fTargetMater = Ge; fIsoMater = Tef; G4Material* nAl = new G4Material("nAl", z=13., a=26.981*g/mole, density= 0.1*g/cm*3); fDeviceMater = nAl; ///G4cout << *(G4Material::GetMaterialTable()) << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() { // Cleanup old geometry G4GeometryManager::GetInstance()->OpenGeometry(); G4PhysicalVolumeStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4SolidStore::GetInstance()->Clean(); // World // // (re) compute World dimensions if necessary fWorldLength = std::max(fTargetLength,fDetectorLength); fWorldRadius = fTargetRadius + fDetectorThickness; G4bool checkOverlaps = true; G4Orb* sWorld = new G4Orb("World", //name fDetectorThickness); //dimensions G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, //shape fWorldMater, //material "World"); //name fPhysiWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) lWorld, //logical volume "World", //name 0, //mother volume false, //no boolean operation 0); //copy number G4Tubs* sAssembly1 = new G4Tubs("Assembly1", //name 0., 38*mm, 75*mm, 0.,twopi); //dimensions G4Tubs* sAssembly2 = new G4Tubs("Assembly2", //name 0., 36.5*mm, 73.5*mm, 0.,twopi); //dimensions G4SubtractionSolid* sAssembly = new G4SubtractionSolid("Assembly", //name sAssembly1, sAssembly2); //dimensions G4LogicalVolume* fLogicAssembly = new G4LogicalVolume(sAssembly, //shape fAssemblyMater, //material "Assembly"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 75*mm), //at (0,0,0) fLogicAssembly, //logical volume "Assembly", //name lWorld, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4LogicalVolume* fLogicInAssembly = new G4LogicalVolume(sAssembly2, //shape fDetectorMater, //material "InAssembly"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 75*mm), //at (0,0,0) fLogicInAssembly, //logical volume "InAssembly", //name lWorld, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number // Target // G4Tubs* sTarget1 = new G4Tubs("Target1", //name 0., fTargetRadius, 0.5*fTargetLength, 0.,twopi); //dimensions G4Tubs* sTarget2 = new G4Tubs("Target2", //name 0., 5*mm, 16.2*mm, 0.,twopi); //dimensions G4ThreeVector zTrans1(0, 0, 5.9*mm); G4SubtractionSolid* sTarget = new G4SubtractionSolid("Detector", //name sTarget1, sTarget2, 0, zTrans1); //dimensions fLogicTarget = new G4LogicalVolume(sTarget, //shape fTargetMater, //material "Detector"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., -44.7*mm), //at (0,0,0) fLogicTarget, //logical volume "Detector", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sDeadLayerT = new G4Tubs("DeadLayerT", //name 0., 30.25*mm, 1.15*mm, 0.,twopi); //dimensions G4LogicalVolume* fLogicDeadLayerT = new G4LogicalVolume(sDeadLayerT, //shape fTargetMater, //material "DeadLayerT"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., -67.85*mm), //at (0,0,0) fLogicDeadLayerT, //logical volume "DeadLayerT", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sDeadLayerR = new G4Tubs("DeadLayerR", //name fTargetRadius, 30.25*mm, 0.5*fTargetLength, 0.,twopi); //dimensions G4LogicalVolume* fLogicDeadLayerR = new G4LogicalVolume(sDeadLayerR, //shape fTargetMater, //material "DeadLayerR"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., -44.7*mm), //at (0,0,0) fLogicDeadLayerR, //logical volume "DeadLayerR", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sElectrode = new G4Tubs("Electrode", //name 0, 2*mm, 23.5*mm, 0.,twopi); //dimensions G4LogicalVolume* fLogicElectrode = new G4LogicalVolume(sElectrode, //shape fElectrodeMater, //material "Electrode"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., -31.5*mm), //at (0,0,0) fLogicElectrode, //logical volume "Electrode", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number // Detector // G4Tubs* sDetector1 = new G4Tubs("Detector1", 0, 31.01*mm, 32.*mm, 0.,twopi); G4Tubs* sDetector2 = new G4Tubs("Detector2", 0, 30.25*mm, 30.6*mm, 0.,twopi); G4ThreeVector zTrans2 (0, 0, -1.7*mm); G4SubtractionSolid* sDetector12= new G4SubtractionSolid("sDetector12", sDetector1, sDetector2, 0, zTrans2); G4Tubs* sDetector3 = new G4Tubs("Detector3", 31*mm, 33.71*mm, 4.3*mm, 0.,twopi); G4ThreeVector zTrans3 (0, 0, -20.7*mm); G4UnionSolid* sDetector123= new G4UnionSolid("sDetector123", sDetector12, sDetector3, 0, zTrans3); G4ThreeVector zTrans4 (0, 0, 1.3*mm); G4UnionSolid* sDetector= new G4UnionSolid("Holder", sDetector123, sDetector3, 0, zTrans4); fLogicDetector = new G4LogicalVolume(sDetector, //shape fAssemblyMater, //material "Holder"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,-37.*mm), //at (0,0,0) fLogicDetector, //logical volume "Holder", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sSupp1 = new G4Tubs("Supp1", //name 0*mm, 13*mm, 10.*mm, 0.,twopi); //dimensions G4Tubs* sSupp2 = new G4Tubs("Supp2", //name 0*mm, 9*mm, 8.*mm, 0.,twopi); //dimensions G4ThreeVector zTrans5 (0, 0, -2.0*mm); G4SubtractionSolid* sSupp= new G4SubtractionSolid("Supp", sSupp1, sSupp2, 0, zTrans5); G4LogicalVolume* fLogicSupp = new G4LogicalVolume(sSupp, //shape fAssemblyMater, //material "Supp"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 5.*mm), //at (0,0,0) fLogicSupp, //logical volume "Supp", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sIso = new G4Tubs("Iso", //name 0*mm, 9*mm, 8.*mm, 0.,twopi); //dimensions G4LogicalVolume* fLogicIso = new G4LogicalVolume(sIso, //shape fIsoMater, //material "Iso"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 3*mm), //at (0,0,0) fLogicIso, //logical volume "Iso", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sCont = new G4Tubs("Cont", //name 0, 5.*mm, 29.25*mm, 0.,twopi); //dimensions G4LogicalVolume* fLogicCont = new G4LogicalVolume(sCont, //shape fElectrodeMater, //material "Cont"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 44.25*mm), //at (0,0,0) fLogicCont, //logical volume "Cont", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number G4Tubs* sDevice = new G4Tubs("Device", //name 5*mm, 36.5*mm, 14.25*mm, 0.,twopi); //dimensions G4LogicalVolume* fLogicDevice = new G4LogicalVolume(sDevice, //shape fDeviceMater, //material "Device"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0., 59.25*mm), //at (0,0,0) fLogicDevice, //logical volume "Device", //name fLogicInAssembly, //mother volume false, //no boolean operation 0,checkOverlaps); //copy number // G4Tubs* // sDs= new G4Tubs("SDS", 0, fTargetRadius, 1*cm, 0., twopi); // fLogicsDs = new G4LogicalVolume(sDs, //shape // fWorldMater, //material // "SDS"); //name // new G4PVPlacement(0, //no rotation // G4ThreeVector (0*m,0*m,-4.8*cm), //at (0,0,0) // fLogicsDs, //logical volume // "SDS", //name // lWorld, //mother volume // false, //no boolean operation // 0); //copy number PrintParameters(); //always return the root volume // return fPhysiWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::PrintParameters() { G4cout << "\n Target : Length = " << G4BestUnit(fTargetLength,"Length") << " Radius = " << G4BestUnit(fTargetRadius,"Length") << " Material = " << fTargetMater->GetName(); G4cout << "\n Detector : Length = " << G4BestUnit(fDetectorLength,"Length") << " Tickness = " << G4BestUnit(fDetectorThickness,"Length") << " Material = " << fDetectorMater->GetName() << G4endl; G4cout << "\n" << fTargetMater << "\n" << fDetectorMater << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetMaterial(G4String materialChoice) { // search the material by its name G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (pttoMaterial) { fTargetMater = pttoMaterial; if(fLogicTarget) { fLogicTarget->SetMaterial(fTargetMater); } G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } else { G4cout << "\n--> warning from DetectorConstruction::SetTargetMaterial : " << materialChoice << " not found" << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorMaterial(G4String materialChoice) { // search the material by its name G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (pttoMaterial) { fDetectorMater = pttoMaterial; if(fLogicDetector) { fLogicDetector->SetMaterial(fDetectorMater); } G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } else { G4cout << "\n--> warning from DetectorConstruction::SetDetectorMaterial : " << materialChoice << " not found" << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetRadius(G4double value) { fTargetRadius = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetLength(G4double value) { fTargetLength = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorThickness(G4double value) { fDetectorThickness = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorLength(G4double value) { fDetectorLength = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetTargetLength() { return fTargetLength; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetTargetRadius() { return fTargetRadius; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* DetectorConstruction::GetTargetMaterial() { return fTargetMater; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* DetectorConstruction::GetLogicTarget() { return fLogicTarget; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetDetectorLength() { return fDetectorLength; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetDetectorThickness() { return fDetectorThickness; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* DetectorConstruction::GetDetectorMaterial() { return fDetectorMater; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* DetectorConstruction::GetLogicDetector() { return fLogicDetector; } //void DetectorConstruction::ConstructSDandField() //{ // Объявление чувствительной области детектора, в которой можно получить подробную // информацию о состоянии и движении частицы // Назовем чувствительную область DetectorSD // G4String trackerChamberSDname = "DetectorSD"; // Создаем экземпляр чувствительной области // ExG4DetectorSD* aTrackerSD = new ExG4DetectorSD(trackerChamberSDname); // Передаем указатель менеджеру // G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD); // Добавляем чувствительный объем ко всем логическим областям с // именем Detector // SetSensitiveDetector("SDS", aTrackerSD, true); //} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......