Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:08

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