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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.6)


  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 nullptr;
                                                   >>  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  = nullptr;
104   fPreviousAppliedFinalStateBiasingOperation =    111   fPreviousAppliedFinalStateBiasingOperation = nullptr;
105   fPreviousAppliedNonPhysicsBiasingOperation =    112   fPreviousAppliedNonPhysicsBiasingOperation = nullptr;
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;
113     case BAC_FinalState:                          120     case BAC_FinalState:
114       fPreviousAppliedFinalStateBiasingOperati    121       fPreviousAppliedFinalStateBiasingOperation = operationApplied;
115       break;                                      122       break;
116     case BAC_Occurence:                           123     case BAC_Occurence:
117       G4Exception("G4VBiasingOperator::ReportO    124       G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
118                   "BIAS.MNG.02", JustWarning,  << 125             "BIAS.MNG.02",
119                   "Internal logic error, pleas << 126             JustWarning,
                                                   >> 127       "Internal logic error, please report !");
120       break;                                      128       break;
121     default:                                      129     default:
122       G4Exception("G4VBiasingOperator::ReportO    130       G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
123                   "BIAS.MNG.03", JustWarning,  << 131       "BIAS.MNG.03",
124                   "Internal logic error, pleas << 132       JustWarning,
125   }                                            << 133       "Internal logic error, please report !");
                                                   >> 134     }
126   OperationApplied( callingProcess, biasingCas    135   OperationApplied( callingProcess, biasingCase, operationApplied, particleChangeProduced );
127 }                                                 136 }
128                                                   137 
129 void G4VBiasingOperator::                      << 138 void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface*               callingProcess,
130 ReportOperationApplied( const G4BiasingProcess << 139              G4BiasingAppliedCase                              biasingCase,
131                               G4BiasingApplied << 140              G4VBiasingOperation*                occurenceOperationApplied,
132                               G4VBiasingOperat << 141              G4double                        weightForOccurenceInteraction,
133                               G4double weightF << 142              G4VBiasingOperation*               finalStateOperationApplied,
134                               G4VBiasingOperat << 143              const G4VParticleChange*               particleChangeProduced )
135                         const G4VParticleChang << 
136 {                                                 144 {
137   fPreviousBiasingAppliedCase = biasingCase;      145   fPreviousBiasingAppliedCase = biasingCase;
138   fPreviousAppliedOccurenceBiasingOperation =  << 146   fPreviousAppliedOccurenceBiasingOperation  =  occurenceOperationApplied;
139   fPreviousAppliedFinalStateBiasingOperation =    147   fPreviousAppliedFinalStateBiasingOperation = finalStateOperationApplied;
140   OperationApplied( callingProcess, biasingCas    148   OperationApplied( callingProcess, biasingCase, occurenceOperationApplied, weightForOccurenceInteraction, finalStateOperationApplied, particleChangeProduced );
141 }                                                 149 }
142                                                   150 
143 void G4VBiasingOperator::                      << 151 
144 ExitingBiasing( const G4Track* track, const G4 << 152 void G4VBiasingOperator::ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess )
145 {                                                 153 {
146   ExitBiasing( track, callingProcess );           154   ExitBiasing( track, callingProcess );
147                                                   155   
148   // -- reset all data members:                   156   // -- reset all data members:
149   fOccurenceBiasingOperation                      157   fOccurenceBiasingOperation                  = nullptr ;
150   fFinalStateBiasingOperation                     158   fFinalStateBiasingOperation                 = nullptr ;
151   fNonPhysicsBiasingOperation                     159   fNonPhysicsBiasingOperation                 = nullptr ;
152   fPreviousProposedOccurenceBiasingOperation      160   fPreviousProposedOccurenceBiasingOperation  = nullptr ;
153   fPreviousProposedFinalStateBiasingOperation     161   fPreviousProposedFinalStateBiasingOperation = nullptr ;
154   fPreviousProposedNonPhysicsBiasingOperation     162   fPreviousProposedNonPhysicsBiasingOperation = nullptr ;
155   fPreviousAppliedOccurenceBiasingOperation       163   fPreviousAppliedOccurenceBiasingOperation   = nullptr ;
156   fPreviousAppliedFinalStateBiasingOperation      164   fPreviousAppliedFinalStateBiasingOperation  = nullptr ;
157   fPreviousAppliedNonPhysicsBiasingOperation      165   fPreviousAppliedNonPhysicsBiasingOperation  = nullptr ;
158   fPreviousBiasingAppliedCase                     166   fPreviousBiasingAppliedCase                 = BAC_None ;
159 }                                                 167 }
160                                                   168 
                                                   >> 169 
161 // -- dummy empty implementations to allow let    170 // -- dummy empty implementations to allow letting arguments visible in the .hh
162 // -- but avoiding annoying warning messages a    171 // -- but avoiding annoying warning messages about unused variables
163 // -- methods to inform operator that its bias    172 // -- methods to inform operator that its biasing control is over:
164 void G4VBiasingOperator::                      << 173 void G4VBiasingOperator::ExitBiasing( const G4Track*, const G4BiasingProcessInterface*)
165 ExitBiasing( const G4Track*, const G4BiasingPr << 
166 {}                                                174 {}
167 void G4VBiasingOperator::                      << 175 void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
168 OperationApplied( const G4BiasingProcessInterf << 176              G4VBiasingOperation*, const G4VParticleChange* )
169                   G4VBiasingOperation*, const  << 
170 {                                                 177 {
171 }                                                 178 }
172 void G4VBiasingOperator::                      << 179 void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
173 OperationApplied( const G4BiasingProcessInterf << 180              G4VBiasingOperation*,  G4double,
174                   G4VBiasingOperation*, G4doub << 181              G4VBiasingOperation*, const G4VParticleChange* )
175                   G4VBiasingOperation*, const  << 
176 {                                                 182 {
177 }                                                 183 }
178                                                   184 
                                                   >> 185 
179 // -------------------------------------------    186 // ----------------------------------------------------------------------------
180 // -- state machine to get biasing operators m    187 // -- state machine to get biasing operators messaged at the beginning of runs:
181 // -------------------------------------------    188 // ----------------------------------------------------------------------------
182                                                   189 
183 G4BiasingOperatorStateNotifier::G4BiasingOpera    190 G4BiasingOperatorStateNotifier::G4BiasingOperatorStateNotifier()
184 : G4VStateDependent()                             191 : G4VStateDependent()
185 {                                                 192 {
186   fPreviousState =  G4State_PreInit;              193   fPreviousState =  G4State_PreInit;
187 }                                                 194 }
188                                                   195 
189 G4bool G4BiasingOperatorStateNotifier::        << 196 G4BiasingOperatorStateNotifier::~G4BiasingOperatorStateNotifier()
190 Notify( G4ApplicationState requestedState )    << 197 {}
                                                   >> 198 
                                                   >> 199 G4bool G4BiasingOperatorStateNotifier::Notify( G4ApplicationState requestedState )
191 {                                                 200 {
192   if ( ( fPreviousState == G4State_Idle )      << 201   if ( ( fPreviousState == G4State_Idle ) && ( requestedState == G4State_GeomClosed ) )
193     && ( requestedState == G4State_GeomClosed  << 
194   {                                            << 
195     for ( auto i = 0; i < (G4int)G4VBiasingOpe << 
196     {                                             202     {
197       G4VBiasingOperator::fOperators[i]->Start << 203       for ( size_t i = 0 ; i < G4VBiasingOperator::fOperators.Size() ; i++ ) G4VBiasingOperator::fOperators[i]->StartRun();
198     }                                             204     }
199   }                                            << 205 
200   fPreviousState = requestedState;                206   fPreviousState = requestedState;
201                                                   207   
202   return true;                                    208   return true;
203 }                                                 209 }
204                                                   210