Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4VBiasingOperator 27 // ------------------------------------------- 28 29 #include "G4VBiasingOperator.hh" 30 #include "G4VBiasingOperation.hh" 31 #include "G4VParticleChange.hh" 32 33 G4MapCache< const G4LogicalVolume*, G4VBiasing 34 G4VectorCache< G4VBiasingOperator* > G4VBiasin 35 G4Cache< G4BiasingOperatorStateNotifier* > G4V 36 37 G4VBiasingOperator::G4VBiasingOperator(const G 38 : fName( name ) 39 { 40 fOperators.Push_back(this); 41 42 if ( fStateNotifier.Get() == nullptr ) 43 fStateNotifier.Put( new G4BiasingOperatorS 44 } 45 46 void G4VBiasingOperator::AttachTo(const G4Logi 47 { 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 } 64 65 const std::vector < G4VBiasingOperator* >& 66 G4VBiasingOperator::GetBiasingOperators() 67 { 68 return fOperators.Get(); 69 } 70 71 G4VBiasingOperator* G4VBiasingOperator::GetBia 72 { 73 auto it = fLogicalToSetupMap.Find(logical); 74 if ( it == fLogicalToSetupMap.End() ) { retu 75 else { return (*it).second; } 76 } 77 78 G4VBiasingOperation* G4VBiasingOperator::GetPr 79 { 80 fOccurenceBiasingOperation = ProposeOccurenc 81 return fOccurenceBiasingOperation; 82 } 83 84 G4VBiasingOperation* G4VBiasingOperator::GetPr 85 { 86 fFinalStateBiasingOperation = ProposeFinalSt 87 return fFinalStateBiasingOperation; 88 } 89 90 G4VBiasingOperation* G4VBiasingOperator::GetPr 91 { 92 fNonPhysicsBiasingOperation = ProposeNonPhys 93 return fNonPhysicsBiasingOperation; 94 } 95 96 void G4VBiasingOperator:: 97 ReportOperationApplied( const G4BiasingProcess 98 G4BiasingApplied 99 G4VBiasingOperat 100 const G4VParticleChang 101 { 102 fPreviousBiasingAppliedCase = biasingCase; 103 fPreviousAppliedOccurenceBiasingOperation = 104 fPreviousAppliedFinalStateBiasingOperation = 105 fPreviousAppliedNonPhysicsBiasingOperation = 106 switch ( biasingCase ) 107 { 108 case BAC_None: 109 break; 110 case BAC_NonPhysics: 111 fPreviousAppliedNonPhysicsBiasingOperati 112 break; 113 case BAC_FinalState: 114 fPreviousAppliedFinalStateBiasingOperati 115 break; 116 case BAC_Occurence: 117 G4Exception("G4VBiasingOperator::ReportO 118 "BIAS.MNG.02", JustWarning, 119 "Internal logic error, pleas 120 break; 121 default: 122 G4Exception("G4VBiasingOperator::ReportO 123 "BIAS.MNG.03", JustWarning, 124 "Internal logic error, pleas 125 } 126 OperationApplied( callingProcess, biasingCas 127 } 128 129 void G4VBiasingOperator:: 130 ReportOperationApplied( const G4BiasingProcess 131 G4BiasingApplied 132 G4VBiasingOperat 133 G4double weightF 134 G4VBiasingOperat 135 const G4VParticleChang 136 { 137 fPreviousBiasingAppliedCase = biasingCase; 138 fPreviousAppliedOccurenceBiasingOperation = 139 fPreviousAppliedFinalStateBiasingOperation = 140 OperationApplied( callingProcess, biasingCas 141 } 142 143 void G4VBiasingOperator:: 144 ExitingBiasing( const G4Track* track, const G4 145 { 146 ExitBiasing( track, callingProcess ); 147 148 // -- reset all data members: 149 fOccurenceBiasingOperation 150 fFinalStateBiasingOperation 151 fNonPhysicsBiasingOperation 152 fPreviousProposedOccurenceBiasingOperation 153 fPreviousProposedFinalStateBiasingOperation 154 fPreviousProposedNonPhysicsBiasingOperation 155 fPreviousAppliedOccurenceBiasingOperation 156 fPreviousAppliedFinalStateBiasingOperation 157 fPreviousAppliedNonPhysicsBiasingOperation 158 fPreviousBiasingAppliedCase 159 } 160 161 // -- dummy empty implementations to allow let 162 // -- but avoiding annoying warning messages a 163 // -- methods to inform operator that its bias 164 void G4VBiasingOperator:: 165 ExitBiasing( const G4Track*, const G4BiasingPr 166 {} 167 void G4VBiasingOperator:: 168 OperationApplied( const G4BiasingProcessInterf 169 G4VBiasingOperation*, const 170 { 171 } 172 void G4VBiasingOperator:: 173 OperationApplied( const G4BiasingProcessInterf 174 G4VBiasingOperation*, G4doub 175 G4VBiasingOperation*, const 176 { 177 } 178 179 // ------------------------------------------- 180 // -- state machine to get biasing operators m 181 // ------------------------------------------- 182 183 G4BiasingOperatorStateNotifier::G4BiasingOpera 184 : G4VStateDependent() 185 { 186 fPreviousState = G4State_PreInit; 187 } 188 189 G4bool G4BiasingOperatorStateNotifier:: 190 Notify( G4ApplicationState requestedState ) 191 { 192 if ( ( fPreviousState == G4State_Idle ) 193 && ( requestedState == G4State_GeomClosed 194 { 195 for ( auto i = 0; i < (G4int)G4VBiasingOpe 196 { 197 G4VBiasingOperator::fOperators[i]->Start 198 } 199 } 200 fPreviousState = requestedState; 201 202 return true; 203 } 204