Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:37

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 persistency/P02/src/ExP02DetectorConstruction.cc
0027 /// \brief Implementation of the ExP02DetectorConstruction class
0028 //
0029 //
0030 //
0031 #include "ExP02DetectorConstruction.hh"
0032 
0033 #include "G4Box.hh"
0034 #include "G4LogicalVolume.hh"
0035 #include "G4Material.hh"
0036 #include "G4PVPlacement.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4ThreeVector.hh"
0039 #include "G4Tubs.hh"
0040 #include "globals.hh"
0041 
0042 // ROOT
0043 #include "ExP02GeoTree.hh"
0044 #include "TFile.h"
0045 #include "TROOT.h"
0046 #include "TSystem.h"
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 ExP02DetectorConstruction::ExP02DetectorConstruction()
0051   : G4VUserDetectorConstruction(),
0052     fExperimentalHall_log(0),
0053     fTracker_log(0),
0054     fCalorimeterBlock_log(0),
0055     fCalorimeterLayer_log(0),
0056     fExperimentalHall_phys(0),
0057     fCalorimeterLayer_phys(0),
0058     fCalorimeterBlock_phys(0),
0059     fTracker_phys(0)
0060 {
0061   ;
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 ExP02DetectorConstruction::~ExP02DetectorConstruction() {}
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 G4VPhysicalVolume* ExP02DetectorConstruction::Construct()
0071 {
0072   //------------------------------------------------------ materials
0073 
0074   G4double a;  // atomic mass
0075   G4double z;  // atomic number
0076   G4double density;
0077 
0078   G4Material* Ar =
0079     new G4Material("ArgonGas", z = 18., a = 39.95 * g / mole, density = 1.782 * mg / cm3);
0080 
0081   G4Material* Al =
0082     new G4Material("Aluminum", z = 13., a = 26.98 * g / mole, density = 2.7 * g / cm3);
0083 
0084   G4Material* Pb =
0085     new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0086 
0087   //------------------------------------------------------ volumes
0088 
0089   //------------------------------ experimental hall (world volume)
0090   //------------------------------ beam line along x axis
0091 
0092   G4double expHall_x = 3.0 * m;
0093   G4double expHall_y = 1.0 * m;
0094   G4double expHall_z = 1.0 * m;
0095   G4Box* experimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z);
0096   fExperimentalHall_log = new G4LogicalVolume(experimentalHall_box, Ar, "expHall_log", 0, 0, 0);
0097   fExperimentalHall_phys =
0098     new G4PVPlacement(0, G4ThreeVector(), fExperimentalHall_log, "expHall", 0, false, 0);
0099 
0100   //------------------------------ a tracker tube
0101 
0102   G4double innerRadiusOfTheTube = 0. * cm;
0103   G4double outerRadiusOfTheTube = 60. * cm;
0104   G4double hightOfTheTube = 50. * cm;
0105   G4double startAngleOfTheTube = 0. * deg;
0106   G4double spanningAngleOfTheTube = 360. * deg;
0107   G4Tubs* tracker_tube = new G4Tubs("tracker_tube", innerRadiusOfTheTube, outerRadiusOfTheTube,
0108                                     hightOfTheTube, startAngleOfTheTube, spanningAngleOfTheTube);
0109   fTracker_log = new G4LogicalVolume(tracker_tube, Al, "tracker_log", 0, 0, 0);
0110   G4double trackerPos_x = -1.0 * m;
0111   G4double trackerPos_y = 0. * m;
0112   G4double trackerPos_z = 0. * m;
0113   fTracker_phys = new G4PVPlacement(0, G4ThreeVector(trackerPos_x, trackerPos_y, trackerPos_z),
0114                                     fTracker_log, "tracker", fExperimentalHall_log, false, 0);
0115 
0116   //------------------------------ a calorimeter block
0117 
0118   G4double block_x = 1.0 * m;
0119   G4double block_y = 50.0 * cm;
0120   G4double block_z = 50.0 * cm;
0121   G4Box* calorimeterBlock_box = new G4Box("calBlock_box", block_x, block_y, block_z);
0122   fCalorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box, Pb, "caloBlock_log", 0, 0, 0);
0123   G4double blockPos_x = 1.0 * m;
0124   G4double blockPos_y = 0.0 * m;
0125   G4double blockPos_z = 0.0 * m;
0126   fCalorimeterBlock_phys =
0127     new G4PVPlacement(0, G4ThreeVector(blockPos_x, blockPos_y, blockPos_z), fCalorimeterBlock_log,
0128                       "caloBlock", fExperimentalHall_log, false, 0);
0129 
0130   //------------------------------ calorimeter layers
0131 
0132   G4double calo_x = 1. * cm;
0133   G4double calo_y = 40. * cm;
0134   G4double calo_z = 40. * cm;
0135   G4Box* calorimeterLayer_box = new G4Box("caloLayer_box", calo_x, calo_y, calo_z);
0136   fCalorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box, Al, "caloLayer_log", 0, 0, 0);
0137   for (G4int i = 0; i < 19; i++)  // loop for 19 layers
0138   {
0139     G4double caloPos_x = (i - 9) * 10. * cm;
0140     G4double caloPos_y = 0.0 * m;
0141     G4double caloPos_z = 0.0 * m;
0142     fCalorimeterLayer_phys =
0143       new G4PVPlacement(0, G4ThreeVector(caloPos_x, caloPos_y, caloPos_z), fCalorimeterLayer_log,
0144                         "caloLayer", fCalorimeterBlock_log, false, i);
0145   }
0146 
0147   //------------------------------------------------------------------
0148 
0149   // writing the geometry to a ROOT file
0150 
0151   // initialize ROOT
0152   TSystem ts;
0153 
0154   gSystem->Load("libExP02ClassesDict");
0155 
0156   //  gDebug = 1;
0157 
0158   const G4ElementTable* eltab = G4Element::GetElementTable();
0159 
0160   ExP02GeoTree* geotree = new ExP02GeoTree(fExperimentalHall_phys, eltab);
0161 
0162   TFile fo("geo.root", "RECREATE");
0163 
0164   fo.WriteObject(geotree, "my_geo");
0165 
0166   return fExperimentalHall_phys;
0167 }