File indexing completed on 2025-02-23 09:19:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include <cmath>
0032
0033 #include "CCalG4Hcal.hh"
0034
0035 #include "CCalMaterialFactory.hh"
0036 #include "CCalRotationMatrixFactory.hh"
0037 #include "CCalSensitiveDetectors.hh"
0038
0039 #include "CCalutils.hh"
0040
0041 #include "G4SystemOfUnits.hh"
0042 #include "G4ThreeVector.hh"
0043 #include "G4Box.hh"
0044
0045 #include "G4LogicalVolume.hh"
0046 #include "G4PVPlacement.hh"
0047
0048
0049
0050
0051
0052
0053
0054 CCalG4Hcal::CCalG4Hcal( const G4String &name ) :
0055 CCalHcal(name), CCalG4Able(name), sclLog(0), absLog(0)
0056 {}
0057
0058
0059 CCalG4Hcal::~CCalG4Hcal() {
0060 if (sclLog)
0061 delete[] sclLog;
0062 if (absLog)
0063 delete[] absLog;
0064 }
0065
0066
0067 G4VPhysicalVolume* CCalG4Hcal::constructIn( G4VPhysicalVolume* mother ) {
0068 G4cout << "==>> Constructing CCalG4Hcal..." << G4endl;
0069
0070
0071 #ifdef debug
0072 G4cout << tab << "Common logical volumes initialization: "
0073 << getNScintillator() << " scintillaor and " << getNAbsorber()
0074 << " absorber layers." << G4endl;
0075 #endif
0076 G4int i = 0;
0077 sclLog = new ptrG4Log[getNScintillator()];
0078 absLog = new ptrG4Log[getNAbsorber()];
0079 for (i=0; i < getNScintillator(); i++)
0080 sclLog[i] = 0;
0081 for (i=0; i < getNAbsorber(); i++)
0082 absLog[i] = 0;
0083
0084
0085 CCalMaterialFactory* matfact = CCalMaterialFactory::getInstance();
0086
0087
0088 G4Material* matter = matfact->findMaterial(getGenMat());
0089 G4VSolid* solid = new G4Box (Name(), getDx_2Cal()*mm, getDy_2Cal()*mm,
0090 getDy_2Cal()*mm);
0091 G4LogicalVolume* logh = new G4LogicalVolume(solid, matter, Name());
0092 setVisType(CCalVisualisable::PseudoVolumes,logh);
0093 #ifdef debug
0094 G4cout << tab << Name() << " Box made of " << getGenMat()
0095 << " of dimension " << getDx_2Cal()*mm << " " << getDy_2Cal()*mm
0096 << " " << getDy_2Cal()*mm << G4endl;
0097 #endif
0098
0099 G4PVPlacement* hcal = new G4PVPlacement(0,G4ThreeVector(getXposCal()*mm,0,0),
0100 Name(), logh, mother, false, 1);
0101 G4String name("Null");
0102 #ifdef pdebug
0103 if (mother != 0) name = mother->GetName();
0104 G4cout << Name() << " Number 1 positioned in " << name << " at ("
0105 << getXposCal()*mm << ",0,0) with no rotation" << G4endl;
0106 #endif
0107
0108
0109 solid = new G4Box (name, 0.5*getWallThickBox()*mm, getDy_2Box()*mm,
0110 getDy_2Box()*mm);
0111 matter = matfact->findMaterial(getBoxMat());
0112 name = Name() + "Wall";
0113 G4LogicalVolume* logw = new G4LogicalVolume(solid, matter, name);
0114 setVisType(CCalVisualisable::Support,logw);
0115 #ifdef debug
0116 G4cout << tab << name << " Box made of " << getBoxMat()
0117 << " of dimension " << 0.5*getWallThickBox()*mm << " "
0118 << getDy_2Box()*mm << " " << getDy_2Box()*mm << G4endl;
0119 #endif
0120
0121
0122 ptrG4Log* logb = new ptrG4Log[getNBox()];
0123 matter = matfact->findMaterial(getGenMat());
0124 for (i=0; i<getNBox(); i++) {
0125 name = Name() + "Box" + i;
0126 solid = new G4Box (name, getDx_2Box()*mm, getDy_2Box()*mm,
0127 getDy_2Box()*mm);
0128 logb[i]= new G4LogicalVolume(solid, matter, name);
0129 setVisType(CCalVisualisable::PseudoVolumes,logb[i]);
0130 #ifdef debug
0131 G4cout << tab << name << " Box made of " << getGenMat()
0132 << " of dimension " << getDx_2Box()*mm << " " << getDy_2Box()*mm
0133 << " " << getDy_2Box()*mm << G4endl;
0134 #endif
0135
0136 G4double xpos = -(getDx_2Box() - 0.5*getWallThickBox());
0137 new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
0138 logb[i], false, 1);
0139 #ifdef pdebug
0140 G4cout << logw->GetName() << " Number 1 positioned in " << name
0141 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0142 #endif
0143 xpos = (getDx_2Box() - 0.5*getWallThickBox());
0144 new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
0145 logb[i], false, 2);
0146 #ifdef pdebug
0147 G4cout << logw->GetName() << " Number 2 positioned in " << name
0148 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0149 #endif
0150
0151 new G4PVPlacement (0, G4ThreeVector(getXposBox(i)*mm,0,0), logb[i], name,
0152 logh, false, i+1);
0153 #ifdef pdebug
0154 G4cout << name << " Number " << i+1 << " positioned in " << logh->GetName()
0155 << " at (" << getXposBox(i)*mm << ",0,0) with no rotation" << G4endl;
0156 #endif
0157 }
0158
0159
0160 for (i=0; i<getNLayerScnt(); i++) {
0161 G4int lay = getTypeScnt(i);
0162 if (!sclLog[lay])
0163 sclLog[lay] = constructScintillatorLayer(lay);
0164 if (getMotherScnt(i) < 0 || getMotherScnt(i) >= getNScintillator()) {
0165 logw = logh;
0166 } else {
0167 logw = logb[getMotherScnt(i)];
0168 }
0169 G4double xpos = getXposScnt(i);
0170 new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), sclLog[lay],
0171 sclLog[lay]->GetName(), logw, false, i+1);
0172 #ifdef pdebug
0173 G4cout << sclLog[lay]->GetName() << " Number " << i+1 << " positioned in "
0174 << logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
0175 << G4endl;
0176 #endif
0177 }
0178
0179
0180 for (i=0; i<getNLayerAbs(); i++) {
0181 G4int lay = getTypeAbs(i);
0182 if (!absLog[lay])
0183 absLog[lay] = constructAbsorberLayer(lay);
0184 if (getMotherAbs(i) < 0 || getMotherAbs(i) >= getNAbsorber()) {
0185 logw = logh;
0186 } else {
0187 logw = logb[getMotherAbs(i)];
0188 }
0189 G4double xpos = getXposAbs(i);
0190 new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), absLog[lay],
0191 absLog[lay]->GetName(), logw, false, i+1);
0192 #ifdef pdebug
0193 G4cout << absLog[lay]->GetName() << " Number " << i+1 << " positioned in "
0194 << logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
0195 << G4endl;
0196 #endif
0197 }
0198
0199 delete [] logb;
0200
0201 G4cout << "<<== End of CCalG4Hcal construction ..." << G4endl;
0202
0203 return hcal;
0204 }
0205
0206
0207 G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer( G4int lay ) {
0208
0209
0210 CCalMaterialFactory* matfact = CCalMaterialFactory::getInstance();
0211
0212
0213 G4Material* matter = matfact->findMaterial(getGenMat());
0214 G4String name = Name() + "ScntLayer" + lay;
0215 G4VSolid* solid = new G4Box (name, getDx_2ScntLay(lay)*mm,
0216 getDy_2ScntLay(lay)*mm,
0217 getDy_2ScntLay(lay)*mm);
0218 G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
0219 setVisType(CCalVisualisable::PseudoVolumes,log);
0220 #ifdef debug
0221 G4cout << tab << name << " Box made of " << getGenMat() << " of dimension "
0222 << getDx_2ScntLay(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
0223 << getDy_2ScntLay(lay)*mm << G4endl;
0224 #endif
0225
0226 G4LogicalVolume* logd;
0227 G4double xpos;
0228
0229 if (getDx_2Wrap(lay) > 0) {
0230 name = Name() + "ScntWrapper" + lay;
0231 matter = matfact->findMaterial(getWrapMat());
0232 solid = new G4Box (name, getDx_2Wrap(lay)*mm,
0233 getDy_2ScntLay(lay)*mm, getDy_2ScntLay(lay)*mm);
0234 logd = new G4LogicalVolume(solid, matter, name);
0235 setVisType(CCalVisualisable::Support,logd);
0236 #ifdef debug
0237 G4cout << tab << name << " Box made of " << getWrapMat() << " of dimension "
0238 << getDx_2Wrap(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
0239 << getDy_2ScntLay(lay)*mm << G4endl;
0240 #endif
0241 xpos =-(getDx_2ScntLay(lay)-getDx_2Wrap(lay));
0242 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
0243 #ifdef pdebug
0244 G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
0245 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0246 #endif
0247 xpos = (getDx_2ScntLay(lay)-getDx_2Wrap(lay));
0248 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,2);
0249 #ifdef pdebug
0250 G4cout << logd->GetName() << " Number 2 positioned in " << log->GetName()
0251 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0252 #endif
0253 }
0254
0255
0256 matter = matfact->findMaterial(getPlasMat());
0257 name = Name() + "FrontPlastic" + lay;
0258 solid = new G4Box (name, getDx_2FrontP(lay)*mm, getDy_2ScntLay(lay)*mm,
0259 getDy_2ScntLay(lay)*mm);
0260 logd = new G4LogicalVolume(solid, matter, name);
0261 setVisType(CCalVisualisable::Cable,logd);
0262 #ifdef debug
0263 G4cout << tab << name << " Box made of " << getPlasMat() << " of dimension "
0264 << getDx_2FrontP(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
0265 << getDy_2ScntLay(lay)*mm << G4endl;
0266 #endif
0267 xpos =-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+getDx_2FrontP(lay);
0268 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
0269 #ifdef pdebug
0270 G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
0271 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0272 #endif
0273 name = Name() + "BackPlastic" + lay;
0274 solid = new G4Box (name, getDx_2BackP(lay)*mm, getDy_2ScntLay(lay)*mm,
0275 getDy_2ScntLay(lay)*mm);
0276 logd = new G4LogicalVolume(solid, matter, name);
0277 setVisType(CCalVisualisable::Cable,logd);
0278 #ifdef debug
0279 G4cout << tab << name << " Box made of " << getPlasMat() << " of dimension "
0280 << getDx_2BackP(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
0281 << getDy_2ScntLay(lay)*mm << G4endl;
0282 #endif
0283 xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+2.*getDx_2FrontP(lay)+
0284 2.*getDx_2Scnt(lay)+getDx_2BackP(lay));
0285 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
0286 #ifdef pdebug
0287 G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
0288 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0289 #endif
0290
0291
0292 matter = matfact->findMaterial(getScntMat());
0293 name = Name() + "Scintillator" + lay;
0294 solid = new G4Box (name, getDx_2Scnt(lay)*mm, getDy_2ScntLay(lay)*mm,
0295 getDy_2ScntLay(lay)*mm);
0296 logd = new G4LogicalVolume(solid, matter, name);
0297 setVisType(CCalVisualisable::Sensitive,logd);
0298 allSensitiveLogs.push_back(logd);
0299 #ifdef debug
0300 G4cout << tab << name << " Box made of " << getScntMat() << " of dimension "
0301 << getDx_2Scnt(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
0302 << getDy_2ScntLay(lay)*mm << G4endl;
0303 #endif
0304 xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+2.*getDx_2FrontP(lay)+
0305 getDx_2Scnt(lay));
0306 new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
0307 #ifdef pdebug
0308 G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
0309 << " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
0310 #endif
0311
0312 return log;
0313 }
0314
0315
0316 G4LogicalVolume* CCalG4Hcal::constructAbsorberLayer( G4int lay ) {
0317
0318 CCalMaterialFactory* matfact = CCalMaterialFactory::getInstance();
0319
0320 G4Material* matter = matfact->findMaterial(getAbsMat());
0321 G4String name = Name() + "Absorber" + lay;
0322 G4VSolid* solid = new G4Box (name, getDx_2Abs(lay)*mm, getDy_2Abs()*mm, getDy_2Abs()*mm);
0323 G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
0324 setVisType(CCalVisualisable::Absorber,log);
0325 #ifdef debug
0326 G4cout << tab << name << " Box made of " << getAbsMat() << " of dimension "
0327 << getDx_2Abs(lay)*mm << " " << getDy_2Abs()*mm << " "
0328 << getDy_2Abs()*mm << G4endl;
0329 #endif
0330 return log;
0331 }
0332
0333
0334 void CCalG4Hcal::constructDaughters() {}
0335
0336
0337 void CCalG4Hcal::constructSensitive() {
0338 if (allSensitiveLogs.size()>0) {
0339 CCalSensitiveDetectors* sensDets = CCalSensitiveDetectors::getInstance();
0340 G4String SDname = Name();
0341 for (std::vector<ptrG4Log>::iterator iter=allSensitiveLogs.begin();
0342 iter<allSensitiveLogs.end(); iter++) {
0343 sensDets->registerVolume(SDname, (*iter));
0344 #ifdef sdebug
0345 G4cout << "Register volume " << (*iter)->GetName() << " for" << SDname
0346 << G4endl;
0347 #endif
0348 }
0349 } else {
0350 G4cerr << "CCalG4Hcal ERROR: Could not construct Sensitive Detector"
0351 << G4endl;
0352 }
0353 }
0354