Back to home page

EIC code displayed by LXR

 
 

    


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

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 RE05/src/RE05DetectorConstruction.cc
0028 /// \brief Implementation of the RE05DetectorConstruction class
0029 //
0030 
0031 #include "RE05DetectorConstruction.hh"
0032 
0033 #include "RE05CalorimeterParametrisation.hh"
0034 #include "RE05CalorimeterSD.hh"
0035 #include "RE05Field.hh"
0036 #include "RE05MuonSD.hh"
0037 #include "RE05TrackerParametrisation.hh"
0038 #include "RE05TrackerSD.hh"
0039 
0040 #include "G4Box.hh"
0041 #include "G4Colour.hh"
0042 #include "G4Element.hh"
0043 #include "G4ElementTable.hh"
0044 #include "G4FieldManager.hh"
0045 #include "G4LogicalVolume.hh"
0046 #include "G4Material.hh"
0047 #include "G4MaterialTable.hh"
0048 #include "G4PVParameterised.hh"
0049 #include "G4PVPlacement.hh"
0050 #include "G4RotationMatrix.hh"
0051 #include "G4SDManager.hh"
0052 #include "G4SystemOfUnits.hh"
0053 #include "G4ThreeVector.hh"
0054 #include "G4Transform3D.hh"
0055 #include "G4TransportationManager.hh"
0056 #include "G4Tubs.hh"
0057 #include "G4VisAttributes.hh"
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 RE05DetectorConstruction::RE05DetectorConstruction() : G4VUserDetectorConstruction()
0062 {
0063 #include "RE05DetectorParameterDef.icc"
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 RE05DetectorConstruction::~RE05DetectorConstruction() {}
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 void RE05DetectorConstruction::DefineMaterials()
0073 {
0074   //-------------------------------------------------------------------------
0075   // Materials
0076   //-------------------------------------------------------------------------
0077 
0078   G4double a, z, density;
0079   G4int nel;
0080 
0081   G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole);
0082   G4Element* C = new G4Element("Carbon", "C", z = 6., a = 12.01 * g / mole);
0083   G4Element* N = new G4Element("Nitrogen", "N", z = 7., a = 14.01 * g / mole);
0084   G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
0085 
0086   fAir = new G4Material("Air", density = 1.29 * mg / cm3, nel = 2);
0087   fAir->AddElement(N, 70. * perCent);
0088   fAir->AddElement(O, 30. * perCent);
0089 
0090   fLead = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0091 
0092   fAr = new G4Material("ArgonGas", z = 18., a = 39.95 * g / mole, density = 1.782 * mg / cm3);
0093 
0094   fSilicon = new G4Material("Silicon", z = 14., a = 28.09 * g / mole, density = 2.33 * g / cm3);
0095 
0096   fScinti = new G4Material("Scintillator", density = 1.032 * g / cm3, nel = 2);
0097   fScinti->AddElement(C, 9);
0098   fScinti->AddElement(H, 10);
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 G4VPhysicalVolume* RE05DetectorConstruction::Construct()
0104 {
0105   DefineMaterials();
0106 
0107   //-------------------------------------------------------------------------
0108   // Detector geometry
0109   //-------------------------------------------------------------------------
0110 
0111   //------------------------------ experimental hall
0112   G4Box* experimentalHall_box = new G4Box("expHall_b", fExpHall_x, fExpHall_y, fExpHall_z);
0113   G4LogicalVolume* experimentalHall_log =
0114     new G4LogicalVolume(experimentalHall_box, fAir, "expHall_L", 0, 0, 0);
0115   G4VPhysicalVolume* experimentalHall_phys =
0116     new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log, "expHall_P", 0, false, 0);
0117   experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible());
0118 
0119   //------------------------------ tracker
0120   G4VSolid* fTracker_tubs = new G4Tubs("trkTubs_tubs", fTrkTubs_rmin, fTrkTubs_rmax, fTrkTubs_dz,
0121                                        fTrkTubs_sphi, fTrkTubs_dphi);
0122   G4LogicalVolume* fTracker_log = new G4LogicalVolume(fTracker_tubs, fAr, "trackerT_L", 0, 0, 0);
0123   // G4VPhysicalVolume * fTracker_phys =
0124   new G4PVPlacement(0, G4ThreeVector(), fTracker_log, "tracker_phys", experimentalHall_log, false,
0125                     0);
0126   G4VisAttributes* fTracker_logVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0));
0127   fTracker_log->SetVisAttributes(fTracker_logVisAtt);
0128 
0129   //------------------------------ tracker layers
0130   // As an example for Parameterised volume
0131   // dummy values for G4Tubs -- modified by parameterised volume
0132   G4VSolid* trackerLayer_tubs = new G4Tubs("trackerLayer_tubs", fTrkTubs_rmin, fTrkTubs_rmax,
0133                                            fTrkTubs_dz, fTrkTubs_sphi, fTrkTubs_dphi);
0134   G4LogicalVolume* trackerLayer_log =
0135     new G4LogicalVolume(trackerLayer_tubs, fSilicon, "trackerB_L", 0, 0, 0);
0136   G4VPVParameterisation* trackerParam = new RE05TrackerParametrisation;
0137   // dummy value : kXAxis -- modified by parameterised volume
0138   // G4VPhysicalVolume *trackerLayer_phys =
0139   new G4PVParameterised("trackerLayer_phys", trackerLayer_log, fTracker_log, kXAxis, fNotrkLayers,
0140                         trackerParam);
0141   G4VisAttributes* trackerLayer_logVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0));
0142   trackerLayer_logVisAtt->SetForceWireframe(true);
0143   trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
0144 
0145   //------------------------------ calorimeter
0146   G4VSolid* calorimeter_tubs = new G4Tubs("calorimeter_tubs", fCaloTubs_rmin, fCaloTubs_rmax,
0147                                           fCaloTubs_dz, fCaloTubs_sphi, fCaloTubs_dphi);
0148   G4LogicalVolume* calorimeter_log =
0149     new G4LogicalVolume(calorimeter_tubs, fScinti, "caloT_L", 0, 0, 0);
0150   // G4VPhysicalVolume * calorimeter_phys =
0151   new G4PVPlacement(0, G4ThreeVector(), calorimeter_log, "caloM_P", experimentalHall_log, false, 0);
0152   G4VisAttributes* calorimeter_logVisATT = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0153   calorimeter_logVisATT->SetForceWireframe(true);
0154   calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
0155 
0156   //------------------------------- Lead layers
0157   // As an example for Parameterised volume
0158   // dummy values for G4Tubs -- modified by parameterised volume
0159   G4VSolid* caloLayer_tubs = new G4Tubs("caloLayer_tubs", fCaloRing_rmin, fCaloRing_rmax,
0160                                         fCaloRing_dz, fCaloRing_sphi, fCaloRing_dphi);
0161   G4LogicalVolume* caloLayer_log = new G4LogicalVolume(caloLayer_tubs, fLead, "caloR_L", 0, 0, 0);
0162   G4VPVParameterisation* calorimeterParam = new RE05CalorimeterParametrisation;
0163   // dummy value : kXAxis -- modified by parameterised volume
0164   // G4VPhysicalVolume * caloLayer_phys =
0165   new G4PVParameterised("caloLayer_phys", caloLayer_log, calorimeter_log, kXAxis, fNocaloLayers,
0166                         calorimeterParam);
0167   G4VisAttributes* caloLayer_logVisAtt = new G4VisAttributes(G4Colour(0.7, 1.0, 0.0));
0168   caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
0169 
0170   //------------------------------ muon counters
0171   // As an example of CSG volumes with rotation
0172   G4VSolid* muoncounter_box =
0173     new G4Box("muoncounter_box", fMuBox_width, fMuBox_thick, fMuBox_length);
0174   G4LogicalVolume* muoncounter_log =
0175     new G4LogicalVolume(muoncounter_box, fScinti, "mucounter_L", 0, 0, 0);
0176   for (int i = 0; i < fNomucounter; i++) {
0177     G4double phi, x, y, z;
0178     phi = 360. * deg / fNomucounter * i;
0179     x = fMuBox_radius * std::sin(phi);
0180     y = fMuBox_radius * std::cos(phi);
0181     z = 0. * cm;
0182     G4RotationMatrix rm;
0183     rm.rotateZ(phi);
0184     new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(x, y, z)), muoncounter_log, "muoncounter_P",
0185                       experimentalHall_log, false, i);
0186   }
0187   G4VisAttributes* muoncounter_logVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0));
0188   muoncounter_logVisAtt->SetForceWireframe(true);
0189   muoncounter_log->SetVisAttributes(muoncounter_logVisAtt);
0190 
0191   return experimentalHall_phys;
0192 }
0193 
0194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0195 
0196 void RE05DetectorConstruction::ConstructSDandField()
0197 {
0198   //-------------------------------------------------------------------------
0199   // Magnetic field
0200   //-------------------------------------------------------------------------
0201   RE05Field* myField = new RE05Field;
0202   G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
0203   fieldMgr->SetDetectorField(myField);
0204   fieldMgr->CreateChordFinder(myField);
0205 
0206   //------------------------------------------------------------------
0207   // Sensitive Detectors
0208   //------------------------------------------------------------------
0209   G4String trackerSDname = "/mydet/tracker";
0210   RE05TrackerSD* trackerSD = new RE05TrackerSD(trackerSDname);
0211   G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD);
0212   SetSensitiveDetector("trackerB_L", trackerSD);
0213 
0214   G4String muonSDname = "/mydet/muon";
0215   RE05MuonSD* muonSD = new RE05MuonSD(muonSDname);
0216   G4SDManager::GetSDMpointer()->AddNewDetector(muonSD);
0217   SetSensitiveDetector("mucounter_L", muonSD);
0218 }
0219 
0220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......