Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 /// \file g3tog4/clGeometry/src/G3toG4Detector << 27 /// \brief Implementation of the G3toG4Detecto << 28 // << 29 // 23 // >> 24 // $Id: G3toG4DetectorConstruction.cc,v 1.4 2003/07/04 15:55:01 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-07-00-patch-01 $ 30 // 26 // 31 //-------------------------------------------- 27 //-------------------------------------------------------------------------- 32 // G3toG4DetectorConstruction. Most the work i 28 // G3toG4DetectorConstruction. Most the work is Done in 33 // G4BuildGeom, which returns a G4LogicalVolum 29 // G4BuildGeom, which returns a G4LogicalVolume*, a pointer to the 34 // top-level logiical volume in the detector d 30 // top-level logiical volume in the detector defined by the call List file 35 // inFile 31 // inFile 36 //-------------------------------------------- 32 //-------------------------------------------------------------------------- 37 33 >> 34 #include "G4ios.hh" 38 #include "G3toG4DetectorConstruction.hh" 35 #include "G3toG4DetectorConstruction.hh" 39 << 36 #include "G4VisAttributes.hh" 40 #include "G4Box.hh" << 41 #include "G4Colour.hh" 37 #include "G4Colour.hh" 42 #include "G4Material.hh" 38 #include "G4Material.hh" 43 #include "G4SystemOfUnits.hh" << 39 #include "G4Box.hh" 44 #include "G4VisAttributes.hh" << 45 #include "G4ios.hh" << 46 << 47 //....oooOO0OOooo........oooOO0OOooo........oo << 48 40 49 G3toG4DetectorConstruction::G3toG4DetectorCons << 41 G3toG4DetectorConstruction::G3toG4DetectorConstruction(G4String inFile){ 50 : G4VUserDetectorConstruction(), fInFile(inF << 42 _inFile = inFile; 51 { << 43 G4cout << "Instantiated G3toG4DetectorConstruction using call list file \"" 52 G4cout << "Instantiated G3toG4DetectorConstr << 44 << _inFile << "\"" << G4endl; 53 << G4endl; << 54 } 45 } 55 46 56 //....oooOO0OOooo........oooOO0OOooo........oo << 47 G3toG4DetectorConstruction::~G3toG4DetectorConstruction(){ 57 << 48 // G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl; 58 G3toG4DetectorConstruction::~G3toG4DetectorCon << 59 { << 60 // G4cout << "Deleted G3toG4DetectorConstruc << 61 } 49 } 62 50 63 //....oooOO0OOooo........oooOO0OOooo........oo << 51 G4VPhysicalVolume* 64 << 52 G3toG4DetectorConstruction::Construct(){ 65 G4VPhysicalVolume* G3toG4DetectorConstruction: << 53 _lv = G4BuildGeom(_inFile); 66 { << 54 //_lv = SimpleConstruct(); 67 G4LogicalVolume* lv = G4BuildGeom(fInFile); << 55 if (_lv != 0) { 68 // G4LogicalVolume* lv = SimpleConstruct(); << 56 _pv = new G4PVPlacement(0, G4ThreeVector(), _lv, _lv->GetName(), 0, 69 if (lv) { << 57 false, 0); 70 G4VPhysicalVolume* pv = new G4PVPlacement( << 58 G4cout << "Top-level G3toG4 logical volume " << _lv->GetName() << " " 71 G4cout << "Top-level G3toG4 logical volume << 59 << *(_lv -> GetVisAttributes()) << G4endl; 72 << *(lv->GetVisAttributes()) << G4e << 60 } else 73 return pv; << 61 G4cerr << "creation of logical mother failed !!!" << G4endl; 74 } << 62 return _pv; 75 << 76 G4cerr << "creation of logical mother failed << 77 return 0; << 78 } 63 } 79 << 64 G4LogicalVolume* 80 //....oooOO0OOooo........oooOO0OOooo........oo << 65 G3toG4DetectorConstruction::SimpleConstruct(){ 81 << 66 G4String name, symbol; //a=mass of a mole; 82 G4LogicalVolume* G3toG4DetectorConstruction::S << 67 G4double a, z, density, fractionmass; //z=mean number of protons; 83 { << 68 G4int ncomponents; //iz=number of protons in an isotope; 84 G4String name, symbol; // a=mass of a mole; << 85 G4double a, z, density, fractionmass; // z= << 86 G4int ncomponents; // iz=number of protons << 87 // n=number of nucleons in an isotope; 69 // n=number of nucleons in an isotope; 88 70 89 a = 14.01 * g / mole; << 71 a = 14.01*g/mole; 90 G4Element* eN = new G4Element(name = "Nitrog << 72 G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); 91 73 92 a = 16.00 * g / mole; << 74 a = 16.00*g/mole; 93 G4Element* eO = new G4Element(name = "Oxygen << 75 G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); 94 76 95 // 77 // 96 // define a material from elements. case 2 78 // define a material from elements. case 2: mixture by fractional mass 97 // 79 // 98 80 99 density = 1.290 * mg / cm3; << 81 density = 1.290*mg/cm3; 100 G4Material* air = new G4Material(name = "Air << 82 G4Material* Air = new G4Material(name="Air" , density, ncomponents=2); 101 air->AddElement(eN, fractionmass = 0.7); << 83 Air->AddElement(N, fractionmass=0.7); 102 air->AddElement(eO, fractionmass = 0.3); << 84 Air->AddElement(O, fractionmass=0.3); 103 G4VSolid* mother = new G4Box("TestMother", << 85 G4VSolid* Mother = new G4Box("TestMother", //its name 104 100 * cm, 100 * << 86 100*cm, 100*cm, 100*cm); //its size 105 << 87 106 G4VSolid* daughter = new G4Box("TestDaughter << 88 G4VSolid* Daughter = new G4Box("TestDaughter", 50*cm, 20*cm, 10*cm); 107 << 89 108 G4LogicalVolume* logicMother = new G4Logical << 90 G4LogicalVolume* logicMother = new G4LogicalVolume(Mother, //its solid 109 << 91 Air, //its material 110 << 92 "LTestMother");//its name 111 << 93 112 G4LogicalVolume* logicDaughter = new G4Logic << 94 G4LogicalVolume* logicDaughter = new G4LogicalVolume(Daughter, //its solid 113 << 95 Air, //its material 114 << 96 "LTestDaughter"); 115 << 97 116 new G4PVPlacement(0, G4ThreeVector(), logicD << 98 // G4VPhysicalVolume* physiDaughter = >> 99 new G4PVPlacement(0, >> 100 G4ThreeVector(), >> 101 logicDaughter, >> 102 "PTestDaughter", >> 103 logicMother, >> 104 false,0); 117 // 105 // 118 // Visualization attributes 106 // Visualization attributes 119 // 107 // 120 108 121 logicMother->SetVisAttributes(G4VisAttribute << 109 logicMother->SetVisAttributes (G4VisAttributes::Invisible); 122 G4VisAttributes* daughterVisAtt = new G4VisA << 110 G4VisAttributes* DaughterVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 123 daughterVisAtt->SetVisibility(true); << 111 DaughterVisAtt->SetVisibility(true); 124 logicDaughter->SetVisAttributes(daughterVisA << 112 logicDaughter->SetVisAttributes(DaughterVisAtt); 125 return logicMother; 113 return logicMother; 126 } 114 } 127 115 128 //....oooOO0OOooo........oooOO0OOooo........oo << 116 >> 117 >> 118 >> 119 >> 120 >> 121 >> 122 >> 123 >> 124 129 125