File indexing completed on 2025-02-25 09:22:34
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
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #include "GRGeomImpBiasWorld.hh"
0045 #include "GRDetectorConstruction.hh"
0046
0047 #include "G4Orb.hh"
0048 #include "G4LogicalVolume.hh"
0049 #include "G4VPhysicalVolume.hh"
0050 #include "G4PVPlacement.hh"
0051
0052 #include "G4Region.hh"
0053 #include "GRBiasingRegionInfo.hh"
0054
0055 #include "G4UIcommand.hh"
0056 #include "G4VisAttributes.hh"
0057
0058 GRGeomImpBiasWorld::GRGeomImpBiasWorld(G4String& wName,GRDetectorConstruction* det)
0059 : G4VUserParallelWorld(wName),detector(det)
0060 {
0061 stateNotifier = new GRGeomImpBiasWorldStateNotifier(this);
0062 }
0063
0064 GRGeomImpBiasWorld::~GRGeomImpBiasWorld()
0065 {
0066 delete stateNotifier;
0067 }
0068
0069 void GRGeomImpBiasWorld::Construct()
0070 {
0071 if(constructed) return;
0072
0073 constructed = true;
0074 fWorld = GetWorld();
0075 G4LogicalVolume* motherLog = fWorld->GetLogicalVolume();
0076 biasingRegion = new G4Region(fWorldName+"_Region");
0077 auto biasInfo = new GRBiasingRegionInfo();
0078 biasingRegion->SetUserInformation(biasInfo);
0079 biasingRegion->AddRootLogicalVolume(motherLog);
0080 biasingRegion->SetWorld(fWorld);
0081 G4VisAttributes* wvisatt = new G4VisAttributes(G4Colour(.2,.2,0.));
0082 wvisatt->SetVisibility(false);
0083 motherLog->SetVisAttributes(wvisatt);
0084
0085 G4double r0 = detector->geoImpP.radius;
0086 if(r0 < 0.)
0087 {
0088
0089
0090 r0 = GRDetectorConstruction::GetWorldSize() * 0.8;
0091 G4cout<<"############ Radius of the outermost biasing sphere is set to "<<r0<<" (mm)"<<G4endl;
0092 }
0093
0094 G4int nL = detector->geoImpP.nLayer;
0095 G4ThreeVector dp = (detector->geoImpP.posT - detector->geoImpP.pos0) / (nL-1);
0096 G4double rt = detector->geoImpP.radiusT;
0097 if(rt<0.)
0098 { rt = r0/nL; }
0099 G4double dr = (r0 - rt)/(nL-1);
0100
0101 for(G4int i=0;i<nL;i++)
0102 {
0103 G4double r = r0 - dr*i;
0104 G4String vName = fWorldName + "_" + G4UIcommand::ConvertToString(i);
0105 auto sph = new G4Orb(vName+"_solid",r);
0106 auto lv = new G4LogicalVolume(sph,nullptr,vName+"_lv");
0107 G4ThreeVector pos = detector->geoImpP.pos0;
0108 if(i!=0) pos = dp;
0109 new G4PVPlacement(0,pos,lv,vName+"_pv",motherLog,false,i+1);
0110 motherLog = lv;
0111 G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.7,.7,0.));
0112 visatt->SetVisibility(true);
0113 lv->SetVisAttributes(visatt);
0114 }
0115
0116 return;
0117 }
0118
0119 void GRGeomImpBiasWorld::ConstructSD()
0120 { ; }
0121
0122 void GRGeomImpBiasWorld::Update()
0123 {
0124 GRBiasingRegionInfo* biasInfo = static_cast<GRBiasingRegionInfo*>(biasingRegion->GetUserInformation());
0125 biasInfo->SetBiasingFactor(detector->geoImpP.factor);
0126 biasInfo->SetProbability(detector->geoImpP.prob);
0127 }
0128
0129