Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 07:51:29

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 RE01DetectorConstruction.cc
0027 /// \brief Implementation of the RE01DetectorConstruction class
0028 
0029 #include "RE01DetectorConstruction.hh"
0030 
0031 #include "RE01CalorimeterParametrisation.hh"
0032 #include "RE01Field.hh"
0033 #include "RE01RegionInformation.hh"
0034 #include "RE01TrackerParametrisation.hh"
0035 #include "RE01TrackerSD.hh"
0036 
0037 #include "G4Box.hh"
0038 #include "G4Colour.hh"
0039 #include "G4Element.hh"
0040 #include "G4ElementTable.hh"
0041 #include "G4FieldManager.hh"
0042 #include "G4LogicalVolume.hh"
0043 #include "G4Material.hh"
0044 #include "G4MaterialTable.hh"
0045 #include "G4NistManager.hh"
0046 #include "G4PVParameterised.hh"
0047 #include "G4PVPlacement.hh"
0048 #include "G4Region.hh"
0049 #include "G4RegionStore.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 RE01DetectorConstruction::RE01DetectorConstruction() : G4VUserDetectorConstruction()
0061 {
0062 #include "RE01DetectorParameterDef.icc"
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 RE01DetectorConstruction::~RE01DetectorConstruction()
0067 {
0068   ;
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 G4VPhysicalVolume* RE01DetectorConstruction::Construct()
0073 {
0074   //-------------------------------------------------------------------------
0075   // Materials
0076   //-------------------------------------------------------------------------
0077 
0078   G4double a, iz, density;
0079   G4String name, symbol;
0080   G4int nel;
0081 
0082   a = 1.01 * g / mole;
0083   G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", iz = 1., a);
0084 
0085   a = 12.01 * g / mole;
0086   G4Element* elC = new G4Element(name = "Carbon", symbol = "C", iz = 6., a);
0087 
0088   //  Material Information imported from NIST database.
0089   G4NistManager* NISTman = G4NistManager::Instance();
0090   G4Material* air = NISTman->FindOrBuildMaterial("G4_AIR");
0091   G4Material* lead = NISTman->FindOrBuildMaterial("G4_Pb");
0092   G4Material* arGas = NISTman->FindOrBuildMaterial("G4_Ar");
0093   G4Material* silicon = NISTman->FindOrBuildMaterial("G4_Si");
0094 
0095   density = 1.032 * g / cm3;
0096   G4Material* scinti = new G4Material(name = "Scintillator", density, nel = 2);
0097   scinti->AddElement(elC, 9);
0098   scinti->AddElement(elH, 10);
0099 
0100   //-------------------------------------------------------------------------
0101   // Detector geometry
0102   //-------------------------------------------------------------------------
0103   //------------------------------ experimental hall
0104   G4Box* experimentalHall_box = new G4Box("expHall_b", fExpHall_x, fExpHall_y, fExpHall_z);
0105   G4LogicalVolume* experimentalHall_log =
0106     new G4LogicalVolume(experimentalHall_box, air, "expHall_L", 0, 0, 0);
0107   G4VPhysicalVolume* experimentalHall_phys =
0108     new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log, "expHall_P", 0, false, 0);
0109   G4VisAttributes* experimentalHallVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0110   experimentalHallVisAtt->SetForceWireframe(true);
0111   experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
0112   G4Region* defaultRegion = (*(G4RegionStore::GetInstance()))[0];
0113   RE01RegionInformation* defaultRInfo = new RE01RegionInformation();
0114   defaultRInfo->SetWorld();
0115   defaultRInfo->Print();
0116   defaultRegion->SetUserInformation(defaultRInfo);
0117 
0118   //------------------------------ tracker
0119   G4VSolid* tracker_tubs = new G4Tubs("trkTubs_tubs", fTrkTubs_rmin, fTrkTubs_rmax, fTrkTubs_dz,
0120                                       fTrkTubs_sphi, fTrkTubs_dphi);
0121   G4LogicalVolume* tracker_log = new G4LogicalVolume(tracker_tubs, arGas, "trackerT_L", 0, 0, 0);
0122   // G4VPhysicalVolume * tracker_phys =
0123   new G4PVPlacement(0, G4ThreeVector(), tracker_log, "tracker_phys", experimentalHall_log, false,
0124                     0);
0125   G4VisAttributes* tracker_logVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0));
0126   tracker_logVisAtt->SetForceWireframe(true);
0127   tracker_log->SetVisAttributes(tracker_logVisAtt);
0128   G4Region* trackerRegion = new G4Region("TrackerRegion");
0129   RE01RegionInformation* trackerInfo = new RE01RegionInformation();
0130   trackerInfo->SetTracker();
0131   trackerRegion->SetUserInformation(trackerInfo);
0132   tracker_log->SetRegion(trackerRegion);
0133   trackerRegion->AddRootLogicalVolume(tracker_log);
0134 
0135   //------------------------------ tracker layers
0136   // As an example for Parameterised volume
0137   // dummy values for G4Tubs -- modified by parameterised volume
0138   G4VSolid* trackerLayer_tubs = new G4Tubs("trackerLayer_tubs", fTrkTubs_rmin, fTrkTubs_rmax,
0139                                            fTrkTubs_dz, fTrkTubs_sphi, fTrkTubs_dphi);
0140   fTrackerLayer_log = new G4LogicalVolume(trackerLayer_tubs, silicon, "trackerB_L", 0, 0, 0);
0141   G4VPVParameterisation* trackerParam = new RE01TrackerParametrisation;
0142   // dummy value : kXAxis -- modified by parameterised volume
0143   // G4VPhysicalVolume *trackerLayer_phys =
0144   new G4PVParameterised("trackerLayer_phys", fTrackerLayer_log, tracker_log, kXAxis, fNotrkLayers,
0145                         trackerParam);
0146   G4VisAttributes* trackerLayer_logVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0));
0147   trackerLayer_logVisAtt->SetForceWireframe(true);
0148   fTrackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
0149 
0150   //------------------------------ calorimeter
0151   G4VSolid* calorimeter_tubs = new G4Tubs("calorimeter_tubs", fCaloTubs_rmin, fCaloTubs_rmax,
0152                                           fCaloTubs_dz, fCaloTubs_sphi, fCaloTubs_dphi);
0153   fCalorimeter_log = new G4LogicalVolume(calorimeter_tubs, scinti, "caloT_L", 0, 0, 0);
0154   // G4VPhysicalVolume * calorimeter_phys =
0155   new G4PVPlacement(0, G4ThreeVector(), fCalorimeter_log, "caloM_P", experimentalHall_log, false,
0156                     0);
0157   G4VisAttributes* calorimeter_logVisATT = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0158   calorimeter_logVisATT->SetForceWireframe(true);
0159   fCalorimeter_log->SetVisAttributes(calorimeter_logVisATT);
0160   G4Region* calorimeterRegion = new G4Region("CalorimeterRegion");
0161   RE01RegionInformation* calorimeterInfo = new RE01RegionInformation();
0162   calorimeterInfo->SetCalorimeter();
0163   calorimeterRegion->SetUserInformation(calorimeterInfo);
0164   fCalorimeter_log->SetRegion(calorimeterRegion);
0165   calorimeterRegion->AddRootLogicalVolume(fCalorimeter_log);
0166 
0167   //------------------------------- Lead layers
0168   // As an example for Parameterised volume
0169   // dummy values for G4Tubs -- modified by parameterised volume
0170   G4VSolid* caloLayer_tubs = new G4Tubs("caloLayer_tubs", fCaloRing_rmin, fCaloRing_rmax,
0171                                         fCaloRing_dz, fCaloRing_sphi, fCaloRing_dphi);
0172   G4LogicalVolume* caloLayer_log = new G4LogicalVolume(caloLayer_tubs, lead, "caloR_L", 0, 0, 0);
0173   G4VPVParameterisation* calorimeterParam = new RE01CalorimeterParametrisation;
0174   // dummy value : kXAxis -- modified by parameterised volume
0175   // G4VPhysicalVolume * caloLayer_phys =
0176   new G4PVParameterised("caloLayer_phys", caloLayer_log, fCalorimeter_log, kXAxis, fNocaloLayers,
0177                         calorimeterParam);
0178   G4VisAttributes* caloLayer_logVisAtt = new G4VisAttributes(G4Colour(0.7, 1.0, 0.0));
0179   caloLayer_logVisAtt->SetForceWireframe(true);
0180   caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
0181 
0182   return experimentalHall_phys;
0183 }
0184 
0185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0186 void RE01DetectorConstruction::ConstructSDandField()
0187 {
0188   //------------------------------------------------------------------
0189   // Sensitive Detector
0190   //------------------------------------------------------------------
0191 
0192   G4String trackerSDname = "/mydet/tracker";
0193   RE01TrackerSD* trackerSD = new RE01TrackerSD(trackerSDname);
0194   G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD);
0195   SetSensitiveDetector(fTrackerLayer_log, trackerSD);
0196 
0197   // N.B. Calorimeter SD is defined in the parallel world.
0198 
0199   //-------------------------------------------------------------------------
0200   // Magnetic field
0201   //-------------------------------------------------------------------------
0202 
0203   RE01Field* myField = new RE01Field;
0204   G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
0205   fieldMgr->SetDetectorField(myField);
0206   fieldMgr->CreateChordFinder(myField);
0207 }