Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:30:34

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 ExGflash1DetectorConstruction.cc
0027 /// \brief Implementation of the ExGflash1DetectorConstruction 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 "ExGflash1DetectorConstruction.hh"
0036 
0037 #include "ExGflash1SensitiveDetector.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 // fast simulation
0055 #include "GFlashHitMaker.hh"
0056 #include "GFlashHomoShowerParameterisation.hh"
0057 #include "GFlashParticleBounds.hh"
0058 #include "GFlashShowerModel.hh"
0059 
0060 #include "G4FastSimulationManager.hh"
0061 
0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0063 
0064 ExGflash1DetectorConstruction::ExGflash1DetectorConstruction()
0065 {
0066   G4cout << "ExGflash1DetectorConstruction::Detector constructor" << G4endl;
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 ExGflash1DetectorConstruction::~ExGflash1DetectorConstruction()
0072 {
0073   delete fFastShowerModel;
0074   delete fParameterisation;
0075   delete fParticleBounds;
0076   delete fHitMaker;
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 G4VPhysicalVolume* ExGflash1DetectorConstruction::Construct()
0082 {
0083   //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
0084   G4cout << "Defining the materials" << G4endl;
0085   // Get nist material manager
0086   G4NistManager* nistManager = G4NistManager::Instance();
0087   // Build materials
0088   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0089   G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
0090 
0091   /*******************************
0092    * The Experimental Hall       *
0093    *******************************/
0094   G4double experimentalHall_x = 1000. * cm;
0095   G4double experimentalHall_y = 1000. * cm;
0096   G4double experimentalHall_z = 1000. * cm;
0097 
0098   G4VSolid* experimentalHall_box = new G4Box("expHall_box",  // World Volume
0099                                              experimentalHall_x,  // x size
0100                                              experimentalHall_y,  // y size
0101                                              experimentalHall_z);  // z size
0102 
0103   auto experimentalHallLog = new G4LogicalVolume(experimentalHall_box, air, "expHallLog",
0104                                                  nullptr,  // opt: fieldManager
0105                                                  nullptr,  // opt: SensitiveDetector
0106                                                  nullptr);  // opt: UserLimits
0107   G4VPhysicalVolume* experimentalHallPhys =
0108     new G4PVPlacement(nullptr,
0109                       G4ThreeVector(),  // at (0,0,0)
0110                       "expHall", experimentalHallLog, nullptr, false, 0);
0111 
0112   //------------------------------
0113   // Calorimeter segments
0114   //------------------------------
0115   // Simplified `CMS-like` PbWO4 crystal calorimeter
0116 
0117   G4int nbOfCrystals = 10;  // this are the crystals PER ROW in this example
0118                             // cube of 10 x 10 crystals
0119                             // don't change it @the moment, since
0120                             // the readout in event action assumes this
0121                             // dimensions and is not automatically adapted
0122                             // in this version of the example :-(
0123   // Simplified `CMS-like` PbWO4 crystal calorimeter
0124   G4double calo_xside = 31 * cm;
0125   G4double calo_yside = 31 * cm;
0126   G4double calo_zside = 24 * cm;
0127 
0128   G4double crystalWidth = 3 * cm;
0129   G4double crystalLength = 24 * cm;
0130 
0131   calo_xside = (crystalWidth * nbOfCrystals) + 1 * cm;
0132   calo_yside = (crystalWidth * nbOfCrystals) + 1 * cm;
0133   calo_zside = crystalLength;
0134 
0135   auto calo_box = new G4Box("CMS calorimeter",  // its name
0136                             calo_xside / 2.,  // size
0137                             calo_yside / 2., calo_zside / 2.);
0138   auto caloLog = new G4LogicalVolume(calo_box,  // its solid
0139                                      air,  // its material
0140                                      "calo log",  // its name
0141                                      nullptr,  // opt: fieldManager
0142                                      nullptr,  // opt: SensitiveDetector
0143                                      nullptr);  // opt: UserLimit
0144 
0145   G4double xpos = 0.0;
0146   G4double ypos = 0.0;
0147   G4double zpos = 100.0 * cm;
0148   new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), caloLog, "calorimeter",
0149                     experimentalHallLog, false, 1);
0150 
0151   // Crystals
0152   G4VSolid* crystal_box = new G4Box("Crystal",  // its name
0153                                     crystalWidth / 2, crystalWidth / 2, crystalLength / 2);
0154   // size
0155   fCrystalLog = new G4LogicalVolume(crystal_box,  // its solid
0156                                     pbWO4,  // its material
0157                                     "CrystalLog");  // its name
0158 
0159   for (G4int i = 0; i < nbOfCrystals; i++) {
0160     for (G4int j = 0; j < nbOfCrystals; j++) {
0161       G4int n = i * 10 + j;
0162       G4ThreeVector crystalPos((i * crystalWidth) - 135, (j * crystalWidth) - 135, 0);
0163       fCrystalPhys[n] = new G4PVPlacement(nullptr,  // no rotation
0164                                           crystalPos,  // translation
0165                                           fCrystalLog,
0166                                           "crystal",  // its name
0167                                           caloLog, false, i);
0168     }
0169   }
0170   G4cout << "There are " << nbOfCrystals << " crystals per row in the calorimeter, so in total "
0171          << nbOfCrystals * nbOfCrystals << " crystals" << G4endl;
0172   G4cout << "They have width of  " << crystalWidth / cm << "  cm and a length of  "
0173          << crystalLength / cm << " cm. The Material is " << pbWO4 << G4endl;
0174 
0175   experimentalHallLog->SetVisAttributes(G4VisAttributes::GetInvisible());
0176   auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0177   auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0178   caloLog->SetVisAttributes(caloVisAtt);
0179   fCrystalLog->SetVisAttributes(crystalVisAtt);
0180 
0181   // define the fParameterisation region
0182   fRegion = new G4Region("crystals");
0183   caloLog->SetRegion(fRegion);
0184   fRegion->AddRootLogicalVolume(caloLog);
0185 
0186   return experimentalHallPhys;
0187 }
0188 
0189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0190 
0191 void ExGflash1DetectorConstruction::ConstructSDandField()
0192 {
0193   // -- sensitive detectors:
0194   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0195   auto CaloSD = new ExGflash1SensitiveDetector("Calorimeter", this);
0196   SDman->AddNewDetector(CaloSD);
0197   fCrystalLog->SetSensitiveDetector(CaloSD);
0198 
0199   // Get nist material manager
0200   G4NistManager* nistManager = G4NistManager::Instance();
0201   G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
0202   // -- fast simulation models:
0203   // **********************************************
0204   // * Initializing shower modell
0205   // ***********************************************
0206   G4cout << "Creating shower parameterization models" << G4endl;
0207   fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
0208   fParameterisation = new GFlashHomoShowerParameterisation(pbWO4);
0209   fFastShowerModel->SetParameterisation(*fParameterisation);
0210   // Energy Cuts to kill particles:
0211   fParticleBounds = new GFlashParticleBounds();
0212   fFastShowerModel->SetParticleBounds(*fParticleBounds);
0213   // Makes the EnergieSpots
0214   fHitMaker = new GFlashHitMaker();
0215   fFastShowerModel->SetHitMaker(*fHitMaker);
0216   G4cout << "end shower parameterization." << G4endl;
0217   // **********************************************
0218 }
0219 
0220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......