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 | // Rich advanced example for Geant4 |
---|
27 | // HpdSiEnergyLoss.cc for Rich of LHCb |
---|
28 | // History: |
---|
29 | // Created: Sajan Easo (Sajan.Easo@cern.ch) |
---|
30 | // Revision: Patricia Mendez (Patricia.Mendez@cern.ch) |
---|
31 | ///////////////////////////////////////////////////////////////////////////// |
---|
32 | #include "HpdSiEnergyLoss.hh" |
---|
33 | #include "G4Material.hh" |
---|
34 | #include "Randomize.hh" |
---|
35 | #include "RichTbMaterialParameters.hh" |
---|
36 | #include "RichTbAnalysisManager.hh" |
---|
37 | |
---|
38 | HpdSiEnergyLoss::HpdSiEnergyLoss(const G4String& materialName, |
---|
39 | const G4String& processName) |
---|
40 | : G4VEnergyLoss(processName), |
---|
41 | MinKineticEnergy(1.*eV),MipEnergy(30000.0*eV), |
---|
42 | finalRangeforStep(0.15*mm) { |
---|
43 | ElossMaterialName= materialName; |
---|
44 | |
---|
45 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
46 | G4int numberOfMat = G4Material::GetNumberOfMaterials(); |
---|
47 | |
---|
48 | G4int iMat=0; |
---|
49 | for(iMat=0;iMat<numberOfMat;iMat++) { |
---|
50 | if ( materialName == (*theMaterialTable)[iMat]->GetName()){ |
---|
51 | fMatIndex=(*theMaterialTable)[iMat]->GetIndex(); |
---|
52 | break; |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|
56 | if(iMat >= numberOfMat ) { |
---|
57 | G4Exception("Invalid material Name in HpdSiEnergyLoss constructor" ); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | HpdSiEnergyLoss::~HpdSiEnergyLoss() { } |
---|
62 | |
---|
63 | G4bool HpdSiEnergyLoss::IsApplicable(const G4ParticleDefinition& |
---|
64 | aParticleType) { |
---|
65 | return(aParticleType.GetPDGCharge()!= 0.); |
---|
66 | } |
---|
67 | |
---|
68 | G4double HpdSiEnergyLoss::GetContinuousStepLimit(const G4Track& track, |
---|
69 | G4double, |
---|
70 | G4double, |
---|
71 | G4double& ){ |
---|
72 | |
---|
73 | G4double RangeForStep = finalRangeforStep; |
---|
74 | |
---|
75 | if( fMatIndex != G4int(track.GetMaterial() -> GetIndex()) ) { |
---|
76 | RangeForStep = DBL_MAX; |
---|
77 | } |
---|
78 | |
---|
79 | return RangeForStep; |
---|
80 | } |
---|
81 | |
---|
82 | G4double HpdSiEnergyLoss::GetMeanFreePath(const G4Track&, |
---|
83 | G4double, |
---|
84 | G4ForceCondition* condition) { |
---|
85 | // return infinity so that it does nothing. |
---|
86 | *condition = NotForced; |
---|
87 | return DBL_MAX; |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | G4VParticleChange* HpdSiEnergyLoss::PostStepDoIt(const G4Track& aTrack, |
---|
92 | const G4Step& aStep) { |
---|
93 | // Do nothing |
---|
94 | aParticleChange.Initialize(aTrack) ; |
---|
95 | return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack,aStep); |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | G4VParticleChange* HpdSiEnergyLoss::AlongStepDoIt(const G4Track& aTrack, |
---|
100 | const G4Step&) { |
---|
101 | |
---|
102 | |
---|
103 | #ifdef G4ANALYSIS_USE |
---|
104 | RichTbAnalysisManager * analysis = RichTbAnalysisManager::getInstance(); |
---|
105 | #endif |
---|
106 | |
---|
107 | |
---|
108 | aParticleChange.Initialize(aTrack); |
---|
109 | G4int aMaterialIndex = aTrack.GetMaterial()->GetIndex(); |
---|
110 | if(fMatIndex != aMaterialIndex ) { |
---|
111 | return &aParticleChange; |
---|
112 | } |
---|
113 | |
---|
114 | const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); |
---|
115 | G4double aKinEnergyInit = aParticle->GetKineticEnergy(); |
---|
116 | G4double Eloss, aKinEnergyFinal; |
---|
117 | if(aKinEnergyInit < MinKineticEnergy ) { Eloss=0.0 ; } |
---|
118 | else if( aKinEnergyInit < MipEnergy ) {Eloss= aKinEnergyInit ;} |
---|
119 | else { Eloss = MipEnergy; } |
---|
120 | |
---|
121 | aKinEnergyFinal=aKinEnergyInit-Eloss; |
---|
122 | |
---|
123 | |
---|
124 | //In the G4example the backscattering is implemented in |
---|
125 | //an adhoc manner as done below. It simply causes an |
---|
126 | // efficiency loss. |
---|
127 | |
---|
128 | G4double bckratio; |
---|
129 | if( SignalToNoiseInData > 0.0 ){ |
---|
130 | bckratio = NsigmaInPedCut/ SignalToNoiseInData ; |
---|
131 | |
---|
132 | } |
---|
133 | G4double Effs = 1.0 - backscaprob * bckratio; |
---|
134 | G4double Randbsk = G4UniformRand(); |
---|
135 | if(Randbsk <= Effs && Eloss > 0.0 ) { |
---|
136 | aParticleChange.ProposeLocalEnergyDeposit(Eloss); |
---|
137 | |
---|
138 | #ifdef G4ANALYSIS_USE |
---|
139 | |
---|
140 | analysis->bumpNumHitInSi(); |
---|
141 | |
---|
142 | #endif |
---|
143 | |
---|
144 | // G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint(); |
---|
145 | // G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName(); |
---|
146 | // G4int tpreVP = pPreStepPoint -> GetPhysicalVolume()->GetCopyNo(); |
---|
147 | } |
---|
148 | if (aKinEnergyFinal <= MinKineticEnergy ) { |
---|
149 | aParticleChange.ProposeTrackStatus(fStopAndKill); |
---|
150 | |
---|
151 | }else { |
---|
152 | aParticleChange.ProposeEnergy(aKinEnergyFinal); |
---|
153 | |
---|
154 | } |
---|
155 | return &aParticleChange; |
---|
156 | |
---|
157 | } |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | |
---|