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