| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: DetectorConstruction.cc,v 1.12 2006/10/20 16:03:40 maire Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 |
|
|---|
| 30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 32 |
|
|---|
| 33 | #include "DetectorConstruction.hh"
|
|---|
| 34 | #include "DetectorMessenger.hh"
|
|---|
| 35 |
|
|---|
| 36 | #include "G4Tubs.hh"
|
|---|
| 37 | #include "G4LogicalVolume.hh"
|
|---|
| 38 | #include "G4PVPlacement.hh"
|
|---|
| 39 | #include "G4UniformMagField.hh"
|
|---|
| 40 |
|
|---|
| 41 | #include "G4GeometryManager.hh"
|
|---|
| 42 | #include "G4PhysicalVolumeStore.hh"
|
|---|
| 43 | #include "G4LogicalVolumeStore.hh"
|
|---|
| 44 | #include "G4SolidStore.hh"
|
|---|
| 45 |
|
|---|
| 46 | #include "G4UnitsTable.hh"
|
|---|
| 47 |
|
|---|
| 48 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 49 |
|
|---|
| 50 | DetectorConstruction::DetectorConstruction()
|
|---|
| 51 | :nLtot(40),nRtot(50),dLradl(0.5),dRradl(0.1),
|
|---|
| 52 | dLlength(0.),dRlength(0.),
|
|---|
| 53 | myMaterial(0),magField(0),
|
|---|
| 54 | EcalLength(0.),EcalRadius(0.),
|
|---|
| 55 | solidEcal(0),logicEcal(0),physiEcal(0)
|
|---|
| 56 | {
|
|---|
| 57 | DefineMaterials();
|
|---|
| 58 | SetMaterial("PbWO4");
|
|---|
| 59 | detectorMessenger = new DetectorMessenger(this);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 63 |
|
|---|
| 64 | DetectorConstruction::~DetectorConstruction()
|
|---|
| 65 | { delete detectorMessenger;}
|
|---|
| 66 |
|
|---|
| 67 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 68 |
|
|---|
| 69 | G4VPhysicalVolume* DetectorConstruction::Construct()
|
|---|
| 70 | {
|
|---|
| 71 | return ConstructVolumes();
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 75 |
|
|---|
| 76 | void DetectorConstruction::DefineMaterials()
|
|---|
| 77 | {
|
|---|
| 78 | //
|
|---|
| 79 | // define few Elements
|
|---|
| 80 | //
|
|---|
| 81 | G4double a, z;
|
|---|
| 82 |
|
|---|
| 83 | G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
|
|---|
| 84 | G4Element* N = new G4Element("Nitrogen", "N", z= 7., a= 14.01*g/mole);
|
|---|
| 85 | G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
|
|---|
| 86 | G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
|
|---|
| 87 | G4Element* W = new G4Element("Tungsten", "W", z=74., a= 183.84*g/mole);
|
|---|
| 88 | G4Element* Pb = new G4Element("Lead", "Pb",z=82., a= 207.19*g/mole);
|
|---|
| 89 | G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
|
|---|
| 90 |
|
|---|
| 91 | //
|
|---|
| 92 | // define materials
|
|---|
| 93 | //
|
|---|
| 94 | G4double density;
|
|---|
| 95 | G4double fractionmass; G4int ncomponents, natoms;
|
|---|
| 96 |
|
|---|
| 97 | G4Material* Air =
|
|---|
| 98 | new G4Material("Air", density= 1.29*mg/cm3, ncomponents=2);
|
|---|
| 99 | Air->AddElement(N, fractionmass=0.7);
|
|---|
| 100 | Air->AddElement(O, fractionmass=0.3);
|
|---|
| 101 |
|
|---|
| 102 | G4Material* H2O =
|
|---|
| 103 | new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
|
|---|
| 104 | H2O->AddElement(H, natoms=2);
|
|---|
| 105 | H2O->AddElement(O, natoms=1);
|
|---|
| 106 | H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV);
|
|---|
| 107 |
|
|---|
| 108 | new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
|
|---|
| 109 |
|
|---|
| 110 | new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
|
|---|
| 111 |
|
|---|
| 112 | new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
|
|---|
| 113 |
|
|---|
| 114 | new G4Material("Copper" , z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
|
|---|
| 115 |
|
|---|
| 116 | new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
|
|---|
| 117 |
|
|---|
| 118 | new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
|
|---|
| 119 |
|
|---|
| 120 | G4Material* BGO =
|
|---|
| 121 | new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
|
|---|
| 122 | BGO->AddElement(O , natoms=12);
|
|---|
| 123 | BGO->AddElement(Ge, natoms= 3);
|
|---|
| 124 | BGO->AddElement(Bi, natoms= 4);
|
|---|
| 125 |
|
|---|
| 126 | G4Material* PbWO =
|
|---|
| 127 | new G4Material("PbWO4", density= 8.28*g/cm3, ncomponents=3);
|
|---|
| 128 | PbWO->AddElement(O , natoms=4);
|
|---|
| 129 | PbWO->AddElement(Pb, natoms=1);
|
|---|
| 130 | PbWO->AddElement(W , natoms=1);
|
|---|
| 131 |
|
|---|
| 132 | G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 136 |
|
|---|
| 137 | G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
|
|---|
| 138 | {
|
|---|
| 139 | G4double Radl = myMaterial->GetRadlen();
|
|---|
| 140 |
|
|---|
| 141 | dLlength = dLradl*Radl; dRlength = dRradl*Radl;
|
|---|
| 142 | EcalLength = nLtot*dLlength; EcalRadius = nRtot*dRlength;
|
|---|
| 143 |
|
|---|
| 144 | // Cleanup old geometry
|
|---|
| 145 | G4GeometryManager::GetInstance()->OpenGeometry();
|
|---|
| 146 | G4PhysicalVolumeStore::GetInstance()->Clean();
|
|---|
| 147 | G4LogicalVolumeStore::GetInstance()->Clean();
|
|---|
| 148 | G4SolidStore::GetInstance()->Clean();
|
|---|
| 149 |
|
|---|
| 150 | //
|
|---|
| 151 | // Ecal
|
|---|
| 152 | //
|
|---|
| 153 | solidEcal = new G4Tubs("Ecal",0.,EcalRadius,0.5*EcalLength,0.,360*deg);
|
|---|
| 154 | logicEcal = new G4LogicalVolume( solidEcal,myMaterial,"Ecal",0,0,0);
|
|---|
| 155 | physiEcal = new G4PVPlacement(0,G4ThreeVector(),
|
|---|
| 156 | logicEcal,"Ecal",0,false,0);
|
|---|
| 157 |
|
|---|
| 158 | G4cout << "Absorber is " << G4BestUnit(EcalLength,"Length")
|
|---|
| 159 | << " of " << myMaterial->GetName() << G4endl;
|
|---|
| 160 | G4cout << myMaterial << G4endl;
|
|---|
| 161 |
|
|---|
| 162 | //
|
|---|
| 163 | //always return the physical World
|
|---|
| 164 | //
|
|---|
| 165 | return physiEcal;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 169 |
|
|---|
| 170 | void DetectorConstruction::SetMaterial(const G4String& materialChoice)
|
|---|
| 171 | {
|
|---|
| 172 | // search the material by its name
|
|---|
| 173 | G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
|
|---|
| 174 | if (pttoMaterial) myMaterial = pttoMaterial;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 178 |
|
|---|
| 179 | void DetectorConstruction::SetLBining(G4ThreeVector Value)
|
|---|
| 180 | {
|
|---|
| 181 | nLtot = (G4int)Value(0);
|
|---|
| 182 | if (nLtot > MaxBin) {
|
|---|
| 183 | G4cout << "\n ---> warning from SetLBining: "
|
|---|
| 184 | << nLtot << " truncated to " << MaxBin << G4endl;
|
|---|
| 185 | nLtot = MaxBin;
|
|---|
| 186 | }
|
|---|
| 187 | dLradl = Value(1);
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 191 |
|
|---|
| 192 | void DetectorConstruction::SetRBining(G4ThreeVector Value)
|
|---|
| 193 | {
|
|---|
| 194 | nRtot = (G4int)Value(0);
|
|---|
| 195 | if (nRtot > MaxBin) {
|
|---|
| 196 | G4cout << "\n ---> warning from SetRBining: "
|
|---|
| 197 | << nRtot << " truncated to " << MaxBin << G4endl;
|
|---|
| 198 | nRtot = MaxBin;
|
|---|
| 199 | }
|
|---|
| 200 | dRradl = Value(1);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 204 |
|
|---|
| 205 | #include "G4FieldManager.hh"
|
|---|
| 206 | #include "G4TransportationManager.hh"
|
|---|
| 207 |
|
|---|
| 208 | void DetectorConstruction::SetMagField(G4double fieldValue)
|
|---|
| 209 | {
|
|---|
| 210 | //apply a global uniform magnetic field along Z axis
|
|---|
| 211 | G4FieldManager* fieldMgr
|
|---|
| 212 | = G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
|---|
| 213 |
|
|---|
| 214 | if(magField) delete magField; //delete the existing magn field
|
|---|
| 215 |
|
|---|
| 216 | if(fieldValue!=0.) // create a new one if non nul
|
|---|
| 217 | { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
|
|---|
| 218 | fieldMgr->SetDetectorField(magField);
|
|---|
| 219 | fieldMgr->CreateChordFinder(magField);
|
|---|
| 220 | } else {
|
|---|
| 221 | magField = 0;
|
|---|
| 222 | fieldMgr->SetDetectorField(magField);
|
|---|
| 223 | }
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 227 |
|
|---|
| 228 | #include "G4RunManager.hh"
|
|---|
| 229 |
|
|---|
| 230 | void DetectorConstruction::UpdateGeometry()
|
|---|
| 231 | {
|
|---|
| 232 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|