Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-25 09:22:34

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
0027 //
0028 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
0029 //
0030 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
0031 //  under the contract NNJ15HK11B.
0032 //
0033 // ********************************************************************
0034 //
0035 // GRGeomImpBiasWorld.cc
0036 //   A parallel world class that defines the geometry
0037 //   of the geometry improtance biasing.
0038 //
0039 // History
0040 //   September 8th, 2020 : first implementation
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(); //physical volume of the world volume of parallel world
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     // radius of the outermost sphere is not specified, so seting it to the default
0089     // value as the 80% of the world volume.
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