[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: G3toG4DetectorConstruction.cc,v 1.5 2006/06/29 17:20:53 gunter Exp $ |
---|
[1230] | 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[807] | 29 | // |
---|
| 30 | //-------------------------------------------------------------------------- |
---|
| 31 | // G3toG4DetectorConstruction. Most the work is Done in |
---|
| 32 | // G4BuildGeom, which returns a G4LogicalVolume*, a pointer to the |
---|
| 33 | // top-level logiical volume in the detector defined by the call List file |
---|
| 34 | // inFile |
---|
| 35 | //-------------------------------------------------------------------------- |
---|
| 36 | |
---|
| 37 | #include "G4ios.hh" |
---|
| 38 | #include "G3toG4DetectorConstruction.hh" |
---|
| 39 | #include "G4VisAttributes.hh" |
---|
| 40 | #include "G4Colour.hh" |
---|
| 41 | #include "G4Material.hh" |
---|
| 42 | #include "G4Box.hh" |
---|
| 43 | |
---|
| 44 | G3toG4DetectorConstruction::G3toG4DetectorConstruction(G4String inFile){ |
---|
| 45 | _inFile = inFile; |
---|
| 46 | G4cout << "Instantiated G3toG4DetectorConstruction using call list file \"" |
---|
| 47 | << _inFile << "\"" << G4endl; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | G3toG4DetectorConstruction::~G3toG4DetectorConstruction(){ |
---|
| 51 | // G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | G4VPhysicalVolume* |
---|
| 55 | G3toG4DetectorConstruction::Construct(){ |
---|
| 56 | _lv = G4BuildGeom(_inFile); |
---|
| 57 | //_lv = SimpleConstruct(); |
---|
| 58 | if (_lv != 0) { |
---|
| 59 | _pv = new G4PVPlacement(0, G4ThreeVector(), _lv, _lv->GetName(), 0, |
---|
| 60 | false, 0); |
---|
| 61 | G4cout << "Top-level G3toG4 logical volume " << _lv->GetName() << " " |
---|
| 62 | << *(_lv -> GetVisAttributes()) << G4endl; |
---|
| 63 | } else |
---|
| 64 | G4cerr << "creation of logical mother failed !!!" << G4endl; |
---|
| 65 | return _pv; |
---|
| 66 | } |
---|
| 67 | G4LogicalVolume* |
---|
| 68 | G3toG4DetectorConstruction::SimpleConstruct(){ |
---|
| 69 | G4String name, symbol; //a=mass of a mole; |
---|
| 70 | G4double a, z, density, fractionmass; //z=mean number of protons; |
---|
| 71 | G4int ncomponents; //iz=number of protons in an isotope; |
---|
| 72 | // n=number of nucleons in an isotope; |
---|
| 73 | |
---|
| 74 | a = 14.01*g/mole; |
---|
| 75 | G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); |
---|
| 76 | |
---|
| 77 | a = 16.00*g/mole; |
---|
| 78 | G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); |
---|
| 79 | |
---|
| 80 | // |
---|
| 81 | // define a material from elements. case 2: mixture by fractional mass |
---|
| 82 | // |
---|
| 83 | |
---|
| 84 | density = 1.290*mg/cm3; |
---|
| 85 | G4Material* Air = new G4Material(name="Air" , density, ncomponents=2); |
---|
| 86 | Air->AddElement(N, fractionmass=0.7); |
---|
| 87 | Air->AddElement(O, fractionmass=0.3); |
---|
| 88 | G4VSolid* Mother = new G4Box("TestMother", //its name |
---|
| 89 | 100*cm, 100*cm, 100*cm); //its size |
---|
| 90 | |
---|
| 91 | G4VSolid* Daughter = new G4Box("TestDaughter", 50*cm, 20*cm, 10*cm); |
---|
| 92 | |
---|
| 93 | G4LogicalVolume* logicMother = new G4LogicalVolume(Mother, //its solid |
---|
| 94 | Air, //its material |
---|
| 95 | "LTestMother");//its name |
---|
| 96 | |
---|
| 97 | G4LogicalVolume* logicDaughter = new G4LogicalVolume(Daughter, //its solid |
---|
| 98 | Air, //its material |
---|
| 99 | "LTestDaughter"); |
---|
| 100 | |
---|
| 101 | // G4VPhysicalVolume* physiDaughter = |
---|
| 102 | new G4PVPlacement(0, |
---|
| 103 | G4ThreeVector(), |
---|
| 104 | logicDaughter, |
---|
| 105 | "PTestDaughter", |
---|
| 106 | logicMother, |
---|
| 107 | false,0); |
---|
| 108 | // |
---|
| 109 | // Visualization attributes |
---|
| 110 | // |
---|
| 111 | |
---|
| 112 | logicMother->SetVisAttributes (G4VisAttributes::Invisible); |
---|
| 113 | G4VisAttributes* DaughterVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); |
---|
| 114 | DaughterVisAtt->SetVisibility(true); |
---|
| 115 | logicDaughter->SetVisAttributes(DaughterVisAtt); |
---|
| 116 | return logicMother; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|