Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN05DetectorConstruction.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 //
26 //
27 // $Id$
28 //
30 #include "ExN05CalorimeterSD.hh"
31 #include "ExN05EMShowerModel.hh"
32 #include "ExN05PiModel.hh"
33 
34 #include "G4Material.hh"
35 #include "G4MaterialTable.hh"
36 #include "G4Element.hh"
37 #include "G4ProductionCuts.hh"
38 #include "G4ElementTable.hh"
39 #include "G4Box.hh"
40 #include "G4Tubs.hh"
41 #include "G4LogicalVolume.hh"
42 #include "G4ThreeVector.hh"
43 #include "G4PVPlacement.hh"
44 #include "G4SDManager.hh"
45 #include "G4VisAttributes.hh"
46 #include "G4Colour.hh"
47 #include "G4SystemOfUnits.hh"
48 
50 {;}
51 
53 {;}
54 
56 {
57  G4cout << "\nExN05DetectorConstruction....\n" << G4endl;
58 
59  //--------- Material definition ---------
60 
61  G4double a, iz, z, density;
63  G4int nel;
64 
65  a = 14.01*g/mole;
66  G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
67  a = 16.00*g/mole;
68  G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a);
69  a = 126.9*g/mole;
70  G4Element* elI = new G4Element(name="Iodine", symbol="I", iz=53., a);
71  a = 132.9*g/mole;
72  G4Element* elCs= new G4Element(name="Cesium", symbol="Cs", iz=55., a);
73 
74 
75  density = 4.51*g/cm3;
76  G4Material* CsI = new G4Material(name="CsI", density, nel = 2);
77  CsI->AddElement(elI, .5);
78  CsI->AddElement(elCs,.5);
79  a = 4.0*g/mole;
80  density = 0.1786e-03*g/cm3;
81  G4Material* He = new G4Material(name="He", z=2., a, density);
82 
83  a = 55.85*g/mole;
84  density = 7.87*g/cm3;
85  G4Material* Fe = new G4Material(name="Fer", z=26., a, density);
86  density = 1.29e-03*g/cm3;
87  G4Material* Air = new G4Material(name="Air", density, nel=2);
88  Air->AddElement(elN, .7);
89  Air->AddElement(elO, .3);
90 
91  //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume ---------
92 
93  //--------------
94  // World:
95  //--------------
96  G4Box *WorldBox= new G4Box("WorldBox",400*cm, 400*cm, 400*cm);
97  G4LogicalVolume *WorldLog=new G4LogicalVolume(WorldBox,Air,
98  "WorldLogical", 0, 0, 0);
99  G4PVPlacement *WorldPhys=new G4PVPlacement(0,G4ThreeVector(),
100  "WorldPhysical",
101  WorldLog,
102  0,false,0);
103  // Size of detectors:
104  G4double detectSize = 125*cm;
105 
106  //-----------------------------
107  // "Drift Chamber":
108  // Not used in parameterisation.
109  //-----------------------------
110  // -- Logical volume:
111  G4Box *driftChamberBox
112  = new G4Box("DriftChamberSolid", detectSize, detectSize, 40*cm);
113  G4LogicalVolume *driftChamberLog
114  = new G4LogicalVolume(driftChamberBox,He,
115  "DriftChamberLogical", 0, 0, 0);
116  // -- Placement:
117  // G4PVPlacement *driftChamberPhys =
118  new G4PVPlacement(0,G4ThreeVector(0., 0., 50*cm),
119  "DriftChamberPhysical",
120  driftChamberLog,
121  WorldPhys,false,0);
122 
123  //--------------------------
124  // "Calorimeter": used in
125  // parameterisation below
126  //--------------------------
127  // -- Logical volume:
128  G4Box *calorimeterBox
129  = new G4Box("CalorimeterSolid", detectSize, detectSize, 20*cm);
130  G4LogicalVolume *calorimeterLog = new G4LogicalVolume(calorimeterBox,Air,
131  "CalorimeterLogical", 0, 0, 0);
132  // -- Placement:
133  G4PVPlacement *calorimeterPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 120*cm),
134  "CalorimeterPhysical",
135  calorimeterLog,
136  WorldPhys,false,0);
137 
138  //--------------------------------------
139  // The calorimeter is filled with
140  // crystals:
141  //--------------------------------------
142  // -- Logical volume:
143  G4double CrystalX = 2.5*cm;
144  G4double CrystalY = CrystalX;
145  G4double CrystalZ = 20*cm;
146  G4Box *CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ);
147  theCrystalLog = new G4LogicalVolume(CrystalSolid,CsI,
148  "CrystalLogical", 0, 0, 0);
149 
150  G4String tName1("Crystal"); // Allow all target physicals to share
151  // same name (delayed copy)
152 
153  // -- and placements inside the calorimeter:
154  G4int copyNo=0;
155  G4double xTlate, yTlate;
156  G4int nX = 48;
157  G4int nY = 48;
158  for (G4int j = 0; j < nY; j++)
159  {
160  yTlate = -detectSize + 3*CrystalY + j*2*CrystalY;
161  for (G4int i = 0; i < nX; i++)
162  {
163  xTlate = -detectSize + 3*CrystalX + i*2*CrystalX;
164  new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
165  tName1,
166  theCrystalLog,
167  calorimeterPhys,false,copyNo++);
168  }
169  }
170 
171 
172  //--------------------------
173  // "Hadron Calorimeter": used
174  // in parameterisation with
175  // a parallel geometry
176  //--------------------------
177  // -- Logical volume:
178  G4Box *hadCaloBox
179  = new G4Box("HadCaloSolid", detectSize, detectSize, 50*cm);
180  G4LogicalVolume *hadCaloLog = new G4LogicalVolume(hadCaloBox,Air,
181  "HadCaloLogical", 0, 0, 0);
182  // -- Placement:
183  G4PVPlacement *hadCaloPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 200*cm),
184  "HadCaloPhysical",
185  hadCaloLog,
186  WorldPhys,false,0);
187 
188  //--------------------------------------
189  // The calorimeter is filled with
190  // towers:
191  //--------------------------------------
192  // -- Logical volume:
193  G4double TowerX = 5*cm;
194  G4double TowerY = TowerX;
195  G4double TowerZ = 45*cm;
196  G4Box *TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ);
197  theTowerLog = new G4LogicalVolume(TowerSolid,Fe,
198  "TowerLogical", 0, 0, 0);
199 
200  G4String tName2("Tower");
201 
202  // -- and placements inside the calorimeter:
203  copyNo=0;
204  G4int nXhad = 23;
205  G4int nYhad = 23;
206  for (G4int jj = 0; jj < nYhad; jj++)
207  {
208  yTlate = -detectSize + 3*TowerY + jj*2*TowerY;
209  for (G4int i = 0; i < nXhad; i++)
210  {
211  xTlate = -detectSize + 3*TowerX + i*2*TowerX;
212  new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
213  tName2,
214  theTowerLog,
215  hadCaloPhys,false,copyNo++);
216  }
217  }
218 
219 
220  //--------- Sensitive detector -------------------------------------
222  G4String calorimeterSDname = "ExN05/Calorimeter";
223  ExN05CalorimeterSD* CalorimeterSD = new ExN05CalorimeterSD( calorimeterSDname, nX*nY, "CalCollection" );
224  SDman->AddNewDetector( CalorimeterSD );
225  theCrystalLog->SetSensitiveDetector(CalorimeterSD);
226 
227  G4String hadCalorimeterSDname = "ExN05/HadronCalorimeter";
228  ExN05CalorimeterSD* HadCalorimeterSD = new ExN05CalorimeterSD( hadCalorimeterSDname, nXhad*nYhad, "HadCollection" );
229  SDman->AddNewDetector( HadCalorimeterSD );
230  theTowerLog->SetSensitiveDetector(HadCalorimeterSD);
231 
232  //------------------ Parameterisation Models --------------------------
233  // -- Makes the calorimeterLog volume becoming a G4Region:
234  G4Region* caloRegion = new G4Region("EM_calo_region");
235  caloRegion->AddRootLogicalVolume(calorimeterLog);
236  std::vector<double> cuts;
237  cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);
238  caloRegion->SetProductionCuts(new G4ProductionCuts());
239  caloRegion->GetProductionCuts()->SetProductionCuts(cuts);
240  // builds a model and sets it to the envelope of the calorimeter:
241  new ExN05EMShowerModel("emShowerModel",caloRegion);
242  // -- uncomment for seeing warning message with /param/showSetup command new ExN05PiModel(caloRegion);
243 
244  // ---------------- Makes had. calo a region too ------------------
245  G4Region* hadRegion = new G4Region("HAD_calo_region");
246  hadRegion->AddRootLogicalVolume(hadCaloLog);
247  cuts.clear();
248  cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);
249  hadRegion->SetProductionCuts(new G4ProductionCuts());
250  hadRegion->GetProductionCuts()->SetProductionCuts(cuts);
251 
252  //--------- Visualization attributes -------------------------------
254 
255  G4VisAttributes * driftchamberTubeVisAtt
256  = new G4VisAttributes(G4Colour(0.0,1.0,0.0));
257  driftchamberTubeVisAtt->SetForceWireframe(true);
258  driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt);
259 
260  G4VisAttributes * calorimeterBoxVisAtt
261  = new G4VisAttributes(G4Colour(0.0,0.0,1.0));
262  calorimeterBoxVisAtt->SetForceWireframe(true);
263  calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt);
264 
265  G4VisAttributes * crystalVisAtt
266  = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
267  crystalVisAtt->SetForceWireframe(true);
268  theCrystalLog->SetVisAttributes(crystalVisAtt);
269 
270  G4VisAttributes * hadCaloBoxVisAtt
271  = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
272  hadCaloBoxVisAtt->SetForceWireframe(true);
273  hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt);
274 
275  G4VisAttributes * towerVisAtt
276  = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
277  towerVisAtt->SetForceWireframe(true);
278  theTowerLog->SetVisAttributes(towerVisAtt);
279 
280  //------------------------------------------------------------------
281 
282 
283  //-----------------------
284  // Returns the pointer to
285  // the physical world:
286  //-----------------------
287  return WorldPhys;
288 }
289