ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.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 //
27 
28 #include "DetectorConstruction.hh"
29 
30 #include "G4Material.hh"
31 #include "G4NistManager.hh"
32 
33 #include "G4Box.hh"
34 
35 #include "G4LogicalVolume.hh"
36 #include "G4PVPlacement.hh"
37 #include "G4SystemOfUnits.hh"
38 #include "G4PhysicalConstants.hh"
39 
40 #include "G4GeometryManager.hh"
41 #include "G4PhysicalVolumeStore.hh"
42 #include "G4LogicalVolumeStore.hh"
43 #include "G4SolidStore.hh"
44 
45 #include "G4VisAttributes.hh"
46 #include "G4Colour.hh"
47 
48 #include "G4CrystalExtension.hh"
49 #include "G4ExtendedMaterial.hh"
51 
54 
55 #include "SensitiveDetector.hh"
56 
57 #include "G4SDManager.hh"
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 fECfileName("Si220pl"),
63 fMaterialName("G4_Si"),
64 fSizes(G4ThreeVector(1.*CLHEP::mm,
65  70.*CLHEP::mm,
66  1.94 * CLHEP::mm)),
67 fBR(G4ThreeVector(0.,0.,0.)),
68 fAngles(G4ThreeVector(0.,0.,0.)){
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
73 
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
77 
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 
84  //** World **//
85  G4Material* worldMaterial =
87 
88  G4double worldSizeXY = 1. * CLHEP::meter;
89  G4double worldSizeZ = 22. * CLHEP::meter;
90 
91  G4Box* worldSolid = new G4Box("world.solid",
92  worldSizeXY/2.,
93  worldSizeXY/2.,
94  worldSizeZ/2.);
95 
96  G4LogicalVolume* worldLogic = new G4LogicalVolume(worldSolid,
97  worldMaterial,
98  "world.logic");
99 
100  G4PVPlacement* worldPhysical = new G4PVPlacement(0,
101  G4ThreeVector(),
102  worldLogic,
103  "world.physic",
104  0,
105  false,
106  0);
107 
108  //** Detectors instantiation **//
109  G4ThreeVector fDetectorSizes(G4ThreeVector(38.0 * CLHEP::mm,
110  38.0 * CLHEP::mm,
111  0.64 * CLHEP::mm));
112  G4double fDetectorDistance[3] = {
113  -9.998 * CLHEP::m,
114  -0.320 * CLHEP::m,
115  +10.756* CLHEP::m};
116 
117  G4Box* ssdSolid = new G4Box("ssd.solid",
118  fDetectorSizes.x()/2.,
119  fDetectorSizes.y()/2.,
120  fDetectorSizes.z()/2.);
121 
122  G4Material* detectorMaterial =
124  G4LogicalVolume* ssdLogic =
125  new G4LogicalVolume(ssdSolid,
126  detectorMaterial,
127  "ssd.logic");
128 
129  for(size_t i1=0;i1<3;i1++){
130  new G4PVPlacement(0,
131  G4ThreeVector(0.,
132  0.,
133  fDetectorDistance[i1]),
134  ssdLogic,
135  "ssd.physic",
136  worldLogic,
137  false,
138  i1);
139 
140  }
141 
142  //** Crystal solid parameters **//
143  G4Box* crystalSolid = new G4Box("crystal.solid",
144  fSizes.x()/2.,
145  fSizes.y()/2.,
146  fSizes.z()/2.);
147 
148  //** Crystal Definition Start **//
149  G4Material* mat =
152  new G4ExtendedMaterial("crystal.material",mat);
153 
154  Crystal->RegisterExtension(std::unique_ptr<G4CrystalExtension>(
155  new G4CrystalExtension(Crystal)));
156  G4CrystalExtension* crystalExtension =
157  (G4CrystalExtension*)Crystal->RetrieveExtension("crystal");
158  crystalExtension->SetUnitCell(
160  5.43 * CLHEP::angstrom,
161  5.43 * CLHEP::angstrom,
165  227));
166 
167  Crystal->RegisterExtension(std::unique_ptr<G4ChannelingMaterialData>(
168  new G4ChannelingMaterialData("channeling")));
169  G4ChannelingMaterialData* crystalChannelingData =
170  (G4ChannelingMaterialData*)Crystal->RetrieveExtension("channeling");
171  crystalChannelingData->SetFilename(fECfileName);
172 
173  if(fBR!=G4ThreeVector()){
174  crystalChannelingData->SetBR(fBR.x());
175  }
176 
177  G4LogicalCrystalVolume* crystalLogic =
178  new G4LogicalCrystalVolume(crystalSolid,
179  Crystal,
180  "crystal.logic");
181  crystalLogic->SetVerbose(1);
182  //** Crystal Definition End **//
183 
185  if(fAngles.x()!=0.){
186  rot->rotateX(fAngles.x());
187  }
188  if(fAngles.y()!=0.){
189  rot->rotateY(fAngles.y());
190  }
191  if(fAngles.z()!=0.){
192  rot->rotateZ(fAngles.z());
193  }
194 
195  new G4PVPlacement(rot,
196  G4ThreeVector(),
197  crystalLogic,
198  "crystal.physic",
199  worldLogic,
200  false,
201  0);
202 
203 #ifndef G4MULTITHREADED
206  testMany->AttachTo(crystalLogic);
207  G4cout << " Attaching biasing operator " << testMany->GetName()
208  << " to logical volume " << crystalLogic->GetName()
209  << G4endl;
210 
211  G4VSensitiveDetector* telescope = new SensitiveDetector("/telescope");
213  for(unsigned int i1=0;i1<3;i1++){
214  ssdLogic->SetSensitiveDetector(telescope);
215  }
216 #endif
217 
218  return worldPhysical;
219 }
220 
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
222 
223 #ifdef G4MULTITHREADED
225  G4LogicalVolume* crystalLogic =
226  G4LogicalVolumeStore::GetInstance()->GetVolume("crystal.logic");
229  testMany->AttachTo(crystalLogic);
230  G4cout << " Attaching biasing operator " << testMany->GetName()
231  << " to logical volume " << crystalLogic->GetName()
232  << G4endl;
233 
234  G4LogicalVolume* ssdLogic =
236  G4VSensitiveDetector* telescope = new SensitiveDetector("/telescope");
238  for(unsigned int i1=0;i1<3;i1++){
239  ssdLogic->SetSensitiveDetector(telescope);
240  }
241 }
242 #else
244 #endif
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......