| [807] | 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: ExN02DetectorConstruction.cc,v 1.20 2007/10/17 08:50:35 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 32 |
|
|---|
| 33 | #include "ExN02DetectorConstruction.hh"
|
|---|
| 34 | #include "ExN02DetectorMessenger.hh"
|
|---|
| 35 | #include "ExN02ChamberParameterisation.hh"
|
|---|
| 36 | #include "ExN02MagneticField.hh"
|
|---|
| 37 | #include "ExN02TrackerSD.hh"
|
|---|
| 38 |
|
|---|
| 39 | #include "G4Material.hh"
|
|---|
| 40 | #include "G4Box.hh"
|
|---|
| 41 | #include "G4LogicalVolume.hh"
|
|---|
| 42 | #include "G4PVPlacement.hh"
|
|---|
| 43 | #include "G4PVParameterised.hh"
|
|---|
| 44 | #include "G4SDManager.hh"
|
|---|
| 45 | #include "G4GeometryTolerance.hh"
|
|---|
| 46 | #include "G4GeometryManager.hh"
|
|---|
| 47 |
|
|---|
| 48 | #include "G4UserLimits.hh"
|
|---|
| 49 |
|
|---|
| 50 | #include "G4VisAttributes.hh"
|
|---|
| 51 | #include "G4Colour.hh"
|
|---|
| 52 |
|
|---|
| 53 | #include "G4ios.hh"
|
|---|
| 54 |
|
|---|
| 55 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 56 |
|
|---|
| 57 | ExN02DetectorConstruction::ExN02DetectorConstruction()
|
|---|
| 58 | :solidWorld(0), logicWorld(0), physiWorld(0),
|
|---|
| 59 | solidTarget(0), logicTarget(0), physiTarget(0),
|
|---|
| 60 | solidTracker(0),logicTracker(0),physiTracker(0),
|
|---|
| 61 | solidChamber(0),logicChamber(0),physiChamber(0),
|
|---|
| 62 | TargetMater(0), ChamberMater(0),chamberParam(0),
|
|---|
| 63 | stepLimit(0), fpMagField(0),
|
|---|
| 64 | fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
|
|---|
| 65 | NbOfChambers(0) , ChamberWidth(0.), ChamberSpacing(0.)
|
|---|
| 66 | {
|
|---|
| 67 | fpMagField = new ExN02MagneticField();
|
|---|
| 68 | detectorMessenger = new ExN02DetectorMessenger(this);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 72 |
|
|---|
| 73 | ExN02DetectorConstruction::~ExN02DetectorConstruction()
|
|---|
| 74 | {
|
|---|
| 75 | delete fpMagField;
|
|---|
| 76 | delete stepLimit;
|
|---|
| 77 | delete chamberParam;
|
|---|
| 78 | delete detectorMessenger;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 82 |
|
|---|
| 83 | G4VPhysicalVolume* ExN02DetectorConstruction::Construct()
|
|---|
| 84 | {
|
|---|
| 85 | //--------- Material definition ---------
|
|---|
| 86 |
|
|---|
| 87 | G4double a, z;
|
|---|
| 88 | G4double density, temperature, pressure;
|
|---|
| 89 | G4int nel;
|
|---|
| 90 |
|
|---|
| 91 | //Air
|
|---|
| 92 | G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
|
|---|
| 93 | G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole);
|
|---|
| 94 |
|
|---|
| 95 | G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
|
|---|
| 96 | Air->AddElement(N, 70*perCent);
|
|---|
| 97 | Air->AddElement(O, 30*perCent);
|
|---|
| 98 |
|
|---|
| 99 | //Lead
|
|---|
| 100 | G4Material* Pb =
|
|---|
| 101 | new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
|
|---|
| 102 |
|
|---|
| 103 | //Xenon gas
|
|---|
| 104 | G4Material* Xenon =
|
|---|
| 105 | new G4Material("XenonGas", z=54., a=131.29*g/mole, density= 5.458*mg/cm3,
|
|---|
| 106 | kStateGas, temperature= 293.15*kelvin, pressure= 1*atmosphere);
|
|---|
| 107 |
|
|---|
| 108 | // Print all the materials defined.
|
|---|
| 109 | //
|
|---|
| 110 | G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
|
|---|
| 111 | G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
|---|
| 112 |
|
|---|
| 113 | //--------- Sizes of the principal geometrical components (solids) ---------
|
|---|
| 114 |
|
|---|
| 115 | NbOfChambers = 5;
|
|---|
| 116 | ChamberWidth = 20*cm;
|
|---|
| 117 | ChamberSpacing = 80*cm;
|
|---|
| 118 |
|
|---|
| 119 | fTrackerLength = (NbOfChambers+1)*ChamberSpacing; // Full length of Tracker
|
|---|
| 120 | fTargetLength = 5.0 * cm; // Full length of Target
|
|---|
| 121 |
|
|---|
| 122 | TargetMater = Pb;
|
|---|
| 123 | ChamberMater = Xenon;
|
|---|
| 124 |
|
|---|
| 125 | fWorldLength= 1.2 *(fTargetLength+fTrackerLength);
|
|---|
| 126 |
|
|---|
| 127 | G4double targetSize = 0.5*fTargetLength; // Half length of the Target
|
|---|
| 128 | G4double trackerSize = 0.5*fTrackerLength; // Half length of the Tracker
|
|---|
| 129 |
|
|---|
| 130 | //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
|
|---|
| 131 |
|
|---|
| 132 | //------------------------------
|
|---|
| 133 | // World
|
|---|
| 134 | //------------------------------
|
|---|
| 135 |
|
|---|
| 136 | G4double HalfWorldLength = 0.5*fWorldLength;
|
|---|
| 137 |
|
|---|
| 138 | G4GeometryManager::GetInstance()->SetWorldMaximumExtent(fWorldLength);
|
|---|
| 139 | G4cout << "Computed tolerance = "
|
|---|
| 140 | << G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()/mm
|
|---|
| 141 | << " mm" << G4endl;
|
|---|
| 142 |
|
|---|
| 143 | solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
|
|---|
| 144 | logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
|
|---|
| 145 |
|
|---|
| 146 | // Must place the World Physical volume unrotated at (0,0,0).
|
|---|
| 147 | //
|
|---|
| 148 | physiWorld = new G4PVPlacement(0, // no rotation
|
|---|
| 149 | G4ThreeVector(), // at (0,0,0)
|
|---|
| 150 | logicWorld, // its logical volume
|
|---|
| 151 | "World", // its name
|
|---|
| 152 | 0, // its mother volume
|
|---|
| 153 | false, // no boolean operations
|
|---|
| 154 | 0); // copy number
|
|---|
| 155 |
|
|---|
| 156 | //------------------------------
|
|---|
| 157 | // Target
|
|---|
| 158 | //------------------------------
|
|---|
| 159 |
|
|---|
| 160 | G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetSize+trackerSize));
|
|---|
| 161 |
|
|---|
| 162 | solidTarget = new G4Box("target",targetSize,targetSize,targetSize);
|
|---|
| 163 | logicTarget = new G4LogicalVolume(solidTarget,TargetMater,"Target",0,0,0);
|
|---|
| 164 | physiTarget = new G4PVPlacement(0, // no rotation
|
|---|
| 165 | positionTarget, // at (x,y,z)
|
|---|
| 166 | logicTarget, // its logical volume
|
|---|
| 167 | "Target", // its name
|
|---|
| 168 | logicWorld, // its mother volume
|
|---|
| 169 | false, // no boolean operations
|
|---|
| 170 | 0); // copy number
|
|---|
| 171 |
|
|---|
| 172 | G4cout << "Target is " << fTargetLength/cm << " cm of "
|
|---|
| 173 | << TargetMater->GetName() << G4endl;
|
|---|
| 174 |
|
|---|
| 175 | //------------------------------
|
|---|
| 176 | // Tracker
|
|---|
| 177 | //------------------------------
|
|---|
| 178 |
|
|---|
| 179 | G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
|
|---|
| 180 |
|
|---|
| 181 | solidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
|
|---|
| 182 | logicTracker = new G4LogicalVolume(solidTracker , Air, "Tracker",0,0,0);
|
|---|
| 183 | physiTracker = new G4PVPlacement(0, // no rotation
|
|---|
| 184 | positionTracker, // at (x,y,z)
|
|---|
| 185 | logicTracker, // its logical volume
|
|---|
| 186 | "Tracker", // its name
|
|---|
| 187 | logicWorld, // its mother volume
|
|---|
| 188 | false, // no boolean operations
|
|---|
| 189 | 0); // copy number
|
|---|
| 190 |
|
|---|
| 191 | //------------------------------
|
|---|
| 192 | // Tracker segments
|
|---|
| 193 | //------------------------------
|
|---|
| 194 | //
|
|---|
| 195 | // An example of Parameterised volumes
|
|---|
| 196 | // dummy values for G4Box -- modified by parameterised volume
|
|---|
| 197 |
|
|---|
| 198 | solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
|
|---|
| 199 | logicChamber = new G4LogicalVolume(solidChamber,ChamberMater,"Chamber",0,0,0);
|
|---|
| 200 |
|
|---|
| 201 | G4double firstPosition = -trackerSize + 0.5*ChamberWidth;
|
|---|
| 202 | G4double firstLength = fTrackerLength/10;
|
|---|
| 203 | G4double lastLength = fTrackerLength;
|
|---|
| 204 |
|
|---|
| 205 | chamberParam = new ExN02ChamberParameterisation(
|
|---|
| 206 | NbOfChambers, // NoChambers
|
|---|
| 207 | firstPosition, // Z of center of first
|
|---|
| 208 | ChamberSpacing, // Z spacing of centers
|
|---|
| 209 | ChamberWidth, // Width Chamber
|
|---|
| 210 | firstLength, // lengthInitial
|
|---|
| 211 | lastLength); // lengthFinal
|
|---|
| 212 |
|
|---|
| 213 | // dummy value : kZAxis -- modified by parameterised volume
|
|---|
| 214 | //
|
|---|
| 215 | physiChamber = new G4PVParameterised(
|
|---|
| 216 | "Chamber", // their name
|
|---|
| 217 | logicChamber, // their logical volume
|
|---|
| 218 | logicTracker, // Mother logical volume
|
|---|
| 219 | kZAxis, // Are placed along this axis
|
|---|
| 220 | NbOfChambers, // Number of chambers
|
|---|
| 221 | chamberParam); // The parametrisation
|
|---|
| 222 |
|
|---|
| 223 | G4cout << "There are " << NbOfChambers << " chambers in the tracker region. "
|
|---|
| 224 | << "The chambers are " << ChamberWidth/mm << " mm of "
|
|---|
| 225 | << ChamberMater->GetName() << "\n The distance between chamber is "
|
|---|
| 226 | << ChamberSpacing/cm << " cm" << G4endl;
|
|---|
| 227 |
|
|---|
| 228 | //------------------------------------------------
|
|---|
| 229 | // Sensitive detectors
|
|---|
| 230 | //------------------------------------------------
|
|---|
| 231 |
|
|---|
| 232 | G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
|---|
| 233 |
|
|---|
| 234 | G4String trackerChamberSDname = "ExN02/TrackerChamberSD";
|
|---|
| 235 | ExN02TrackerSD* aTrackerSD = new ExN02TrackerSD( trackerChamberSDname );
|
|---|
| 236 | SDman->AddNewDetector( aTrackerSD );
|
|---|
| 237 | logicChamber->SetSensitiveDetector( aTrackerSD );
|
|---|
| 238 |
|
|---|
| 239 | //--------- Visualization attributes -------------------------------
|
|---|
| 240 |
|
|---|
| 241 | G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
|---|
| 242 | logicWorld ->SetVisAttributes(BoxVisAtt);
|
|---|
| 243 | logicTarget ->SetVisAttributes(BoxVisAtt);
|
|---|
| 244 | logicTracker->SetVisAttributes(BoxVisAtt);
|
|---|
| 245 |
|
|---|
| 246 | G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
|
|---|
| 247 | logicChamber->SetVisAttributes(ChamberVisAtt);
|
|---|
| 248 |
|
|---|
| 249 | //--------- example of User Limits -------------------------------
|
|---|
| 250 |
|
|---|
| 251 | // below is an example of how to set tracking constraints in a given
|
|---|
| 252 | // logical volume(see also in N02PhysicsList how to setup the processes
|
|---|
| 253 | // G4StepLimiter or G4UserSpecialCuts).
|
|---|
| 254 |
|
|---|
| 255 | // Sets a max Step length in the tracker region, with G4StepLimiter
|
|---|
| 256 | //
|
|---|
| 257 | G4double maxStep = 0.5*ChamberWidth;
|
|---|
| 258 | stepLimit = new G4UserLimits(maxStep);
|
|---|
| 259 | logicTracker->SetUserLimits(stepLimit);
|
|---|
| 260 |
|
|---|
| 261 | // Set additional contraints on the track, with G4UserSpecialCuts
|
|---|
| 262 | //
|
|---|
| 263 | // G4double maxLength = 2*fTrackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
|
|---|
| 264 | // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
|
|---|
| 265 | // minEkin));
|
|---|
| 266 |
|
|---|
| 267 | return physiWorld;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 271 |
|
|---|
| 272 | void ExN02DetectorConstruction::setTargetMaterial(G4String materialName)
|
|---|
| 273 | {
|
|---|
| 274 | // search the material by its name
|
|---|
| 275 | G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
|---|
| 276 | if (pttoMaterial)
|
|---|
| 277 | {TargetMater = pttoMaterial;
|
|---|
| 278 | logicTarget->SetMaterial(pttoMaterial);
|
|---|
| 279 | G4cout << "\n----> The target is " << fTargetLength/cm << " cm of "
|
|---|
| 280 | << materialName << G4endl;
|
|---|
| 281 | }
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 285 |
|
|---|
| 286 | void ExN02DetectorConstruction::setChamberMaterial(G4String materialName)
|
|---|
| 287 | {
|
|---|
| 288 | // search the material by its name
|
|---|
| 289 | G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
|---|
| 290 | if (pttoMaterial)
|
|---|
| 291 | {ChamberMater = pttoMaterial;
|
|---|
| 292 | logicChamber->SetMaterial(pttoMaterial);
|
|---|
| 293 | G4cout << "\n----> The chambers are " << ChamberWidth/cm << " cm of "
|
|---|
| 294 | << materialName << G4endl;
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 299 |
|
|---|
| 300 | void ExN02DetectorConstruction::SetMagField(G4double fieldValue)
|
|---|
| 301 | {
|
|---|
| 302 | fpMagField->SetFieldValue(fieldValue);
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|