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 | // |
---|
26 | // $Id: G4QDiscProcessMixer.cc,v 1.2 2007/08/31 09:36:57 mkossov Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
28 | // |
---|
29 | // ---------------- G4QDiscProcessMixer class ----------------- |
---|
30 | // by Mikhail Kossov, Aug 2007. |
---|
31 | // G4QDiscProcessMixer class of the CHIPS Simulation Branch in GEANT4 |
---|
32 | // --------------------------------------------------------------- |
---|
33 | // **************************************************************************************** |
---|
34 | // ********** This CLASS is temporary moved from the "chips/interface" directory ********* |
---|
35 | // **************************************************************************************** |
---|
36 | |
---|
37 | //#define debug |
---|
38 | |
---|
39 | #include "G4QDiscProcessMixer.hh" |
---|
40 | |
---|
41 | // Constructor |
---|
42 | G4QDiscProcessMixer::G4QDiscProcessMixer(const G4String& name, |
---|
43 | const G4ParticleDefinition* particle, |
---|
44 | G4ProcessType pType): |
---|
45 | G4VDiscreteProcess(name, pType), DPParticle(particle) |
---|
46 | { |
---|
47 | #ifdef debug |
---|
48 | G4cout<<"G4QDiscProcessMixer::Constructor is called processName="<<name<<G4endl; |
---|
49 | #endif |
---|
50 | if (verboseLevel>0) G4cout<<GetProcessName()<<" process is created "<<G4endl; |
---|
51 | } |
---|
52 | |
---|
53 | // Destructor |
---|
54 | G4QDiscProcessMixer::~G4QDiscProcessMixer() |
---|
55 | { |
---|
56 | for_each(theDPVector.begin(), theDPVector.end(), DeleteDiscreteProcess()); |
---|
57 | } |
---|
58 | |
---|
59 | void G4QDiscProcessMixer::AddDiscreteProcess(G4VDiscreteProcess* DP, G4double ME) |
---|
60 | { |
---|
61 | if(ME>theDPVector[theDPVector.size()-1]->second) |
---|
62 | { |
---|
63 | std::pair<G4VDiscreteProcess*, G4double>* QDiscProc = |
---|
64 | new std::pair<G4VDiscreteProcess*, G4double>(DP, ME); |
---|
65 | theDPVector.push_back( QDiscProc ); |
---|
66 | } |
---|
67 | else // Wrong Max Energy Order for the new process in the sequence of processes |
---|
68 | { |
---|
69 | G4cerr<<"G4QDiscProcessMixer::AddDiscreteProcess:LastMaxE("<<theDPVector.size()-1<<")=" |
---|
70 | <<theDPVector[theDPVector.size()-1]->second<<" >= MaxE="<<ME<<G4endl; |
---|
71 | G4Exception("G4QDiscProcessMixer::AddDiscreteProcess: Wrong Max Energy Order"); |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | G4bool G4QDiscProcessMixer::IsApplicable(const G4ParticleDefinition& particle) |
---|
76 | { |
---|
77 | if(particle == *DPParticle) return true; |
---|
78 | return false; |
---|
79 | } |
---|
80 | |
---|
81 | G4double G4QDiscProcessMixer::PostStepGetPhysicalInteractionLength(const G4Track& Track, |
---|
82 | G4double PrevStSize, |
---|
83 | G4ForceCondition* F) |
---|
84 | { |
---|
85 | G4double kEn=Track.GetDynamicParticle()->GetKineticEnergy(); // Projectile kinetic energy |
---|
86 | G4int maxDP=theDPVector.size(); |
---|
87 | if(maxDP) for(G4int i=0; i<maxDP; ++i) if(kEn < theDPVector[i]->second) |
---|
88 | return theDPVector[i]->first->PostStepGetPhysicalInteractionLength(Track,PrevStSize,F); |
---|
89 | return DBL_MAX; |
---|
90 | } |
---|
91 | |
---|
92 | G4VParticleChange* G4QDiscProcessMixer::PostStepDoIt(const G4Track& Track, |
---|
93 | const G4Step& Step) |
---|
94 | { |
---|
95 | G4double kEn=Track.GetDynamicParticle()->GetKineticEnergy(); // Projectile kinetic energy |
---|
96 | G4int maxDP=theDPVector.size(); |
---|
97 | if(maxDP) for(G4int i=0; i<maxDP; ++i) if(kEn < theDPVector[i]->second) |
---|
98 | { |
---|
99 | //EnMomConservation= theDPVector[i]->first->GetEnegryMomentumConservation(); |
---|
100 | //nOfNeutrons = theDPVector[i]->first->GetNumberOfNeutronsInTarget(); |
---|
101 | return theDPVector[i]->first->PostStepDoIt(Track, Step); |
---|
102 | } |
---|
103 | return G4VDiscreteProcess::PostStepDoIt(Track, Step); |
---|
104 | } |
---|
105 | |
---|
106 | //G4LorentzVector G4QDiscProcessMixer::GetEnegryMomentumConservation() |
---|
107 | // {return EnMomConservation;} |
---|
108 | |
---|
109 | //G4int G4QDiscProcessMixer::GetNumberOfNeutronsInTarget() |
---|
110 | // {return nOfNeutrons;} |
---|