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3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/biasing/GB06/src/GB06ParallelWorldForSlices.cc (Version 11.3.0) and /examples/extended/biasing/GB06/src/GB06ParallelWorldForSlices.cc (Version 10.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /// \file GB06/src/GB06ParallelWorldForSlices.     26 /// \file GB06/src/GB06ParallelWorldForSlices.cc
 27 /// \brief Implementation of the GB06ParallelW     27 /// \brief Implementation of the GB06ParallelWorldForSlices class
 28 //                                                 28 //
 29 //                                                 29 //
 30 #include "GB06ParallelWorldForSlices.hh"           30 #include "GB06ParallelWorldForSlices.hh"
 31                                                    31 
 32 #include "GB06BOptrSplitAndKillByImportance.hh << 
 33                                                << 
 34 #include "G4Box.hh"                                32 #include "G4Box.hh"
 35 #include "G4LogicalVolume.hh"                      33 #include "G4LogicalVolume.hh"
 36 #include "G4LogicalVolumeStore.hh"                 34 #include "G4LogicalVolumeStore.hh"
 37 #include "G4PVPlacement.hh"                        35 #include "G4PVPlacement.hh"
 38 #include "G4PVReplica.hh"                          36 #include "G4PVReplica.hh"
 39 #include "G4PhysicalVolumeStore.hh"                37 #include "G4PhysicalVolumeStore.hh"
 40 #include "G4SystemOfUnits.hh"                  << 
 41 #include "G4ThreeVector.hh"                        38 #include "G4ThreeVector.hh"
                                                   >>  39 #include "G4SystemOfUnits.hh"
                                                   >>  40 
                                                   >>  41 #include "GB06BOptrSplitAndKillByImportance.hh"
 42                                                    42 
 43 //....oooOO0OOooo........oooOO0OOooo........oo     43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44                                                    44 
 45 GB06ParallelWorldForSlices::GB06ParallelWorldF     45 GB06ParallelWorldForSlices::GB06ParallelWorldForSlices(G4String worldName)
 46   : G4VUserParallelWorld(worldName)                46   : G4VUserParallelWorld(worldName)
 47 {                                              <<  47 {;}
 48   ;                                            << 
 49 }                                              << 
 50                                                    48 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 52                                                    50 
 53 GB06ParallelWorldForSlices::~GB06ParallelWorld     51 GB06ParallelWorldForSlices::~GB06ParallelWorldForSlices()
 54 {                                              <<  52 {;}
 55   ;                                            << 
 56 }                                              << 
 57                                                    53 
 58 //....oooOO0OOooo........oooOO0OOooo........oo     54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 59                                                    55 
 60 void GB06ParallelWorldForSlices::Construct()       56 void GB06ParallelWorldForSlices::Construct()
 61 {                                                  57 {
 62   // -- Inform about construction:                 58   // -- Inform about construction:
 63   // -- (fWorldName is a protected data member     59   // -- (fWorldName is a protected data member of the base parallel world class)
 64   G4cout << "Parallel World `" << fWorldName <     60   G4cout << "Parallel World `" << fWorldName << "' constructed." << G4endl;
 65                                                    61 
 66   // -------------------------                     62   // -------------------------
 67   //  Build parallel geometry:                     63   //  Build parallel geometry:
 68   // -------------------------                     64   // -------------------------
 69                                                <<  65   
 70   // -- Obtain clone of mass geometry world fr     66   // -- Obtain clone of mass geometry world from GetWorld() base class utility:
 71   G4VPhysicalVolume* physicalParallelWorld = G     67   G4VPhysicalVolume* physicalParallelWorld = GetWorld();
 72   G4LogicalVolume* logicalParallelWorld = phys <<  68   G4LogicalVolume*    logicalParallelWorld = physicalParallelWorld->GetLogicalVolume();
                                                   >>  69 
 73                                                    70 
 74   // -- We overlay a sliced geometry on top of     71   // -- We overlay a sliced geometry on top of the block of concrete in the mass geometry
 75   // -- (ie, in the detector construction clas     72   // -- (ie, in the detector construction class), using the same dimensions.
 76   // -- [Note that this is a choice : we can u     73   // -- [Note that this is a choice : we can use different dimensions and shapes, creating
 77   // -- a new solid for that.]                     74   // -- a new solid for that.]
 78   // -- For this we:                               75   // -- For this we:
 79   // --     - 1) get back the solid used to cr     76   // --     - 1) get back the solid used to create the concrete shield;
 80   // --     - 2) create a new logical volume o     77   // --     - 2) create a new logical volume of same shape than the shield and we place
 81   // --          inside the slices                 78   // --          inside the slices
 82   // --     - 3) place the sliced structure, u     79   // --     - 3) place the sliced structure, using the placement of the physical volume of
 83   // --          the concrete shield               80   // --          the concrete shield
 84   // -- In all this construction, no materials     81   // -- In all this construction, no materials are used, as only the volumes boundaries
 85   // -- are of interest. Note that the absence     82   // -- are of interest. Note that the absence of materials is only possible in parallel
 86   // -- geometries.                                83   // -- geometries.
 87                                                    84 
                                                   >>  85   
 88   // -- 1) get back the solid used to create t     86   // -- 1) get back the solid used to create the concrete shield:
 89   //       -----------------------------------     87   //       ------------------------------------------------------
 90                                                <<  88   
 91   // -- get back the logical volume of the shi     89   // -- get back the logical volume of the shield, using its name:
 92   G4LogicalVolume* shieldLogical = G4LogicalVo <<  90   G4LogicalVolume* shieldLogical =
 93                                                <<  91     G4LogicalVolumeStore::GetInstance()->GetVolume("shield.logical");
                                                   >>  92   
 94   // -- get back the solid, a G4box in this ca     93   // -- get back the solid, a G4box in this case. We cast the pointer to access later on
 95   // -- the G4Box class specific methods:          94   // -- the G4Box class specific methods:
 96   auto shieldSolid = (G4Box*)shieldLogical->Ge <<  95   G4Box* shieldSolid = (G4Box*) shieldLogical->GetSolid();
 97                                                <<  96   
 98   // -- we now re-create a logical volume for      97   // -- we now re-create a logical volume for the mother volume of the slices:
 99   G4LogicalVolume* motherForSlicesLogical =        98   G4LogicalVolume* motherForSlicesLogical =
100     new G4LogicalVolume(shieldSolid,  // its s <<  99     new G4LogicalVolume(shieldSolid,                 // its solid
101                         nullptr,  // no materi << 100                         nullptr,                     // no material
102                         "motherForSlices.logic    101                         "motherForSlices.logical");  // its name
103                                                   102 
                                                   >> 103 
                                                   >> 104   
104   // -- 2) new logical volume of same shape th    105   // -- 2) new logical volume of same shape than the shield and place inside the slices:
105   //       -----------------------------------    106   //       -----------------------------------------------------------------------------
106                                                << 107   
107   // -- We create now the slices; we choose 20    108   // -- We create now the slices; we choose 20 slices:
108   const G4int nSlices(20);                        109   const G4int nSlices(20);
109   // -- the solid for slices:                     110   // -- the solid for slices:
110   G4double halfSliceZ = shieldSolid->GetZHalfL    111   G4double halfSliceZ = shieldSolid->GetZHalfLength() / nSlices;
111   G4Box* sliceSolid = new G4Box("slice.solid", << 112   G4Box*             sliceSolid = new G4Box("slice.solid",
112                                 shieldSolid->G << 113                                             shieldSolid->GetXHalfLength(),
113                                                << 114                                             shieldSolid->GetYHalfLength(),
                                                   >> 115                                             halfSliceZ                    );
                                                   >> 116   
114   // -- the logical volume for slices:            117   // -- the logical volume for slices:
115   sliceLogical = new G4LogicalVolume(sliceSoli << 118   G4LogicalVolume* sliceLogical = new G4LogicalVolume(sliceSolid,        // its solid
116                                      nullptr,  << 119                                                       nullptr,           // no material
117                                      "slice.lo << 120                                                       "slice.logical");  // its name
118                                                << 121   
119   // -- we use a replica, to place the 20 slic    122   // -- we use a replica, to place the 20 slices in one go, along the Z axis:
120   slicePhysical = new G4PVReplica("slice.physi << 123   new G4PVReplica( "slice.physical",        // its name
121                                   sliceLogical << 124                    sliceLogical,            // its logical volume
122                                   motherForSli << 125                    motherForSlicesLogical,  // its mother volume
123                                   kZAxis,  //  << 126                    kZAxis,                  // axis of replication
124                                   nSlices,  // << 127                    nSlices,                 // number of replica
125                                   2 * halfSlic << 128                    2*halfSliceZ);           // width of replica
126                                                << 129   
                                                   >> 130   
127   // -- 3) place the sliced structure, using t    131   // -- 3) place the sliced structure, using the concrete shield placement:
128   //       -----------------------------------    132   //       ----------------------------------------------------------------
129                                                << 133   
130   // -- get back the physical volume of the sh    134   // -- get back the physical volume of the shield, using its name:
131   // -- (note that we know we have only one ph    135   // -- (note that we know we have only one physical volume with this name. If we had
132   // -- several, we should loop by ourselves o    136   // -- several, we should loop by ourselves on the store which is of
133   // -- std::vector<G4VPhysicalVolume*> type.)    137   // -- std::vector<G4VPhysicalVolume*> type.)
134   G4VPhysicalVolume* shieldPhysical =          << 138   G4VPhysicalVolume*
135     G4PhysicalVolumeStore::GetInstance()->GetV << 139     shieldPhysical = G4PhysicalVolumeStore::GetInstance()->GetVolume("shield.physical");
136                                                << 140   
137   // -- get back the translation                  141   // -- get back the translation
138   // -- (we don't try to get back the rotation    142   // -- (we don't try to get back the rotation, we know we used nullptr):
139   G4ThreeVector translation = shieldPhysical->    143   G4ThreeVector translation = shieldPhysical->GetObjectTranslation();
140                                                << 144   
141   // -- finally, we place the sliced structure    145   // -- finally, we place the sliced structure:
142   new G4PVPlacement(nullptr,  // no rotation   << 146   new G4PVPlacement( nullptr,                           // no rotation
143                     translation,  // translate << 147                      translation,                       // translate as for the shield
144                     motherForSlicesLogical,  / << 148                      motherForSlicesLogical,            // its logical volume
145                     "motherForSlices.physical" << 149                      "motherForSlices.physical",        // its name
146                     logicalParallelWorld,  //  << 150                      logicalParallelWorld,              // its mother  volume
147                     false,  // no boolean oper << 151                      false,                             // no boolean operation
148                     0);  // copy number        << 152                      0);                                // copy number
                                                   >> 153 
149 }                                                 154 }
150                                                   155 
151 //....oooOO0OOooo........oooOO0OOooo........oo    156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152                                                   157 
153 void GB06ParallelWorldForSlices::ConstructSD()    158 void GB06ParallelWorldForSlices::ConstructSD()
154 {                                                 159 {
155   // -- Create the biasing operator:              160   // -- Create the biasing operator:
156   auto biasingOperator = new GB06BOptrSplitAnd << 161   auto biasingOperator = new GB06BOptrSplitAndKillByImportance("neutron","parallelOptr");
157   // -- Tell it it is active for this parallel    162   // -- Tell it it is active for this parallel geometry, passing the world
158   // -- volume of this geometry :                 163   // -- volume of this geometry :
159   biasingOperator->SetParallelWorld(GetWorld() << 164   biasingOperator->SetParallelWorld( GetWorld() );
160                                                   165 
161   // -- Attach to the logical volume where the    166   // -- Attach to the logical volume where the biasing has to be applied:
162   biasingOperator->AttachTo(sliceLogical);     << 167   auto slice = G4LogicalVolumeStore::GetInstance()->GetVolume("slice.logical");
                                                   >> 168   biasingOperator->AttachTo(slice);
163                                                   169 
164   // -- Create a simple "volume importance" ma    170   // -- Create a simple "volume importance" map, linking replica numbers to importances:
165   //    --------------------------------------    171   //    --------------------------------------------------------------------------------
166   // -- we define the map as going from an imp    172   // -- we define the map as going from an importance to 2*importance when going from
167   // -- a slice to the next one, in the Z dire    173   // -- a slice to the next one, in the Z direction.
168   // -- Get back the replica of slices:           174   // -- Get back the replica of slices:
                                                   >> 175   G4PVReplica* slicePhysical =
                                                   >> 176     (G4PVReplica*)(G4PhysicalVolumeStore::GetInstance()->GetVolume("slice.physical"));
169   G4int nReplica = slicePhysical->GetMultiplic    177   G4int nReplica = slicePhysical->GetMultiplicity();
170   // -- We use and fill the map we defined in     178   // -- We use and fill the map we defined in the biasing operator:
171   G4int importance = 1;                           179   G4int importance = 1;
172   for (G4int iReplica = 0; iReplica < nReplica << 180   for ( G4int iReplica = 0 ; iReplica < nReplica ; iReplica++ )
173     (biasingOperator->GetImportanceMap())[iRep << 181     {
174     importance *= 2;                           << 182       (biasingOperator->GetImportanceMap())[ iReplica ] = importance;
175   }                                            << 183       importance *= 2;
                                                   >> 184     }
                                                   >> 185   
176 }                                                 186 }
177                                                   187