Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 16:42:36

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file RMC01DetectorConstruction.cc
0027 /// \brief Implementation of the RMC01DetectorConstruction class
0028 
0029 //      Class Name:        RMC01DetectorConstruction
0030 //        Author:               L. Desorgher
0031 //         Organisation:         SpaceIT GmbH
0032 //        Contract:        ESA contract 21435/08/NL/AT
0033 //         Customer:             ESA/ESTEC
0034 //////////////////////////////////////////////////////////////
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 #include "RMC01DetectorConstruction.hh"
0040 
0041 #include "RMC01DetectorMessenger.hh"
0042 #include "RMC01SD.hh"
0043 
0044 #include "G4Box.hh"
0045 #include "G4Colour.hh"
0046 #include "G4GeometryManager.hh"
0047 #include "G4LogicalVolume.hh"
0048 #include "G4LogicalVolumeStore.hh"
0049 #include "G4Material.hh"
0050 #include "G4Orb.hh"
0051 #include "G4PVPlacement.hh"
0052 #include "G4PhysicalConstants.hh"
0053 #include "G4PhysicalVolumeStore.hh"
0054 #include "G4RunManager.hh"
0055 #include "G4SDManager.hh"
0056 #include "G4SolidStore.hh"
0057 #include "G4SystemOfUnits.hh"
0058 #include "G4Tubs.hh"
0059 #include "G4VisAttributes.hh"
0060 
0061 #include "G4StateManager.hh"
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 RMC01DetectorConstruction::RMC01DetectorConstruction()
0066   : G4VUserDetectorConstruction(),
0067     fDetectorMessenger(0),
0068     fShield_Thickness(5. * mm),
0069     fSensitive_cylinder_H(1. * mm),
0070     fSensitive_cylinder_Rout(1. * mm)
0071 {
0072   fDetectorMessenger = new RMC01DetectorMessenger(this);
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 RMC01DetectorConstruction::~RMC01DetectorConstruction()
0078 {
0079   if (fDetectorMessenger) delete fDetectorMessenger;
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 G4VPhysicalVolume* RMC01DetectorConstruction::Construct()
0085 {
0086   DefineMaterials();
0087   return ConstructSimpleGeometry();
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 
0092 void RMC01DetectorConstruction::ConstructSDandField()
0093 {
0094 
0095   G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
0096 
0097   RMC01SD *theSensitiveDetector = new RMC01SD("/SensitiveCylinder");
0098 
0099   G4SDManager::GetSDMpointer()->AddNewDetector(theSensitiveDetector);
0100   //logicDetectingCylinder->SetSensitiveDetector(theSensitiveDetector);
0101   SetSensitiveDetector("SensitiveVolume", theSensitiveDetector);
0102 
0103   G4SDManager::GetSDMpointer()->SetVerboseLevel(0);
0104 }
0105 
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0107 
0108 void RMC01DetectorConstruction::DefineMaterials()
0109 {
0110   G4String symbol;  // a=mass of a mole;
0111   G4double a, z, density;  // z=mean number of protons;
0112   G4double fractionmass;
0113   G4int ncomponents;
0114 
0115   //
0116   // define Elements
0117   //
0118 
0119   G4Element* N = new G4Element("Nitrogen", symbol = "N", z = 7., a = 14.01 * g / mole);
0120   G4Element* O = new G4Element("Oxygen", symbol = "O", z = 8., a = 16.00 * g / mole);
0121 
0122   //
0123   // define simple materials
0124   //
0125 
0126   new G4Material("Aluminum", z = 13., a = 26.98 * g / mole, density = 2.700 * g / cm3);
0127   new G4Material("Silicon", z = 14., a = 28.09 * g / mole, density = 2.33 * g / cm3);
0128   new G4Material("Tantalum", z = 73., a = 180.9479 * g / mole, density = 16.654 * g / cm3);
0129 
0130   //
0131   // define air
0132   //
0133 
0134   G4Material* Air = new G4Material("Air", density = 1.290 * mg / cm3, ncomponents = 2);
0135   Air->AddElement(N, fractionmass = 0.7);
0136   Air->AddElement(O, fractionmass = 0.3);
0137 
0138   //
0139   // Example of Vacuum
0140   //
0141 
0142   new G4Material("Vacuum", z = 1., a = 1.01 * g / mole, density = universe_mean_density, kStateGas,
0143                  3.e-18 * pascal, 2.73 * kelvin);
0144 }
0145 
0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0147 
0148 G4VPhysicalVolume* RMC01DetectorConstruction::ConstructSimpleGeometry()
0149 {
0150   // Clean old geometry, if any
0151 
0152   G4GeometryManager::GetInstance()->OpenGeometry();
0153   G4PhysicalVolumeStore::GetInstance()->Clean();
0154   G4LogicalVolumeStore::GetInstance()->Clean();
0155   G4SolidStore::GetInstance()->Clean();
0156 
0157   // World
0158   //-----------
0159 
0160   G4Box* solidWorld = new G4Box("World", 15. * cm, 15. * cm, 15. * cm);
0161   G4LogicalVolume* logicWorld =
0162     new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "World");
0163 
0164   G4VPhysicalVolume* physiWorld = new G4PVPlacement(0,  // no rotation
0165                                                     G4ThreeVector(),  // at (0,0,0)
0166                                                     logicWorld,  // its logical volume
0167                                                     "World",  // its name
0168                                                     0,  // its mother  volume
0169                                                     false,  // no boolean operation
0170                                                     0);
0171 
0172   // Shielding Aluminum Sphere
0173   //-------------------
0174 
0175   G4double radiusShieldingSphere = 10. * cm;
0176 
0177   G4Orb* solidShieldingSphere = new G4Orb("Shielding", radiusShieldingSphere);
0178   G4LogicalVolume* logicShieldingSphere =
0179     new G4LogicalVolume(solidShieldingSphere, G4Material::GetMaterial("Aluminum"),
0180                         "Shielding");  // its name;
0181 
0182   new G4PVPlacement(0,  // no rotation
0183                     G4ThreeVector(),  // at (0,0,0)
0184                     logicShieldingSphere,  // its logical volume
0185                     "Shielding",  // its name
0186                     logicWorld,  // its mother  volume
0187                     false,  // no boolean operation
0188                     0);
0189 
0190   // Bulk Sphere
0191   //-------------------
0192 
0193   G4Orb* solidBulkSphere = new G4Orb("Bulk", radiusShieldingSphere - fShield_Thickness);
0194   G4LogicalVolume* logicBulkSphere =
0195     new G4LogicalVolume(solidBulkSphere,  // its solid
0196                         G4Material::GetMaterial("Air"),  // its material
0197                         "Bulk");  // its name;
0198 
0199   new G4PVPlacement(0,  // no rotation
0200                     G4ThreeVector(),  // at (0,0,0)
0201                     logicBulkSphere,  // its logical volume
0202                     "Bulk",  // its name
0203                     logicShieldingSphere,  // its mother  volume
0204                     false,  // no boolean operation
0205                     0);
0206 
0207   // Detecting cylinder
0208   //-------------------
0209 
0210   G4Tubs* solidDetecting = new G4Tubs("SensitiveVolume", 0., fSensitive_cylinder_Rout,
0211                                       fSensitive_cylinder_H / 2., 0., twopi);
0212 
0213   G4LogicalVolume* logicDetectingCylinder =
0214     new G4LogicalVolume(solidDetecting, G4Material::GetMaterial("Silicon"), "SensitiveVolume");
0215 
0216   new G4PVPlacement(0,  // no rotation
0217                     G4ThreeVector(0., 0., 0.),  // at (0,0,0)
0218                     logicDetectingCylinder,  // its logical volume
0219                     "SensitiveVolume",  // its name
0220                     logicBulkSphere,  // its mother  volume
0221                     false,  // no boolean operation
0222                     0);
0223 
0224    // Tantalum Plates on the top and beside
0225   //-------------------------------------
0226   G4Box* solidPlate = new G4Box("TantalumPlate", 4. * cm, 4. * cm, 0.25 * mm);
0227   G4LogicalVolume* logicPlate =
0228     new G4LogicalVolume(solidPlate,  // its solid
0229                         G4Material::GetMaterial("Tantalum"),  // its material
0230                         "TantalumPlate");  // its name;
0231 
0232   new G4PVPlacement(0,  // no rotation
0233                     G4ThreeVector(0., 0., 6. * cm),  // at (0,0,0)
0234                     logicPlate,  // its logical volume
0235                     "TantalumPlate1",  // its name
0236                     logicBulkSphere,  // its mother  volume
0237                     false,  // no boolean operation
0238                     0);
0239 
0240   new G4PVPlacement(0,  // no rotation
0241                     G4ThreeVector(0., 0., -6. * cm),  // at (0,0,0)
0242                     logicPlate,  // its logical volume
0243                     "TantalumPlate2",  // its name
0244                     logicBulkSphere,  // its mother  volume
0245                     false,  // no boolean operation
0246                     0);
0247 
0248   return physiWorld;
0249 }
0250 
0251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0252 
0253 void RMC01DetectorConstruction::SetSensitiveVolumeRadius(G4double r)
0254 {  fSensitive_cylinder_Rout=r;
0255 UpdateGeometry();
0256 }
0257 
0258 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0259 
0260 void RMC01DetectorConstruction::SetSensitiveVolumeHeight(G4double h)
0261 {
0262   fSensitive_cylinder_H = h;
0263   UpdateGeometry();
0264 }
0265 
0266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0267 
0268 void RMC01DetectorConstruction::SetShieldingThickness(G4double d)
0269 { fShield_Thickness=d;
0270   UpdateGeometry();
0271 }
0272 
0273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0274 
0275 void RMC01DetectorConstruction::UpdateGeometry()
0276 {
0277   G4RunManager* runManager = G4RunManager::GetRunManager();
0278    if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
0279 //      delete G4SDManager::GetSDMpointer()->FindSensitiveDetector("SensitiveVolume");
0280       runManager->DefineWorldVolume(ConstructSimpleGeometry());
0281 //      runManager->DefineWorldVolume(Construct());
0282       runManager->ReinitializeGeometry();
0283    }
0284 }
0285 
0286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......