Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:19

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file g3tog4/clGeometry/src/G3toG4DetectorConstruction.cc
0027 /// \brief Implementation of the G3toG4DetectorConstruction class
0028 //
0029 //
0030 //
0031 //--------------------------------------------------------------------------
0032 // G3toG4DetectorConstruction. Most the work is Done in
0033 // G4BuildGeom, which returns a G4LogicalVolume*, a pointer to the
0034 // top-level logiical volume in the detector defined by the call List file
0035 // inFile
0036 //--------------------------------------------------------------------------
0037 
0038 #include "G3toG4DetectorConstruction.hh"
0039 
0040 #include "G4Box.hh"
0041 #include "G4Colour.hh"
0042 #include "G4Material.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4VisAttributes.hh"
0045 #include "G4ios.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 G3toG4DetectorConstruction::G3toG4DetectorConstruction(G4String inFile)
0050   : G4VUserDetectorConstruction(), fInFile(inFile)
0051 {
0052   G4cout << "Instantiated G3toG4DetectorConstruction using call list file \"" << fInFile << "\""
0053          << G4endl;
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 G3toG4DetectorConstruction::~G3toG4DetectorConstruction()
0059 {
0060   // G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl;
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 G4VPhysicalVolume* G3toG4DetectorConstruction::Construct()
0066 {
0067   G4LogicalVolume* lv = G4BuildGeom(fInFile);
0068   // G4LogicalVolume* lv = SimpleConstruct();
0069   if (lv) {
0070     G4VPhysicalVolume* pv = new G4PVPlacement(0, G4ThreeVector(), lv, lv->GetName(), 0, false, 0);
0071     G4cout << "Top-level G3toG4 logical volume " << lv->GetName() << " "
0072            << *(lv->GetVisAttributes()) << G4endl;
0073     return pv;
0074   }
0075 
0076   G4cerr << "creation of logical mother failed !!!" << G4endl;
0077   return 0;
0078 }
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 
0082 G4LogicalVolume* G3toG4DetectorConstruction::SimpleConstruct()
0083 {
0084   G4String name, symbol;  // a=mass of a mole;
0085   G4double a, z, density, fractionmass;  // z=mean number of protons;
0086   G4int ncomponents;  // iz=number of protons  in an isotope;
0087   // n=number of nucleons in an isotope;
0088 
0089   a = 14.01 * g / mole;
0090   G4Element* eN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0091 
0092   a = 16.00 * g / mole;
0093   G4Element* eO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0094 
0095   //
0096   // define a material from elements.   case 2: mixture by fractional mass
0097   //
0098 
0099   density = 1.290 * mg / cm3;
0100   G4Material* air = new G4Material(name = "Air", density, ncomponents = 2);
0101   air->AddElement(eN, fractionmass = 0.7);
0102   air->AddElement(eO, fractionmass = 0.3);
0103   G4VSolid* mother = new G4Box("TestMother",  // its name
0104                                100 * cm, 100 * cm, 100 * cm);  // its size
0105 
0106   G4VSolid* daughter = new G4Box("TestDaughter", 50 * cm, 20 * cm, 10 * cm);
0107 
0108   G4LogicalVolume* logicMother = new G4LogicalVolume(mother,  // its solid
0109                                                      air,  // its material
0110                                                      "LTestMother");  // its name
0111 
0112   G4LogicalVolume* logicDaughter = new G4LogicalVolume(daughter,  // its solid
0113                                                        air,  // its material
0114                                                        "LTestDaughter");
0115 
0116   new G4PVPlacement(0, G4ThreeVector(), logicDaughter, "PTestDaughter", logicMother, false, 0);
0117   //
0118   // Visualization attributes
0119   //
0120 
0121   logicMother->SetVisAttributes(G4VisAttributes::GetInvisible());
0122   G4VisAttributes* daughterVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0123   daughterVisAtt->SetVisibility(true);
0124   logicDaughter->SetVisAttributes(daughterVisAtt);
0125   return logicMother;
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......