[1316] | 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: TEx01DetectorConstruction.cc,v 1.2 2006/06/29 18:51:28 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
| 29 | // |
---|
| 30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 32 | |
---|
| 33 | #include "TEx01DetectorConstruction.hh" |
---|
| 34 | |
---|
| 35 | #include "G4Material.hh" |
---|
| 36 | #include "G4Box.hh" |
---|
| 37 | #include "G4LogicalVolume.hh" |
---|
| 38 | #include "G4PVPlacement.hh" |
---|
| 39 | #include "G4PVParameterised.hh" |
---|
| 40 | #include "G4SDManager.hh" |
---|
| 41 | |
---|
| 42 | #include "G4UserLimits.hh" |
---|
| 43 | |
---|
| 44 | #include "G4VisAttributes.hh" |
---|
| 45 | #include "G4Colour.hh" |
---|
| 46 | |
---|
| 47 | #include "G4ios.hh" |
---|
| 48 | |
---|
| 49 | #include "G4TriangularFacet.hh" |
---|
| 50 | #include "G4QuadrangularFacet.hh" |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 54 | |
---|
| 55 | TEx01DetectorConstruction::TEx01DetectorConstruction() |
---|
| 56 | :solidWorld(0), logicWorld(0), physiWorld(0), |
---|
| 57 | solidTarget(0), logicTarget(0), physiTarget(0) |
---|
| 58 | {;} |
---|
| 59 | |
---|
| 60 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 61 | |
---|
| 62 | TEx01DetectorConstruction::~TEx01DetectorConstruction() |
---|
| 63 | {;} |
---|
| 64 | |
---|
| 65 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 66 | |
---|
| 67 | G4VPhysicalVolume* TEx01DetectorConstruction::Construct() |
---|
| 68 | { |
---|
| 69 | //--------- Material definition --------- |
---|
| 70 | |
---|
| 71 | G4double a, z; |
---|
| 72 | G4double density; |
---|
| 73 | G4int nel; |
---|
| 74 | |
---|
| 75 | //Air |
---|
| 76 | G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole); |
---|
| 77 | G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole); |
---|
| 78 | |
---|
| 79 | G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2); |
---|
| 80 | Air->AddElement(N, 70*perCent); |
---|
| 81 | Air->AddElement(O, 30*perCent); |
---|
| 82 | |
---|
| 83 | //Lead |
---|
| 84 | G4Material* Pb = |
---|
| 85 | new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3); |
---|
| 86 | |
---|
| 87 | // Print all the materials defined. |
---|
| 88 | // |
---|
| 89 | G4cout << G4endl << "The materials defined are : " << G4endl << G4endl; |
---|
| 90 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; |
---|
| 91 | |
---|
| 92 | //--------- Sizes of the principal geometrical components (solids) --------- |
---|
| 93 | |
---|
| 94 | fTargetLength = 10.0 * cm; // Full length of Target |
---|
| 95 | |
---|
| 96 | fWorldLength= 1.2 *(fTargetLength*2.0); |
---|
| 97 | |
---|
| 98 | G4double targetSize = 0.5*fTargetLength; // Half length of the Target |
---|
| 99 | |
---|
| 100 | //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- |
---|
| 101 | |
---|
| 102 | //------------------------------ |
---|
| 103 | // World |
---|
| 104 | //------------------------------ |
---|
| 105 | |
---|
| 106 | G4double HalfWorldLength = 0.5*fWorldLength; |
---|
| 107 | |
---|
| 108 | solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength); |
---|
| 109 | logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0); |
---|
| 110 | |
---|
| 111 | // Must place the World Physical volume unrotated at (0,0,0). |
---|
| 112 | // |
---|
| 113 | physiWorld = new G4PVPlacement(0, // no rotation |
---|
| 114 | G4ThreeVector(), // at (0,0,0) |
---|
| 115 | logicWorld, // its logical volume |
---|
| 116 | "World", // its name |
---|
| 117 | 0, // its mother volume |
---|
| 118 | false, // no boolean operations |
---|
| 119 | 0); // no field specific to volume |
---|
| 120 | |
---|
| 121 | //------------------------------ |
---|
| 122 | // Target |
---|
| 123 | //------------------------------ |
---|
| 124 | |
---|
| 125 | G4ThreeVector positionTarget = G4ThreeVector(0.0,0.0,0.0); |
---|
| 126 | |
---|
| 127 | //solidTarget = new G4Box("target",targetSize,targetSize,targetSize); |
---|
| 128 | |
---|
| 129 | solidTarget = new G4TessellatedSolid("target"); |
---|
| 130 | G4TriangularFacet *facet1 = new |
---|
| 131 | G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
| 132 | G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
| 133 | G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
| 134 | ABSOLUTE); |
---|
| 135 | G4TriangularFacet *facet2 = new |
---|
| 136 | G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
| 137 | G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
| 138 | G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
| 139 | ABSOLUTE); |
---|
| 140 | G4TriangularFacet *facet3 = new |
---|
| 141 | G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
| 142 | G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
| 143 | G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
| 144 | ABSOLUTE); |
---|
| 145 | G4TriangularFacet *facet4 = new |
---|
| 146 | G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
| 147 | G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
| 148 | G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
| 149 | ABSOLUTE); |
---|
| 150 | G4QuadrangularFacet *facet5 = new |
---|
| 151 | G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
| 152 | G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
| 153 | G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
| 154 | G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
| 155 | ABSOLUTE); |
---|
| 156 | |
---|
| 157 | solidTarget->AddFacet((G4VFacet*) facet1); |
---|
| 158 | solidTarget->AddFacet((G4VFacet*) facet2); |
---|
| 159 | solidTarget->AddFacet((G4VFacet*) facet3); |
---|
| 160 | solidTarget->AddFacet((G4VFacet*) facet4); |
---|
| 161 | solidTarget->AddFacet((G4VFacet*) facet5); |
---|
| 162 | |
---|
| 163 | solidTarget->SetSolidClosed(true); |
---|
| 164 | logicTarget = new G4LogicalVolume(solidTarget,Pb,"Target",0,0,0); |
---|
| 165 | physiTarget = new G4PVPlacement(0, // no rotation |
---|
| 166 | positionTarget, // at (x,y,z) |
---|
| 167 | logicTarget, // its logical volume |
---|
| 168 | "Target", // its name |
---|
| 169 | logicWorld, // its mother volume |
---|
| 170 | false, // no boolean operations |
---|
| 171 | 0); // no particular field |
---|
| 172 | |
---|
| 173 | //--------- Visualization attributes ------------------------------- |
---|
| 174 | |
---|
| 175 | G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); |
---|
| 176 | BoxVisAtt->SetVisibility(false); |
---|
| 177 | G4VisAttributes* FacetVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); |
---|
| 178 | FacetVisAtt->SetVisibility(true); |
---|
| 179 | |
---|
| 180 | logicWorld ->SetVisAttributes(BoxVisAtt); |
---|
| 181 | logicTarget ->SetVisAttributes(FacetVisAtt); |
---|
| 182 | |
---|
| 183 | //--------- example of User Limits ------------------------------- |
---|
| 184 | |
---|
| 185 | // below is an example of how to set tracking constraints in a given |
---|
| 186 | // logical volume(see also in N02PhysicsList how to setup the process |
---|
| 187 | // G4UserSpecialCuts). |
---|
| 188 | // Sets a max Step length in the tracker region |
---|
| 189 | // G4double maxStep = 0.5*ChamberWidth, maxLength = 2*fTrackerLength; |
---|
| 190 | // G4double maxTime = 0.1*ns, minEkin = 10*MeV; |
---|
| 191 | // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime, |
---|
| 192 | // minEkin)); |
---|
| 193 | |
---|
| 194 | return physiWorld; |
---|
| 195 | } |
---|
| 196 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|