Back to home page

EIC code displayed by LXR

 
 

    


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

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 DetectorConstruction::DetectorConstruction()
0045 {}
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 G4VPhysicalVolume* DetectorConstruction::Construct()
0050 {
0051     //Check overlap option
0052     G4bool checkOverlaps = true;
0053 
0054     //Materials
0055     G4NistManager* nist = G4NistManager::Instance();
0056     G4Material* world_mat = nist->FindOrBuildMaterial("G4_Galactic");
0057     G4Material* silicon = nist->FindOrBuildMaterial("G4_Si");
0058 
0059     //World
0060     G4Box* solidWorld = new G4Box("World", 0.2*CLHEP::m, 0.2*CLHEP::m, 10.*CLHEP::m);
0061     G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, world_mat, "World");  
0062     G4VPhysicalVolume* physWorld = new G4PVPlacement
0063                                     (0,                    // no rotation
0064                                     G4ThreeVector(),       // centre position
0065                                     logicWorld,            // its logical volume
0066                                     "World",               // its name
0067                                     0,                     // its mother volume
0068                                     false,                 // no boolean operation
0069                                     0,                     // copy number
0070                                     checkOverlaps);        // overlaps checking
0071     logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
0072 
0073 
0074     // --------------- Crystal ------------------------------------
0075 
0076     /*parameters of the following experiment:
0077       Only channeling: A. Mazzolari et al. Phys. Rev. Lett. 112, 135503 (2014)
0078       Radition:        L. Bandiera et al. Phys. Rev. Lett. 115, 025504 (2015)
0079       Published experimental validation of G4ChannelingFastSimModel (only channeling):
0080       A. Sytov et al. Journal of the Korean Physical Society 83, 132–139 (2023)
0081     */
0082 
0083     //Select crystal material
0084     fCrystalMaterial = nist->FindOrBuildMaterial("G4_Si");
0085 
0086     //Setting crystal rotation angle (also the angle of crystal planes vs the beam)
0087     //Crystal rotation angle (also the angle of crystal planes vs the beam)
0088     G4double angleX = 0.*1e-6; //rad
0089     G4RotationMatrix* crystalRotationMatrix = new G4RotationMatrix;
0090     crystalRotationMatrix->rotateY(-angleX);
0091 
0092     //Crystal bending angle
0093     fBendingAngle = 0.905*CLHEP::mrad;
0094 
0095     //setting crystal dimensions:
0096     G4ThreeVector crystalSize = G4ThreeVector(20.*CLHEP::mm,
0097                                               20.*CLHEP::mm,
0098                                               0.0305*CLHEP::mm);
0099 
0100     //Setting crystal position
0101     G4ThreeVector posCrystal = G4ThreeVector(0., 0., crystalSize.z()/2.);
0102 
0103     //crystal volume
0104     G4Box* solidCrystal = new G4Box("Crystal",
0105                                     crystalSize.x()/2,
0106                                     crystalSize.y()/2,
0107                                     crystalSize.z()/2.);
0108     
0109     fLogicCrystal = new G4LogicalVolume(solidCrystal,
0110                                        fCrystalMaterial,
0111                                        "Crystal");
0112     new G4PVPlacement(crystalRotationMatrix,
0113                       posCrystal,
0114                       fLogicCrystal,
0115                       "Crystal",
0116                       logicWorld,
0117                       false,
0118                       0,
0119                       checkOverlaps);
0120     
0121     //crystal region (necessary for the FastSim model)
0122     G4Region* regionCh = new G4Region("Crystal");
0123     regionCh->AddRootLogicalVolume(fLogicCrystal);
0124 
0125     //visualization attributes
0126     G4VisAttributes* crystalVisAttribute =
0127         new G4VisAttributes(G4Colour(1., 0., 0.));
0128     crystalVisAttribute->SetForceSolid(true);
0129     fLogicCrystal->SetVisAttributes(crystalVisAttribute);
0130         
0131     //print crystal info
0132     G4cout << "Crystal size: " << crystalSize.x()/CLHEP::mm
0133            << " " << crystalSize.y()/CLHEP::mm
0134            << " " << crystalSize.z()/CLHEP::mm << " mm3" << G4endl;
0135     G4cout << "Crystal bending angle: " << fBendingAngle << " rad" << G4endl;
0136     G4cout << "Crystal angleX: " << angleX << " rad" << G4endl;
0137 
0138     // --------------- Detector -----------------------------------
0139     //Setting detector position
0140     G4ThreeVector posDetector = G4ThreeVector(0, 0, 5973*CLHEP::mm);
0141 
0142     //particle detector volume
0143     G4Box* detector = new G4Box("Detector",
0144                                 10*CLHEP::cm/2,
0145                                 10*CLHEP::cm/2,
0146                                 0.3*CLHEP::mm/2);
0147     
0148     G4LogicalVolume* logicDetector = new G4LogicalVolume(detector,
0149                                                          silicon,
0150                                                          "Detector");
0151     new G4PVPlacement(0, 
0152                       posDetector, 
0153                       logicDetector,
0154                       "Detector", 
0155                       logicWorld, 
0156                       false, 
0157                       0, 
0158                       checkOverlaps);
0159 
0160     //visualization attributes
0161     G4VisAttributes* detectorVisAttribute =
0162         new G4VisAttributes(G4Colour(0., 0., 1));
0163     detectorVisAttribute->SetForceSolid(true);
0164     logicDetector->SetVisAttributes(detectorVisAttribute);
0165     
0166     //always return the physical World
0167     return physWorld;
0168 }
0169 
0170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0171 
0172 void DetectorConstruction::ConstructSDandField()
0173 {
0174     // --------------- fast simulation ----------------------------
0175     //extract the region of the crystal from the store
0176     G4RegionStore* regionStore = G4RegionStore::GetInstance();
0177     G4Region* regionCh = regionStore->GetRegion("Crystal");
0178 
0179     ///create the channeling model for this region
0180     G4ChannelingFastSimModel* channelingModel =
0181         new G4ChannelingFastSimModel("ChannelingModel", regionCh);
0182 
0183     ///Crystal planes or axes considered
0184     ///Use brackets (...) for planes and <...> for axes
0185     G4String lattice = "(111)";
0186 
0187     ///activate the channeling model
0188     channelingModel->Input(fCrystalMaterial, lattice);
0189     ///setting bending angle of the crystal planes (default is 0)
0190     channelingModel->GetCrystalData()->SetBendingAngle(fBendingAngle,fLogicCrystal);
0191 
0192     /*
0193     activate radiation model (do it only when you want to take into account the
0194     radiation production in an oriented crystal; it reduces simulation speed.)
0195     */
0196     G4bool activateRadiationModel = true;
0197     if (activateRadiationModel)
0198     {
0199         channelingModel->RadiationModelActivate();
0200         G4cout << "Radiation model activated" << G4endl;
0201     }
0202 }
0203 
0204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0205