Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
B5DetectorConstruction.cc
이 파일의 문서화 페이지로 가기
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 // $Id: B5DetectorConstruction.cc 103284 2017-03-24 08:27:19Z gcosmo $
27 //
30 
32 #include "B5MagneticField.hh"
34 #include "B5HodoscopeSD.hh"
35 #include "B5DriftChamberSD.hh"
36 #include "B5EmCalorimeterSD.hh"
37 #include "B5HadCalorimeterSD.hh"
38 
39 #include "G4FieldManager.hh"
41 #include "G4Mag_UsualEqRhs.hh"
42 
43 #include "G4Material.hh"
44 #include "G4Element.hh"
45 #include "G4MaterialTable.hh"
46 #include "G4NistManager.hh"
47 
48 #include "G4VSolid.hh"
49 #include "G4Box.hh"
50 #include "G4Tubs.hh"
51 #include "G4LogicalVolume.hh"
52 #include "G4VPhysicalVolume.hh"
53 #include "G4PVPlacement.hh"
54 #include "G4PVParameterised.hh"
55 #include "G4PVReplica.hh"
56 #include "G4UserLimits.hh"
57 
58 #include "G4SDManager.hh"
59 #include "G4VSensitiveDetector.hh"
60 #include "G4RunManager.hh"
61 #include "G4GenericMessenger.hh"
62 
63 #include "G4VisAttributes.hh"
64 #include "G4Colour.hh"
65 
66 #include "G4ios.hh"
67 #include "G4SystemOfUnits.hh"
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
78  fMessenger(nullptr),
79  fHodoscope1Logical(nullptr), fHodoscope2Logical(nullptr),
80  fWirePlane1Logical(nullptr), fWirePlane2Logical(nullptr),
81  fCellLogical(nullptr), fHadCalScintiLogical(nullptr),
82  fMagneticLogical(nullptr),
83  fVisAttributes(),
84  fArmAngle(30.*deg), fArmRotation(nullptr), fSecondArmPhys(nullptr)
85 
86 {
89 
90  // define commands for this class
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 
97 {
98  delete fArmRotation;
99  delete fMessenger;
100 
101  for (auto visAttributes: fVisAttributes) {
102  delete visAttributes;
103  }
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
109 {
110  // Construct materials
112  auto air = G4Material::GetMaterial("G4_AIR");
113  //auto argonGas = G4Material::GetMaterial("B5_Ar");
114  auto argonGas = G4Material::GetMaterial("G4_Ar");
115  auto scintillator = G4Material::GetMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
116  auto csI = G4Material::GetMaterial("G4_CESIUM_IODIDE");
117  auto lead = G4Material::GetMaterial("G4_Pb");
118 
119  // Option to switch on/off checking of volumes overlaps
120  //
121  G4bool checkOverlaps = true;
122 
123  // geometries --------------------------------------------------------------
124  // experimental hall (world volume)
125  auto worldSolid
126  = new G4Box("worldBox",10.*m,3.*m,10.*m);
127  auto worldLogical
128  = new G4LogicalVolume(worldSolid,air,"worldLogical");
129  auto worldPhysical
130  = new G4PVPlacement(0,G4ThreeVector(),worldLogical,"worldPhysical",0,
131  false,0,checkOverlaps);
132 
133  // Tube with Local Magnetic field
134 
135  auto magneticSolid
136  = new G4Tubs("magneticTubs",0.,1.*m,1.*m,0.,360.*deg);
137 
139  = new G4LogicalVolume(magneticSolid, air, "magneticLogical");
140 
141  // placement of Tube
142 
143  G4RotationMatrix* fieldRot = new G4RotationMatrix();
144  fieldRot->rotateX(90.*deg);
146  "magneticPhysical",worldLogical,
147  false,0,checkOverlaps);
148 
149  // set step limit in tube with magnetic field
150  G4UserLimits* userLimits = new G4UserLimits(1*m);
151  fMagneticLogical->SetUserLimits(userLimits);
152 
153  // first arm
154  auto firstArmSolid
155  = new G4Box("firstArmBox",1.5*m,1.*m,3.*m);
156  auto firstArmLogical
157  = new G4LogicalVolume(firstArmSolid,air,"firstArmLogical");
158  new G4PVPlacement(0,G4ThreeVector(0.,0.,-5.*m),firstArmLogical,
159  "firstArmPhysical",worldLogical,
160  false,0,checkOverlaps);
161 
162  // second arm
163  auto secondArmSolid
164  = new G4Box("secondArmBox",2.*m,2.*m,3.5*m);
165  auto secondArmLogical
166  = new G4LogicalVolume(secondArmSolid,air,"secondArmLogical");
167  auto x = -5.*m * std::sin(fArmAngle);
168  auto z = 5.*m * std::cos(fArmAngle);
170  = new G4PVPlacement(fArmRotation,G4ThreeVector(x,0.,z),secondArmLogical,
171  "fSecondArmPhys",worldLogical,
172  false,0,checkOverlaps);
173 
174  // hodoscopes in first arm
175  auto hodoscope1Solid
176  = new G4Box("hodoscope1Box",5.*cm,20.*cm,0.5*cm);
178  = new G4LogicalVolume(hodoscope1Solid,scintillator,"hodoscope1Logical");
179 
180  for (auto i=0;i<kNofHodoscopes1;i++) {
181  G4double x1 = (i-kNofHodoscopes1/2)*10.*cm;
183  "hodoscope1Physical",firstArmLogical,
184  false,i,checkOverlaps);
185  }
186 
187  // drift chambers in first arm
188  auto chamber1Solid
189  = new G4Box("chamber1Box",1.*m,30.*cm,1.*cm);
190  auto chamber1Logical
191  = new G4LogicalVolume(chamber1Solid,argonGas,"chamber1Logical");
192 
193  for (auto i=0;i<kNofChambers;i++) {
194  G4double z1 = (i-kNofChambers/2)*0.5*m;
195  new G4PVPlacement(0,G4ThreeVector(0.,0.,z1),chamber1Logical,
196  "chamber1Physical",firstArmLogical,
197  false,i,checkOverlaps);
198  }
199 
200  // "virtual" wire plane
201  auto wirePlane1Solid
202  = new G4Box("wirePlane1Box",1.*m,30.*cm,0.1*mm);
204  = new G4LogicalVolume(wirePlane1Solid,argonGas,"wirePlane1Logical");
206  "wirePlane1Physical",chamber1Logical,
207  false,0,checkOverlaps);
208 
209  // hodoscopes in second arm
210  auto hodoscope2Solid
211  = new G4Box("hodoscope2Box",5.*cm,20.*cm,0.5*cm);
213  = new G4LogicalVolume(hodoscope2Solid,scintillator,"hodoscope2Logical");
214 
215  for (auto i=0;i<kNofHodoscopes2;i++) {
216  G4double x2 = (i-kNofHodoscopes2/2)*10.*cm;
218  "hodoscope2Physical",secondArmLogical,
219  false,i,checkOverlaps);
220  }
221 
222  // drift chambers in second arm
223  auto chamber2Solid
224  = new G4Box("chamber2Box",1.5*m,30.*cm,1.*cm);
225  auto chamber2Logical
226  = new G4LogicalVolume(chamber2Solid,argonGas,"chamber2Logical");
227 
228  for (auto i=0;i<kNofChambers;i++) {
229  G4double z2 = (i-kNofChambers/2)*0.5*m - 1.5*m;
230  new G4PVPlacement(0,G4ThreeVector(0.,0.,z2),chamber2Logical,
231  "chamber2Physical",secondArmLogical,
232  false,i,checkOverlaps);
233  }
234 
235  // "virtual" wire plane
236  auto wirePlane2Solid
237  = new G4Box("wirePlane2Box",1.5*m,30.*cm,0.1*mm);
239  = new G4LogicalVolume(wirePlane2Solid,argonGas,"wirePlane2Logical");
241  "wirePlane2Physical",chamber2Logical,
242  false,0,checkOverlaps);
243 
244  // CsI calorimeter
245  auto emCalorimeterSolid
246  = new G4Box("EMcalorimeterBox",1.5*m,30.*cm,15.*cm);
247  auto emCalorimeterLogical
248  = new G4LogicalVolume(emCalorimeterSolid,csI,"EMcalorimeterLogical");
249  new G4PVPlacement(0,G4ThreeVector(0.,0.,2.*m),emCalorimeterLogical,
250  "EMcalorimeterPhysical",secondArmLogical,
251  false,0,checkOverlaps);
252 
253  // EMcalorimeter cells
254  auto cellSolid
255  = new G4Box("cellBox",7.5*cm,7.5*cm,15.*cm);
257  = new G4LogicalVolume(cellSolid,csI,"cellLogical");
259  new G4PVParameterised("cellPhysical",fCellLogical,emCalorimeterLogical,
260  kXAxis,kNofEmCells,cellParam);
261 
262  // hadron calorimeter
263  auto hadCalorimeterSolid
264  = new G4Box("HadCalorimeterBox",1.5*m,30.*cm,50.*cm);
265  auto hadCalorimeterLogical
266  = new G4LogicalVolume(hadCalorimeterSolid,lead,"HadCalorimeterLogical");
267  new G4PVPlacement(0,G4ThreeVector(0.,0.,3.*m),hadCalorimeterLogical,
268  "HadCalorimeterPhysical",secondArmLogical,
269  false,0,checkOverlaps);
270 
271  // hadron calorimeter column
272  auto HadCalColumnSolid
273  = new G4Box("HadCalColumnBox",15.*cm,30.*cm,50.*cm);
274  auto HadCalColumnLogical
275  = new G4LogicalVolume(HadCalColumnSolid,lead,"HadCalColumnLogical");
276  new G4PVReplica("HadCalColumnPhysical",HadCalColumnLogical,
277  hadCalorimeterLogical,kXAxis,kNofHadColumns,30.*cm);
278 
279  // hadron calorimeter cell
280  auto HadCalCellSolid
281  = new G4Box("HadCalCellBox",15.*cm,15.*cm,50.*cm);
282  auto HadCalCellLogical
283  = new G4LogicalVolume(HadCalCellSolid,lead,"HadCalCellLogical");
284  new G4PVReplica("HadCalCellPhysical",HadCalCellLogical,
285  HadCalColumnLogical,kYAxis,kNofHadRows,30.*cm);
286 
287  // hadron calorimeter layers
288  auto HadCalLayerSolid
289  = new G4Box("HadCalLayerBox",15.*cm,15.*cm,2.5*cm);
290  auto HadCalLayerLogical
291  = new G4LogicalVolume(HadCalLayerSolid,lead,"HadCalLayerLogical");
292  new G4PVReplica("HadCalLayerPhysical",HadCalLayerLogical,
293  HadCalCellLogical,kZAxis,kNofHadCells,5.*cm);
294 
295  // scintillator plates
296  auto HadCalScintiSolid
297  = new G4Box("HadCalScintiBox",15.*cm,15.*cm,0.5*cm);
299  = new G4LogicalVolume(HadCalScintiSolid,scintillator,
300  "HadCalScintiLogical");
302  "HadCalScintiPhysical",HadCalLayerLogical,
303  false,0,checkOverlaps);
304 
305  // visualization attributes ------------------------------------------------
306 
307  auto visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
308  visAttributes->SetVisibility(false);
309  worldLogical->SetVisAttributes(visAttributes);
310  fVisAttributes.push_back(visAttributes);
311 
312  visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9)); // LightGray
313  fMagneticLogical->SetVisAttributes(visAttributes);
314  fVisAttributes.push_back(visAttributes);
315 
316  visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
317  visAttributes->SetVisibility(false);
318  firstArmLogical->SetVisAttributes(visAttributes);
319  secondArmLogical->SetVisAttributes(visAttributes);
320  fVisAttributes.push_back(visAttributes);
321 
322  visAttributes = new G4VisAttributes(G4Colour(0.8888,0.0,0.0));
323  fHodoscope1Logical->SetVisAttributes(visAttributes);
324  fHodoscope2Logical->SetVisAttributes(visAttributes);
325  fVisAttributes.push_back(visAttributes);
326 
327  visAttributes = new G4VisAttributes(G4Colour(0.0,1.0,0.0));
328  chamber1Logical->SetVisAttributes(visAttributes);
329  chamber2Logical->SetVisAttributes(visAttributes);
330  fVisAttributes.push_back(visAttributes);
331 
332  visAttributes = new G4VisAttributes(G4Colour(0.0,0.8888,0.0));
333  visAttributes->SetVisibility(false);
334  fWirePlane1Logical->SetVisAttributes(visAttributes);
335  fWirePlane2Logical->SetVisAttributes(visAttributes);
336  fVisAttributes.push_back(visAttributes);
337 
338  visAttributes = new G4VisAttributes(G4Colour(0.8888,0.8888,0.0));
339  visAttributes->SetVisibility(false);
340  emCalorimeterLogical->SetVisAttributes(visAttributes);
341  fVisAttributes.push_back(visAttributes);
342 
343  visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.0));
344  fCellLogical->SetVisAttributes(visAttributes);
345  fVisAttributes.push_back(visAttributes);
346 
347  visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
348  hadCalorimeterLogical->SetVisAttributes(visAttributes);
349  fVisAttributes.push_back(visAttributes);
350 
351  visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
352  visAttributes->SetVisibility(false);
353  HadCalColumnLogical->SetVisAttributes(visAttributes);
354  HadCalCellLogical->SetVisAttributes(visAttributes);
355  HadCalLayerLogical->SetVisAttributes(visAttributes);
356  fHadCalScintiLogical->SetVisAttributes(visAttributes);
357  fVisAttributes.push_back(visAttributes);
358 
359  // return the world physical volume ----------------------------------------
360 
361  return worldPhysical;
362 }
363 
364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
365 
367 {
368  // sensitive detectors -----------------------------------------------------
369  auto sdManager = G4SDManager::GetSDMpointer();
370  G4String SDname;
371 
372  auto hodoscope1 = new B5HodoscopeSD(SDname="/hodoscope1");
373  sdManager->AddNewDetector(hodoscope1);
375 
376  auto hodoscope2 = new B5HodoscopeSD(SDname="/hodoscope2");
377  sdManager->AddNewDetector(hodoscope2);
379 
380  auto chamber1 = new B5DriftChamberSD(SDname="/chamber1");
381  sdManager->AddNewDetector(chamber1);
383 
384  auto chamber2 = new B5DriftChamberSD(SDname="/chamber2");
385  sdManager->AddNewDetector(chamber2);
387 
388  auto emCalorimeter = new B5EmCalorimeterSD(SDname="/EMcalorimeter");
389  sdManager->AddNewDetector(emCalorimeter);
390  fCellLogical->SetSensitiveDetector(emCalorimeter);
391 
392  auto hadCalorimeter = new B5HadCalorimeterSD(SDname="/HadCalorimeter");
393  sdManager->AddNewDetector(hadCalorimeter);
395 
396  // magnetic field ----------------------------------------------------------
398  fFieldMgr = new G4FieldManager();
401  G4bool forceToAllDaughters = true;
402  fMagneticLogical->SetFieldManager(fFieldMgr, forceToAllDaughters);
403 }
404 
405 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
406 
408 {
409  auto nistManager = G4NistManager::Instance();
410 
411  // Air
412  nistManager->FindOrBuildMaterial("G4_AIR");
413 
414  // Argon gas
415  nistManager->FindOrBuildMaterial("G4_Ar");
416  // With a density different from the one defined in NIST
417  // G4double density = 1.782e-03*g/cm3;
418  // nistManager->BuildMaterialWithNewDensity("B5_Ar","G4_Ar",density);
419  // !! cases segmentation fault
420 
421  // Scintillator
422  // (PolyVinylToluene, C_9H_10)
423  nistManager->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
424 
425  // CsI
426  nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
427 
428  // Lead
429  nistManager->FindOrBuildMaterial("G4_Pb");
430 
431  // Vacuum "Galactic"
432  // nistManager->FindOrBuildMaterial("G4_Galactic");
433 
434  // Vacuum "Air with low density"
435  // auto air = G4Material::GetMaterial("G4_AIR");
436  // G4double density = 1.0e-5*air->GetDensity();
437  // nistManager
438  // ->BuildMaterialWithNewDensity("Air_lowDensity", "G4_AIR", density);
439 
440  G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
441  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
442 }
443 
444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
445 
447 {
448  if (!fSecondArmPhys) {
449  G4cerr << "Detector has not yet been constructed." << G4endl;
450  return;
451  }
452 
453  fArmAngle = val;
454  *fArmRotation = G4RotationMatrix(); // make it unit vector
456  auto x = -5.*m * std::sin(fArmAngle);
457  auto z = 5.*m * std::cos(fArmAngle);
459 
460  // tell G4RunManager that we change the geometry
462 }
463 
464 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
465 
467 {
468  // Define /B5/detector command directory using generic messenger class
469  fMessenger = new G4GenericMessenger(this,
470  "/B5/detector/",
471  "Detector control");
472 
473  // armAngle command
474  auto& armAngleCmd
475  = fMessenger->DeclareMethodWithUnit("armAngle","deg",
477  "Set rotation angle of the second arm.");
478  armAngleCmd.SetParameterName("angle", true);
479  armAngleCmd.SetRange("angle>=0. && angle<180.");
480  armAngleCmd.SetDefaultValue("30.");
481 }
482 
483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Float_t x
Definition: compare.C:6
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
This class is generic messenger.
CLHEP::Hep3Vector G4ThreeVector
Definition of the B5MagneticField class.
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
Float_t x1[n_points_granero]
Definition: compare.C:5
CLHEP::HepRotation G4RotationMatrix
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
#define G4endl
Definition: G4ios.hh:61
Double_t z
EM calorimeter sensitive detector.
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)
Definition of the B5DriftChamberSD class.
void SetTranslation(const G4ThreeVector &v)
Command & SetDefaultValue(const G4String &)
Definition of the B5HodoscopeSD class.
#define G4ThreadLocal
Definition: tls.hh:69
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:608
virtual G4VPhysicalVolume * Construct()
G4bool SetDetectorField(G4Field *detectorField, int failMode=0)
void CreateChordFinder(G4MagneticField *detectorMagField)
Definition of the B5CellParameterisation class.
static constexpr double m
Definition: G4SIunits.hh:129
constexpr G4int kNofHadCells
Definition: B5Constants.hh:44
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
constexpr G4int kNofHodoscopes2
Definition: B5Constants.hh:37
G4LogicalVolume * fHadCalScintiLogical
Definition of the B5DetectorConstruction class.
static constexpr double deg
Definition: G4SIunits.hh:152
constexpr G4int kNofHadRows
Definition: B5Constants.hh:43
Definition: G4Box.hh:64
std::vector< G4VisAttributes * > fVisAttributes
constexpr G4int kNofHadColumns
Definition: B5Constants.hh:42
Command & SetRange(const G4String &range)
G4LogicalVolume * fHodoscope1Logical
G4GenericMessenger * fMessenger
Definition of the B5EmCalorimeterSD class.
void SetVisAttributes(const G4VisAttributes *pVA)
void GeometryHasBeenModified(G4bool prop=true)
G4GLOB_DLL std::ostream G4cerr
void SetUserLimits(G4UserLimits *pULimits)
Hadron calorimeter sensitive detector.
G4VPhysicalVolume * fSecondArmPhys
G4LogicalVolume * fHodoscope2Logical
Magnetic field.
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79
G4RotationMatrix * fArmRotation
constexpr G4int kNofChambers
Definition: B5Constants.hh:38
G4LogicalVolume * fWirePlane2Logical
constexpr G4int kNofHodoscopes1
Definition: B5Constants.hh:36
Definition of the B5HadCalorimeterSD class.
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
EM Calorimeter cell parameterisation.
static G4ThreadLocal G4FieldManager * fFieldMgr
Hodoscope sensitive detector.
Float_t x2[n_points_geant4]
Definition: compare.C:26
G4LogicalVolume * fWirePlane1Logical
constexpr G4int kNofEmCells
Definition: B5Constants.hh:41
Drift chamber sensitive detector.
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
static G4NistManager * Instance()
G4LogicalVolume * fMagneticLogical
static G4ThreadLocal B5MagneticField * fMagneticField
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)