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