Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:31

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