Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 ////////////////////////////////////////////// 27 // File: CCalG4Hcal.cc 28 // Description: CCalG4Hcal Factory class to co 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), 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( G4 68 G4cout << "==>> Constructing CCalG4Hcal..." 69 70 //Common logical volumes between methods. 71 #ifdef debug 72 G4cout << tab << "Common logical volumes ini 73 << getNScintillator() << " scintillaor 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 = CCalMat 86 87 //Mother volume 88 G4Material* matter = matfact->findMaterial(g 89 G4VSolid* solid = new G4Box (Name(), getD 90 getDy_2Cal() 91 G4LogicalVolume* logh = new G4LogicalVolume( 92 setVisType(CCalVisualisable::PseudoVolumes,l 93 #ifdef debug 94 G4cout << tab << Name() << " Box made of " 95 << " of dimension " << getDx_2Cal()*m 96 << " " << getDy_2Cal()*mm << G4endl; 97 #endif 98 99 G4PVPlacement* hcal = new G4PVPlacement(0,G4 100 Name 101 G4String name("Null"); 102 #ifdef pdebug 103 if (mother != 0) name = mother->GetName(); 104 G4cout << Name() << " Number 1 positioned in 105 << getXposCal()*mm << ",0,0) with no ro 106 #endif 107 108 //Wall of the Boxes 109 solid = new G4Box (name, 0.5*getWallThickBo 110 getDy_2Box()*mm); 111 matter = matfact->findMaterial(getBoxMat()); 112 name = Name() + "Wall"; 113 G4LogicalVolume* logw = new G4LogicalVolume( 114 setVisType(CCalVisualisable::Support,logw); 115 #ifdef debug 116 G4cout << tab << name << " Box made of " << 117 << " of dimension " << 0.5*getWallThick 118 << getDy_2Box()*mm << " " << getDy_2Box 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, 127 getDy_2Box()*mm); 128 logb[i]= new G4LogicalVolume(solid, matter 129 setVisType(CCalVisualisable::PseudoVolumes 130 #ifdef debug 131 G4cout << tab << name << " Box made of " < 132 << " of dimension " << getDx_2Box()*m 133 << " " << getDy_2Box()*mm << G4endl; 134 #endif 135 136 G4double xpos = -(getDx_2Box() - 0.5*getWa 137 new G4PVPlacement (0, G4ThreeVector(xpos*m 138 logb[i], false, 1); 139 #ifdef pdebug 140 G4cout << logw->GetName() << " Number 1 po 141 << " at (" << xpos*mm << ",0,0) with 142 #endif 143 xpos = (getDx_2Box() - 0.5*getWallThickBox 144 new G4PVPlacement (0, G4ThreeVector(xpos*m 145 logb[i], false, 2); 146 #ifdef pdebug 147 G4cout << logw->GetName() << " Number 2 po 148 << " at (" << xpos*mm << ",0,0) with 149 #endif 150 151 new G4PVPlacement (0, G4ThreeVector(getXpo 152 logh, false, i+1); 153 #ifdef pdebug 154 G4cout << name << " Number " << i+1 << " p 155 << " at (" << getXposBox(i)*mm << ",0 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 164 if (getMotherScnt(i) < 0 || getMotherScnt( 165 logw = logh; 166 } else { 167 logw = logb[getMotherScnt(i)]; 168 } 169 G4double xpos = getXposScnt(i); 170 new G4PVPlacement (0, G4ThreeVector(xpos*m 171 sclLog[lay]->GetName(), 172 #ifdef pdebug 173 G4cout << sclLog[lay]->GetName() << " Numb 174 << logw->GetName() << " at (" << xpos 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) 185 logw = logh; 186 } else { 187 logw = logb[getMotherAbs(i)]; 188 } 189 G4double xpos = getXposAbs(i); 190 new G4PVPlacement (0, G4ThreeVector(xpos*m 191 absLog[lay]->GetName(), 192 #ifdef pdebug 193 G4cout << absLog[lay]->GetName() << " Numb 194 << logw->GetName() << " at (" << xpos 195 << G4endl; 196 #endif 197 } 198 199 delete [] logb; 200 201 G4cout << "<<== End of CCalG4Hcal constructi 202 203 return hcal; 204 } 205 206 207 G4LogicalVolume* CCalG4Hcal::constructScintill 208 209 //Pointers to the Materials 210 CCalMaterialFactory* matfact = CCalMat 211 212 //The scintillator layer 213 G4Material* matter = matfact->findMaterial(g 214 G4String name = Name() + "ScntLayer" + 215 G4VSolid* solid = new G4Box (name, getDx_ 216 getDy_2ScntL 217 getDy_2ScntL 218 G4LogicalVolume* log = new G4LogicalVolume(s 219 setVisType(CCalVisualisable::PseudoVolumes,l 220 #ifdef debug 221 G4cout << tab << name << " Box made of " << 222 << getDx_2ScntLay(lay)*mm << " " << get 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) 233 getDy_2ScntLay(lay)*mm 234 logd = new G4LogicalVolume(solid, matter 235 setVisType(CCalVisualisable::Support,logd) 236 #ifdef debug 237 G4cout << tab << name << " Box made of " < 238 << getDx_2Wrap(lay)*mm << " " << getD 239 << getDy_2ScntLay(lay)*mm << G4endl; 240 #endif 241 xpos =-(getDx_2ScntLay(lay)-getDx_2Wrap( 242 new G4PVPlacement(0, G4ThreeVector(xpos*mm 243 #ifdef pdebug 244 G4cout << logd->GetName() << " Number 1 po 245 << " at (" << xpos*mm << ",0,0) with 246 #endif 247 xpos = (getDx_2ScntLay(lay)-getDx_2Wrap( 248 new G4PVPlacement(0, G4ThreeVector(xpos*mm 249 #ifdef pdebug 250 G4cout << logd->GetName() << " Number 2 po 251 << " at (" << xpos*mm << ",0,0) with 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) 259 getDy_2ScntLay(lay)*mm); 260 logd = new G4LogicalVolume(solid, matter, 261 setVisType(CCalVisualisable::Cable,logd); 262 #ifdef debug 263 G4cout << tab << name << " Box made of " << 264 << getDx_2FrontP(lay)*mm << " " << getD 265 << getDy_2ScntLay(lay)*mm << G4endl; 266 #endif 267 xpos =-getDx_2ScntLay(lay)+2.*getDx_2Wrap( 268 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0 269 #ifdef pdebug 270 G4cout << logd->GetName() << " Number 1 posi 271 << " at (" << xpos*mm << ",0,0) with no 272 #endif 273 name = Name() + "BackPlastic" + lay; 274 solid = new G4Box (name, getDx_2BackP(lay)* 275 getDy_2ScntLay(lay)*mm); 276 logd = new G4LogicalVolume(solid, matter, 277 setVisType(CCalVisualisable::Cable,logd); 278 #ifdef debug 279 G4cout << tab << name << " Box made of " << 280 << getDx_2BackP(lay)*mm << " " << getDy 281 << getDy_2ScntLay(lay)*mm << G4endl; 282 #endif 283 xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap 284 2.*getDx_2Scnt(lay)+getDx_2BackP(la 285 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0 286 #ifdef pdebug 287 G4cout << logd->GetName() << " Number 1 posi 288 << " at (" << xpos*mm << ",0,0) with no 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)*m 295 getDy_2ScntLay(lay)*mm); 296 logd = new G4LogicalVolume(solid, matter, 297 setVisType(CCalVisualisable::Sensitive,logd) 298 allSensitiveLogs.push_back(logd); 299 #ifdef debug 300 G4cout << tab << name << " Box made of " << 301 << getDx_2Scnt(lay)*mm << " " << getDy_ 302 << getDy_2ScntLay(lay)*mm << G4endl; 303 #endif 304 xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap 305 getDx_2Scnt(lay)); 306 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0 307 #ifdef pdebug 308 G4cout << logd->GetName() << " Number 1 posi 309 << " at (" << xpos*mm << ",0,0) with no 310 #endif 311 312 return log; 313 } 314 315 316 G4LogicalVolume* CCalG4Hcal::constructAbsorber 317 //Pointers to the Materials 318 CCalMaterialFactory* matfact = CCalMaterialF 319 //Now the absorber layer 320 G4Material* matter = matfact->findMaterial(g 321 G4String name = Name() + "Absorber" + l 322 G4VSolid* solid = new G4Box (name, getDx_ 323 G4LogicalVolume* log = new G4LogicalVolume(s 324 setVisType(CCalVisualisable::Absorber,log); 325 #ifdef debug 326 G4cout << tab << name << " Box made of " << 327 << getDx_2Abs(lay)*mm << " " << getDy_2 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 = CCalSen 340 G4String SDname = Name(); 341 for (std::vector<ptrG4Log>::iterator iter= 342 iter<allSensitiveLogs.end(); iter++) 343 sensDets->registerVolume(SDname, (*iter) 344 #ifdef sdebug 345 G4cout << "Register volume " << (*iter)- 346 << G4endl; 347 #endif 348 } 349 } else { 350 G4cerr << "CCalG4Hcal ERROR: Could not con 351 << G4endl; 352 } 353 } 354 355