Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:07:12

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