Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
basic/B2/B2b/src/B2bDetectorConstruction.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$
27 //
30 
31 #include "B2bDetectorConstruction.hh"
32 #include "B2bDetectorMessenger.hh"
33 #include "B2bChamberParameterisation.hh"
34 #include "B2TrackerSD.hh"
35 
36 #include "G4Material.hh"
37 #include "G4NistManager.hh"
38 #include "G4SDManager.hh"
39 
40 #include "G4Box.hh"
41 #include "G4Tubs.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 #include "G4PVParameterised.hh"
46 #include "G4AutoDelete.hh"
47 
48 #include "G4GeometryTolerance.hh"
49 #include "G4GeometryManager.hh"
50 
51 #include "G4UserLimits.hh"
52 
53 #include "G4VisAttributes.hh"
54 #include "G4Colour.hh"
55 
56 #include "G4SystemOfUnits.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62 
65  fLogicTarget(NULL), fLogicChamber(NULL),
66  fTargetMaterial(NULL), fChamberMaterial(NULL),
67  fStepLimit(NULL),
68  fCheckOverlaps(true)
69 {
70  fMessenger = new B2bDetectorMessenger(this);
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  delete fStepLimit;
78  delete fMessenger;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  // Define materials
87 
88  // Define volumes
89  return DefineVolumes();
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
95 {
96  // Material definition
97 
98  G4NistManager* nistManager = G4NistManager::Instance();
99 
100  // Air defined using NIST Manager
101  nistManager->FindOrBuildMaterial("G4_AIR");
102 
103  // Lead defined using NIST Manager
104  fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
105 
106  // Xenon gas defined using NIST Manager
107  fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
108 
109  // Print materials
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117  G4Material* air = G4Material::GetMaterial("G4_AIR");
118 
119  // Sizes of the principal geometrical components (solids)
120 
121  G4int NbOfChambers = 5;
122  G4double chamberSpacing = 80*cm; // from chamber center to center!
123 
124  G4double chamberWidth = 20.0*cm; // width of the chambers
125  G4double targetLength = 5.0*cm; // full length of Target
126 
127  G4double trackerLength = (NbOfChambers+1)*chamberSpacing;
128 
129  G4double worldLength = 1.2 * (2*targetLength + trackerLength);
130 
131  G4double targetRadius = 0.5*targetLength; // Radius of Target
132  targetLength = 0.5*targetLength; // Half length of the Target
133  G4double trackerSize = 0.5*trackerLength; // Half length of the Tracker
134 
135  // Definitions of Solids, Logical Volumes, Physical Volumes
136 
137  // World
138 
140 
141  G4cout << "Computed tolerance = "
143  << " mm" << G4endl;
144 
145  G4Box* worldS
146  = new G4Box("world", //its name
147  worldLength/2,worldLength/2,worldLength/2); //its size
148  G4LogicalVolume* worldLV
149  = new G4LogicalVolume(
150  worldS, //its solid
151  air, //its material
152  "World"); //its name
153 
154  // Must place the World Physical volume unrotated at (0,0,0).
155  //
156  G4VPhysicalVolume* worldPV
157  = new G4PVPlacement(
158  0, // no rotation
159  G4ThreeVector(), // at (0,0,0)
160  worldLV, // its logical volume
161  "World", // its name
162  0, // its mother volume
163  false, // no boolean operations
164  0, // copy number
165  fCheckOverlaps); // checking overlaps
166 
167  // Target
168 
169  G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
170 
171  G4Tubs* targetS
172  = new G4Tubs("target",0.,targetRadius,targetLength,0.*deg,360.*deg);
174  = new G4LogicalVolume(targetS, fTargetMaterial,"Target",0,0,0);
175  new G4PVPlacement(0, // no rotation
176  positionTarget, // at (x,y,z)
177  fLogicTarget, // its logical volume
178  "Target", // its name
179  worldLV, // its mother volume
180  false, // no boolean operations
181  0, // copy number
182  fCheckOverlaps); // checking overlaps
183 
184  G4cout << "Target is " << 2*targetLength/cm << " cm of "
185  << fTargetMaterial->GetName() << G4endl;
186 
187  // Tracker
188 
189  G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
190 
191  G4Tubs* trackerS
192  = new G4Tubs("tracker",0,trackerSize,trackerSize, 0.*deg, 360.*deg);
193  G4LogicalVolume* trackerLV
194  = new G4LogicalVolume(trackerS, air, "Tracker",0,0,0);
195  new G4PVPlacement(0, // no rotation
196  positionTracker, // at (x,y,z)
197  trackerLV, // its logical volume
198  "Tracker", // its name
199  worldLV, // its mother volume
200  false, // no boolean operations
201  0, // copy number
202  fCheckOverlaps); // checking overlaps
203 
204  // Tracker segments
205 
206  // An example of Parameterised volumes
207  // Dummy values for G4Tubs -- modified by parameterised volume
208 
209  G4Tubs* chamberS
210  = new G4Tubs("tracker",0, 100*cm, 100*cm, 0.*deg, 360.*deg);
212  = new G4LogicalVolume(chamberS,fChamberMaterial,"Chamber",0,0,0);
213 
214  G4double firstPosition = -trackerSize + chamberSpacing;
215  G4double firstLength = trackerLength/10;
216  G4double lastLength = trackerLength;
217 
218  G4VPVParameterisation* chamberParam =
220  NbOfChambers, // NoChambers
221  firstPosition, // Z of center of first
222  chamberSpacing, // Z spacing of centers
223  chamberWidth, // chamber width
224  firstLength, // initial length
225  lastLength); // final length
226 
227  // dummy value : kZAxis -- modified by parameterised volume
228 
229  new G4PVParameterised("Chamber", // their name
230  fLogicChamber, // their logical volume
231  trackerLV, // Mother logical volume
232  kZAxis, // Are placed along this axis
233  NbOfChambers, // Number of chambers
234  chamberParam, // The parametrisation
235  fCheckOverlaps); // checking overlaps
236 
237  G4cout << "There are " << NbOfChambers << " chambers in the tracker region. "
238  << G4endl
239  << "The chambers are " << chamberWidth/cm << " cm of "
240  << fChamberMaterial->GetName() << G4endl
241  << "The distance between chamber is " << chamberSpacing/cm << " cm"
242  << G4endl;
243 
244  // Visualization attributes
245 
246  G4VisAttributes* boxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
247  worldLV ->SetVisAttributes(boxVisAtt);
248  fLogicTarget ->SetVisAttributes(boxVisAtt);
249  trackerLV ->SetVisAttributes(boxVisAtt);
250 
251  G4VisAttributes* chamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
252  fLogicChamber->SetVisAttributes(chamberVisAtt);
253 
254  // Example of User Limits
255  //
256  // Below is an example of how to set tracking constraints in a given
257  // logical volume
258  //
259  // Sets a max step length in the tracker region, with G4StepLimiter
260 
261  G4double maxStep = 0.5*chamberWidth;
262  fStepLimit = new G4UserLimits(maxStep);
263  trackerLV->SetUserLimits(fStepLimit);
264 
272 
273  // Always return the physical world
274 
275  return worldPV;
276 }
277 
278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
279 
281 {
282  // Sensitive detectors
283 
284  G4String trackerChamberSDname = "B2/TrackerChamberSD";
285  B2TrackerSD* aTrackerSD = new B2TrackerSD(trackerChamberSDname,
286  "TrackerHitsCollection");
288  SetSensitiveDetector( fLogicChamber, aTrackerSD );
289 
290  // Create global magnetic field messenger.
291  // Uniform magnetic field is then created automatically if
292  // the field value is not zero.
293  G4ThreeVector fieldValue = G4ThreeVector();
296 
297  // Register the field messenger for deleting
299 }
300 
301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
302 
304 {
305  G4NistManager* nistManager = G4NistManager::Instance();
306 
307  G4Material* pttoMaterial =
308  nistManager->FindOrBuildMaterial(materialName);
309 
310  if (fTargetMaterial != pttoMaterial) {
311  if ( pttoMaterial ) {
312  fTargetMaterial = pttoMaterial;
314  G4cout
315  << G4endl
316  << "----> The target is made of " << materialName << G4endl;
317  } else {
318  G4cout
319  << G4endl
320  << "--> WARNING from SetTargetMaterial : "
321  << materialName << " not found" << G4endl;
322  }
323  }
324 }
325 
326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
327 
329 {
330  G4NistManager* nistManager = G4NistManager::Instance();
331 
332  G4Material* pttoMaterial =
333  nistManager->FindOrBuildMaterial(materialName);
334 
335  if (fChamberMaterial != pttoMaterial) {
336  if ( pttoMaterial ) {
337  fChamberMaterial = pttoMaterial;
339  G4cout
340  << G4endl
341  << "----> The chambers are made of " << materialName << G4endl;
342  } else {
343  G4cout
344  << G4endl
345  << "--> WARNING from SetChamberMaterial : "
346  << materialName << " not found" << G4endl;
347  }
348  }
349 }
350 
351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
352 
354 {
355  if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
356 }
357 
358 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CLHEP::Hep3Vector G4ThreeVector
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
void SetVerboseLevel(G4int verboseLevel)
#define G4ThreadLocal
Definition: tls.hh:69
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:608
void Register(T *inst)
Definition: G4AutoDelete.hh:65
const G4String & GetName() const
Definition: G4Material.hh:179
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
void SetVisAttributes(const G4VisAttributes *pVA)
void SetWorldMaximumExtent(G4double worldExtent)
void SetUserLimits(G4UserLimits *pULimits)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger
static constexpr double cm
Definition: G4SIunits.hh:119
G4GLOB_DLL std::ostream G4cout
void SetMaterial(G4Material *pMaterial)
static G4GeometryTolerance * GetInstance()
virtual void SetMaxAllowedStep(G4double ustepMax)
G4double GetSurfaceTolerance() const
static G4NistManager * Instance()