Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 07:45: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 /// \file ExGflash3ParallelWorld.cc
0027 /// \brief Implementation of the ExGflash3ParallelWorld class
0028 
0029 // User Classes
0030 #include "ExGflash3ParallelWorld.hh"
0031 
0032 #include "ExGflash3SensitiveDetector.hh"
0033 
0034 // G4 Classes
0035 #include "G4AutoDelete.hh"
0036 #include "G4Box.hh"
0037 #include "G4Colour.hh"
0038 #include "G4LogicalVolume.hh"
0039 #include "G4Material.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4SDManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4ThreeVector.hh"
0045 #include "G4VPhysicalVolume.hh"
0046 #include "G4VisAttributes.hh"
0047 #include "globals.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 ExGflash3ParallelWorld::ExGflash3ParallelWorld(G4String aWorldName)
0052   : G4VUserParallelWorld(aWorldName)
0053 {
0054   G4cout << "ExGflash3ParallelWorld::Parralel world constructor" << G4endl;
0055 }
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 ExGflash3ParallelWorld::~ExGflash3ParallelWorld() = default;
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void ExGflash3ParallelWorld::Construct()
0064 {
0065   // In parallel world material does not matter
0066   G4Material* dummy = nullptr;
0067 
0068   // Build parallel/ghost geometry:
0069   auto ghostLogicalVolume = GetWorld()->GetLogicalVolume();
0070 
0071   // Use part of the Ex1GflashDetectorConstruction (without individual crystals)
0072 
0073   G4int nbOfCrystals = 10;  // this are the crystals PER ROW in this example
0074                             // cube of 10 x 10 crystals
0075                             // don't change it @the moment, since
0076                             // the readout in event action assumes this
0077                             // dimensions and is not automatically adapted
0078                             // in this version of the example :-(
0079   // Simplified `CMS-like` PbWO4 crystal calorimeter
0080   G4double calo_xside = 31 * cm;
0081   G4double calo_yside = 31 * cm;
0082   G4double calo_zside = 24 * cm;
0083 
0084   G4double crystalWidth = 3 * cm;
0085   G4double crystalLength = 24 * cm;
0086 
0087   calo_xside = (crystalWidth * nbOfCrystals) + 1 * cm;
0088   calo_yside = (crystalWidth * nbOfCrystals) + 1 * cm;
0089   calo_zside = crystalLength;
0090 
0091   auto calo_box = new G4Box("CMS calorimeter",  // its name
0092                             calo_xside / 2.,  // size
0093                             calo_yside / 2., calo_zside / 2.);
0094   auto caloLog = new G4LogicalVolume(calo_box,  // its solid
0095                                      dummy,  // its material
0096                                      "calo log",  // its name
0097                                      nullptr,  // opt: fieldManager
0098                                      nullptr,  // opt: SensitiveDetector
0099                                      nullptr);  // opt: UserLimit
0100 
0101   G4double xpos = 0.0;
0102   G4double ypos = 0.0;
0103   G4double zpos = 100.0 * cm;
0104   new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), caloLog, "calorimeter",
0105                     ghostLogicalVolume, false, 1);
0106 
0107   // Crystals
0108   G4VSolid* crystal_box = new G4Box("Crystal",  // its name
0109                                     crystalWidth / 2, crystalWidth / 2, crystalLength / 2);
0110   // size
0111   fCrystalLog = new G4LogicalVolume(crystal_box,  // its solid
0112                                     dummy,  // its material
0113                                     "CrystalLog");  // its name
0114 
0115   for (G4int i = 0; i < nbOfCrystals; i++) {
0116     for (G4int j = 0; j < nbOfCrystals; j++) {
0117       G4int n = i * 10 + j;
0118       G4ThreeVector crystalPos((i * crystalWidth) - 135, (j * crystalWidth) - 135, 0);
0119       fCrystalPhys[n] = new G4PVPlacement(nullptr,  // no rotation
0120                                           crystalPos,  // translation
0121                                           fCrystalLog,
0122                                           "crystal",  // its name
0123                                           caloLog, false, i);
0124     }
0125   }
0126   G4cout << "There are " << nbOfCrystals << " crystals per row in the calorimeter, so in total "
0127          << nbOfCrystals * nbOfCrystals << " crystals" << G4endl;
0128   G4cout << "They have width of  " << crystalWidth / cm << "  cm and a length of  "
0129          << crystalLength / cm << " cm. " << G4endl;
0130 
0131   auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0132   auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0133   caloLog->SetVisAttributes(caloVisAtt);
0134   fCrystalLog->SetVisAttributes(crystalVisAtt);
0135 }
0136 
0137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0138 
0139 void ExGflash3ParallelWorld::ConstructSD()
0140 {
0141   // -- sensitive detectors:
0142   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0143   auto CaloSD = new ExGflash3SensitiveDetector("Calorimeter", this);
0144   SDman->AddNewDetector(CaloSD);
0145   fCrystalLog->SetSensitiveDetector(CaloSD);
0146 }
0147 
0148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......