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