Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-30 07:51:10

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