ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ChannelingOptrChangeCrossSection.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ChannelingOptrChangeCrossSection.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
29 
30 #include "G4ParticleDefinition.hh"
31 #include "G4ParticleTable.hh"
32 #include "G4VProcess.hh"
33 
34 #include "Randomize.hh"
35 
37 
38 #include "G4ChannelingTrackData.hh"
39 #include "G4EmProcessSubType.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  G4String name)
45 :G4VBiasingOperator(name),
46 fChannelingID(-1),
47 fSetup(true){
49 
50  if ( fParticleToBias == 0 )
51  {
53  ed << "Particle `" << particleName << "' not found !" << G4endl;
54  G4Exception("G4ChannelingOptrChangeCrossSection(...)",
55  "G4Channeling",
57  ed);
58  }
59 
60  fProcessToDensity["channeling"] = fDensityRatioNone;
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66  for ( std::map< const G4BiasingProcessInterface*, G4BOptnChangeCrossSection* >::iterator
69  it++ ) delete (*it).second;
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75  if ( fSetup ){
76  const G4ProcessManager* processManager = fParticleToBias->GetProcessManager();
77  const G4BiasingProcessSharedData* sharedData =
79  if ( sharedData ){
80  for ( size_t i = 0 ; i < (sharedData->GetPhysicsBiasingProcessInterfaces()).size(); i++ ){
81  const G4BiasingProcessInterface* wrapperProcess =
82  (sharedData->GetPhysicsBiasingProcessInterfaces())[i];
83  G4String processName = wrapperProcess->GetWrappedProcess()->GetProcessName();
84  G4String operationName = "channelingChangeXS-" + processName;
85  fChangeCrossSectionOperations[wrapperProcess] =
86  new G4BOptnChangeCrossSection(operationName);
87 
88  G4ProcessType type = wrapperProcess->GetWrappedProcess()->GetProcessType();
89  G4int subType = wrapperProcess->GetWrappedProcess()->GetProcessSubType();
90 
91  switch (type) {
92  case fNotDefined:
94  break;
95  case fTransportation:
96  fProcessToDensity[processName] = fDensityRatioNone;
97  break;
98  case fElectromagnetic:
99  if(subType == fCoulombScattering ||
100  subType == fMultipleScattering){
101  fProcessToDensity[processName] = fDensityRatioNuD;
102  }
103  if(subType == fIonisation ||
104  subType == fPairProdByCharged ||
105  subType == fAnnihilation ||
106  subType == fAnnihilationToMuMu ||
107  subType == fAnnihilationToHadrons){
108  fProcessToDensity[processName] = fDensityRatioElD;
109  }
110  if(subType == fBremsstrahlung ||
111  subType == fNuclearStopping){
112  fProcessToDensity[processName] = fDensityRatioNuDElD;
113  }
114 
115  if(subType == fCerenkov ||
116  subType == fScintillation ||
117  subType == fSynchrotronRadiation ||
118  subType == fTransitionRadiation){
119  fProcessToDensity[processName] = fDensityRatioNone;
120  }
121  if(subType == fRayleigh ||
122  subType == fPhotoElectricEffect ||
123  subType == fComptonScattering ||
124  subType == fGammaConversion ||
125  subType == fGammaConversionToMuMu){
126  fProcessToDensity[processName] = fDensityRatioNone;
127  }
128  break;
129  case fOptical:
130  fProcessToDensity[processName] = fDensityRatioNone;
131  break;
132  case fHadronic:
133  fProcessToDensity[processName] = fDensityRatioNuD;
134  break;
135  case fPhotolepton_hadron:
136  fProcessToDensity[processName] = fDensityRatioNuD;
137  break;
138  case fGeneral:
139  fProcessToDensity[processName] = fDensityRatioNone;
140  break;
141  case fDecay:
142  fProcessToDensity[processName] = fDensityRatioNone;
143  break;
144  case fParameterisation:
145  fProcessToDensity[processName] = fDensityRatioNone;
146  break;
147  case fUserDefined:
148  fProcessToDensity[processName] = fDensityRatioNone;
149  break;
150  case fParallel:
151  fProcessToDensity[processName] = fDensityRatioNone;
152  break;
153  case fPhonon:
154  fProcessToDensity[processName] = fDensityRatioNone;
155  break;
156  case fUCN:
157  fProcessToDensity[processName] = fDensityRatioNone;
158  break;
159  default:
160  fProcessToDensity[processName] = fDensityRatioNone;
161  break;
162  }
163  }
164  }
165  fSetup = false;
166  }
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 
174  callingProcess)
175 {
176  if ( track->GetDefinition() != fParticleToBias ) return 0;
177 
178  G4double analogInteractionLength =
179  callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
180  if ( analogInteractionLength > DBL_MAX/10. ) return 0;
181 
182  G4double analogXS = 1./analogInteractionLength;
183 
184  if(fChannelingID==-1){
186  }
187  G4ChannelingTrackData* trackdata =
189  if(trackdata==nullptr) return 0;
190 
191  G4double XStransformation = 1.;
192  auto search = fProcessToDensity.find(callingProcess->GetWrappedProcess()->GetProcessName());
193  if(search != fProcessToDensity.end()) {
194  switch (search->second) {
195  case fDensityRatioNuDElD:
196  XStransformation = trackdata->GetDensity();
197  break;
198  case fDensityRatioNuD:
199  XStransformation = trackdata->GetNuD();
200  break;
201  case fDensityRatioElD:
202  XStransformation = trackdata->GetElD();
203  break;
204  case fDensityRatioNone:
205  return 0;
206  break;
208  return 0;
209  break;
210  default:
211  return 0;
212  break;
213  }
214  }
215  else{
216  XStransformation = trackdata->GetDensity();
217  }
218 
219  G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
220  G4VBiasingOperation* previousOperation = callingProcess->GetPreviousOccurenceBiasingOperation();
221 
222  if ( previousOperation == 0 ){
223  operation->SetBiasedCrossSection( XStransformation * analogXS );
224  operation->Sample();
225  }
226  else{
227  if ( previousOperation != operation ){
229  ed << " Logic problem in operation handling !" << G4endl;
230  G4Exception("G4ChannelingOptrChangeCrossSection::ProposeOccurenceBiasingOperation(...)",
231  "G4Channeling",
232  JustWarning,
233  ed);
234  return 0;
235  }
236  if ( operation->GetInteractionOccured() ){
237  operation->SetBiasedCrossSection( XStransformation * analogXS );
238  operation->Sample();
239  }
240  else{
241  operation->UpdateForStep( callingProcess->GetPreviousStepSize() );
242  operation->SetBiasedCrossSection( XStransformation * analogXS );
243  operation->UpdateForStep( 0.0 );
244  }
245  }
246 
247  return operation;
248 
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
256  G4VBiasingOperation* occurenceOperationApplied,
257  G4double,
259  const G4VParticleChange* )
260 {
261  G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
262  if ( operation == occurenceOperationApplied ) operation->SetInteractionOccured();
263 }
264 
265 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......