Back to home page

EIC code displayed by LXR

 
 

    


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

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