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.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 /// \file eventgenerator/HepMC/MCTruth/src/DetectorConstruction.cc
 27 /// \brief Implementation of the DetectorConstruction class
 28 //
 29 //
 30 //
 31 //
 32 // --------------------------------------------------------------
 33 //      GEANT 4 - DetectorConstruction class
 34 // --------------------------------------------------------------
 35 //
 36 // Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
 37 //
 38 // --------------------------------------------------------------
 39 //
 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 41 
 42 #include "DetectorConstruction.hh"
 43 
 44 #include "G4Box.hh"
 45 #include "G4LogicalVolume.hh"
 46 #include "G4Material.hh"
 47 #include "G4NistManager.hh"
 48 #include "G4PVPlacement.hh"
 49 #include "G4PhysicalConstants.hh"
 50 #include "G4SystemOfUnits.hh"
 51 #include "G4ThreeVector.hh"
 52 #include "globals.hh"
 53 
 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 55 
 56 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction(), fAbsorberMaterial(0)
 57 {}
 58 
 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 60 
 61 DetectorConstruction::~DetectorConstruction() {}
 62 
 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 64 
 65 G4VPhysicalVolume* DetectorConstruction::Construct()
 66 {
 67   //------------------- materials ------------------------
 68 
 69   //--- simple materials
 70 
 71   G4NistManager* nistManager = G4NistManager::Instance();
 72 
 73   // Iron has a  X0 = 1.7585 cm  and  lambda_I = 16.760 cm.
 74   G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe");
 75 
 76   // Copper has a  X0 = 1.4353 cm  and  lambda_I = 15.056 cm.
 77   G4Material* copper = nistManager->FindOrBuildMaterial("G4_Cu");
 78 
 79   // Tungsten has a  X0 = 0.35 cm  and  lambda_I = 9.5855 cm.
 80   G4Material* tungsten = nistManager->FindOrBuildMaterial("G4_W");
 81 
 82   // Lead has a  X0 = 0.56120 cm  and  lambda_I = 17.092 cm.
 83   G4Material* lead = nistManager->FindOrBuildMaterial("G4_Pb");
 84 
 85   // Uranium has a  X0 = 0.31662 cm  and  lambda_I = 10.501 cm.
 86   G4Material* uranium = nistManager->FindOrBuildMaterial("G4_U");
 87 
 88   // Liquid Argon has a  X0 = 10.971 cm  and  lambda_I = 65.769 cm.
 89   G4double a, z, density;
 90   density = 1.4 * g / cm3;
 91   a = 39.95 * g / mole;
 92   G4Material* liquidArgon = new G4Material("LiquidArgon", z = 18., a, density);
 93 
 94   //--- mixtures
 95 
 96   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
 97 
 98   // 4-May-2006 : We rename "Vacuum" as "G4vacuum" to avoid
 99   //              problems with Flugg.
100   G4double pressure, temperature, fractionMass;
101   G4int nel;
102   density = 1.e-5 * g / cm3;
103   pressure = 2.e-2 * bar;
104   temperature = STP_Temperature;  // From PhysicalConstants.h .
105   G4Material* vacuum =
106     new G4Material("G4vacuum", density, nel = 1, kStateGas, temperature, pressure);
107   vacuum->AddMaterial(air, fractionMass = 1.);
108 
109   // Plastic scintillator tiles (used both in CMS hadron calorimeter
110   // and ATLAS hadron barrel calorimeter):
111   //     X0 = 42.4 cm  and  lambda_I = 79.360 cm.
112   G4int natoms;
113   G4Element* elH = nistManager->FindOrBuildElement("H");
114   G4Element* elC = nistManager->FindOrBuildElement("C");
115   density = 1.032 * g / cm3;
116   G4Material* polystyrene = new G4Material("Polystyrene", density, nel = 2);
117   polystyrene->AddElement(elC, natoms = 19);
118   polystyrene->AddElement(elH, natoms = 21);
119 
120   // PbWO4 CMS crystals. It has a  X0 = 0.89 cm  and  lambda_I = 22.4 cm.
121   G4Element* elPb = nistManager->FindOrBuildElement("Pb");
122   G4Element* elW = nistManager->FindOrBuildElement("W");
123   G4Element* elO = nistManager->FindOrBuildElement("O");
124   density = 8.28 * g / cm3;
125   G4Material* pbWO4 = new G4Material("PbWO4", density, nel = 3);
126   pbWO4->AddElement(elPb, natoms = 1);
127   pbWO4->AddElement(elW, natoms = 1);
128   pbWO4->AddElement(elO, natoms = 4);
129 
130   //------------------- volumes --------------------------
131 
132   // --- experimental hall (world volume)
133   //     beam line along z axis
134 
135   //***LOOKHERE***
136   const G4double sizeExpHall = 4.0 * m;  // For normal calorimeter
137   // const G4double sizeExpHall = 10.0*m;     // For Scintillator calorimeter
138 
139   G4double expHall_x = sizeExpHall / 2.0;  // half dimension along x
140   G4double expHall_y = sizeExpHall / 2.0;  // half dimension along y
141   G4double expHall_z = sizeExpHall / 2.0;  // half dimension along z
142 
143   G4Box* experimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z);
144 
145   G4LogicalVolume* experimentalHallLog = new G4LogicalVolume(experimentalHall_box,  // solid
146                                                              vacuum,  // material
147                                                              "expHall_log",  // name
148                                                              0,  // field manager
149                                                              0,  // sensitive detector
150                                                              0);  // user limits
151 
152   G4VPhysicalVolume* experimentalHallPhys =
153     new G4PVPlacement(0,  // rotation
154                       G4ThreeVector(),  // translation
155                       "expHall",  // name
156                       experimentalHallLog,  // logical volume
157                       0,  // mother physical volume
158                       false,  // boolean operation
159                       0);  // copy number
160 
161   // --- Detector
162 
163   //***LOOKHERE***
164   const G4double sizeCalo = 2.0 * m;  // For normal calorimeter
165   // const G4double sizeCalo = 8.0*m;         // For Scintillator calorimeter
166 
167   G4double xAbsorber = sizeCalo / 2.0;  // half dimension along x
168   G4double yAbsorber = sizeCalo / 2.0;  // half dimension along y
169   G4double zAbsorber = sizeCalo / 2.0;  // half dimension along z
170 
171   G4Box* solidAbsorber = new G4Box("solidAbsorber", xAbsorber, yAbsorber, zAbsorber);
172 
173   G4LogicalVolume* logicAbsorber = new G4LogicalVolume(solidAbsorber,  // solid
174                                                        fAbsorberMaterial,  // material
175                                                        "logicAbsorber",  // name
176                                                        0,  // field manager
177                                                        0,  // sensitive detector
178                                                        0);  // user limits
179 
180   new G4PVPlacement(0,  // rotation
181                     G4ThreeVector(),  // translation
182                     "physiAbsorber",  // its name
183                     logicAbsorber,  // logical volume
184                     experimentalHallPhys,  // mother physical volume
185                     false,  // boolean operation
186                     100);  // copy number
187 
188   // --- Check if all materials were built
189   if ((!iron) || (!copper) || (!tungsten) || (!lead) || (!uranium) || (!pbWO4) || (!polystyrene)
190       || (!liquidArgon))
191   {
192     G4cerr << "Failure in building materials." << G4endl;
193   }
194 
195   // --- Set default values    ***LOOKHERE***
196   fAbsorberMaterial = iron;
197   // fAbsorberMaterial = copper;
198   // fAbsorberMaterial = tungsten;
199   // fAbsorberMaterial = lead;
200   // fAbsorberMaterial = uranium;
201   // fAbsorberMaterial = pbWO4;
202   // fAbsorberMaterial = polystyrene;
203   // fAbsorberMaterial = liquidArgon;
204 
205   logicAbsorber->SetMaterial(fAbsorberMaterial);
206 
207   PrintParameters();
208 
209   return experimentalHallPhys;
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
213 
214 void DetectorConstruction::PrintParameters()
215 {
216   G4cout << G4endl << G4endl << " ------  DetectorConstruction::PrintParameters() ------ " << G4endl
217          << " Absorber Material = ";
218   if (fAbsorberMaterial) {
219     G4cout << fAbsorberMaterial->GetName();
220   }
221   else {
222     G4cout << " UNDEFINED ";
223   }
224   G4cout << G4endl << " -------------------------------------------------------- " << G4endl
225          << G4endl;
226 }
227 
228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
229