Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0028 #include "DetectorConstruction.hh"
0029 
0030 #include "SensitiveDetector.hh"
0031 
0032 #include "G4Box.hh"
0033 #include "G4ChannelingMaterialData.hh"
0034 #include "G4ChannelingOptrMultiParticleChangeCrossSection.hh"
0035 #include "G4Colour.hh"
0036 #include "G4CrystalExtension.hh"
0037 #include "G4ExtendedMaterial.hh"
0038 #include "G4GeometryManager.hh"
0039 #include "G4LogicalCrystalVolume.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4LogicalVolumeStore.hh"
0042 #include "G4Material.hh"
0043 #include "G4NistManager.hh"
0044 #include "G4PVPlacement.hh"
0045 #include "G4PhysicalConstants.hh"
0046 #include "G4PhysicalVolumeStore.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4SolidStore.hh"
0049 #include "G4SystemOfUnits.hh"
0050 #include "G4VisAttributes.hh"
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 DetectorConstruction::DetectorConstruction()
0055   : fECfileName("Si220pl"),
0056     fMaterialName("G4_Si"),
0057     fSizes(G4ThreeVector(1. * CLHEP::mm, 70. * CLHEP::mm, 1.94 * CLHEP::mm)),
0058     fBR(G4ThreeVector(0., 0., 0.)),
0059     fAngles(G4ThreeVector(0., 0., 0.))
0060 {
0061   fMessenger = new DetectorConstructionMessenger(this);
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0065 
0066 DetectorConstruction::~DetectorConstruction()
0067 {
0068   ;
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0072 
0073 void DetectorConstruction::DefineMaterials()
0074 {
0075   ;
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 G4VPhysicalVolume* DetectorConstruction::Construct()
0081 {
0082   //** World **//
0083   G4Material* worldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
0084 
0085   G4double worldSizeXY = 1. * CLHEP::meter;
0086   G4double worldSizeZ = 22. * CLHEP::meter;
0087 
0088   G4Box* worldSolid = new G4Box("world.solid", worldSizeXY / 2., worldSizeXY / 2., worldSizeZ / 2.);
0089 
0090   G4LogicalVolume* worldLogic = new G4LogicalVolume(worldSolid, worldMaterial, "world.logic");
0091 
0092   G4PVPlacement* worldPhysical =
0093     new G4PVPlacement(0, G4ThreeVector(), worldLogic, "world.physic", 0, false, 0);
0094 
0095   //** Detectors instantiation **//
0096   G4ThreeVector fDetectorSizes(G4ThreeVector(38.0 * CLHEP::mm, 38.0 * CLHEP::mm, 0.64 * CLHEP::mm));
0097   G4double fDetectorDistance[3] = {-9.998 * CLHEP::m, -0.320 * CLHEP::m, +10.756 * CLHEP::m};
0098 
0099   G4Box* ssdSolid = new G4Box("ssd.solid", fDetectorSizes.x() / 2., fDetectorSizes.y() / 2.,
0100                               fDetectorSizes.z() / 2.);
0101 
0102   G4Material* detectorMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0103   G4LogicalVolume* ssdLogic = new G4LogicalVolume(ssdSolid, detectorMaterial, "ssd.logic");
0104 
0105   for (size_t i1 = 0; i1 < 3; i1++) {
0106     new G4PVPlacement(0, G4ThreeVector(0., 0., fDetectorDistance[i1]), ssdLogic, "ssd.physic",
0107                       worldLogic, false, i1);
0108   }
0109 
0110   //** Crystal solid parameters **//
0111   G4Box* crystalSolid =
0112     new G4Box("crystal.solid", fSizes.x() / 2., fSizes.y() / 2., fSizes.z() / 2.);
0113 
0114   //** Crystal Definition Start **//
0115   G4Material* mat = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0116   G4ExtendedMaterial* Crystal = new G4ExtendedMaterial("crystal.material", mat);
0117 
0118   Crystal->RegisterExtension(std::unique_ptr<G4CrystalExtension>(new G4CrystalExtension(Crystal)));
0119   G4CrystalExtension* crystalExtension = (G4CrystalExtension*)Crystal->RetrieveExtension("crystal");
0120   crystalExtension->SetUnitCell(
0121     new G4CrystalUnitCell(5.43 * CLHEP::angstrom, 5.43 * CLHEP::angstrom, 5.43 * CLHEP::angstrom,
0122                           CLHEP::halfpi, CLHEP::halfpi, CLHEP::halfpi, 227));
0123 
0124   Crystal->RegisterExtension(
0125     std::unique_ptr<G4ChannelingMaterialData>(new G4ChannelingMaterialData("channeling")));
0126   G4ChannelingMaterialData* crystalChannelingData =
0127     (G4ChannelingMaterialData*)Crystal->RetrieveExtension("channeling");
0128   crystalChannelingData->SetFilename(fECfileName);
0129 
0130   if (fBR != G4ThreeVector()) {
0131     crystalChannelingData->SetBR(fBR.x());
0132   }
0133 
0134   G4LogicalCrystalVolume* crystalLogic =
0135     new G4LogicalCrystalVolume(crystalSolid, Crystal, "crystal.logic");
0136   crystalLogic->SetVerbose(1);
0137   //** Crystal Definition End **//
0138 
0139   G4RotationMatrix* rot = new G4RotationMatrix;
0140   if (fAngles.x() != 0.) {
0141     rot->rotateX(fAngles.x());
0142   }
0143   if (fAngles.y() != 0.) {
0144     rot->rotateY(fAngles.y());
0145   }
0146   if (fAngles.z() != 0.) {
0147     rot->rotateZ(fAngles.z());
0148   }
0149 
0150   new G4PVPlacement(rot, G4ThreeVector(), crystalLogic, "crystal.physic", worldLogic, false, 0);
0151 
0152 #ifndef G4MULTITHREADED
0153   G4ChannelingOptrMultiParticleChangeCrossSection* testMany =
0154     new G4ChannelingOptrMultiParticleChangeCrossSection();
0155   testMany->AttachTo(crystalLogic);
0156   G4cout << " Attaching biasing operator " << testMany->GetName() << " to logical volume "
0157          << crystalLogic->GetName() << G4endl;
0158 
0159   G4VSensitiveDetector* telescope = new SensitiveDetector("/telescope");
0160   G4SDManager::GetSDMpointer()->AddNewDetector(telescope);
0161   for (unsigned int i1 = 0; i1 < 3; i1++) {
0162     ssdLogic->SetSensitiveDetector(telescope);
0163   }
0164 #endif
0165 
0166   return worldPhysical;
0167 }
0168 
0169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0170 
0171 #ifdef G4MULTITHREADED
0172 void DetectorConstruction::ConstructSDandField()
0173 {
0174   G4LogicalVolume* crystalLogic = G4LogicalVolumeStore::GetInstance()->GetVolume("crystal.logic");
0175   G4ChannelingOptrMultiParticleChangeCrossSection* testMany =
0176     new G4ChannelingOptrMultiParticleChangeCrossSection();
0177   testMany->AttachTo(crystalLogic);
0178   G4cout << " Attaching biasing operator " << testMany->GetName() << " to logical volume "
0179          << crystalLogic->GetName() << G4endl;
0180 
0181   G4LogicalVolume* ssdLogic = G4LogicalVolumeStore::GetInstance()->GetVolume("ssd.logic");
0182   G4VSensitiveDetector* telescope = new SensitiveDetector("/telescope");
0183   G4SDManager::GetSDMpointer()->AddNewDetector(telescope);
0184   for (unsigned int i1 = 0; i1 < 3; i1++) {
0185     ssdLogic->SetSensitiveDetector(telescope);
0186   }
0187 }
0188 #else
0189 void DetectorConstruction::ConstructSDandField()
0190 {
0191   ;
0192 }
0193 #endif
0194 
0195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......