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