Back to home page

EIC code displayed by LXR

 
 

    


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

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