Geant4  10.02.p01
G3toG4DetectorConstruction.cc
Go to the documentation of this file.
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 //
28 //
29 //
30 // $Id: G3toG4DetectorConstruction.cc 84605 2014-10-17 07:49:11Z gcosmo $
31 //
32 //--------------------------------------------------------------------------
33 // G3toG4DetectorConstruction. Most the work is Done in
34 // G4BuildGeom, which returns a G4LogicalVolume*, a pointer to the
35 // top-level logiical volume in the detector defined by the call List file
36 // inFile
37 //--------------------------------------------------------------------------
38 
39 #include "G4SystemOfUnits.hh"
40 #include "G4ios.hh"
42 #include "G4VisAttributes.hh"
43 #include "G4Colour.hh"
44 #include "G4Material.hh"
45 #include "G4Box.hh"
46 #include "G4SystemOfUnits.hh"
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
52  fInFile(inFile)
53 {
54  G4cout << "Instantiated G3toG4DetectorConstruction using call list file \""
55  << fInFile << "\"" << G4endl;
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  // G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
70  //G4LogicalVolume* lv = SimpleConstruct();
71  if ( lv ) {
73  = new G4PVPlacement(0, G4ThreeVector(), lv, lv->GetName(), 0, false, 0);
74  G4cout << "Top-level G3toG4 logical volume " << lv->GetName() << " "
75  << *(lv -> GetVisAttributes()) << G4endl;
76  return pv;
77  }
78 
79  G4cerr << "creation of logical mother failed !!!" << G4endl;
80  return 0;
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  G4String name, symbol; //a=mass of a mole;
88  G4double a, z, density, fractionmass; //z=mean number of protons;
89  G4int ncomponents; //iz=number of protons in an isotope;
90  // n=number of nucleons in an isotope;
91 
92  a = 14.01*g/mole;
93  G4Element* eN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
94 
95  a = 16.00*g/mole;
96  G4Element* eO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
97 
98  //
99  // define a material from elements. case 2: mixture by fractional mass
100  //
101 
102  density = 1.290*mg/cm3;
103  G4Material* air = new G4Material(name="Air" , density, ncomponents=2);
104  air->AddElement(eN, fractionmass=0.7);
105  air->AddElement(eO, fractionmass=0.3);
106  G4VSolid* mother = new G4Box("TestMother", //its name
107  100*cm, 100*cm, 100*cm); //its size
108 
109  G4VSolid* daughter = new G4Box("TestDaughter", 50*cm, 20*cm, 10*cm);
110 
111  G4LogicalVolume* logicMother = new G4LogicalVolume(mother, //its solid
112  air, //its material
113  "LTestMother");//its name
114 
115  G4LogicalVolume* logicDaughter = new G4LogicalVolume(daughter, //its solid
116  air, //its material
117  "LTestDaughter");
118 
119  new G4PVPlacement(0,
120  G4ThreeVector(),
121  logicDaughter,
122  "PTestDaughter",
123  logicMother,
124  false,0);
125  //
126  // Visualization attributes
127  //
128 
130  G4VisAttributes* daughterVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
131  daughterVisAtt->SetVisibility(true);
132  logicDaughter->SetVisAttributes(daughterVisAtt);
133  return logicMother;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:118
G4String symbol
Definition: TRTMaterials.hh:40
Definition of the G3toG4DetectorConstruction class.
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:64
G4String name
Definition: TRTMaterials.hh:40
void SetVisibility(G4bool)
G4double a
Definition: TRTMaterials.hh:39
static const double mg
Definition: G4SIunits.hh:181
int G4int
Definition: G4Types.hh:78
G4double density
Definition: TRTMaterials.hh:39
G4GLOB_DLL std::ostream G4cout
static const double cm3
Definition: G4SIunits.hh:120
G3toG4DetectorConstruction(G4String inFile="svt.dat")
static const double g
Definition: G4SIunits.hh:180
G4LogicalVolume * G4BuildGeom(G4String &inFile)
Definition: G4BuildGeom.cc:55
static const G4VisAttributes Invisible
static const double mole
Definition: G4SIunits.hh:283
virtual G4VPhysicalVolume * Construct()
#define G4endl
Definition: G4ios.hh:61
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
const G4String & GetName() const
double G4double
Definition: G4Types.hh:76
void SetVisAttributes(const G4VisAttributes *pVA)
G4GLOB_DLL std::ostream G4cerr