Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 08:29:07

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 H02DetectorConstruction.cc
0027 /// \brief Implementation of the H02DetectorConstruction class
0028 
0029 #include "H02DetectorConstruction.hh"
0030 
0031 #include "H02Field.hh"
0032 #include "H02MuonSD.hh"
0033 
0034 #include "G4Box.hh"
0035 #include "G4ChordFinder.hh"
0036 #include "G4Element.hh"
0037 #include "G4FieldManager.hh"
0038 #include "G4LogicalVolume.hh"
0039 #include "G4Material.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4SDManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4TransportationManager.hh"
0045 #include "G4Tubs.hh"
0046 #include "G4VisAttributes.hh"
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 // constants (detector parameters)
0050 // [experimental hall]
0051 static const G4double R_EXPHALL = 5. * m;
0052 static const G4double DZ_EXPHALL = 10. * m;
0053 
0054 // [calorimeter]
0055 static const G4double RIN_BARREL_CAL = 2. * m;
0056 static const G4double ROUT_BARREL_CAL = 3. * m;
0057 static const G4double DZ_BARREL_CAL = 5. * m;
0058 
0059 static const G4double RIN_ENDCAP_CAL = 1. * m;
0060 static const G4double ROUT_ENDCAP_CAL = 3. * m;
0061 static const G4double DZ_ENDCAP_CAL = 0.5 * m;
0062 
0063 // [muon system]
0064 static const G4double RIN_BARREL_MUON = 4.3 * m;
0065 // static const G4double ROUT_BARREL_MUON= 4.5*m;
0066 static const G4double DX_BARREL_MUON = RIN_BARREL_MUON * std::cos(67.5 * deg) - 5. * cm;
0067 static const G4double DY_BARREL_MUON = 10. * cm;
0068 static const G4double DZ_BARREL_MUON = 7. * m;
0069 
0070 static const G4double RIN_ENDCAP_MUON = 1. * m;
0071 static const G4double ROUT_ENDCAP_MUON = 4.5 * m;
0072 static const G4double DZ_ENDCAP_MUON = 10. * cm;
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 H02DetectorConstruction::H02DetectorConstruction() : G4VUserDetectorConstruction() {}
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 H02DetectorConstruction::~H02DetectorConstruction() {}
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 G4VPhysicalVolume* H02DetectorConstruction::Construct()
0082 {
0083   // ==============================================================
0084   // Materials
0085   // ==============================================================
0086 
0087   G4NistManager* nistManager = G4NistManager::Instance();
0088   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0089   G4Material* lead = nistManager->FindOrBuildMaterial("G4_Pb");
0090 
0091   // Argon gas
0092   G4double a, z, density;
0093   a = 39.95 * g / mole;
0094   density = 1.782e-03 * g / cm3;
0095   G4Material* ar = new G4Material("ArgonGas", z = 18., a, density);
0096 
0097   // ==============================================================
0098   // Experimental Hall (world)
0099   // ==============================================================
0100   G4Tubs* expHallSolid = new G4Tubs("EXP_HALL", 0., R_EXPHALL, DZ_EXPHALL, 0., 360. * deg);
0101 
0102   G4LogicalVolume* expHallLV = new G4LogicalVolume(expHallSolid, air, "EXP_HALL_LV");
0103 
0104   // visualization attributes
0105   G4VisAttributes* expHallVisAtt = new G4VisAttributes(false, G4Colour(1., 1., 1.));
0106   // expHallVisAtt-> SetForceWireframe(TRUE);
0107   expHallLV->SetVisAttributes(expHallVisAtt);
0108 
0109   G4PVPlacement* expHall =
0110     new G4PVPlacement(0, G4ThreeVector(), "EXP_HALL_PV", expHallLV, 0, FALSE, 0);
0111   //            ...                                    MV, MANY, copy#
0112 
0113   // ==============================================================
0114   // each detector component
0115   // ==============================================================
0116   // calorimeter system
0117   G4Tubs* barrelCalSolid =
0118     new G4Tubs("BARREL_CAL", RIN_BARREL_CAL, ROUT_BARREL_CAL, DZ_BARREL_CAL, 0., 360. * deg);
0119 
0120   G4Tubs* endcapCalSolid =
0121     new G4Tubs("ENDCAP_CAL", RIN_ENDCAP_CAL, ROUT_ENDCAP_CAL, DZ_ENDCAP_CAL, 0., 360. * deg);
0122 
0123   G4LogicalVolume* barrelCalLV = new G4LogicalVolume(barrelCalSolid, lead, "BARREL_CAL_LV");
0124 
0125   G4LogicalVolume* endcapCalLV = new G4LogicalVolume(endcapCalSolid, lead, "ENDCAP_CAL_LV");
0126 
0127   G4VisAttributes* calVisAtt = new G4VisAttributes(true, G4Colour(0., 1., 1.));
0128   barrelCalLV->SetVisAttributes(calVisAtt);
0129   endcapCalLV->SetVisAttributes(calVisAtt);
0130 
0131   // G4PVPlacement* barrelCal=
0132   new G4PVPlacement(0, G4ThreeVector(), "BARREL_CAL_PV", barrelCalLV, expHall, FALSE, 0);
0133 
0134   G4ThreeVector posCal(0., 0., 6. * m);
0135   // G4PVPlacement* endcapCal1=
0136   new G4PVPlacement(0, posCal, "ENDCAP_CAL_PV", endcapCalLV, expHall, FALSE, 0);
0137 
0138   // G4PVPlacement* endcapCal2=
0139   new G4PVPlacement(0, -posCal, "ENDCAP_CAL_PV", endcapCalLV, expHall, FALSE, 1);
0140 
0141   // muon system
0142   G4Box* barrelMuonSolid = new G4Box("BARREL_MUON", DX_BARREL_MUON, DY_BARREL_MUON, DZ_BARREL_MUON);
0143   G4Tubs* endcapMuonSolid =
0144     new G4Tubs("ENDCAP_MUON", RIN_ENDCAP_MUON, ROUT_ENDCAP_MUON, DZ_ENDCAP_MUON, 0., 360. * deg);
0145 
0146   G4LogicalVolume* barrelMuonLV = new G4LogicalVolume(barrelMuonSolid, ar, "BARREL_MUON_LV");
0147 
0148   G4LogicalVolume* endcapMuonLV = new G4LogicalVolume(endcapMuonSolid, ar, "ENDCAP_MUON_LV");
0149 
0150   G4VisAttributes* muonVisAtt = new G4VisAttributes(true, G4Colour(1., 1., 0.5));
0151   // muonVisAtt-> SetForceWireframe(TRUE);
0152   barrelMuonLV->SetVisAttributes(muonVisAtt);
0153   endcapMuonLV->SetVisAttributes(muonVisAtt);
0154 
0155   const G4double dangle = 45. * deg;
0156   G4ThreeVector posM(RIN_BARREL_MUON + DY_BARREL_MUON / 2., 0., 0.);
0157   G4RotationMatrix* rotM = new G4RotationMatrix;
0158   rotM->rotateZ(90. * deg);
0159 
0160   for (G4int k = 0; k < 8; k++) {
0161     G4Transform3D transformM(*rotM, posM);
0162     new G4PVPlacement(transformM, "BARREL_MUON_PV", barrelMuonLV, expHall, FALSE, k);
0163     rotM->rotateZ(dangle);
0164     posM.rotateZ(dangle);
0165   }
0166 
0167   G4ThreeVector posMuon(0., 0., 8. * m);
0168   // G4PVPlacement* endcapMuon1=
0169   new G4PVPlacement(0, posMuon, "ENDCAP_MUON_PV", endcapMuonLV, expHall, FALSE, 0);
0170 
0171   // G4PVPlacement* endcapMuon2=
0172   new G4PVPlacement(0, -posMuon, "ENDCAP_MUON_PV", endcapMuonLV, expHall, FALSE, 1);
0173 
0174   // sensitive Detectors
0175   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0176 
0177   G4String muonSDname = "/mydet/muon";
0178   H02MuonSD* muonSD = new H02MuonSD(muonSDname);
0179   SDman->AddNewDetector(muonSD);
0180   barrelMuonLV->SetSensitiveDetector(muonSD);
0181   endcapMuonLV->SetSensitiveDetector(muonSD);
0182 
0183   // magnetic field
0184   H02Field* myfield = new H02Field;
0185   G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
0186   fieldMgr->SetDetectorField(myfield);
0187   fieldMgr->CreateChordFinder(myfield);
0188 
0189   return expHall;
0190 }