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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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