Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:30:27

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 RE06ParallelWorld.cc
0027 /// \brief Implementation of the RE06ParallelWorld class
0028 
0029 #include "RE06ParallelWorld.hh"
0030 
0031 #include "G4LogicalVolume.hh"
0032 #include "G4MultiFunctionalDetector.hh"
0033 #include "G4PSEnergyDeposit.hh"
0034 #include "G4PSMinKinEAtGeneration.hh"
0035 #include "G4PSNofSecondary.hh"
0036 #include "G4PSNofStep.hh"
0037 #include "G4PSTrackLength.hh"
0038 #include "G4PVPlacement.hh"
0039 #include "G4PVReplica.hh"
0040 #include "G4SDManager.hh"
0041 #include "G4SDParticleFilter.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4Tubs.hh"
0044 #include "G4VPrimitiveScorer.hh"
0045 #include "G4VSDFilter.hh"
0046 #include "G4ios.hh"
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 G4ThreadLocal G4bool RE06ParallelWorld::fSDConstructed = false;
0051 
0052 RE06ParallelWorld::RE06ParallelWorld(G4String worldName)
0053   : G4VUserParallelWorld(worldName),
0054     fConstructed(false),
0055     fSerial(false),
0056     fTotalThickness(2.0 * m),
0057     fNumberOfLayers(20)
0058 {
0059   for (size_t i = 0; i < 3; i++) {
0060     fCalorLogical[i] = 0;
0061     fLayerLogical[i] = 0;
0062     fCalorPhysical[i] = 0;
0063     fLayerPhysical[i] = 0;
0064   }
0065   fCalName[0] = "Calor-AP";
0066   fCalName[1] = "Calor-BP";
0067   fCalName[2] = "Calor-CP";
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 RE06ParallelWorld::~RE06ParallelWorld()
0073 {
0074   ;
0075 }
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 
0079 void RE06ParallelWorld::Construct()
0080 {
0081   if (!fConstructed) {
0082     fConstructed = true;
0083     SetupGeometry();
0084   }
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 void RE06ParallelWorld::ConstructSD()
0090 {
0091   if (!fSDConstructed) {
0092     fSDConstructed = true;
0093     SetupDetectors();
0094   }
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 void RE06ParallelWorld::SetupGeometry()
0099 {
0100   //
0101   // World
0102   //
0103   G4VPhysicalVolume* ghostWorld = GetWorld();
0104   G4LogicalVolume* worldLogical = ghostWorld->GetLogicalVolume();
0105 
0106   //
0107   // Calorimeter
0108   //
0109   G4VSolid* calorSolid = new G4Tubs("Calor", 0.0, 0.5 * m, fTotalThickness / 2., 0.0, 360. * deg);
0110   G4int i;
0111   for (i = 0; i < 3; i++) {
0112     fCalorLogical[i] = new G4LogicalVolume(calorSolid, 0, fCalName[i]);
0113     if (fSerial) {
0114       fCalorPhysical[i] =
0115         new G4PVPlacement(0, G4ThreeVector(0., 0., G4double(i - 1) * fTotalThickness),
0116                           fCalorLogical[i], fCalName[i], worldLogical, false, i);
0117     }
0118     else {
0119       fCalorPhysical[i] = new G4PVPlacement(0, G4ThreeVector(0., G4double(i - 1) * m, 0.),
0120                                             fCalorLogical[i], fCalName[i], worldLogical, false, i);
0121     }
0122   }
0123 
0124   //
0125   // Layers --- as absorbers
0126   //
0127   G4VSolid* layerSolid = new G4Tubs("Layer", 0.0, 0.5 * m, fTotalThickness / 2., 0.0, 360. * deg);
0128   for (i = 0; i < 3; i++) {
0129     fLayerLogical[i] = new G4LogicalVolume(layerSolid, 0, fCalName[i] + "_LayerLog");
0130     fLayerPhysical[i] = new G4PVReplica(fCalName[i] + "_Layer", fLayerLogical[i], fCalorLogical[i],
0131                                         kRho, fNumberOfLayers, 0.5 * m / fNumberOfLayers);
0132   }
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0136 
0137 void RE06ParallelWorld::SetupDetectors()
0138 {
0139   G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
0140   G4String filterName, particleName;
0141 
0142   G4SDParticleFilter* gammaFilter =
0143     new G4SDParticleFilter(filterName = "gammaFilter", particleName = "gamma");
0144   G4SDParticleFilter* electronFilter =
0145     new G4SDParticleFilter(filterName = "electronFilter", particleName = "e-");
0146   G4SDParticleFilter* positronFilter =
0147     new G4SDParticleFilter(filterName = "positronFilter", particleName = "e+");
0148   G4SDParticleFilter* epFilter = new G4SDParticleFilter(filterName = "epFilter");
0149   epFilter->add(particleName = "e-");
0150   epFilter->add(particleName = "e+");
0151 
0152   for (G4int i = 0; i < 3; i++) {
0153     G4String detName = fCalName[i] + "_para";
0154     G4MultiFunctionalDetector* det = new G4MultiFunctionalDetector(detName);
0155 
0156     G4VPrimitiveScorer* primitive;
0157     primitive = new G4PSEnergyDeposit("eDep");
0158     det->RegisterPrimitive(primitive);
0159     primitive = new G4PSNofSecondary("nGamma");
0160     primitive->SetFilter(gammaFilter);
0161     det->RegisterPrimitive(primitive);
0162     primitive = new G4PSNofSecondary("nElectron");
0163     primitive->SetFilter(electronFilter);
0164     det->RegisterPrimitive(primitive);
0165     primitive = new G4PSNofSecondary("nPositron");
0166     primitive->SetFilter(positronFilter);
0167     det->RegisterPrimitive(primitive);
0168     primitive = new G4PSTrackLength("trackLength");
0169     primitive->SetFilter(epFilter);
0170     det->RegisterPrimitive(primitive);
0171     primitive = new G4PSNofStep("nStep");
0172     primitive->SetFilter(epFilter);
0173     det->RegisterPrimitive(primitive);
0174 
0175     G4SDManager::GetSDMpointer()->AddNewDetector(det);
0176     SetSensitiveDetector(fLayerLogical[i], det);
0177   }
0178   G4SDManager::GetSDMpointer()->SetVerboseLevel(0);
0179 }
0180 
0181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0182 
0183 void RE06ParallelWorld::SetSerialGeometry(G4bool serial)
0184 {
0185   if (fSerial == serial) return;
0186   fSerial = serial;
0187   if (!fConstructed) return;
0188   for (G4int i = 0; i < 3; i++) {
0189     if (fSerial) {
0190       fCalorPhysical[i]->SetTranslation(G4ThreeVector(0., 0., G4double(i - 1) * 2. * m));
0191     }
0192     else {
0193       fCalorPhysical[i]->SetTranslation(G4ThreeVector(0., G4double(i - 1) * m, 0.));
0194     }
0195   }
0196 }
0197 
0198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......