Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:28:58

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 ExGflash2DetectorConstruction.cc
0027 /// \brief Implementation of the ExGflash2DetectorConstruction class
0028 
0029 // Created by Joanna Weng 26.11.2004
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 // User Classes
0035 #include "ExGflash2DetectorConstruction.hh"
0036 
0037 #include "ExGflash2SensitiveDetector.hh"
0038 
0039 // G4 Classes
0040 #include "G4AutoDelete.hh"
0041 #include "G4Box.hh"
0042 #include "G4Colour.hh"
0043 #include "G4LogicalVolume.hh"
0044 #include "G4Material.hh"
0045 #include "G4NistManager.hh"
0046 #include "G4PVPlacement.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4ThreeVector.hh"
0050 #include "G4VPhysicalVolume.hh"
0051 #include "G4VisAttributes.hh"
0052 #include "globals.hh"
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 ExGflash2DetectorConstruction::ExGflash2DetectorConstruction()
0057 {
0058   G4cout << "ExGflash2DetectorConstruction::Detector constructor" << G4endl;
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 ExGflash2DetectorConstruction::~ExGflash2DetectorConstruction() = default;
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 G4VPhysicalVolume* ExGflash2DetectorConstruction::Construct()
0068 {
0069   //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
0070   G4cout << "Defining the materials" << G4endl;
0071   // Get nist material manager
0072   G4NistManager* nistManager = G4NistManager::Instance();
0073   // Build materials
0074   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0075   G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
0076 
0077   /*******************************
0078    * The Experimental Hall       *
0079    *******************************/
0080   G4double experimentalHall_x = 1000. * cm;
0081   G4double experimentalHall_y = 1000. * cm;
0082   G4double experimentalHall_z = 1000. * cm;
0083 
0084   G4VSolid* experimentalHall_box = new G4Box("expHall_box",  // World Volume
0085                                              experimentalHall_x,  // x size
0086                                              experimentalHall_y,  // y size
0087                                              experimentalHall_z);  // z size
0088 
0089   auto experimentalHallLog = new G4LogicalVolume(experimentalHall_box, air, "expHallLog",
0090                                                  nullptr,  // opt: fieldManager
0091                                                  nullptr,  // opt: SensitiveDetector
0092                                                  nullptr);  // opt: UserLimits
0093   G4VPhysicalVolume* experimentalHallPhys =
0094     new G4PVPlacement(nullptr,
0095                       G4ThreeVector(),  // at (0,0,0)
0096                       "expHall", experimentalHallLog, nullptr, false, 0);
0097 
0098   //------------------------------
0099   // Calorimeter segments
0100   //------------------------------
0101   // Simplified `CMS-like` PbWO4 crystal calorimeter
0102 
0103   G4int nbOfCrystals = 10;  // this are the crystals PER ROW in this example
0104                             // cube of 10 x 10 crystals
0105                             // don't change it @the moment, since
0106                             // the readout in event action assumes this
0107                             // dimensions and is not automatically adapted
0108                             // in this version of the example :-(
0109   // Simplified `CMS-like` PbWO4 crystal calorimeter
0110   G4double calo_xside = 31 * cm;
0111   G4double calo_yside = 31 * cm;
0112   G4double calo_zside = 24 * cm;
0113 
0114   G4double crystalWidth = 3 * cm;
0115   G4double crystalLength = 24 * cm;
0116 
0117   calo_xside = (crystalWidth * nbOfCrystals) + 1 * cm;
0118   calo_yside = (crystalWidth * nbOfCrystals) + 1 * cm;
0119   calo_zside = crystalLength;
0120 
0121   auto calo_box = new G4Box("CMS calorimeter",  // its name
0122                             calo_xside / 2.,  // size
0123                             calo_yside / 2., calo_zside / 2.);
0124   auto caloLog = new G4LogicalVolume(calo_box,  // its solid
0125                                      air,  // its material
0126                                      "calo log",  // its name
0127                                      nullptr,  // opt: fieldManager
0128                                      nullptr,  // opt: SensitiveDetector
0129                                      nullptr);  // opt: UserLimit
0130 
0131   G4double xpos = 0.0;
0132   G4double ypos = 0.0;
0133   G4double zpos = 100.0 * cm;
0134   new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), caloLog, "calorimeter",
0135                     experimentalHallLog, false, 1);
0136 
0137   // Crystals
0138   G4VSolid* crystal_box = new G4Box("Crystal",  // its name
0139                                     crystalWidth / 2, crystalWidth / 2, crystalLength / 2);
0140   // size
0141   fCrystalLog = new G4LogicalVolume(crystal_box,  // its solid
0142                                     pbWO4,  // its material
0143                                     "CrystalLog");  // its name
0144 
0145   for (G4int i = 0; i < nbOfCrystals; i++) {
0146     for (G4int j = 0; j < nbOfCrystals; j++) {
0147       G4int n = i * 10 + j;
0148       G4ThreeVector crystalPos((i * crystalWidth) - 135, (j * crystalWidth) - 135, 0);
0149       fCrystalPhys[n] = new G4PVPlacement(nullptr,  // no rotation
0150                                           crystalPos,  // translation
0151                                           fCrystalLog,
0152                                           "crystal",  // its name
0153                                           caloLog, false, i);
0154     }
0155   }
0156   G4cout << "There are " << nbOfCrystals << " crystals per row in the calorimeter, so in total "
0157          << nbOfCrystals * nbOfCrystals << " crystals" << G4endl;
0158   G4cout << "They have width of  " << crystalWidth / cm << "  cm and a length of  "
0159          << crystalLength / cm << " cm. The Material is " << pbWO4 << G4endl;
0160 
0161   experimentalHallLog->SetVisAttributes(G4VisAttributes::GetInvisible());
0162   auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0163   auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0164   caloLog->SetVisAttributes(caloVisAtt);
0165   fCrystalLog->SetVisAttributes(crystalVisAtt);
0166 
0167   // Parametrisation region defined in ExGflash2ParallelWorld
0168 
0169   return experimentalHallPhys;
0170 }
0171 
0172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0173 
0174 void ExGflash2DetectorConstruction::ConstructSDandField()
0175 {
0176   // -- sensitive detectors:
0177   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0178   auto CaloSD = new ExGflash2SensitiveDetector("Calorimeter", this);
0179   SDman->AddNewDetector(CaloSD);
0180   fCrystalLog->SetSensitiveDetector(CaloSD);
0181 
0182   // Fast simulation implemented in ExGflash2ParallelWorld
0183 }
0184 
0185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......