| 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.9 2006/06/29 17:02:59 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | /////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | //
|
|---|
| 33 | // TestEm9: Crystal calorimeter
|
|---|
| 34 | //
|
|---|
| 35 | // Created: 31.01.03 V.Ivanchenko
|
|---|
| 36 | //
|
|---|
| 37 | // Modified:
|
|---|
| 38 | //
|
|---|
| 39 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 40 | //
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 44 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 45 |
|
|---|
| 46 | #include "DetectorConstruction.hh"
|
|---|
| 47 | #include "DetectorMessenger.hh"
|
|---|
| 48 |
|
|---|
| 49 | #include "G4Box.hh"
|
|---|
| 50 | #include "G4LogicalVolume.hh"
|
|---|
| 51 | #include "G4PVPlacement.hh"
|
|---|
| 52 | #include "G4PVReplica.hh"
|
|---|
| 53 |
|
|---|
| 54 | #include "G4TransportationManager.hh"
|
|---|
| 55 |
|
|---|
| 56 | #include "G4GeometryManager.hh"
|
|---|
| 57 | #include "G4RunManager.hh"
|
|---|
| 58 | #include "G4Region.hh"
|
|---|
| 59 | #include "G4RegionStore.hh"
|
|---|
| 60 | #include "G4PhysicalVolumeStore.hh"
|
|---|
| 61 | #include "G4LogicalVolumeStore.hh"
|
|---|
| 62 | #include "G4SolidStore.hh"
|
|---|
| 63 | #include "G4NistManager.hh"
|
|---|
| 64 |
|
|---|
| 65 | #include "G4VisAttributes.hh"
|
|---|
| 66 | #include "G4Colour.hh"
|
|---|
| 67 |
|
|---|
| 68 | #include "G4UnitsTable.hh"
|
|---|
| 69 | #include "G4ios.hh"
|
|---|
| 70 |
|
|---|
| 71 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 72 |
|
|---|
| 73 | DetectorConstruction::DetectorConstruction()
|
|---|
| 74 | :logicC(0),logicA1(0),logicA2(0)
|
|---|
| 75 | {
|
|---|
| 76 | detectorMessenger = new DetectorMessenger(this);
|
|---|
| 77 |
|
|---|
| 78 | ecalLength = 36.*cm;
|
|---|
| 79 | ecalWidth = 6.*cm;
|
|---|
| 80 | vertexLength = 3.*cm;
|
|---|
| 81 | padLength = 0.1*mm;
|
|---|
| 82 | padWidth = 0.02*mm;
|
|---|
| 83 | absLength = 2.*mm;
|
|---|
| 84 | vertexRegion = 0;
|
|---|
| 85 | muonRegion = 0;
|
|---|
| 86 | DefineMaterials();
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 90 |
|
|---|
| 91 | DetectorConstruction::~DetectorConstruction()
|
|---|
| 92 | { delete detectorMessenger;}
|
|---|
| 93 |
|
|---|
| 94 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 95 |
|
|---|
| 96 | G4VPhysicalVolume* DetectorConstruction::Construct()
|
|---|
| 97 | {
|
|---|
| 98 | return ConstructVolumes();
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 102 |
|
|---|
| 103 | void DetectorConstruction::DefineMaterials()
|
|---|
| 104 | {
|
|---|
| 105 | // Default materials
|
|---|
| 106 |
|
|---|
| 107 | G4NistManager* man = G4NistManager::Instance();
|
|---|
| 108 | man->SetVerbose(1);
|
|---|
| 109 | worldMaterial = man->FindOrBuildMaterial("G4_AIR");
|
|---|
| 110 | absMaterial = man->FindOrBuildMaterial("G4_Al");
|
|---|
| 111 | vertMaterial = man->FindOrBuildMaterial("G4_Si");
|
|---|
| 112 | yorkMaterial = man->FindOrBuildMaterial("G4_Fe");
|
|---|
| 113 | calMaterial = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 117 |
|
|---|
| 118 | G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
|
|---|
| 119 | {
|
|---|
| 120 | G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
|---|
| 121 |
|
|---|
| 122 | // Cleanup old geometry
|
|---|
| 123 |
|
|---|
| 124 | G4GeometryManager::GetInstance()->OpenGeometry();
|
|---|
| 125 | G4PhysicalVolumeStore::GetInstance()->Clean();
|
|---|
| 126 | G4LogicalVolumeStore::GetInstance()->Clean();
|
|---|
| 127 | G4SolidStore::GetInstance()->Clean();
|
|---|
| 128 |
|
|---|
| 129 | if(vertexRegion) delete vertexRegion;
|
|---|
| 130 | if(muonRegion) delete muonRegion;
|
|---|
| 131 | vertexRegion = new G4Region("VertexDetector");
|
|---|
| 132 | muonRegion = new G4Region("MuonDetector");
|
|---|
| 133 |
|
|---|
| 134 | if(vertexLength < padLength*5.0) vertexLength = padLength*5.0;
|
|---|
| 135 | G4double gap = 0.01*mm;
|
|---|
| 136 | G4double biggap = 2.*cm;
|
|---|
| 137 | G4double york = 10.*cm;
|
|---|
| 138 |
|
|---|
| 139 | worldZ = 2.*vertexLength + 3.*absLength + 0.5*(ecalLength + york) + biggap*2.;
|
|---|
| 140 | G4double worldX = ecalWidth*3.0;
|
|---|
| 141 | G4double vertexZ= -worldZ + vertexLength*2.0 + absLength + biggap;
|
|---|
| 142 | G4double absZ2 = -worldZ + vertexLength*4.0 + absLength*3.5 + biggap;
|
|---|
| 143 | G4double ecalZ = -worldZ + vertexLength*4.0 + absLength*4.0 + ecalLength*0.5 + 2.*biggap;
|
|---|
| 144 | G4double yorkZ = -worldZ + vertexLength*4.0 + absLength*5.0 + ecalLength
|
|---|
| 145 | + york*0.5 + 3.*biggap;
|
|---|
| 146 |
|
|---|
| 147 | //
|
|---|
| 148 | // World
|
|---|
| 149 | //
|
|---|
| 150 | G4Box* solidW = new G4Box("World",worldX,worldX,worldZ);
|
|---|
| 151 | G4LogicalVolume* logicW = new G4LogicalVolume( solidW,worldMaterial,
|
|---|
| 152 | "World");
|
|---|
| 153 | G4VPhysicalVolume* world = new G4PVPlacement(0,G4ThreeVector(),
|
|---|
| 154 | "World",logicW,0,false,0);
|
|---|
| 155 |
|
|---|
| 156 | //
|
|---|
| 157 | // Ecal
|
|---|
| 158 | //
|
|---|
| 159 | G4Box* solidE = new G4Box("VolE",worldX,worldX,ecalLength*0.5 + gap);
|
|---|
| 160 | G4LogicalVolume* logicE = new G4LogicalVolume( solidE,worldMaterial,
|
|---|
| 161 | "VolE");
|
|---|
| 162 | G4VPhysicalVolume* physE = new G4PVPlacement(0,G4ThreeVector(0.,0.,ecalZ),
|
|---|
| 163 | "VolE",logicE,world,false,0);
|
|---|
| 164 |
|
|---|
| 165 | G4Box* solidC = new G4Box("Ecal",ecalWidth*0.5,ecalWidth*0.5,ecalLength*0.5);
|
|---|
| 166 | logicC = new G4LogicalVolume( solidC,calMaterial,"Ecal");
|
|---|
| 167 |
|
|---|
| 168 | G4cout << "Ecal is " << G4BestUnit(ecalLength,"Length")
|
|---|
| 169 | << " of " << calMaterial->GetName() << G4endl;
|
|---|
| 170 |
|
|---|
| 171 | // Crystals
|
|---|
| 172 |
|
|---|
| 173 | G4double x0 = -(ecalWidth + gap)*2.0;
|
|---|
| 174 | G4double y = x0;
|
|---|
| 175 | G4double x;
|
|---|
| 176 | G4int k = 0;
|
|---|
| 177 | G4VPhysicalVolume* pv;
|
|---|
| 178 | G4int i,j;
|
|---|
| 179 |
|
|---|
| 180 | for (i=0; i<5; i++) {
|
|---|
| 181 | x = x0;
|
|---|
| 182 | for (j=0; j<5; j++) {
|
|---|
| 183 |
|
|---|
| 184 | pv = new G4PVPlacement(0,G4ThreeVector(x,y,0.),"Ecal",logicC,
|
|---|
| 185 | physE,false,k);
|
|---|
| 186 | k++;
|
|---|
| 187 | x += ecalWidth + gap;
|
|---|
| 188 | }
|
|---|
| 189 | y += ecalWidth + gap;
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | //Absorber
|
|---|
| 193 |
|
|---|
| 194 | G4Box* solidA = new G4Box("Abso",worldX,worldX,absLength*0.5);
|
|---|
| 195 | logicA2 = new G4LogicalVolume( solidA,absMaterial,"Abs2");
|
|---|
| 196 | pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,absZ2),
|
|---|
| 197 | "Abs2",logicA2,world,false,0);
|
|---|
| 198 |
|
|---|
| 199 | G4cout << "Absorber is " << G4BestUnit(absLength,"Length")
|
|---|
| 200 | << " of " << absMaterial->GetName() << G4endl;
|
|---|
| 201 |
|
|---|
| 202 | //York
|
|---|
| 203 |
|
|---|
| 204 | G4Box* solidYV = new G4Box("VolY",worldX,worldX,york*0.5+absLength);
|
|---|
| 205 | G4LogicalVolume* logicYV = new G4LogicalVolume( solidYV,yorkMaterial,"VolY");
|
|---|
| 206 | G4VPhysicalVolume* physYV = new G4PVPlacement(0,G4ThreeVector(0.,0.,yorkZ),
|
|---|
| 207 | "VolY",logicYV,world,false,0);
|
|---|
| 208 |
|
|---|
| 209 | G4Box* solidY = new G4Box("York",worldX,worldX,york*0.5);
|
|---|
| 210 | G4LogicalVolume* logicY = new G4LogicalVolume( solidY,yorkMaterial,"York");
|
|---|
| 211 | pv = new G4PVPlacement(0,G4ThreeVector(),
|
|---|
| 212 | "York",logicY,physYV,false,0);
|
|---|
| 213 |
|
|---|
| 214 | logicA3 = new G4LogicalVolume( solidA,absMaterial,"Abs3");
|
|---|
| 215 | logicA4 = new G4LogicalVolume( solidA,absMaterial,"Abs4");
|
|---|
| 216 | pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,-(york+absLength)*0.5),
|
|---|
| 217 | "Abs3",logicA3,physYV,false,0);
|
|---|
| 218 | pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,(york+absLength)*0.5),
|
|---|
| 219 | "Abs4",logicA4,physYV,false,0);
|
|---|
| 220 |
|
|---|
| 221 | //Vertex volume
|
|---|
| 222 |
|
|---|
| 223 | G4Box* solidVV = new G4Box("VolV",worldX,worldX,vertexLength*2.+absLength+gap);
|
|---|
| 224 | G4LogicalVolume* logicVV = new G4LogicalVolume( solidVV,worldMaterial,"VolV");
|
|---|
| 225 | G4VPhysicalVolume* physVV = new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexZ),
|
|---|
| 226 | "VolV",logicVV,world,false,0);
|
|---|
| 227 |
|
|---|
| 228 | //Absorber
|
|---|
| 229 |
|
|---|
| 230 | logicA1 = new G4LogicalVolume( solidA,absMaterial,"Abs1");
|
|---|
| 231 | pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexLength*2.-absLength*0.5),
|
|---|
| 232 | "Abs1",logicA1,physVV,false,0);
|
|---|
| 233 |
|
|---|
| 234 | //Vertex
|
|---|
| 235 |
|
|---|
| 236 | G4double vertWidth = ecalWidth/5.;
|
|---|
| 237 | G4int npads = (G4int)(vertWidth/padWidth);
|
|---|
| 238 | npads = (npads/2)*2 + 1;
|
|---|
| 239 | x0 = -0.5*padWidth*((G4double)(npads-1));
|
|---|
| 240 | G4double x1 = std::fabs(x0) + 0.5*padWidth + gap;
|
|---|
| 241 | G4double z = -(vertexLength+absLength);
|
|---|
| 242 |
|
|---|
| 243 | G4Box* solidVD = new G4Box("VertDet",x1,ecalWidth*0.5+gap,padLength*0.5);
|
|---|
| 244 | G4LogicalVolume* logicVD = new G4LogicalVolume( solidVD,vertMaterial,"VertDet");
|
|---|
| 245 |
|
|---|
| 246 | G4Box* solidV = new G4Box("Vert",padWidth*0.5,ecalWidth*0.5,padLength*0.5);
|
|---|
| 247 | G4LogicalVolume* logicV = new G4LogicalVolume( solidV,vertMaterial,"Vert");
|
|---|
| 248 |
|
|---|
| 249 | for (i=0; i<3; i++) {
|
|---|
| 250 | pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,z),"VertDet",logicVD,
|
|---|
| 251 | physVV,false,i);
|
|---|
| 252 | z += vertexLength;
|
|---|
| 253 | }
|
|---|
| 254 | x = x0;
|
|---|
| 255 |
|
|---|
| 256 | for (j=0; j<npads; j++) {
|
|---|
| 257 |
|
|---|
| 258 | pv = new G4PVPlacement(0,G4ThreeVector(x,0.,0.),logicV,"Vert",logicVD,
|
|---|
| 259 | false,k);
|
|---|
| 260 | x += padWidth;
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | G4cout << "Vertex is " << G4BestUnit(vertexLength,"Length")
|
|---|
| 264 | << " of 3 layers of Si of " << G4BestUnit(padLength,"Length")
|
|---|
| 265 | << " npads= " << npads
|
|---|
| 266 | << G4endl;
|
|---|
| 267 |
|
|---|
| 268 | // Define region for the vertex detector
|
|---|
| 269 |
|
|---|
| 270 | vertexRegion->AddRootLogicalVolume(logicVV);
|
|---|
| 271 | vertexRegion->AddRootLogicalVolume(logicA3);
|
|---|
| 272 |
|
|---|
| 273 | // Define region for the muon detector
|
|---|
| 274 |
|
|---|
| 275 | muonRegion->AddRootLogicalVolume(logicYV);
|
|---|
| 276 |
|
|---|
| 277 | // color regions
|
|---|
| 278 |
|
|---|
| 279 | logicVV-> SetVisAttributes(G4VisAttributes::Invisible);
|
|---|
| 280 | logicV-> SetVisAttributes(G4VisAttributes::Invisible);
|
|---|
| 281 | logicE-> SetVisAttributes(G4VisAttributes::Invisible);
|
|---|
| 282 | logicYV-> SetVisAttributes(G4VisAttributes::Invisible);
|
|---|
| 283 |
|
|---|
| 284 | G4VisAttributes* regWcolor = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
|
|---|
| 285 | logicW->SetVisAttributes(regWcolor);
|
|---|
| 286 |
|
|---|
| 287 | G4VisAttributes* regVcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
|
|---|
| 288 | logicVD->SetVisAttributes(regVcolor);
|
|---|
| 289 |
|
|---|
| 290 | G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.7, 0.3));
|
|---|
| 291 | logicC->SetVisAttributes(regCcolor);
|
|---|
| 292 |
|
|---|
| 293 | G4VisAttributes* regAcolor = new G4VisAttributes(G4Colour(1., 0.5, 0.5));
|
|---|
| 294 | logicA1->SetVisAttributes(regAcolor);
|
|---|
| 295 | logicA2->SetVisAttributes(regAcolor);
|
|---|
| 296 | logicA3->SetVisAttributes(regAcolor);
|
|---|
| 297 | logicA4->SetVisAttributes(regAcolor);
|
|---|
| 298 |
|
|---|
| 299 | G4VisAttributes* regMcolor = new G4VisAttributes(G4Colour(1., 1., 0.));
|
|---|
| 300 | logicY->SetVisAttributes(regMcolor);
|
|---|
| 301 |
|
|---|
| 302 | // always return world
|
|---|
| 303 | G4cout << "### New geometry is constructed" << G4endl;
|
|---|
| 304 |
|
|---|
| 305 | return world;
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 309 |
|
|---|
| 310 | void DetectorConstruction::SetEcalMaterial(const G4String& mat)
|
|---|
| 311 | {
|
|---|
| 312 | // search the material by its name
|
|---|
| 313 | G4Material* pttoMaterial =
|
|---|
| 314 | G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
|
|---|
| 315 | if (pttoMaterial) calMaterial = pttoMaterial;
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 319 |
|
|---|
| 320 | void DetectorConstruction::SetAbsMaterial(const G4String& mat)
|
|---|
| 321 | {
|
|---|
| 322 | // search the material by its name
|
|---|
| 323 | G4Material* pttoMaterial =
|
|---|
| 324 | G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
|
|---|
| 325 | if (pttoMaterial) absMaterial = pttoMaterial;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 329 |
|
|---|
| 330 | void DetectorConstruction::UpdateGeometry()
|
|---|
| 331 | {
|
|---|
| 332 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|