Geant4  10.01.p03
CCalG4Hcal.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 //
27 // File: CCalG4Hcal.cc
28 // Description: CCalG4Hcal Factory class to construct the G4 geometry of the
29 // hadron calorimeter
31 #include <cmath>
32 
33 #include "CCalG4Hcal.hh"
34 
35 #include "CCalMaterialFactory.hh"
38 
39 #include "CCalutils.hh"
40 
41 #include "G4SystemOfUnits.hh"
42 #include "G4ThreeVector.hh"
43 #include "G4Box.hh"
44 
45 #include "G4LogicalVolume.hh"
46 #include "G4PVPlacement.hh"
47 
48 //#define debug
49 //#define ddebug
50 //#define pdebug
51 //#define sdebug
52 
54 // CCalG4Hcal constructor & destructor...
56 
58  CCalHcal(name), CCalG4Able(name), sclLog(0), absLog(0) {}
59 
61  if (sclLog)
62  delete[] sclLog;
63  if (absLog)
64  delete[] absLog;
65 }
66 
68 // CCalG4Hcal methods...
70 
72  G4cout << "==>> Constructing CCalG4Hcal..." << G4endl;
73 
74  //Common logical volumes between methods.
75 #ifdef debug
76  G4cout << tab << "Common logical volumes initialization: "
77  << getNScintillator() << " scintillaor and " << getNAbsorber()
78  << " absorber layers." << G4endl;
79 #endif
80  G4int i = 0;
82  absLog = new ptrG4Log[getNAbsorber()];
83  for (i=0; i < getNScintillator(); i++)
84  sclLog[i] = 0;
85  for (i=0; i < getNAbsorber(); i++)
86  absLog[i] = 0;
87 
88  //Pointers to the Materials
90 
91  //Mother volume
92  G4Material* matter = matfact->findMaterial(getGenMat());
93  G4VSolid* solid = new G4Box (Name(), getDx_2Cal()*mm, getDy_2Cal()*mm,
94  getDy_2Cal()*mm);
95  G4LogicalVolume* logh = new G4LogicalVolume(solid, matter, Name());
97 #ifdef debug
98  G4cout << tab << Name() << " Box made of " << getGenMat()
99  << " of dimension " << getDx_2Cal()*mm << " " << getDy_2Cal()*mm
100  << " " << getDy_2Cal()*mm << G4endl;
101 #endif
102 
104  Name(), logh, mother, false, 1);
105  G4String name("Null");
106 #ifdef pdebug
107  if (mother != 0) name = mother->GetName();
108  G4cout << Name() << " Number 1 positioned in " << name << " at ("
109  << getXposCal()*mm << ",0,0) with no rotation" << G4endl;
110 #endif
111 
112  //Wall of the Boxes
113  solid = new G4Box (name, 0.5*getWallThickBox()*mm, getDy_2Box()*mm,
114  getDy_2Box()*mm);
115  matter = matfact->findMaterial(getBoxMat());
116  name = Name() + "Wall";
117  G4LogicalVolume* logw = new G4LogicalVolume(solid, matter, name);
119 #ifdef debug
120  G4cout << tab << name << " Box made of " << getBoxMat()
121  << " of dimension " << 0.5*getWallThickBox()*mm << " "
122  << getDy_2Box()*mm << " " << getDy_2Box()*mm << G4endl;
123 #endif
124 
125  //Now the boxes
126  ptrG4Log* logb = new ptrG4Log[getNBox()];
127  matter = matfact->findMaterial(getGenMat());
128  for (i=0; i<getNBox(); i++) {
129  name = Name() + "Box" + i;
130  solid = new G4Box (name, getDx_2Box()*mm, getDy_2Box()*mm,
131  getDy_2Box()*mm);
132  logb[i]= new G4LogicalVolume(solid, matter, name);
134 #ifdef debug
135  G4cout << tab << name << " Box made of " << getGenMat()
136  << " of dimension " << getDx_2Box()*mm << " " << getDy_2Box()*mm
137  << " " << getDy_2Box()*mm << G4endl;
138 #endif
139 
140  G4double xpos = -(getDx_2Box() - 0.5*getWallThickBox());
141  new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
142  logb[i], false, 1);
143 #ifdef pdebug
144  G4cout << logw->GetName() << " Number 1 positioned in " << name
145  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
146 #endif
147  xpos = (getDx_2Box() - 0.5*getWallThickBox());
148  new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
149  logb[i], false, 2);
150 #ifdef pdebug
151  G4cout << logw->GetName() << " Number 2 positioned in " << name
152  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
153 #endif
154 
155  new G4PVPlacement (0, G4ThreeVector(getXposBox(i)*mm,0,0), logb[i], name,
156  logh, false, i+1);
157 #ifdef pdebug
158  G4cout << name << " Number " << i+1 << " positioned in " << logh->GetName()
159  << " at (" << getXposBox(i)*mm << ",0,0) with no rotation" << G4endl;
160 #endif
161  }
162 
163  //Loop over scintillator layers
164  for (i=0; i<getNLayerScnt(); i++) {
165  G4int lay = getTypeScnt(i);
166  if (!sclLog[lay])
168  if (getMotherScnt(i) < 0 || getMotherScnt(i) >= getNScintillator()) {
169  logw = logh;
170  } else {
171  logw = logb[getMotherScnt(i)];
172  }
173  G4double xpos = getXposScnt(i);
174  new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), sclLog[lay],
175  sclLog[lay]->GetName(), logw, false, i+1);
176 #ifdef pdebug
177  G4cout << sclLog[lay]->GetName() << " Number " << i+1 << " positioned in "
178  << logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
179  << G4endl;
180 #endif
181  }
182 
183  //Loop over absorber layers
184  for (i=0; i<getNLayerAbs(); i++) {
185  G4int lay = getTypeAbs(i);
186  if (!absLog[lay])
187  absLog[lay] = constructAbsorberLayer(lay);
188  if (getMotherAbs(i) < 0 || getMotherAbs(i) >= getNAbsorber()) {
189  logw = logh;
190  } else {
191  logw = logb[getMotherAbs(i)];
192  }
193  G4double xpos = getXposAbs(i);
194  new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), absLog[lay],
195  absLog[lay]->GetName(), logw, false, i+1);
196 #ifdef pdebug
197  G4cout << absLog[lay]->GetName() << " Number " << i+1 << " positioned in "
198  << logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
199  << G4endl;
200 #endif
201  }
202 
203  delete [] logb;
204 
205  G4cout << "<<== End of CCalG4Hcal construction ..." << G4endl;
206 
207  return hcal;
208 }
209 
210 
212 
213  //Pointers to the Materials
215 
216  //The scintillator layer
217  G4Material* matter = matfact->findMaterial(getGenMat());
218  G4String name = Name() + "ScntLayer" + lay;
219  G4VSolid* solid = new G4Box (name, getDx_2ScntLay(lay)*mm,
220  getDy_2ScntLay(lay)*mm,
221  getDy_2ScntLay(lay)*mm);
222  G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
224 #ifdef debug
225  G4cout << tab << name << " Box made of " << getGenMat() << " of dimension "
226  << getDx_2ScntLay(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
227  << getDy_2ScntLay(lay)*mm << G4endl;
228 #endif
229 
230  G4LogicalVolume* logd;
231  G4double xpos;
232  //Wrappers if any
233  if (getDx_2Wrap(lay) > 0) {
234  name = Name() + "ScntWrapper" + lay;
235  matter = matfact->findMaterial(getWrapMat());
236  solid = new G4Box (name, getDx_2Wrap(lay)*mm,
237  getDy_2ScntLay(lay)*mm, getDy_2ScntLay(lay)*mm);
238  logd = new G4LogicalVolume(solid, matter, name);
240 #ifdef debug
241  G4cout << tab << name << " Box made of " << getWrapMat() << " of dimension "
242  << getDx_2Wrap(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
243  << getDy_2ScntLay(lay)*mm << G4endl;
244 #endif
245  xpos =-(getDx_2ScntLay(lay)-getDx_2Wrap(lay));
246  new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
247 #ifdef pdebug
248  G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
249  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
250 #endif
251  xpos = (getDx_2ScntLay(lay)-getDx_2Wrap(lay));
252  new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,2);
253 #ifdef pdebug
254  G4cout << logd->GetName() << " Number 2 positioned in " << log->GetName()
255  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
256 #endif
257  }
258 
259  //Plastic covers
260  matter = matfact->findMaterial(getPlasMat());
261  name = Name() + "FrontPlastic" + lay;
262  solid = new G4Box (name, getDx_2FrontP(lay)*mm, getDy_2ScntLay(lay)*mm,
263  getDy_2ScntLay(lay)*mm);
264  logd = new G4LogicalVolume(solid, matter, name);
266 #ifdef debug
267  G4cout << tab << name << " Box made of " << getPlasMat() << " of dimension "
268  << getDx_2FrontP(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
269  << getDy_2ScntLay(lay)*mm << G4endl;
270 #endif
271  xpos =-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+getDx_2FrontP(lay);
272  new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
273 #ifdef pdebug
274  G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
275  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
276 #endif
277  name = Name() + "BackPlastic" + lay;
278  solid = new G4Box (name, getDx_2BackP(lay)*mm, getDy_2ScntLay(lay)*mm,
279  getDy_2ScntLay(lay)*mm);
280  logd = new G4LogicalVolume(solid, matter, name);
282 #ifdef debug
283  G4cout << tab << name << " Box made of " << getPlasMat() << " of dimension "
284  << getDx_2BackP(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
285  << getDy_2ScntLay(lay)*mm << G4endl;
286 #endif
287  xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+2.*getDx_2FrontP(lay)+
288  2.*getDx_2Scnt(lay)+getDx_2BackP(lay));
289  new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
290 #ifdef pdebug
291  G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
292  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
293 #endif
294 
295  //Now the scintillators
296  matter = matfact->findMaterial(getScntMat());
297  name = Name() + "Scintillator" + lay;
298  solid = new G4Box (name, getDx_2Scnt(lay)*mm, getDy_2ScntLay(lay)*mm,
299  getDy_2ScntLay(lay)*mm);
300  logd = new G4LogicalVolume(solid, matter, name);
302  allSensitiveLogs.push_back(logd);
303 #ifdef debug
304  G4cout << tab << name << " Box made of " << getScntMat() << " of dimension "
305  << getDx_2Scnt(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
306  << getDy_2ScntLay(lay)*mm << G4endl;
307 #endif
308  xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+2.*getDx_2FrontP(lay)+
309  getDx_2Scnt(lay));
310  new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
311 #ifdef pdebug
312  G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
313  << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
314 #endif
315 
316  return log;
317 }
318 
319 
321 
322  //Pointers to the Materials
324 
325  //Now the absorber layer
326  G4Material* matter = matfact->findMaterial(getAbsMat());
327  G4String name = Name() + "Absorber" + lay;
328  G4VSolid* solid = new G4Box (name, getDx_2Abs(lay)*mm, getDy_2Abs()*mm,
329  getDy_2Abs()*mm);
330  G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
332 #ifdef debug
333  G4cout << tab << name << " Box made of " << getAbsMat() << " of dimension "
334  << getDx_2Abs(lay)*mm << " " << getDy_2Abs()*mm << " "
335  << getDy_2Abs()*mm << G4endl;
336 #endif
337 
338  return log;
339 }
340 
341 
343 
344  if (allSensitiveLogs.size()>0) {
346  G4String SDname = Name();
347  for (std::vector<ptrG4Log>::iterator iter=allSensitiveLogs.begin();
348  iter<allSensitiveLogs.end(); iter++) {
349  sensDets->registerVolume(SDname, (*iter));
350 #ifdef sdebug
351  G4cout << "Register volume " << (*iter)->GetName() << " for" << SDname
352  << G4endl;
353 #endif
354  }
355  } else {
356  G4cerr << "CCalG4Hcal ERROR: Could not construct Sensitive Detector"
357  << G4endl;
358  }
359 }
360 
double getDx_2BackP(unsigned int i) const
Definition: CCalHcal.hh:72
CCalG4Hcal(const G4String &name)
Definition: CCalG4Hcal.cc:57
virtual G4VPhysicalVolume * constructIn(G4VPhysicalVolume *)
Definition: CCalG4Hcal.cc:71
G4String getPlasMat() const
Definition: CCalHcal.hh:66
int getNBox() const
Definition: CCalHcal.hh:47
double getXposScnt(unsigned int i) const
Definition: CCalHcal.hh:55
double getDx_2ScntLay(unsigned int i) const
Definition: CCalHcal.hh:69
G4String GetName() const
CLHEP::Hep3Vector G4ThreeVector
virtual void constructDaughters()
Definition: CCalG4Hcal.cc:361
double getDy_2Cal() const
Definition: CCalHcal.hh:43
double getDy_2Box() const
Definition: CCalHcal.hh:48
Definition: G4Box.hh:64
G4String name
Definition: TRTMaterials.hh:40
void setVisType(CCalVisualisable::visType, G4LogicalVolume *)
Definition: CCalG4Able.cc:104
ptrG4Log * sclLog
Definition: CCalG4Hcal.hh:61
G4String Name() const
Definition: CCalDetector.hh:77
int getMotherScnt(unsigned int i) const
Definition: CCalHcal.hh:54
virtual void constructSensitive()
Definition: CCalG4Hcal.cc:342
int getNLayerAbs() const
Definition: CCalHcal.hh:56
static CCalSensitiveDetectors * getInstance()
G4LogicalVolume * constructAbsorberLayer(G4int)
Definition: CCalG4Hcal.cc:320
G4String getScntMat() const
Definition: CCalHcal.hh:64
double getXposCal() const
Definition: CCalHcal.hh:45
double getDy_2Abs() const
Definition: CCalHcal.hh:62
double getWallThickBox() const
Definition: CCalHcal.hh:50
int G4int
Definition: G4Types.hh:78
int getTypeAbs(unsigned int i) const
Definition: CCalHcal.hh:57
std::vector< ptrG4Log > allSensitiveLogs
Definition: CCalG4Hcal.hh:65
int getMotherAbs(unsigned int i) const
Definition: CCalHcal.hh:58
double getDx_2Wrap(unsigned int i) const
Definition: CCalHcal.hh:70
void registerVolume(const G4String &name, G4LogicalVolume *)
double getDx_2Box() const
Definition: CCalHcal.hh:49
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
double getDx_2FrontP(unsigned int i) const
Definition: CCalHcal.hh:71
G4Material * findMaterial(const G4String &) const
G4String getAbsMat() const
Definition: CCalHcal.hh:60
G4String getGenMat() const
Definition: CCalHcal.hh:42
double getDx_2Abs(unsigned int i) const
Definition: CCalHcal.hh:63
double getDx_2Cal() const
Definition: CCalHcal.hh:44
int getNLayerScnt() const
Definition: CCalHcal.hh:52
double getDy_2ScntLay(unsigned int i) const
Definition: CCalHcal.hh:68
double getXposAbs(unsigned int i) const
Definition: CCalHcal.hh:59
G4String getWrapMat() const
Definition: CCalHcal.hh:65
int getNAbsorber() const
Definition: CCalHcal.hh:61
int getNScintillator() const
Definition: CCalHcal.hh:67
G4String getBoxMat() const
Definition: CCalHcal.hh:46
int getTypeScnt(unsigned int i) const
Definition: CCalHcal.hh:53
#define G4endl
Definition: G4ios.hh:61
static CCalMaterialFactory * getInstance()
double G4double
Definition: G4Types.hh:76
virtual ~CCalG4Hcal()
Definition: CCalG4Hcal.cc:60
static const double mm
Definition: G4SIunits.hh:102
double getDx_2Scnt(unsigned int i) const
Definition: CCalHcal.hh:73
double getXposBox(unsigned int i) const
Definition: CCalHcal.hh:51
G4LogicalVolume * constructScintillatorLayer(G4int)
Definition: CCalG4Hcal.cc:211
G4GLOB_DLL std::ostream G4cerr
ptrG4Log * absLog
Definition: CCalG4Hcal.hh:62