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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 
 27 #include "eRositaDetectorConstruction.hh"
 28 #include "eRositaTrackerSD.hh"
 29 
 30 #include "G4Box.hh"
 31 #include "G4Colour.hh"
 32 #include "G4GeometryManager.hh"
 33 #include "G4GeometryTolerance.hh"
 34 #include "G4ios.hh"
 35 #include "G4LogicalVolume.hh"
 36 #include "G4Material.hh"
 37 #include "G4PhysicalConstants.hh"
 38 #include "G4PVParameterised.hh"
 39 #include "G4PVPlacement.hh"
 40 #include "G4SDManager.hh"
 41 #include "G4SystemOfUnits.hh"
 42 #include "G4UserLimits.hh"
 43 #include "G4VisAttributes.hh"
 44 
 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 46 
 47 eRositaDetectorConstruction::eRositaDetectorConstruction()
 48 {
 49 }
 50 
 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 52 
 53 eRositaDetectorConstruction::~eRositaDetectorConstruction()
 54 {
 55 }
 56 
 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 58 
 59 auto eRositaDetectorConstruction::Construct() -> G4VPhysicalVolume*
 60 {
 61     // -----------------------
 62     // - Material definition -
 63     // -----------------------
 64 
 65 /*
 66     // Nitrogen
 67     constexpr auto NITROGEN_ATOMIC_NUMBER{7.};
 68     constexpr auto NITROGEN_MOLAR_MASS{14.01 * g / mole};
 69 
 70     auto *nitrogen = new G4Element("Nitrogen", "N", NITROGEN_ATOMIC_NUMBER, NITROGEN_MOLAR_MASS);
 71     
 72     // Oxygen
 73     constexpr auto OXYGEN_ATOMIC_NUMBER{8.};
 74     constexpr auto OXYGEN_MOLAR_MASS{16.00 * g / mole};
 75 
 76     auto *oxygen = new G4Element("Oxygen", "O", OXYGEN_ATOMIC_NUMBER, OXYGEN_MOLAR_MASS);
 77     
 78     // Air
 79     constexpr auto AIR_DENSITY{1.29 * mg / cm3};
 80     constexpr auto AIR_NUMBER_OF_ELEMENTS{2};
 81     constexpr auto NITROGEN_PERCENTAGE{70};
 82     constexpr auto OXYGEN_PERCENTAGE{30};
 83 
 84     auto *air = new G4Material("Air", AIR_DENSITY, AIR_NUMBER_OF_ELEMENTS);
 85     air->AddElement(nitrogen, NITROGEN_PERCENTAGE * perCent);
 86     air->AddElement(oxygen, OXYGEN_PERCENTAGE * perCent);
 87 */
 88 
 89     // Copper
 90     constexpr auto COPPER_ATOMIC_NUMBER{29.};
 91     constexpr auto COPPER_DENSITY{8.92 * g / cm3};
 92     constexpr auto COPPER_MOLAR_MASS{63.55 * g / mole};
 93 
 94     auto *copper = new G4Material("Copper", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY);
 95 
 96     // // Aluminium (for testing)
 97     // constexpr auto COPPER_ATOMIC_NUMBER{13.};
 98     // constexpr auto COPPER_DENSITY{2.7 * g / cm3};
 99     // constexpr auto COPPER_MOLAR_MASS{26.98 * g / mole};
100 
101     // auto *copper = new G4Material("Aluminium", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY);
102 
103     // Silicon
104     constexpr auto SILICON_ATOMIC_NUMBER{14.};
105     constexpr auto SILICON_DENSITY{2.33 * g / cm3};
106     constexpr auto SILICON_MOLAR_MASS{28.09 * g / mole};
107 
108     auto *silicon = new G4Material("Silicon", SILICON_ATOMIC_NUMBER, SILICON_MOLAR_MASS, SILICON_DENSITY);
109 
110     // Vacuum
111 
112     constexpr auto VACUUM_ATOMIC_NUMBER{1};
113     constexpr auto VACUUM_DENSITY{universe_mean_density}; // from PhysicalConstants.h
114     constexpr auto VACUUM_MOLAR_MASS{1.01 * g / mole};
115     constexpr auto VACUUM_PRESSURE{3.e-18 * pascal};
116     constexpr auto VACUUM_TEMPERATURE{2.73 * kelvin};
117 
118     vacuum = new G4Material("Galactic", VACUUM_ATOMIC_NUMBER, VACUUM_MOLAR_MASS, VACUUM_DENSITY, kStateGas, VACUUM_TEMPERATURE, VACUUM_PRESSURE);
119 
120     // Print all the materials defined.
121     G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
122     G4cout << *(G4Material::GetMaterialTable()) << G4endl;
123 
124     // --------- Sizes of the principal geometrical components (solids) ---------
125 
126     // world volume
127     constexpr auto WORLD_HALF_LENGTH{50.0 * mm};
128 
129     worldHalfLength = WORLD_HALF_LENGTH;
130 
131     // target: 0.5 cm * 0.5 cm * 3 cm
132     constexpr auto TARGET_HALF_LENGTH{2.5 * mm};
133     constexpr auto TARGET_HALF_DEPTH{15.0 * mm};
134 
135     targetHalfLength = TARGET_HALF_LENGTH;
136     targetHalfDepth = TARGET_HALF_DEPTH;
137 
138     // tracker (CCD): 4 cm * 450 mu_m * 4 cm
139     constexpr auto TRACKER_HALF_LENGTH{20.0 * mm};
140     constexpr auto TRACKER_HALF_DEPTH{0.225 * mm};
141 
142     trackerHalfLength = TRACKER_HALF_LENGTH;
143     trackerHalfDepth = TRACKER_HALF_DEPTH;
144 
145     //--------- positions of the principal geometrical components --------
146 
147     // target position: (0 cm, 0 cm, 0 cm)
148     constexpr auto TARGET_INITIAL_POSITION_X{0.0 * cm};
149     constexpr auto TARGET_INITIAL_POSITION_Y{0.0 * cm};
150     constexpr auto TARGET_INITIAL_POSITION_Z{0.0 * cm};
151 
152     targetPositionX = TARGET_INITIAL_POSITION_X;
153     targetPositionY = TARGET_INITIAL_POSITION_Y;
154     targetPositionZ = TARGET_INITIAL_POSITION_Z;
155 
156     // tracker position: (0 cm, 2 cm, 0 cm)
157     constexpr auto TRACKER_INITIAL_POSITION_X{0.0 * cm};
158     constexpr auto TRACKER_INITIAL_POSITION_Y{2.0 * cm};
159     constexpr auto TRACKER_INITIAL_POSITION_Z{0.0 * cm};
160 
161     trackerPositionX = TRACKER_INITIAL_POSITION_X;
162     trackerPositionY = TRACKER_INITIAL_POSITION_Y;
163     trackerPositionZ = TRACKER_INITIAL_POSITION_Z;
164    
165     // ------------
166     // - Material -
167     // ------------
168 
169     // worldMaterial = air;
170     worldMaterial = vacuum;
171     targetMaterial = copper;
172     trackerMaterial = silicon;
173 
174     //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
175 
176     // ---------
177     // - World -
178     // ---------
179 
180     worldSolid = new G4Box("world", worldHalfLength, worldHalfLength, worldHalfLength); // cube
181     worldLogicalVolume = new G4LogicalVolume(worldSolid, worldMaterial, "World", nullptr, nullptr, nullptr);
182 
183     // Place the world physical volume unrotated at (0, 0, 0).
184     worldPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
185         G4ThreeVector(), // at (0, 0, 0)
186         worldLogicalVolume, // its logical volume
187         "World", // its name
188         nullptr, // its mother volume
189         false, // no boolean operations
190         0); // copy number
191 
192     // ----------
193     // - Target -
194     // ----------
195 
196     auto targetPosition = G4ThreeVector(targetPositionX, targetPositionY, targetPositionZ);
197 
198     targetSolid = new G4Box("target", targetHalfLength, targetHalfLength, targetHalfDepth);
199     targetLogicalVolume = new G4LogicalVolume(targetSolid, targetMaterial, "Target", nullptr, nullptr, nullptr);
200     targetPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
201         targetPosition, // at (x, y, z)
202         targetLogicalVolume, // its logical volume
203         "Target", // its name
204         worldLogicalVolume, // its mother volume
205         false, // no boolean operations
206         0); // copy number
207 
208     // -----------
209     // - Tracker -
210     // -----------
211 
212     auto trackerPosition = G4ThreeVector(trackerPositionX, trackerPositionY, trackerPositionZ);
213 
214     trackerSolid = new G4Box("tracker", trackerHalfLength, trackerHalfDepth, trackerHalfLength);
215     trackerLogicalVolume = new G4LogicalVolume(trackerSolid, trackerMaterial, "Tracker", nullptr, nullptr, nullptr);
216     trackerPhysicalVolume = new G4PVPlacement(nullptr, // no rotation
217         trackerPosition, // at (x, y, z)
218         trackerLogicalVolume, // its logical volume
219         "Tracker", // its name
220         worldLogicalVolume, // its mother volume
221         false, // no boolean operations
222         0); // copy number
223 
224     //-----------------------
225     // - Sensitive detector -
226     //-----------------------
227 
228     constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"};
229     auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME);
230     trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector);
231 
232     //------------------
233     // - Visualization -
234     //------------------
235 
236     // make world volume invisible
237     worldVisualizationStyle = new G4VisAttributes();
238     worldVisualizationStyle->SetVisibility(false);
239     worldLogicalVolume->SetVisAttributes(worldVisualizationStyle);
240 
241     // render the target in reddish color
242     targetVisualizationStyle = new G4VisAttributes();
243     // targetVisualizationStyle->SetColor(G4Color(1.0, 0.3, 0.3)); // reddish
244     targetVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black
245     targetLogicalVolume->SetVisAttributes(targetVisualizationStyle);
246 
247     // render the tracker in blueish color
248     trackerVisualizationStyle = new G4VisAttributes();
249     // trackerVisualizationStyle->SetColor(G4Color(0.3, 0.3, 1.0)); // blueish
250     trackerVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black
251     trackerLogicalVolume->SetVisAttributes(trackerVisualizationStyle);
252 
253     return worldPhysicalVolume;
254 }
255 
256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
257 
258 void eRositaDetectorConstruction::ConstructSDandField()
259 {
260     G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
261     auto *sensitiveDetectorManager = G4SDManager::GetSDMpointer();
262 
263     constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"};
264     auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME);
265     sensitiveDetectorManager->AddNewDetector(trackerSensitiveDetector);
266     trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector);
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
270 
271 /*
272 void eRositaDetectorConstruction::SetTargetMaterial(G4String materialName)
273 {
274     // search the material by name
275     auto *material = G4Material::GetMaterial(materialName);
276     if (material != nullptr) {
277         targetMaterial = material;
278         targetLogicalVolume->SetMaterial(material);
279         G4cout << "\n----> The target is " << targetFullLength / cm << " cm long and made of " << materialName << G4endl;
280     }
281 }
282 */
283