File indexing completed on 2025-10-13 08:26:57
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 "DetectorConstruction.hh"
0032
0033 #include "G4RunManager.hh"
0034 #include "G4NistManager.hh"
0035 #include "G4Box.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4RegionStore.hh"
0038 #include "G4VisAttributes.hh"
0039 #include "PrimaryGeneratorAction.hh"
0040
0041
0042
0043 DetectorConstruction::DetectorConstruction()
0044 {
0045
0046 fMessenger = new DetectorConstructionMessenger(this);
0047
0048
0049 fCrystalSize.setX(20*CLHEP::mm);
0050 fCrystalSize.setY(20*CLHEP::mm);
0051 fCrystalSize.setZ(0.0305*CLHEP::mm);
0052
0053
0054 fLattice = "(111)";
0055
0056
0057 fDetectorSize.setX(10*CLHEP::cm);
0058 fDetectorSize.setY(10*CLHEP::cm);
0059 fDetectorSize.setZ(0.1*CLHEP::mm);
0060 }
0061
0062
0063
0064 G4VPhysicalVolume* DetectorConstruction::Construct()
0065 {
0066
0067 G4bool checkOverlaps = true;
0068
0069
0070 G4NistManager* nist = G4NistManager::Instance();
0071 G4Material* world_mat = nist->FindOrBuildMaterial("G4_Galactic");
0072 G4Material* silicon = nist->FindOrBuildMaterial("G4_Si");
0073
0074
0075 G4Box* solidWorld = new G4Box("World", 0.2*CLHEP::m, 0.2*CLHEP::m, 10.*CLHEP::m);
0076 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, world_mat, "World");
0077 G4VPhysicalVolume* physWorld = new G4PVPlacement
0078 (0,
0079 G4ThreeVector(),
0080 logicWorld,
0081 "World",
0082 0,
0083 false,
0084 0,
0085 checkOverlaps);
0086 logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
0087
0088
0089
0090
0091
0092 fCrystalMaterial = nist->FindOrBuildMaterial(fCrystalMaterialStr);
0093
0094
0095 G4RotationMatrix* crystalRotationMatrix = new G4RotationMatrix;
0096 crystalRotationMatrix->rotateY(-fAngleX);
0097 crystalRotationMatrix->rotateX(-fAngleY);
0098
0099
0100 G4ThreeVector posCrystal = G4ThreeVector(0., 0., fCrystalSize.z()/2.);
0101
0102
0103 G4Box* solidCrystal = new G4Box("Crystal",
0104 fCrystalSize.x()/2,
0105 fCrystalSize.y()/2,
0106 fCrystalSize.z()/2.);
0107
0108 fLogicCrystal = new G4LogicalVolume(solidCrystal,
0109 fCrystalMaterial,
0110 "Crystal");
0111 new G4PVPlacement(crystalRotationMatrix,
0112 posCrystal,
0113 fLogicCrystal,
0114 "Crystal",
0115 logicWorld,
0116 false,
0117 0,
0118 checkOverlaps);
0119
0120 if (fActivateChannelingModel)
0121 {
0122
0123 G4Region* regionCh = new G4Region("Crystal");
0124 regionCh->AddRootLogicalVolume(fLogicCrystal);
0125 }
0126
0127
0128 G4VisAttributes* crystalVisAttribute =
0129 new G4VisAttributes(G4Colour(1., 0., 0.));
0130 crystalVisAttribute->SetForceSolid(true);
0131 fLogicCrystal->SetVisAttributes(crystalVisAttribute);
0132
0133
0134 G4cout << "Crystal material: " << fCrystalMaterial->GetName() << G4endl;
0135 G4cout << "Crystal size: " << fCrystalSize.x()/CLHEP::mm
0136 << "x" << fCrystalSize.y()/CLHEP::mm
0137 << "x" << fCrystalSize.z()/CLHEP::mm << " mm3" << G4endl;
0138 if (fActivateChannelingModel)
0139 {
0140 G4cout << "G4ChannelingFastSimModel activated" << G4endl;
0141 G4cout << "Crystal bending angle: " << fBendingAngle << " rad" << G4endl;
0142 G4cout << "Crystal Lattice: " << fLattice << G4endl;
0143 G4cout << "Crystal angleX: " << fAngleX << " rad" << G4endl;
0144 G4cout << "Crystal angleY: " << fAngleY << " rad" << G4endl;
0145 G4cout << "ActivateRadiationModel: " << fActivateRadiationModel << G4endl;
0146
0147 if (fCrystallineUndulatorAmplitude > DBL_EPSILON &&
0148 fCrystallineUndulatorPeriod > DBL_EPSILON) {
0149 G4cout << "Crystalline undulator activated: " << G4endl;
0150 G4cout << "undulator amplitude: "
0151 << fCrystallineUndulatorAmplitude/CLHEP::nm
0152 << " nm" << G4endl;
0153 G4cout << "undulator period: "
0154 << fCrystallineUndulatorPeriod/CLHEP::mm
0155 << " mm" << G4endl;
0156 G4cout << "undulator phase: "
0157 << fCrystallineUndulatorPhase
0158 << " rad" << G4endl;
0159 }
0160
0161 G4cout << G4endl;
0162 }
0163 else
0164 {
0165 G4cout << "G4ChannelingFastSimModel is not activated" << G4endl << G4endl;
0166 }
0167
0168
0169
0170 G4ThreeVector posDetector =
0171 G4ThreeVector(0, 0, fDetectorFrontPosZ+fDetectorSize.z()/2.);
0172
0173
0174 G4Box* detector = new G4Box("Detector",
0175 fDetectorSize.x()/2,
0176 fDetectorSize.y()/2,
0177 fDetectorSize.z()/2.);
0178
0179 G4LogicalVolume* logicDetector = new G4LogicalVolume(detector,
0180 silicon,
0181 "Detector");
0182 new G4PVPlacement(0,
0183 posDetector,
0184 logicDetector,
0185 "Detector",
0186 logicWorld,
0187 false,
0188 0,
0189 checkOverlaps);
0190
0191
0192 G4VisAttributes* detectorVisAttribute =
0193 new G4VisAttributes(G4Colour(1., 0., 1., 0.3));
0194 detectorVisAttribute->SetForceSolid(true);
0195 logicDetector->SetVisAttributes(detectorVisAttribute);
0196
0197
0198 return physWorld;
0199 }
0200
0201
0202
0203 void DetectorConstruction::ConstructSDandField()
0204 {
0205 if (fActivateChannelingModel)
0206 {
0207
0208
0209 G4RegionStore* regionStore = G4RegionStore::GetInstance();
0210 G4Region* regionCh = regionStore->GetRegion("Crystal");
0211
0212
0213 G4ChannelingFastSimModel* channelingModel =
0214 new G4ChannelingFastSimModel("ChannelingModel", regionCh);
0215
0216
0217 channelingModel->Input(fCrystalMaterial, fLattice, fPotentialPath);
0218
0219 channelingModel->GetCrystalData()->SetBendingAngle(fBendingAngle, fLogicCrystal);
0220
0221
0222
0223 if (fCrystallineUndulatorAmplitude > DBL_EPSILON &&
0224 fCrystallineUndulatorPeriod > DBL_EPSILON)
0225 {
0226 channelingModel->GetCrystalData()->SetCrystallineUndulatorParameters(
0227 fCrystallineUndulatorAmplitude,
0228 fCrystallineUndulatorPeriod,
0229 fCrystallineUndulatorPhase,
0230 fLogicCrystal);
0231 }
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 channelingModel->SetDefaultLindhardAngleNumberHighLimit(fLindhardAngles);
0244
0245
0246 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesProton,"proton");
0247 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesAntiproton,
0248 "anti_proton");
0249 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesPiPlus,"pi+");
0250 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesPiMinus,"pi-");
0251 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesPositron,"e+");
0252 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesElectron,"e-");
0253 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesMuPlus,"mu+");
0254 channelingModel->SetLindhardAngleNumberHighLimit(fLindhardAnglesMuMinus,"mu-");
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266 channelingModel->SetDefaultLowKineticEnergyLimit(fParticleMinKinEnergy);
0267
0268
0269 channelingModel->SetLowKineticEnergyLimit(fProtonMinKinEnergy,"proton");
0270 channelingModel->SetLowKineticEnergyLimit(fAntiprotonMinKinEnergy,"anti_proton");
0271 channelingModel->SetLowKineticEnergyLimit(fPiPlusMinKinEnergy,"pi+");
0272 channelingModel->SetLowKineticEnergyLimit(fPiMinusMinKinEnergy,"pi-");
0273 channelingModel->SetLowKineticEnergyLimit(fPositronMinKinEnergy,"e+");
0274 channelingModel->SetLowKineticEnergyLimit(fElectronMinKinEnergy,"e-");
0275 channelingModel->SetLowKineticEnergyLimit(fMuPlusMinKinEnergy,"mu+");
0276 channelingModel->SetLowKineticEnergyLimit(fMuMinusMinKinEnergy,"mu-");
0277
0278
0279
0280
0281
0282
0283 if (fActivateRadiationModel)
0284 {
0285 channelingModel->RadiationModelActivate();
0286 G4cout << "Radiation model activated" << G4endl;
0287
0288
0289
0290
0291
0292
0293
0294 channelingModel->GetRadiationModel()->
0295 SetSamplingPhotonsNumber(fSamplingPhotonsNumber);
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313 if(fTimesPhotonStatistics>1)
0314 {channelingModel->GetRadiationModel()->
0315 AddStatisticsInPhotonEnergyRegion(fMinPhotonEnergyAddStat,
0316 fMaxPhotonEnergyAddStat,
0317 fTimesPhotonStatistics);}
0318
0319
0320
0321
0322
0323
0324
0325
0326 channelingModel->GetRadiationModel()->
0327 SetRadiationAngleFactor(fRadiationAngleFactor);
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337 channelingModel->GetRadiationModel()->SetMinPhotonEnergy(fMinPhotonEnergy);
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350 channelingModel->GetRadiationModel()->
0351 SetNSmallTrajectorySteps(fNSmallTrajectorySteps);
0352 }
0353 }
0354 }
0355
0356
0357