Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:26:58

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 DetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 //
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0030 
0031 #include "DetectorConstruction.hh"
0032 
0033 #include "G4RunManager.hh"
0034 #include "G4NistManager.hh"
0035 #include "G4Box.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4RegionStore.hh"
0038 #include "G4VisAttributes.hh"
0039 #include "PrimaryGeneratorAction.hh"
0040 #include <CLHEP/Units/SystemOfUnits.h>
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 G4VPhysicalVolume* DetectorConstruction::Construct()
0045 {
0046     //Check overlap option
0047     G4bool checkOverlaps = true;
0048 
0049     //Materials
0050     G4NistManager* nist = G4NistManager::Instance();
0051     G4Material* world_mat = nist->FindOrBuildMaterial("G4_Galactic");
0052     G4Material* silicon = nist->FindOrBuildMaterial("G4_Si");
0053 
0054     //World
0055     G4Box* solidWorld = new G4Box("World", 0.2*CLHEP::m, 0.2*CLHEP::m, 0.3*CLHEP::m);
0056     G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, world_mat, "World");  
0057     G4VPhysicalVolume* physWorld = new G4PVPlacement
0058                                     (0,                    // no rotation
0059                                     G4ThreeVector(),       // centre position
0060                                     logicWorld,            // its logical volume
0061                                     "World",               // its name
0062                                     0,                     // its mother volume
0063                                     false,                 // no boolean operation
0064                                     0,                     // copy number
0065                                     checkOverlaps);        // overlaps checking
0066     logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
0067 
0068 
0069     // --------------- Crystal ------------------------------------
0070 
0071     //Select crystal material
0072     fCrystalMaterial = nist->FindOrBuildMaterial("G4_W");
0073 
0074     //Setting crystal rotation angle (also the angle of crystal planes vs the beam)
0075     //Crystal rotation angle (also the angle of crystal planes vs the beam)
0076     G4double angleX = 0.*1e-6; //rad
0077     G4RotationMatrix* crystalRotationMatrix = new G4RotationMatrix;
0078     crystalRotationMatrix->rotateY(-angleX);
0079 
0080     //setting crystal dimensions
0081     /*at high energies the electromagnetic shower in
0082       oriented tungsten should behave similarly to the
0083       e.m. shower in several times thicker amorphous tungsten
0084       (several times reduction of the effective radiation length)*/
0085     G4ThreeVector crystalSize = G4ThreeVector(10.*CLHEP::mm,
0086                                               10.*CLHEP::mm,
0087                                               0.1*CLHEP::mm);
0088 
0089     //Setting crystal position
0090     G4ThreeVector posCrystal = G4ThreeVector(0., 0., crystalSize.z()/2.);
0091 
0092     //crystal volume
0093     G4Box* solidCrystal = new G4Box("Crystal",
0094                                     crystalSize.x()/2,
0095                                     crystalSize.y()/2,
0096                                     crystalSize.z()/2.);
0097     
0098     fLogicCrystal = new G4LogicalVolume(solidCrystal,
0099                                        fCrystalMaterial,
0100                                        "Crystal");
0101     new G4PVPlacement(crystalRotationMatrix,
0102                       posCrystal,
0103                       fLogicCrystal,
0104                       "Crystal",
0105                       logicWorld,
0106                       false,
0107                       0,
0108                       checkOverlaps);
0109     
0110     //crystal region (necessary for the FastSim model)
0111     G4Region* regionCh = new G4Region("Crystal");
0112     regionCh->AddRootLogicalVolume(fLogicCrystal);
0113 
0114     //visualization attributes
0115     G4VisAttributes* crystalVisAttribute =
0116         new G4VisAttributes(G4Colour(1., 0., 0.));
0117     crystalVisAttribute->SetForceSolid(true);
0118     fLogicCrystal->SetVisAttributes(crystalVisAttribute);
0119         
0120     //print crystal info
0121     G4cout << "Crystal size: " << crystalSize.x()/CLHEP::mm
0122            << " " << crystalSize.y()/CLHEP::mm
0123            << " " << crystalSize.z()/CLHEP::mm << " mm3" << G4endl;
0124     G4cout << "Crystal angleX: " << angleX << " rad" << G4endl;
0125 
0126     // --------------- Detector -----------------------------------
0127     //Setting detector position
0128     G4ThreeVector posDetector = G4ThreeVector(0, 0, 0.1*CLHEP::m);
0129 
0130     //particle detector volume
0131     G4Box* detector = new G4Box("Detector",
0132                                 10*CLHEP::cm/2,
0133                                 10*CLHEP::cm/2,
0134                                 0.3*CLHEP::mm/2);
0135     
0136     G4LogicalVolume* logicDetector = new G4LogicalVolume(detector,
0137                                                          silicon,
0138                                                          "Detector");
0139     new G4PVPlacement(0, 
0140                       posDetector, 
0141                       logicDetector,
0142                       "Detector", 
0143                       logicWorld, 
0144                       false, 
0145                       0, 
0146                       checkOverlaps);
0147 
0148     //visualization attributes
0149     G4VisAttributes* detectorVisAttribute =
0150         new G4VisAttributes(G4Colour(0., 0., 1));
0151     detectorVisAttribute->SetForceSolid(true);
0152     logicDetector->SetVisAttributes(detectorVisAttribute);
0153     
0154     //always return the physical World
0155     return physWorld;
0156 }
0157 
0158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0159 
0160 void DetectorConstruction::ConstructSDandField()
0161 {
0162     // --------------- fast simulation ----------------------------
0163     //extract the region of the crystal from the store
0164     G4RegionStore* regionStore = G4RegionStore::GetInstance();
0165     G4Region* regionCh = regionStore->GetRegion("Crystal");
0166 
0167     //create the channeling model for this region
0168     G4ChannelingFastSimModel* channelingModel =
0169         new G4ChannelingFastSimModel("ChannelingModel", regionCh);
0170 
0171     //Crystal planes or axes considered
0172     //Use brackets (...) for planes and <...> for axes
0173     G4String lattice = "<111>";
0174 
0175     //activate the channeling model
0176     channelingModel->Input(fCrystalMaterial, lattice);
0177 
0178     /*
0179     activate radiation model (do it only when you want to take into account the
0180     radiation production in an oriented crystal; it reduces simulation speed.)
0181     */
0182     G4bool activateRadiationModel = true;
0183     if (activateRadiationModel)
0184     {
0185         channelingModel->RadiationModelActivate();
0186         G4cout << "Radiation model activated" << G4endl;
0187     }
0188 }
0189 
0190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0191