Back to home page

EIC code displayed by LXR

 
 

    


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

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