Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:29:23

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 ExErrorDetectorConstruction.cc
0027 /// \brief Implementation of the ExErrorDetectorConstruction class
0028 
0029 #include "ExErrorDetectorConstruction.hh"
0030 
0031 #include "ExErrorDetectorMessenger.hh"
0032 #include "ExErrorMagneticField.hh"
0033 
0034 #include "G4Box.hh"
0035 #include "G4Colour.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4PVPlacement.hh"
0039 #include "G4PVReplica.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4UserLimits.hh"
0042 #include "G4VisAttributes.hh"
0043 #include "G4ios.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 ExErrorDetectorConstruction::ExErrorDetectorConstruction()
0047   : G4VUserDetectorConstruction(),
0048     fXBEAM(5. * cm),
0049     fXCDET(20. * cm),
0050     fXECAL(40. * cm),
0051     fXSOLN(10. * cm),
0052     fXHCAL(100. * cm),
0053     fXMUON(50. * cm),
0054     fNdivECAL(40. / 10.),
0055     fNdivHCAL(100. / 10.),
0056     fYZLength(50. * cm),
0057     fXHalfWorldLength(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON),
0058     fUserLimits(0),
0059     fMagField(0),
0060     fDetectorMessenger(0)
0061 {
0062   // create UserLimits
0063   fUserLimits = new G4UserLimits();
0064 
0065   fMagField =
0066     new ExErrorMagneticField(G4ThreeVector(0. * kilogauss, 0. * kilogauss, -1. * kilogauss));
0067   fDetectorMessenger = new ExErrorDetectorMessenger(this);
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 ExErrorDetectorConstruction::~ExErrorDetectorConstruction()
0072 {
0073   delete fMagField;
0074   delete fDetectorMessenger;
0075 }
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 G4VPhysicalVolume* ExErrorDetectorConstruction::Construct()
0079 {
0080   //--------- Material definition ---------
0081 
0082   // Vacuum
0083   /*  a = 1.*g/mole;
0084   density = 1.E-9*g/cm3;
0085   G4Material* Vacuum = new G4Material(name="Vacuum", z=1., a, density);
0086   */
0087 
0088   G4NistManager* nistMgr = G4NistManager::Instance();
0089   G4Material* air = nistMgr->FindOrBuildMaterial("G4_AIR");
0090   // Al
0091   G4Material* al = nistMgr->FindOrBuildMaterial("G4_Al");
0092   // Fe
0093   G4Material* fe = nistMgr->FindOrBuildMaterial("G4_Fe");
0094   // Cu
0095   G4Material* cu = nistMgr->FindOrBuildMaterial("G4_Cu");
0096 
0097   // Print all the materials defined.
0098   //
0099   G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
0100   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0101 
0102   //--- Sizes of the principal geometrical components (solids)  --- (half lengths)
0103   // double fXBEAM  = 5.*2.*cm;
0104   // double fXCDET  = 90.*cm;
0105   // double fXECAL  = 40.*cm;
0106   // double fXSOLN  = 10.*cm;
0107   // double fXHCAL  = 100.*cm;
0108   // double fXMUON  = 50.*cm;
0109   // double fNdivECAL  = 10;
0110   // double fNdivHCAL  = 10;
0111   // double fYZLength = 100.*cm;
0112 
0113   //  double fXWorldLength= fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON;
0114 
0115   //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
0116 
0117   //------------------------------
0118   // World
0119   //------------------------------
0120   //-  G4double HalfWorldLength = fXWorldLength;
0121   G4cout << " HalfWorldLength " << fXHalfWorldLength << G4endl;
0122 
0123   G4Box* solidWorld = new G4Box("world", fXHalfWorldLength, fYZLength, fYZLength);
0124   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, air, "World", 0, 0, 0);
0125   //  Must place the World Physical volume unrotated at (0,0,0).
0126   //
0127   G4VPhysicalVolume* physiWorld = new G4PVPlacement(0,  // no rotation
0128                                                     G4ThreeVector(),  // at (0,0,0)
0129                                                     "World",  // its name
0130                                                     logicWorld,  // its logical volume
0131                                                     0,  // its mother  volume
0132                                                     false,  // no boolean operations
0133                                                     0);  // no field specific to volum
0134 
0135   //------------------------------
0136   // BEAM
0137   //------------------------------
0138   G4Box* solidBEAM = new G4Box("BEAM", fXBEAM, fYZLength, fYZLength);
0139   G4LogicalVolume* logicBEAM = new G4LogicalVolume(solidBEAM, air, "BEAM", 0, 0, 0);
0140   G4ThreeVector positionBEAM = G4ThreeVector(0., 0., 0.);
0141   // G4VPhysicalVolume* physiBEAM =
0142   new G4PVPlacement(0,  // no rotation
0143                     positionBEAM,  // at (x,y,z)
0144                     "BEAM",  // its name
0145                     logicBEAM,  // its logical volume
0146                     physiWorld,  // its mother  volume
0147                     false,  // no boolean operations
0148                     0);  // no particular field
0149 
0150   //------------------------------
0151   // CDET (Central DETector)
0152   //------------------------------
0153   G4ThreeVector positionCdet = G4ThreeVector(fXBEAM + fXCDET / 2., 0., 0.);
0154   G4Box* solidCDET = new G4Box("CDET", fXCDET / 2., fYZLength, fYZLength);
0155   G4LogicalVolume* logicCDET = new G4LogicalVolume(solidCDET, air, "Cdet", 0, 0, 0);
0156   //  G4VPhysicalVolume* physiCDET =
0157   new G4PVPlacement(0,  // no rotation
0158                     positionCdet,  // at (x,y,z)
0159                     "CDET",  // its name
0160                     logicCDET,  // its logical volume
0161                     physiWorld,  // its mother  volume
0162                     false,  // no boolean operations
0163                     0);  // no particular field
0164 
0165   //------------------------------
0166   // ECAL
0167   //------------------------------
0168   G4ThreeVector positionECAL = G4ThreeVector(fXBEAM + fXCDET + fXECAL / 2., 0., 0.);
0169   G4Box* solidECAL = new G4Box("ECAL", fXECAL / 2., fYZLength, fYZLength);
0170   G4LogicalVolume* logicECAL = new G4LogicalVolume(solidECAL, cu, "ECAL", 0, 0, 0);
0171   G4VPhysicalVolume* physiECAL = new G4PVPlacement(0,  // no rotation
0172                                                    positionECAL,  // at (x,y,z)
0173                                                    "ECAL",  // its name
0174                                                    logicECAL,  // its logical volume
0175                                                    physiWorld,  // its mother  volume
0176                                                    false,  // no boolean operations
0177                                                    0);  // no particular field
0178   //--------- Divide it
0179   G4Box* solidECALdiv = new G4Box("ECAL", fXECAL / 2. / fNdivECAL, fYZLength, fYZLength);
0180   G4LogicalVolume* logicECALdiv = new G4LogicalVolume(solidECALdiv, cu, "ECALdiv", 0, 0, 0);
0181   new G4PVReplica("DVEC", logicECALdiv, physiECAL, kXAxis, G4int(fNdivECAL), fXECAL / fNdivECAL);
0182 
0183   //------------------------------
0184   // SOLN
0185   //------------------------------
0186   G4ThreeVector positionSOLN = G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN / 2., 0., 0.);
0187   G4Box* solidSOLN = new G4Box("SOLN", fXSOLN / 2., fYZLength, fYZLength);
0188   G4LogicalVolume* logicSOLN = new G4LogicalVolume(solidSOLN, al, "SOLN", 0, 0, 0);
0189   new G4PVPlacement(0,  // no rotation
0190                     positionSOLN,  // at (x,y,z)
0191                     "SOLN",  // its name
0192                     logicSOLN,  // its logical volume
0193                     physiWorld,  // its mother  volume
0194                     false,  // no boolean operations
0195                     0);  // no particular field
0196 
0197   //------------------------------
0198   // HCAL
0199   //------------------------------
0200   G4ThreeVector positionHCAL =
0201     G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL / 2., 0., 0.);
0202   G4Box* solidHCAL = new G4Box("HCAL", fXHCAL / 2., fYZLength, fYZLength);
0203   G4LogicalVolume* logicHCAL = new G4LogicalVolume(solidHCAL, fe, "HCAL", 0, 0, 0);
0204   G4VPhysicalVolume* physiHCAL = new G4PVPlacement(0,  // no rotation
0205                                                    positionHCAL,  // at (x,y,z)
0206                                                    "HCAL",  // its name
0207                                                    logicHCAL,  // its logical volume
0208                                                    physiWorld,  // its mother  volume
0209                                                    false,  // no boolean operations
0210                                                    0);  // no particular field
0211   //--------- Divide it
0212   G4Box* solidHCALdiv = new G4Box("HCAL", fXHCAL / 2. / fNdivHCAL, fYZLength, fYZLength);
0213   G4LogicalVolume* logicHCALdiv = new G4LogicalVolume(solidHCALdiv, fe, "HCALdiv", 0, 0, 0);
0214   new G4PVReplica("DVEH", logicHCALdiv, physiHCAL, kXAxis, G4int(fNdivHCAL), fXHCAL / fNdivHCAL);
0215 
0216   //------------------------------
0217   // MUON
0218   //------------------------------
0219   G4ThreeVector positionMUON =
0220     G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON / 2., 0., 0.);
0221   G4Box* solidMUON = new G4Box("MUON", fXMUON / 2., fYZLength, fYZLength);
0222   G4LogicalVolume* logicMUON = new G4LogicalVolume(solidMUON, air, "MUON", 0, 0, 0);
0223   new G4PVPlacement(0,  // no rotation
0224                     positionMUON,  // at (x,y,z)
0225                     "MUON",  // its name
0226                     logicMUON,  // its logical volume
0227                     physiWorld,  // its mother  volume
0228                     false,  // no boolean operations
0229                     0);  // no particular field
0230 
0231   G4VisAttributes* worldVisAtt = new G4VisAttributes(0);
0232   logicWorld->SetVisAttributes(worldVisAtt);
0233   return physiWorld;
0234 }
0235 
0236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0237 void ExErrorDetectorConstruction::SetMagField(G4double fieldValue)
0238 {
0239   fMagField->SetFieldValue(fieldValue);
0240 }