]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFlukaCerenkov.cxx
Add sensitivity flag.
[u/mrichter/AliRoot.git] / TFluka / TFlukaCerenkov.cxx
1 #include "TFlukaCerenkov.h"
2
3 ClassImp(TFlukaCerenkov);
4
5
6 TFlukaCerenkov::TFlukaCerenkov()
7     : fSamples(0), 
8       fIsMetal(kFALSE),
9       fIsSensitive(kFALSE),
10       fEnergy(0),
11       fWaveLength(0),
12       fAbsorptionCoefficient(0),
13       fQuantumEfficiency(0),
14       fRefractionIndex(0)
15 {
16 // Default constructor
17 }
18
19
20 TFlukaCerenkov::TFlukaCerenkov(Int_t npckov, Float_t *ppckov, Float_t *absco, Float_t *effic, Float_t *rindex)
21 {
22 // Constructor    
23     fSamples = npckov;
24     fEnergy                = new Float_t[fSamples];
25     fWaveLength            = new Float_t[fSamples];
26     fAbsorptionCoefficient = new Float_t[fSamples];
27     fRefractionIndex       = new Float_t[fSamples];
28     fQuantumEfficiency     = new Float_t[fSamples];
29     for (Int_t i = 0; i < fSamples; i++) {
30         fEnergy[i]             = ppckov[i];
31         fWaveLength[i]         = khc / ppckov[i];
32         if (absco[i] > 0.) {
33             fAbsorptionCoefficient[i]   = 1./ absco[i];
34         } else {
35             fAbsorptionCoefficient[i]   = 1.e15;
36         }
37         fRefractionIndex[i]    = rindex[i];
38         fQuantumEfficiency[i]  = effic[i];
39         //
40         // Flag is sensitive if quantum efficiency 0 < eff < 1 for at least one value.
41         if (effic[i] < 1. && effic[i] > 0.) fIsSensitive = 1;
42     }
43 }
44
45 Float_t TFlukaCerenkov::GetAbsorptionCoefficient(Float_t energy)
46 {
47 //
48 // Get AbsorptionCoefficient for given energy 
49 //
50     return Interpolate(energy, fEnergy, fAbsorptionCoefficient);
51     
52 }
53
54 Float_t TFlukaCerenkov::GetRefractionIndex(Float_t energy)
55 {
56 //
57 // Get RefractionIndex for given energy 
58 //
59     return Interpolate(energy, fEnergy, fRefractionIndex);
60     
61 }
62
63 Float_t TFlukaCerenkov::GetQuantumEfficiency(Float_t energy)
64 {
65 //
66 // Get QuantumEfficiency for given energy 
67 //
68     return Interpolate(energy, fEnergy, fQuantumEfficiency);
69     
70 }
71
72
73 Float_t TFlukaCerenkov::GetAbsorptionCoefficientByWaveLength(Float_t wavelength)
74 {
75 //
76 // Get AbsorptionCoefficient for given wavelength 
77 //
78     Float_t energy = khc / wavelength;    
79     return Interpolate(energy, fEnergy, fAbsorptionCoefficient);
80     
81 }
82
83 Float_t TFlukaCerenkov::GetRefractionIndexByWaveLength(Float_t wavelength)
84 {
85 //
86 // Get RefractionIndex for given wavelenth 
87 //
88     Float_t energy = khc / wavelength;    
89     return Interpolate(energy, fEnergy, fRefractionIndex);
90 }
91
92 Float_t TFlukaCerenkov::GetQuantumEfficiencyByWaveLength(Float_t wavelength)
93 {
94 //
95 // Get QuantumEfficiency for given wavelength 
96 //
97     Float_t energy = khc / wavelength;    
98     return Interpolate(energy, fEnergy, fQuantumEfficiency);
99 }
100
101 Float_t TFlukaCerenkov::Interpolate(Float_t value, Float_t* array1, Float_t* array2)
102 {
103 //
104 // Interpolate array values 
105 //
106     if (value < array1[0] && value >= array1[fSamples - 1]) {
107         Warning("Interpolate()", "Photon energy out of range. Returning 0.");
108         return (0.);
109     }
110     
111     Int_t i = TMath::BinarySearch(fSamples, array1, value);
112     if (i == (fSamples-1)) {
113         return (array2[i]);
114     } else {
115         return (array2[i] + (array2[i+1] - array2[i]) / (array1[i+1] - array1[i]) * (value - array1[i]));
116     }
117 }
118