Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:04

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 #include "eRositaDetectorConstruction.hh"
0028 #include "eRositaTrackerSD.hh"
0029 
0030 #include "G4Box.hh"
0031 #include "G4Colour.hh"
0032 #include "G4GeometryManager.hh"
0033 #include "G4GeometryTolerance.hh"
0034 #include "G4ios.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4Material.hh"
0037 #include "G4PhysicalConstants.hh"
0038 #include "G4PVParameterised.hh"
0039 #include "G4PVPlacement.hh"
0040 #include "G4SDManager.hh"
0041 #include "G4SystemOfUnits.hh"
0042 #include "G4UserLimits.hh"
0043 #include "G4VisAttributes.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0046 
0047 eRositaDetectorConstruction::eRositaDetectorConstruction()
0048 {
0049 }
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0052 
0053 eRositaDetectorConstruction::~eRositaDetectorConstruction()
0054 {
0055 }
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0058 
0059 auto eRositaDetectorConstruction::Construct() -> G4VPhysicalVolume*
0060 {
0061     // -----------------------
0062     // - Material definition -
0063     // -----------------------
0064 
0065 /*
0066     // Nitrogen
0067     constexpr auto NITROGEN_ATOMIC_NUMBER{7.};
0068     constexpr auto NITROGEN_MOLAR_MASS{14.01 * g / mole};
0069 
0070     auto *nitrogen = new G4Element("Nitrogen", "N", NITROGEN_ATOMIC_NUMBER, NITROGEN_MOLAR_MASS);
0071     
0072     // Oxygen
0073     constexpr auto OXYGEN_ATOMIC_NUMBER{8.};
0074     constexpr auto OXYGEN_MOLAR_MASS{16.00 * g / mole};
0075 
0076     auto *oxygen = new G4Element("Oxygen", "O", OXYGEN_ATOMIC_NUMBER, OXYGEN_MOLAR_MASS);
0077     
0078     // Air
0079     constexpr auto AIR_DENSITY{1.29 * mg / cm3};
0080     constexpr auto AIR_NUMBER_OF_ELEMENTS{2};
0081     constexpr auto NITROGEN_PERCENTAGE{70};
0082     constexpr auto OXYGEN_PERCENTAGE{30};
0083 
0084     auto *air = new G4Material("Air", AIR_DENSITY, AIR_NUMBER_OF_ELEMENTS);
0085     air->AddElement(nitrogen, NITROGEN_PERCENTAGE * perCent);
0086     air->AddElement(oxygen, OXYGEN_PERCENTAGE * perCent);
0087 */
0088 
0089     // Copper
0090     constexpr auto COPPER_ATOMIC_NUMBER{29.};
0091     constexpr auto COPPER_DENSITY{8.92 * g / cm3};
0092     constexpr auto COPPER_MOLAR_MASS{63.55 * g / mole};
0093 
0094     auto *copper = new G4Material("Copper", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY);
0095 
0096     // // Aluminium (for testing)
0097     // constexpr auto COPPER_ATOMIC_NUMBER{13.};
0098     // constexpr auto COPPER_DENSITY{2.7 * g / cm3};
0099     // constexpr auto COPPER_MOLAR_MASS{26.98 * g / mole};
0100 
0101     // auto *copper = new G4Material("Aluminium", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY);
0102 
0103     // Silicon
0104     constexpr auto SILICON_ATOMIC_NUMBER{14.};
0105     constexpr auto SILICON_DENSITY{2.33 * g / cm3};
0106     constexpr auto SILICON_MOLAR_MASS{28.09 * g / mole};
0107 
0108     auto *silicon = new G4Material("Silicon", SILICON_ATOMIC_NUMBER, SILICON_MOLAR_MASS, SILICON_DENSITY);
0109 
0110     // Vacuum
0111 
0112     constexpr auto VACUUM_ATOMIC_NUMBER{1};
0113     constexpr auto VACUUM_DENSITY{universe_mean_density}; // from PhysicalConstants.h
0114     constexpr auto VACUUM_MOLAR_MASS{1.01 * g / mole};
0115     constexpr auto VACUUM_PRESSURE{3.e-18 * pascal};
0116     constexpr auto VACUUM_TEMPERATURE{2.73 * kelvin};
0117 
0118     vacuum = new G4Material("Galactic", VACUUM_ATOMIC_NUMBER, VACUUM_MOLAR_MASS, VACUUM_DENSITY, kStateGas, VACUUM_TEMPERATURE, VACUUM_PRESSURE);
0119 
0120     // Print all the materials defined.
0121     G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
0122     G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0123 
0124     // --------- Sizes of the principal geometrical components (solids) ---------
0125 
0126     // world volume
0127     constexpr auto WORLD_HALF_LENGTH{50.0 * mm};
0128 
0129     worldHalfLength = WORLD_HALF_LENGTH;
0130 
0131     // target: 0.5 cm * 0.5 cm * 3 cm
0132     constexpr auto TARGET_HALF_LENGTH{2.5 * mm};
0133     constexpr auto TARGET_HALF_DEPTH{15.0 * mm};
0134 
0135     targetHalfLength = TARGET_HALF_LENGTH;
0136     targetHalfDepth = TARGET_HALF_DEPTH;
0137 
0138     // tracker (CCD): 4 cm * 450 mu_m * 4 cm
0139     constexpr auto TRACKER_HALF_LENGTH{20.0 * mm};
0140     constexpr auto TRACKER_HALF_DEPTH{0.225 * mm};
0141 
0142     trackerHalfLength = TRACKER_HALF_LENGTH;
0143     trackerHalfDepth = TRACKER_HALF_DEPTH;
0144 
0145     //--------- positions of the principal geometrical components --------
0146 
0147     // target position: (0 cm, 0 cm, 0 cm)
0148     constexpr auto TARGET_INITIAL_POSITION_X{0.0 * cm};
0149     constexpr auto TARGET_INITIAL_POSITION_Y{0.0 * cm};
0150     constexpr auto TARGET_INITIAL_POSITION_Z{0.0 * cm};
0151 
0152     targetPositionX = TARGET_INITIAL_POSITION_X;
0153     targetPositionY = TARGET_INITIAL_POSITION_Y;
0154     targetPositionZ = TARGET_INITIAL_POSITION_Z;
0155 
0156     // tracker position: (0 cm, 2 cm, 0 cm)
0157     constexpr auto TRACKER_INITIAL_POSITION_X{0.0 * cm};
0158     constexpr auto TRACKER_INITIAL_POSITION_Y{2.0 * cm};
0159     constexpr auto TRACKER_INITIAL_POSITION_Z{0.0 * cm};
0160 
0161     trackerPositionX = TRACKER_INITIAL_POSITION_X;
0162     trackerPositionY = TRACKER_INITIAL_POSITION_Y;
0163     trackerPositionZ = TRACKER_INITIAL_POSITION_Z;
0164    
0165     // ------------
0166     // - Material -
0167     // ------------
0168 
0169     // worldMaterial = air;
0170     worldMaterial = vacuum;
0171     targetMaterial = copper;
0172     trackerMaterial = silicon;
0173 
0174     //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
0175 
0176     // ---------
0177     // - World -
0178     // ---------
0179 
0180     worldSolid = new G4Box("world", worldHalfLength, worldHalfLength, worldHalfLength); // cube
0181     worldLogicalVolume = new G4LogicalVolume(worldSolid, worldMaterial, "World", nullptr, nullptr, nullptr);
0182 
0183     // Place the world physical volume unrotated at (0, 0, 0).
0184     worldPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
0185         G4ThreeVector(), // at (0, 0, 0)
0186         worldLogicalVolume, // its logical volume
0187         "World", // its name
0188         nullptr, // its mother volume
0189         false, // no boolean operations
0190         0); // copy number
0191 
0192     // ----------
0193     // - Target -
0194     // ----------
0195 
0196     auto targetPosition = G4ThreeVector(targetPositionX, targetPositionY, targetPositionZ);
0197 
0198     targetSolid = new G4Box("target", targetHalfLength, targetHalfLength, targetHalfDepth);
0199     targetLogicalVolume = new G4LogicalVolume(targetSolid, targetMaterial, "Target", nullptr, nullptr, nullptr);
0200     targetPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
0201         targetPosition, // at (x, y, z)
0202         targetLogicalVolume, // its logical volume
0203         "Target", // its name
0204         worldLogicalVolume, // its mother volume
0205         false, // no boolean operations
0206         0); // copy number
0207 
0208     // -----------
0209     // - Tracker -
0210     // -----------
0211 
0212     auto trackerPosition = G4ThreeVector(trackerPositionX, trackerPositionY, trackerPositionZ);
0213 
0214     trackerSolid = new G4Box("tracker", trackerHalfLength, trackerHalfDepth, trackerHalfLength);
0215     trackerLogicalVolume = new G4LogicalVolume(trackerSolid, trackerMaterial, "Tracker", nullptr, nullptr, nullptr);
0216     trackerPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
0217         trackerPosition, // at (x, y, z)
0218         trackerLogicalVolume, // its logical volume
0219         "Tracker", // its name
0220         worldLogicalVolume, // its mother volume
0221         false, // no boolean operations
0222         0); // copy number
0223 
0224     //-----------------------
0225     // - Sensitive detector -
0226     //-----------------------
0227 
0228     constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"};
0229     auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME);
0230     trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector);
0231 
0232     //------------------
0233     // - Visualization -
0234     //------------------
0235 
0236     // make world volume invisible
0237     worldVisualizationStyle = new G4VisAttributes();
0238     worldVisualizationStyle->SetVisibility(false);
0239     worldLogicalVolume->SetVisAttributes(worldVisualizationStyle);
0240 
0241     // render the target in reddish color
0242     targetVisualizationStyle = new G4VisAttributes();
0243     // targetVisualizationStyle->SetColor(G4Color(1.0, 0.3, 0.3)); // reddish
0244     targetVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black
0245     targetLogicalVolume->SetVisAttributes(targetVisualizationStyle);
0246 
0247     // render the tracker in blueish color
0248     trackerVisualizationStyle = new G4VisAttributes();
0249     // trackerVisualizationStyle->SetColor(G4Color(0.3, 0.3, 1.0)); // blueish
0250     trackerVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black
0251     trackerLogicalVolume->SetVisAttributes(trackerVisualizationStyle);
0252 
0253     return worldPhysicalVolume;
0254 }
0255 
0256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0257 
0258 void eRositaDetectorConstruction::ConstructSDandField()
0259 {
0260     G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
0261     auto *sensitiveDetectorManager = G4SDManager::GetSDMpointer();
0262 
0263     constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"};
0264     auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME);
0265     sensitiveDetectorManager->AddNewDetector(trackerSensitiveDetector);
0266     trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector);
0267 }
0268 
0269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0270 
0271 /*
0272 void eRositaDetectorConstruction::SetTargetMaterial(G4String materialName)
0273 {
0274     // search the material by name
0275     auto *material = G4Material::GetMaterial(materialName);
0276     if (material != nullptr) {
0277         targetMaterial = material;
0278         targetLogicalVolume->SetMaterial(material);
0279         G4cout << "\n----> The target is " << targetFullLength / cm << " cm long and made of " << materialName << G4endl;
0280     }
0281 }
0282 */