]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFlukaCerenkov.cxx
Calling TVirtualMCApplication::MisalignGeometry() to apply the misalignment to TGeo...
[u/mrichter/AliRoot.git] / TFluka / TFlukaCerenkov.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$*/
17
18 //
19 // Stores user defined cerenkov properties of media like 
20 // absorption coefficient, refraction index and quantum efficiency. 
21 // The properties are stored in arrays. The array index corresponds to discrete 
22 // optical photon energies defined in fEnergy.
23 // Access to the properties is provided by interpolation.
24 // 
25 // Author:
26 // A. Morsch 
27 // andreas.morsch@cern.ch
28 //
29
30 #include "TFlukaCerenkov.h"
31
32 Double_t TFlukaCerenkov::fgGlobalMaximumEfficiency = 0.;
33    
34 ClassImp(TFlukaCerenkov)
35
36
37 TFlukaCerenkov::TFlukaCerenkov()
38     : fSamples(0), 
39       fIsMetal(kFALSE),
40       fIsSensitive(kFALSE),
41       fEnergy(0),
42       fWaveLength(0),
43       fAbsorptionCoefficient(0),
44       fQuantumEfficiency(0),
45       fRefractionIndex(0),
46       fReflectivity(0),
47       fMaximumEfficiency(0.)
48 {
49 // Default constructor
50 }
51
52
53 TFlukaCerenkov::TFlukaCerenkov(Int_t npckov, Float_t *ppckov, Float_t *absco, Float_t *effic, Float_t *rindex)
54     : fSamples(npckov),
55       fIsMetal(kFALSE),
56       fIsSensitive(kFALSE),
57       fEnergy(new Float_t[fSamples]),
58       fWaveLength(new Float_t[fSamples]),
59       fAbsorptionCoefficient(new Float_t[fSamples]),
60       fQuantumEfficiency(new Float_t[fSamples]),
61       fRefractionIndex(new Float_t[fSamples]),
62       fReflectivity(new Float_t[fSamples]),
63       fMaximumEfficiency(0.)
64 {
65 // Constructor
66
67 //    fSamples = npckov;
68 //    fEnergy                = new Float_t[fSamples];
69 //    fWaveLength            = new Float_t[fSamples];
70 //    fAbsorptionCoefficient = new Float_t[fSamples];
71 //    fRefractionIndex       = new Float_t[fSamples];
72 //    fQuantumEfficiency     = new Float_t[fSamples];
73 //    fReflectivity          = new Float_t[fSamples];    
74
75     for (Int_t i = 0; i < fSamples; i++) {
76         fEnergy[i]             = ppckov[i];
77         fWaveLength[i]         = khc / ppckov[i];
78         if (absco[i] > 0.) {
79             fAbsorptionCoefficient[i]   = 1./ absco[i];
80         } else {
81             fAbsorptionCoefficient[i]   = 1.e15;
82         }
83         fRefractionIndex[i]    = rindex[i];
84         fQuantumEfficiency[i]  = effic[i];
85         //
86         // Find local maximum quantum efficiency
87         if (effic[i] > fMaximumEfficiency) fMaximumEfficiency = effic[i];
88         //
89         // Flag is sensitive if quantum efficiency 0 < eff < 1 for at least one value.
90         if (effic[i] < 1. && effic[i] > 0.) fIsSensitive = 1;
91         // G3 way to define metal
92         if (rindex[0] == 0.) {
93             fIsMetal = kTRUE;
94             fReflectivity[i] = absco[i];
95         }
96     }
97     // Find global  maximum quantum efficiency
98     if (fMaximumEfficiency > GetGlobalMaximumEfficiency()) {
99         SetGlobalMaximumEfficiency(fMaximumEfficiency);
100     }
101 }
102
103 TFlukaCerenkov::TFlukaCerenkov(Int_t npckov, Float_t *ppckov, Float_t *absco, Float_t *effic, Float_t *rindex, Float_t *refl)
104     : fSamples(npckov),
105       fIsMetal(kFALSE),
106       fIsSensitive(kFALSE),
107       fEnergy(new Float_t[fSamples]),
108       fWaveLength(new Float_t[fSamples]),
109       fAbsorptionCoefficient(new Float_t[fSamples]),
110       fQuantumEfficiency(new Float_t[fSamples]),
111       fRefractionIndex(new Float_t[fSamples]),
112       fReflectivity(new Float_t[fSamples]),
113       fMaximumEfficiency(0.)
114 {
115     // Constructor including reflectivity
116 //    fSamples = npckov;
117 //    fEnergy                = new Float_t[fSamples];
118 //    fWaveLength            = new Float_t[fSamples];
119 //    fAbsorptionCoefficient = new Float_t[fSamples];
120 //    fRefractionIndex       = new Float_t[fSamples];
121 //    fQuantumEfficiency     = new Float_t[fSamples];
122     
123     
124     for (Int_t i = 0; i < fSamples; i++) {
125         fEnergy[i]             = ppckov[i];
126         fWaveLength[i]         = khc / ppckov[i];
127         if (absco[i] > 0.) {
128             fAbsorptionCoefficient[i]   = 1./ absco[i];
129         } else {
130             fAbsorptionCoefficient[i]   = 1.e15;
131         }
132         fRefractionIndex[i]    = rindex[i];
133         fQuantumEfficiency[i]  = effic[i];
134         //
135         // Find local maximum quantum efficiency
136         if (effic[i] > fMaximumEfficiency) fMaximumEfficiency = effic[i];
137         //
138         // Flag is sensitive if quantum efficiency 0 < eff < 1 for at least one value.
139         if (effic[i] < 1. && effic[i] > 0.) fIsSensitive = 1;
140         //
141
142     }
143     // Find global  maximum quantum efficiency
144     if (fMaximumEfficiency > GetGlobalMaximumEfficiency()) {
145         SetGlobalMaximumEfficiency(fMaximumEfficiency);
146     }
147 //    fReflectivity     = new Float_t[fSamples];
148     for (Int_t i = 0; i < fSamples; i++) fReflectivity[i] = refl[i];
149     fIsMetal = kTRUE;
150 }
151
152 Float_t TFlukaCerenkov::GetAbsorptionCoefficient(Float_t energy)
153 {
154 //
155 // Get AbsorptionCoefficient for given energy 
156 //
157     return Interpolate(energy, fEnergy, fAbsorptionCoefficient);
158     
159 }
160
161 Float_t TFlukaCerenkov::GetRefractionIndex(Float_t energy)
162 {
163 //
164 // Get RefractionIndex for given energy 
165 //
166     return Interpolate(energy, fEnergy, fRefractionIndex);
167     
168 }
169
170 Float_t TFlukaCerenkov::GetReflectivity(Float_t energy)
171 {
172 //
173 // Get RefractionIndex for given energy 
174 //
175     return Interpolate(energy, fEnergy, fReflectivity);
176     
177 }
178
179 Float_t TFlukaCerenkov::GetQuantumEfficiency(Float_t energy)
180 {
181 //
182 // Get QuantumEfficiency for given energy 
183 //
184     return Interpolate(energy, fEnergy, fQuantumEfficiency);
185     
186 }
187
188
189 Float_t TFlukaCerenkov::GetAbsorptionCoefficientByWaveLength(Float_t wavelength)
190 {
191 //
192 // Get AbsorptionCoefficient for given wavelength 
193 //
194     Float_t energy = khc / wavelength;    
195     return Interpolate(energy, fEnergy, fAbsorptionCoefficient);
196     
197 }
198
199 Float_t TFlukaCerenkov::GetRefractionIndexByWaveLength(Float_t wavelength)
200 {
201 //
202 // Get RefractionIndex for given wavelenth 
203 //
204     Float_t energy = khc / wavelength;    
205     return Interpolate(energy, fEnergy, fRefractionIndex);
206 }
207
208 Float_t TFlukaCerenkov::GetReflectivityByWaveLength(Float_t wavelength)
209 {
210 //
211 // Get RefractionIndex for given wavelenth 
212 //
213     Float_t energy = khc / wavelength;    
214     return Interpolate(energy, fEnergy, fReflectivity);
215 }
216
217 Float_t TFlukaCerenkov::GetQuantumEfficiencyByWaveLength(Float_t wavelength)
218 {
219 //
220 // Get QuantumEfficiency for given wavelength 
221 //
222     Float_t energy = khc / wavelength;    
223     return Interpolate(energy, fEnergy, fQuantumEfficiency);
224 }
225
226 Float_t TFlukaCerenkov::Interpolate(Float_t value, Float_t* array1, Float_t* array2)
227 {
228 //
229 // Interpolate array values 
230 //
231     if (value < array1[0] && value >= array1[fSamples - 1]) {
232         Warning("Interpolate()", "Photon energy out of range. Returning 0.");
233         return (0.);
234     }
235     
236     Int_t i = TMath::BinarySearch(fSamples, array1, value);
237     if (i == (fSamples-1)) {
238         return (array2[i]);
239     } else {
240         return (array2[i] + (array2[i+1] - array2[i]) / (array1[i+1] - array1[i]) * (value - array1[i]));
241     }
242 }
243