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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 /processes/biasing/management/src/G4VBiasingOperator.cc (Version 11.3.0) and /processes/biasing/management/src/G4VBiasingOperator.cc (Version 10.2.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 // G4VBiasingOperator                          << 
 27 // ------------------------------------------- << 
 28                                                << 
 29 #include "G4VBiasingOperator.hh"                   26 #include "G4VBiasingOperator.hh"
 30 #include "G4VBiasingOperation.hh"                  27 #include "G4VBiasingOperation.hh"
 31 #include "G4VParticleChange.hh"                    28 #include "G4VParticleChange.hh"
 32                                                    29 
                                                   >>  30 
 33 G4MapCache< const G4LogicalVolume*, G4VBiasing     31 G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* > G4VBiasingOperator::fLogicalToSetupMap;
 34 G4VectorCache< G4VBiasingOperator* > G4VBiasin <<  32 G4VectorCache< G4VBiasingOperator* >                      G4VBiasingOperator::fOperators;
 35 G4Cache< G4BiasingOperatorStateNotifier* > G4V <<  33 G4Cache< G4BiasingOperatorStateNotifier* >                G4VBiasingOperator::fStateNotifier(0);
                                                   >>  34 
 36                                                    35 
 37 G4VBiasingOperator::G4VBiasingOperator(const G <<  36 G4VBiasingOperator::G4VBiasingOperator(G4String name)
 38   : fName( name )                              <<  37   : fName                                      (name),
                                                   >>  38     fOccurenceBiasingOperation                 (nullptr),
                                                   >>  39     fFinalStateBiasingOperation                (nullptr),
                                                   >>  40     fNonPhysicsBiasingOperation                (nullptr),
                                                   >>  41     fPreviousProposedOccurenceBiasingOperation (nullptr),
                                                   >>  42     fPreviousProposedFinalStateBiasingOperation(nullptr),
                                                   >>  43     fPreviousProposedNonPhysicsBiasingOperation(nullptr),
                                                   >>  44     fPreviousAppliedOccurenceBiasingOperation  (nullptr),
                                                   >>  45     fPreviousAppliedFinalStateBiasingOperation (nullptr),
                                                   >>  46     fPreviousAppliedNonPhysicsBiasingOperation (nullptr),
                                                   >>  47     fPreviousBiasingAppliedCase                (BAC_None)
 39 {                                                  48 {
 40   fOperators.Push_back(this);                      49   fOperators.Push_back(this);
 41                                                    50 
 42   if ( fStateNotifier.Get() == nullptr )       <<  51   if ( fStateNotifier.Get() == 0 ) fStateNotifier.Put( new G4BiasingOperatorStateNotifier() );
 43     fStateNotifier.Put( new G4BiasingOperatorS <<  52 
 44 }                                                  53 }
 45                                                    54 
 46 void G4VBiasingOperator::AttachTo(const G4Logi <<  55 G4VBiasingOperator::~G4VBiasingOperator()
 47 {                                                  56 {
 48   auto it = fLogicalToSetupMap.Find(logical);  << 
 49   if ( it == fLogicalToSetupMap.End() )        << 
 50   {                                            << 
 51     fLogicalToSetupMap[logical] = this;        << 
 52   }                                            << 
 53   else if ( (*it).second != this )             << 
 54   {                                            << 
 55     G4ExceptionDescription ed;                 << 
 56     ed << "Biasing operator `" << GetName()    << 
 57        << "' can not be attached to Logical vo << 
 58        << logical->GetName() << "' which is al << 
 59        << G4endl;                              << 
 60     G4Exception("G4VBiasingOperator::AttachTo( << 
 61                 "BIAS.MNG.01", JustWarning, ed << 
 62   }                                            << 
 63 }                                                  57 }
 64                                                    58 
 65 const std::vector < G4VBiasingOperator* >&     <<  59 void G4VBiasingOperator::AttachTo(const G4LogicalVolume* logical)
 66 G4VBiasingOperator::GetBiasingOperators()      << 
 67 {                                                  60 {
 68   return fOperators.Get();                     <<  61   G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
                                                   >>  62   it = fLogicalToSetupMap.Find(logical);
                                                   >>  63   if ( it == fLogicalToSetupMap.End() ) fLogicalToSetupMap[logical] = this;
                                                   >>  64   else if ( (*it).second != this )
                                                   >>  65     {
                                                   >>  66       G4ExceptionDescription ed;
                                                   >>  67       ed << "Biasing operator `" << GetName() 
                                                   >>  68    << "' can not be attached to Logical volume `"
                                                   >>  69    << logical->GetName() << "' which is already used by an other operator !" << G4endl;
                                                   >>  70       G4Exception("G4VBiasingOperator::AttachTo(...)",
                                                   >>  71       "BIAS.MNG.01",
                                                   >>  72       JustWarning,
                                                   >>  73       ed);
                                                   >>  74     }
 69 }                                                  75 }
 70                                                    76 
                                                   >>  77 
 71 G4VBiasingOperator* G4VBiasingOperator::GetBia     78 G4VBiasingOperator* G4VBiasingOperator::GetBiasingOperator(const G4LogicalVolume* logical)
 72 {                                                  79 {
 73   auto it = fLogicalToSetupMap.Find(logical);  <<  80   G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
 74   if ( it == fLogicalToSetupMap.End() ) { retu <<  81   it = fLogicalToSetupMap.Find(logical);
 75   else  { return (*it).second; }               <<  82   if ( it == fLogicalToSetupMap.End() ) return 0;
                                                   >>  83   else return (*it).second;
 76 }                                                  84 }
 77                                                    85 
 78 G4VBiasingOperation* G4VBiasingOperator::GetPr     86 G4VBiasingOperation* G4VBiasingOperator::GetProposedOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
 79 {                                                  87 {
 80   fOccurenceBiasingOperation = ProposeOccurenc     88   fOccurenceBiasingOperation = ProposeOccurenceBiasingOperation(track, callingProcess);
 81   return fOccurenceBiasingOperation;               89   return fOccurenceBiasingOperation;
 82 }                                                  90 }
 83                                                    91 
 84 G4VBiasingOperation* G4VBiasingOperator::GetPr     92 G4VBiasingOperation* G4VBiasingOperator::GetProposedFinalStateBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
 85 {                                                  93 {
 86   fFinalStateBiasingOperation = ProposeFinalSt     94   fFinalStateBiasingOperation = ProposeFinalStateBiasingOperation(track, callingProcess); 
 87   return fFinalStateBiasingOperation;              95   return fFinalStateBiasingOperation;
 88 }                                                  96 }
 89                                                    97 
 90 G4VBiasingOperation* G4VBiasingOperator::GetPr     98 G4VBiasingOperation* G4VBiasingOperator::GetProposedNonPhysicsBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
 91 {                                                  99 {
 92   fNonPhysicsBiasingOperation = ProposeNonPhys    100   fNonPhysicsBiasingOperation = ProposeNonPhysicsBiasingOperation(track, callingProcess);
 93   return fNonPhysicsBiasingOperation;             101   return fNonPhysicsBiasingOperation;
 94 }                                                 102 }
 95                                                   103 
 96 void G4VBiasingOperator::                      << 104 void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface*  callingProcess,
 97 ReportOperationApplied( const G4BiasingProcess << 105              G4BiasingAppliedCase                 biasingCase,
 98                               G4BiasingApplied << 106              G4VBiasingOperation*             operationApplied,
 99                               G4VBiasingOperat << 107              const G4VParticleChange*   particleChangeProduced )
100                         const G4VParticleChang << 
101 {                                                 108 {
102   fPreviousBiasingAppliedCase = biasingCase;      109   fPreviousBiasingAppliedCase = biasingCase;
103   fPreviousAppliedOccurenceBiasingOperation  = << 110   fPreviousAppliedOccurenceBiasingOperation  = 0;
104   fPreviousAppliedFinalStateBiasingOperation = << 111   fPreviousAppliedFinalStateBiasingOperation = 0;
105   fPreviousAppliedNonPhysicsBiasingOperation = << 112   fPreviousAppliedNonPhysicsBiasingOperation = 0;
106   switch ( biasingCase )                          113   switch ( biasingCase )
107   {                                            << 114     {
108     case BAC_None:                                115     case BAC_None:
109       break;                                      116       break;
110     case BAC_NonPhysics:                          117     case BAC_NonPhysics:
111       fPreviousAppliedNonPhysicsBiasingOperati    118       fPreviousAppliedNonPhysicsBiasingOperation = operationApplied ;
112       break;                                      119       break;
                                                   >> 120     case BAC_DenyInteraction: // -- ยงยง will b deprecated
                                                   >> 121       fPreviousAppliedOccurenceBiasingOperation  = operationApplied;
                                                   >> 122       break;
113     case BAC_FinalState:                          123     case BAC_FinalState:
114       fPreviousAppliedFinalStateBiasingOperati    124       fPreviousAppliedFinalStateBiasingOperation = operationApplied;
115       break;                                      125       break;
116     case BAC_Occurence:                           126     case BAC_Occurence:
117       G4Exception("G4VBiasingOperator::ReportO    127       G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
118                   "BIAS.MNG.02", JustWarning,  << 128             "BIAS.MNG.02",
119                   "Internal logic error, pleas << 129             JustWarning,
                                                   >> 130       "Internal logic error, please report !");
120       break;                                      131       break;
121     default:                                      132     default:
122       G4Exception("G4VBiasingOperator::ReportO    133       G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
123                   "BIAS.MNG.03", JustWarning,  << 134       "BIAS.MNG.03",
124                   "Internal logic error, pleas << 135       JustWarning,
125   }                                            << 136       "Internal logic error, please report !");
                                                   >> 137     }
126   OperationApplied( callingProcess, biasingCas    138   OperationApplied( callingProcess, biasingCase, operationApplied, particleChangeProduced );
127 }                                                 139 }
128                                                   140 
129 void G4VBiasingOperator::                      << 141 void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface*               callingProcess,
130 ReportOperationApplied( const G4BiasingProcess << 142              G4BiasingAppliedCase                              biasingCase,
131                               G4BiasingApplied << 143              G4VBiasingOperation*                occurenceOperationApplied,
132                               G4VBiasingOperat << 144              G4double                        weightForOccurenceInteraction,
133                               G4double weightF << 145              G4VBiasingOperation*               finalStateOperationApplied,
134                               G4VBiasingOperat << 146              const G4VParticleChange*               particleChangeProduced )
135                         const G4VParticleChang << 
136 {                                                 147 {
137   fPreviousBiasingAppliedCase = biasingCase;      148   fPreviousBiasingAppliedCase = biasingCase;
138   fPreviousAppliedOccurenceBiasingOperation =  << 149   fPreviousAppliedOccurenceBiasingOperation  =  occurenceOperationApplied;
139   fPreviousAppliedFinalStateBiasingOperation =    150   fPreviousAppliedFinalStateBiasingOperation = finalStateOperationApplied;
140   OperationApplied( callingProcess, biasingCas    151   OperationApplied( callingProcess, biasingCase, occurenceOperationApplied, weightForOccurenceInteraction, finalStateOperationApplied, particleChangeProduced );
141 }                                                 152 }
142                                                   153 
143 void G4VBiasingOperator::                      << 154 
144 ExitingBiasing( const G4Track* track, const G4 << 155 void G4VBiasingOperator::ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess )
145 {                                                 156 {
146   ExitBiasing( track, callingProcess );           157   ExitBiasing( track, callingProcess );
147                                                   158   
148   // -- reset all data members:                   159   // -- reset all data members:
149   fOccurenceBiasingOperation                   << 160   fOccurenceBiasingOperation                  = 0 ;
150   fFinalStateBiasingOperation                  << 161   fFinalStateBiasingOperation                 = 0 ;
151   fNonPhysicsBiasingOperation                  << 162   fNonPhysicsBiasingOperation                 = 0 ;
152   fPreviousProposedOccurenceBiasingOperation   << 163   fPreviousProposedOccurenceBiasingOperation  = 0 ;
153   fPreviousProposedFinalStateBiasingOperation  << 164   fPreviousProposedFinalStateBiasingOperation = 0 ;
154   fPreviousProposedNonPhysicsBiasingOperation  << 165   fPreviousProposedNonPhysicsBiasingOperation = 0 ;
155   fPreviousAppliedOccurenceBiasingOperation    << 166   fPreviousAppliedOccurenceBiasingOperation   = 0 ;
156   fPreviousAppliedFinalStateBiasingOperation   << 167   fPreviousAppliedFinalStateBiasingOperation  = 0 ;
157   fPreviousAppliedNonPhysicsBiasingOperation   << 168   fPreviousAppliedNonPhysicsBiasingOperation  = 0 ;
158   fPreviousBiasingAppliedCase                     169   fPreviousBiasingAppliedCase                 = BAC_None ;
159 }                                                 170 }
160                                                   171 
                                                   >> 172 
161 // -- dummy empty implementations to allow let    173 // -- dummy empty implementations to allow letting arguments visible in the .hh
162 // -- but avoiding annoying warning messages a    174 // -- but avoiding annoying warning messages about unused variables
163 // -- methods to inform operator that its bias    175 // -- methods to inform operator that its biasing control is over:
164 void G4VBiasingOperator::                      << 176 void G4VBiasingOperator::ExitBiasing( const G4Track*, const G4BiasingProcessInterface*)
165 ExitBiasing( const G4Track*, const G4BiasingPr << 
166 {}                                                177 {}
167 void G4VBiasingOperator::                      << 178 void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
168 OperationApplied( const G4BiasingProcessInterf << 179              G4VBiasingOperation*, const G4VParticleChange* )
169                   G4VBiasingOperation*, const  << 
170 {                                                 180 {
171 }                                                 181 }
172 void G4VBiasingOperator::                      << 182 void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
173 OperationApplied( const G4BiasingProcessInterf << 183              G4VBiasingOperation*,  G4double,
174                   G4VBiasingOperation*, G4doub << 184              G4VBiasingOperation*, const G4VParticleChange* )
175                   G4VBiasingOperation*, const  << 
176 {                                                 185 {
177 }                                                 186 }
178                                                   187 
                                                   >> 188 
179 // -------------------------------------------    189 // ----------------------------------------------------------------------------
180 // -- state machine to get biasing operators m    190 // -- state machine to get biasing operators messaged at the beginning of runs:
181 // -------------------------------------------    191 // ----------------------------------------------------------------------------
182                                                   192 
183 G4BiasingOperatorStateNotifier::G4BiasingOpera    193 G4BiasingOperatorStateNotifier::G4BiasingOperatorStateNotifier()
184 : G4VStateDependent()                             194 : G4VStateDependent()
185 {                                                 195 {
186   fPreviousState =  G4State_PreInit;              196   fPreviousState =  G4State_PreInit;
187 }                                                 197 }
188                                                   198 
189 G4bool G4BiasingOperatorStateNotifier::        << 199 G4BiasingOperatorStateNotifier::~G4BiasingOperatorStateNotifier()
190 Notify( G4ApplicationState requestedState )    << 200 {}
                                                   >> 201 
                                                   >> 202 G4bool G4BiasingOperatorStateNotifier::Notify( G4ApplicationState requestedState )
191 {                                                 203 {
192   if ( ( fPreviousState == G4State_Idle )      << 204   if ( ( fPreviousState == G4State_Idle ) && ( requestedState == G4State_GeomClosed ) )
193     && ( requestedState == G4State_GeomClosed  << 
194   {                                            << 
195     for ( auto i = 0; i < (G4int)G4VBiasingOpe << 
196     {                                             205     {
197       G4VBiasingOperator::fOperators[i]->Start << 206       for ( size_t i = 0 ; i < G4VBiasingOperator::fOperators.Size() ; i++ ) G4VBiasingOperator::fOperators[i]->StartRun();
198     }                                             207     }
199   }                                            << 208 
200   fPreviousState = requestedState;                209   fPreviousState = requestedState;
201                                                   210   
202   return true;                                    211   return true;
203 }                                                 212 }
204                                                   213