Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par01DetectorConstruction.cc
Go to the documentation of this file.
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 //
28 //
29 //
30 // $Id: Par01DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
31 //
33 #include "Par01CalorimeterSD.hh"
34 #include "Par01EMShowerModel.hh"
35 #include "Par01PiModel.hh"
36 
37 #include "G4Material.hh"
38 #include "G4MaterialTable.hh"
39 #include "G4Element.hh"
40 #include "G4ProductionCuts.hh"
41 #include "G4ElementTable.hh"
42 #include "G4Box.hh"
43 #include "G4Tubs.hh"
44 #include "G4LogicalVolume.hh"
45 #include "G4ThreeVector.hh"
46 #include "G4PVPlacement.hh"
47 #include "G4SDManager.hh"
48 #include "G4VisAttributes.hh"
49 #include "G4Colour.hh"
50 #include "G4SystemOfUnits.hh"
51 #include "G4NistManager.hh"
52 
53 #include "G4RegionStore.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {;}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {;}
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  G4cout << "\nPar01DetectorConstruction....\n" << G4endl;
70 
71  //--------- Material definition ---------
72  // Get nist material manager
73  G4NistManager* nistManager = G4NistManager::Instance();
74 
75  // Build materials
76  G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
77  G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
78  G4Material* helium = nistManager->FindOrBuildMaterial("G4_He");
79  G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe");
80 
81 
82  //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume ---------
83 
84  //--------------
85  // World:
86  //--------------
87  G4Box *WorldBox= new G4Box("WorldBox",400*cm, 400*cm, 400*cm);
88  G4LogicalVolume *WorldLog=new G4LogicalVolume(WorldBox,air,
89  "WorldLogical", 0, 0, 0);
90  G4PVPlacement *WorldPhys=new G4PVPlacement(0,G4ThreeVector(),
91  "WorldPhysical",
92  WorldLog,
93  0,false,0);
94  // Size of detectors:
95  G4double detectSize = 125*cm;
96 
97  //-----------------------------
98  // "Drift Chamber":
99  // Not used in parameterisation.
100  //-----------------------------
101  // -- Logical volume:
102  G4Box *driftChamberBox
103  = new G4Box("DriftChamberSolid", detectSize, detectSize, 40*cm);
104  G4LogicalVolume *driftChamberLog
105  = new G4LogicalVolume(driftChamberBox,helium,
106  "DriftChamberLogical", 0, 0, 0);
107  // -- Placement:
108  // G4PVPlacement *driftChamberPhys =
109  new G4PVPlacement(0,G4ThreeVector(0., 0., 50*cm),
110  "DriftChamberPhysical",
111  driftChamberLog,
112  WorldPhys,false,0);
113 
114  //--------------------------
115  // "Calorimeter": used in
116  // parameterisation below
117  //--------------------------
118  // -- Logical volume:
119  G4Box *calorimeterBox
120  = new G4Box("CalorimeterSolid", detectSize, detectSize, 20*cm);
121  G4LogicalVolume *calorimeterLog = new G4LogicalVolume(calorimeterBox,air,
122  "CalorimeterLogical", 0, 0, 0);
123  // -- Placement:
124  G4PVPlacement *calorimeterPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 120*cm),
125  "CalorimeterPhysical",
126  calorimeterLog,
127  WorldPhys,false,0);
128 
129  //--------------------------------------
130  // The calorimeter is filled with
131  // crystals:
132  //--------------------------------------
133  // -- Logical volume:
134  G4double CrystalX = 2.5*cm;
135  G4double CrystalY = CrystalX;
136  G4double CrystalZ = 20*cm;
137  G4Box *CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ);
138  fCrystalLog = new G4LogicalVolume(CrystalSolid,csi,
139  "CrystalLogical", 0, 0, 0);
140 
141  G4String tName1("Crystal"); // Allow all target physicals to share
142  // same name (delayed copy)
143 
144  // -- and placements inside the calorimeter:
145  G4int copyNo=0;
146  G4double xTlate, yTlate;
147  fnX = 48;
148  fnY = 48;
149  for (G4int j = 0; j < fnY; j++)
150  {
151  yTlate = -detectSize + 3*CrystalY + j*2*CrystalY;
152  for (G4int i = 0; i < fnX; i++)
153  {
154  xTlate = -detectSize + 3*CrystalX + i*2*CrystalX;
155  new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
156  tName1,
157  fCrystalLog,
158  calorimeterPhys,false,copyNo++);
159  }
160  }
161 
162 
163  //--------------------------
164  // "Hadron Calorimeter": used
165  // in parameterisation with
166  // a parallel geometry
167  //--------------------------
168  // -- Logical volume:
169  G4Box *hadCaloBox
170  = new G4Box("HadCaloSolid", detectSize, detectSize, 50*cm);
171  G4LogicalVolume *hadCaloLog = new G4LogicalVolume(hadCaloBox,air,
172  "HadCaloLogical", 0, 0, 0);
173  // -- Placement:
174  G4PVPlacement *hadCaloPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 200*cm),
175  "HadCaloPhysical",
176  hadCaloLog,
177  WorldPhys,false,0);
178 
179  //--------------------------------------
180  // The calorimeter is filled with
181  // towers:
182  //--------------------------------------
183  // -- Logical volume:
184  G4double TowerX = 5*cm;
185  G4double TowerY = TowerX;
186  G4double TowerZ = 45*cm;
187  G4Box *TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ);
188  fTowerLog = new G4LogicalVolume(TowerSolid,iron,
189  "TowerLogical", 0, 0, 0);
190 
191  G4String tName2("Tower");
192 
193  // -- and placements inside the calorimeter:
194  copyNo=0;
195  fnXhad = 23;
196  fnYhad = 23;
197  for (G4int jj = 0; jj < fnYhad; jj++)
198  {
199  yTlate = -detectSize + 3*TowerY + jj*2*TowerY;
200  for (G4int i = 0; i < fnXhad; i++)
201  {
202  xTlate = -detectSize + 3*TowerX + i*2*TowerX;
203  new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
204  tName2,
205  fTowerLog,
206  hadCaloPhys,false,copyNo++);
207  }
208  }
209 
210 
211 
212 
213  // -- Makes the calorimeterLog volume becoming a G4Region:
214  G4Region* caloRegion = new G4Region("EM_calo_region");
215  caloRegion->AddRootLogicalVolume(calorimeterLog);
216  std::vector<double> cuts;
217  cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);
218  caloRegion->SetProductionCuts(new G4ProductionCuts());
219  caloRegion->GetProductionCuts()->SetProductionCuts(cuts);
220 
221  // Makes had. calo a region to:
222  G4Region* hadRegion = new G4Region("HAD_calo_region");
223  hadRegion->AddRootLogicalVolume(hadCaloLog);
224  cuts.clear();
225  cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);
226  hadRegion->SetProductionCuts(new G4ProductionCuts());
227  hadRegion->GetProductionCuts()->SetProductionCuts(cuts);
228 
229  //--------- Visualization attributes -------------------------------
231 
232  G4VisAttributes * driftchamberTubeVisAtt
233  = new G4VisAttributes(G4Colour(0.0,1.0,0.0));
234  driftchamberTubeVisAtt->SetForceWireframe(true);
235  driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt);
236 
237  G4VisAttributes * calorimeterBoxVisAtt
238  = new G4VisAttributes(G4Colour(0.0,0.0,1.0));
239  calorimeterBoxVisAtt->SetForceWireframe(true);
240  calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt);
241 
242  G4VisAttributes * crystalVisAtt
243  = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
244  crystalVisAtt->SetForceWireframe(true);
245  fCrystalLog->SetVisAttributes(crystalVisAtt);
246 
247  G4VisAttributes * hadCaloBoxVisAtt
248  = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
249  hadCaloBoxVisAtt->SetForceWireframe(true);
250  hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt);
251 
252  G4VisAttributes * towerVisAtt
253  = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
254  towerVisAtt->SetForceWireframe(true);
255  fTowerLog->SetVisAttributes(towerVisAtt);
256 
257  //------------------------------------------------------------------
258 
259 
260  //-----------------------
261  // Returns the pointer to
262  // the physical world:
263  //-----------------------
264  return WorldPhys;
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
271  //--------- Sensitive detector -------------------------------------
273  G4String calorimeterSDname = "Par01/Calorimeter";
274  Par01CalorimeterSD* CalorimeterSD = new Par01CalorimeterSD( calorimeterSDname,
275  fnX*fnY,
276  "CalCollection" );
277  SDman->AddNewDetector( CalorimeterSD );
278  fCrystalLog->SetSensitiveDetector(CalorimeterSD);
279 
280  G4String hadCalorimeterSDname = "Par01/HadronCalorimeter";
281  Par01CalorimeterSD* HadCalorimeterSD = new Par01CalorimeterSD( hadCalorimeterSDname,
282  fnXhad*fnYhad,
283  "HadCollection" );
284  SDman->AddNewDetector( HadCalorimeterSD );
285  fTowerLog->SetSensitiveDetector(HadCalorimeterSD);
286 
287  // --------------- fast simulation ----------------------------
288  G4RegionStore* regionStore = G4RegionStore::GetInstance();
289 
290  G4Region* caloRegion = regionStore->GetRegion("EM_calo_region");
291  // builds a model and sets it to the envelope of the calorimeter:
292  new Par01EMShowerModel("emShowerModel",caloRegion);
293 }
G4ProductionCuts * GetProductionCuts() const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
static constexpr double mm
Definition: G4SIunits.hh:115
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
Definition of the Par01EMShowerModel class.
Definition: G4Box.hh:64
virtual G4VPhysicalVolume * Construct()
Definition of the Par01PiModel class.
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4RegionStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
Definition of the Par01CalorimeterSD class.
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
void SetProductionCuts(G4ProductionCuts *cut)
Definition of the Par01DetectorConstruction class.
double G4double
Definition: G4Types.hh:76
static const G4VisAttributes & GetInvisible()
void SetForceWireframe(G4bool=true)
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
void SetProductionCuts(std::vector< G4double > &)