Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:05:40

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 eventgenerator/HepMC/HepMCEx01/src/ExN04DetectorConstruction.cc
0027 /// \brief Implementation of the ExN04DetectorConstruction class
0028 //
0029 //
0030 
0031 #include "ExN04DetectorConstruction.hh"
0032 
0033 #include "ExN04CalorimeterParametrisation.hh"
0034 #include "ExN04CalorimeterROGeometry.hh"
0035 #include "ExN04CalorimeterSD.hh"
0036 #include "ExN04Field.hh"
0037 #include "ExN04MuonSD.hh"
0038 #include "ExN04TrackerParametrisation.hh"
0039 #include "ExN04TrackerSD.hh"
0040 
0041 #include "G4Box.hh"
0042 #include "G4Colour.hh"
0043 #include "G4Element.hh"
0044 #include "G4FieldManager.hh"
0045 #include "G4LogicalVolume.hh"
0046 #include "G4Material.hh"
0047 #include "G4MaterialTable.hh"
0048 #include "G4NistManager.hh"
0049 #include "G4PVParameterised.hh"
0050 #include "G4PVPlacement.hh"
0051 #include "G4RotationMatrix.hh"
0052 #include "G4SDManager.hh"
0053 #include "G4SystemOfUnits.hh"
0054 #include "G4ThreeVector.hh"
0055 #include "G4Transform3D.hh"
0056 #include "G4TransportationManager.hh"
0057 #include "G4Tubs.hh"
0058 #include "G4VisAttributes.hh"
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 ExN04DetectorConstruction::ExN04DetectorConstruction() : G4VUserDetectorConstruction()
0062 {
0063 #include "ExN04DetectorParameterDef.icc"
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 ExN04DetectorConstruction::~ExN04DetectorConstruction() {}
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 void ExN04DetectorConstruction::DefineMaterials()
0071 {
0072   //-------------------------------------------------------------------------
0073   // Materials
0074   //-------------------------------------------------------------------------
0075   G4NistManager* nistManager = G4NistManager::Instance();
0076   fAir = nistManager->FindOrBuildMaterial("G4_AIR");
0077   fLead = nistManager->FindOrBuildMaterial("G4_Pb");
0078   fSilicon = nistManager->FindOrBuildMaterial("G4_Si");
0079 
0080   G4double a, z, density;
0081   G4int nel;
0082 
0083   // Argon gas
0084   a = 39.95 * g / mole;
0085   density = 1.782e-03 * g / cm3;
0086   fAr = new G4Material("ArgonGas", z = 18., a, density);
0087 
0088   // Scintillator
0089   G4Element* elH = nistManager->FindOrBuildElement("H");
0090   G4Element* elC = nistManager->FindOrBuildElement("C");
0091   fScinti = new G4Material("Scintillator", density = 1.032 * g / cm3, nel = 2);
0092   fScinti->AddElement(elC, 9);
0093   fScinti->AddElement(elH, 10);
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 G4VPhysicalVolume* ExN04DetectorConstruction::Construct()
0098 {
0099   //-------------------------------------------------------------------------
0100   // Magnetic field
0101   //-------------------------------------------------------------------------
0102 
0103   static G4bool fieldIsInitialized = false;
0104   if (!fieldIsInitialized) {
0105     ExN04Field* myField = new ExN04Field;
0106     G4FieldManager* fieldMgr =
0107       G4TransportationManager::GetTransportationManager()->GetFieldManager();
0108     fieldMgr->SetDetectorField(myField);
0109     fieldMgr->CreateChordFinder(myField);
0110     fieldIsInitialized = true;
0111   }
0112 
0113   //-------------------------------------------------------------------------
0114   // Materials
0115   //-------------------------------------------------------------------------
0116   DefineMaterials();
0117 
0118   //-------------------------------------------------------------------------
0119   // Detector geometry
0120   //-------------------------------------------------------------------------
0121 
0122   //------------------------------ experimental hall
0123   G4Box* experimentalHall_box = new G4Box("expHall_b", fexpHall_x, fexpHall_y, fexpHall_z);
0124   G4LogicalVolume* experimentalHall_log =
0125     new G4LogicalVolume(experimentalHall_box, fAir, "expHall_L", 0, 0, 0);
0126   G4VPhysicalVolume* experimentalHall_phys =
0127     new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log, "expHall_P", 0, false, 0);
0128   G4VisAttributes* experimentalHallVisAtt = new G4VisAttributes(G4Colour(1., 1., 1.));
0129   experimentalHallVisAtt->SetForceWireframe(true);
0130   experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
0131 
0132   //------------------------------ tracker
0133   G4VSolid* tracker_tubs = new G4Tubs("trkTubs_tubs", ftrkTubs_rmin, ftrkTubs_rmax, ftrkTubs_dz,
0134                                       ftrkTubs_sphi, ftrkTubs_dphi);
0135   G4LogicalVolume* tracker_log = new G4LogicalVolume(tracker_tubs, fAr, "trackerT_L", 0, 0, 0);
0136   // G4VPhysicalVolume * tracker_phys =
0137   new G4PVPlacement(0, G4ThreeVector(), tracker_log, "tracker_phys", experimentalHall_log, false,
0138                     0);
0139   G4VisAttributes* tracker_logVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0));
0140   tracker_logVisAtt->SetForceWireframe(true);
0141   tracker_log->SetVisAttributes(tracker_logVisAtt);
0142 
0143   //------------------------------ tracker layers
0144   // As an example for Parameterised volume
0145   // dummy values for G4Tubs -- modified by parameterised volume
0146   G4VSolid* trackerLayer_tubs = new G4Tubs("trackerLayer_tubs", ftrkTubs_rmin, ftrkTubs_rmax,
0147                                            ftrkTubs_dz, ftrkTubs_sphi, ftrkTubs_dphi);
0148   G4LogicalVolume* trackerLayer_log =
0149     new G4LogicalVolume(trackerLayer_tubs, fSilicon, "trackerB_L", 0, 0, 0);
0150   G4VPVParameterisation* trackerParam = new ExN04TrackerParametrisation;
0151   // dummy value : kXAxis -- modified by parameterised volume
0152   // G4VPhysicalVolume *trackerLayer_phys =
0153   new G4PVParameterised("trackerLayer_phys", trackerLayer_log, tracker_log, kXAxis, fnotrkLayers,
0154                         trackerParam);
0155   G4VisAttributes* trackerLayer_logVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0));
0156   trackerLayer_logVisAtt->SetForceWireframe(true);
0157   trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
0158 
0159   //------------------------------ calorimeter
0160   G4VSolid* calorimeter_tubs = new G4Tubs("calorimeter_tubs", fcaloTubs_rmin, fcaloTubs_rmax,
0161                                           fcaloTubs_dz, fcaloTubs_sphi, fcaloTubs_dphi);
0162   G4LogicalVolume* calorimeter_log =
0163     new G4LogicalVolume(calorimeter_tubs, fScinti, "caloT_L", 0, 0, 0);
0164   // G4VPhysicalVolume * calorimeter_phys =
0165   new G4PVPlacement(0, G4ThreeVector(), calorimeter_log, "caloM_P", experimentalHall_log, false, 0);
0166   G4VisAttributes* calorimeter_logVisATT = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0167   calorimeter_logVisATT->SetForceWireframe(true);
0168   calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
0169 
0170   //------------------------------- Lead layers
0171   // As an example for Parameterised volume
0172   // dummy values for G4Tubs -- modified by parameterised volume
0173   G4VSolid* caloLayer_tubs = new G4Tubs("caloLayer_tubs", fcaloRing_rmin, fcaloRing_rmax,
0174                                         fcaloRing_dz, fcaloRing_sphi, fcaloRing_dphi);
0175   G4LogicalVolume* caloLayer_log = new G4LogicalVolume(caloLayer_tubs, fLead, "caloR_L", 0, 0, 0);
0176   G4VPVParameterisation* calorimeterParam = new ExN04CalorimeterParametrisation;
0177   // dummy value : kXAxis -- modified by parameterised volume
0178   // G4VPhysicalVolume * caloLayer_phys =
0179   new G4PVParameterised("caloLayer_phys", caloLayer_log, calorimeter_log, kXAxis, fnocaloLayers,
0180                         calorimeterParam);
0181   G4VisAttributes* caloLayer_logVisAtt = new G4VisAttributes(G4Colour(0.7, 1.0, 0.0));
0182   caloLayer_logVisAtt->SetForceWireframe(true);
0183   caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
0184 
0185   //------------------------------ muon counters
0186   // As an example of CSG volumes with rotation
0187   G4VSolid* muoncounter_box =
0188     new G4Box("muoncounter_box", fmuBox_width, fmuBox_thick, fmuBox_length);
0189   G4LogicalVolume* muoncounter_log =
0190     new G4LogicalVolume(muoncounter_box, fScinti, "mucounter_L", 0, 0, 0);
0191   G4VPhysicalVolume* muoncounter_phys;
0192   for (G4int i = 0; i < fnomucounter; i++) {
0193     G4double phi, x, y, z;
0194     phi = 360. * deg / fnomucounter * i;
0195     x = fmuBox_radius * std::sin(phi);
0196     y = fmuBox_radius * std::cos(phi);
0197     z = 0. * cm;
0198     G4RotationMatrix rm;
0199     rm.rotateZ(phi);
0200     muoncounter_phys = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(x, y, z)), muoncounter_log,
0201                                          "muoncounter_P", experimentalHall_log, false, i);
0202   }
0203   G4VisAttributes* muoncounter_logVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0));
0204   muoncounter_logVisAtt->SetForceWireframe(true);
0205   muoncounter_log->SetVisAttributes(muoncounter_logVisAtt);
0206 
0207   //------------------------------------------------------------------
0208   // Sensitive Detector
0209   //------------------------------------------------------------------
0210 
0211   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0212 
0213   G4String trackerSDname = "/mydet/tracker";
0214   ExN04TrackerSD* trackerSD = new ExN04TrackerSD(trackerSDname);
0215   SDman->AddNewDetector(trackerSD);
0216   trackerLayer_log->SetSensitiveDetector(trackerSD);
0217 
0218   G4String calorimeterSDname = "/mydet/calorimeter";
0219   ExN04CalorimeterSD* calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname);
0220   G4String ROgeometryName = "CalorimeterROGeom";
0221   G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName);
0222   calRO->BuildROGeometry();
0223   calorimeterSD->SetROgeometry(calRO);
0224   SDman->AddNewDetector(calorimeterSD);
0225   calorimeter_log->SetSensitiveDetector(calorimeterSD);
0226 
0227   G4String muonSDname = "/mydet/muon";
0228   ExN04MuonSD* muonSD = new ExN04MuonSD(muonSDname);
0229   SDman->AddNewDetector(muonSD);
0230   muoncounter_log->SetSensitiveDetector(muonSD);
0231 
0232   //------------------------------------------------------------------
0233   // Digitizer modules
0234   //------------------------------------------------------------------
0235 
0236   return experimentalHall_phys;
0237 }