]>
Commit | Line | Data |
---|---|---|
ba030c0e | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
ba030c0e | 17 | |
18 | // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay | |
19 | // | |
20 | // Class AliMUONSt1ResponseParameter | |
21 | // --------------------------------- | |
22 | // Describes a set of filters to be applied to a digital value | |
23 | // in order to simulate electronics characteristics | |
24 | // (pedestal, noise, sticky bits, etc....) | |
25 | // Threshold levels for the MANU zero supression algorithm are included. | |
26 | ||
27 | #include <fstream> | |
28 | #include <TRandom.h> | |
29 | #include "AliMUONSt1ResponseParameter.h" | |
30 | ||
31 | ClassImp(AliMUONSt1ResponseParameter); | |
32 | ||
33 | //_________________________________________________________________________ | |
34 | AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter() | |
35 | :TNamed() | |
36 | { | |
37 | // default constructor | |
38 | fPedestalMode = kNone; | |
39 | fNoiseMode = kNone; | |
40 | fState=1; | |
41 | fNofSigma=3; | |
42 | fStickyOn=fStickyOff=0; | |
43 | } | |
44 | ||
45 | //_________________________________________________________________________ | |
46 | AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter(const TString& name,const TString& title) | |
47 | :TNamed(name,title) | |
48 | { | |
49 | // normal constructor | |
50 | fPedestalMode = kNone; | |
51 | fNoiseMode = kNone; | |
52 | fState=1; | |
53 | fNofSigma=3; | |
54 | fStickyOn=fStickyOff=0; | |
55 | } | |
56 | ||
57 | //_________________________________________________________________________ | |
58 | AliMUONSt1ResponseParameter::~AliMUONSt1ResponseParameter() | |
59 | { | |
60 | // destructor | |
61 | } | |
62 | ||
63 | //_________________________________________________________________________ | |
64 | void AliMUONSt1ResponseParameter::SetState(Bool_t state) | |
65 | { | |
66 | // If set to off, no information will be available from the electronics | |
67 | // --- | |
68 | ||
69 | fState=state; | |
70 | } | |
71 | ||
72 | //_________________________________________________________________________ | |
73 | void AliMUONSt1ResponseParameter::SetPedestal(Double_t val) | |
74 | { | |
75 | // Set pedestal values to a constant | |
76 | // --- | |
77 | ||
78 | fPedestalMode = kValue; | |
79 | fPedestalParam.value = val; | |
80 | } | |
81 | ||
82 | //_________________________________________________________________________ | |
83 | void AliMUONSt1ResponseParameter::SetPedestal(Double_t mean,Double_t sigma) | |
84 | { | |
85 | // Set pedestal values to a parameterized gaussian | |
86 | // --- | |
87 | ||
88 | fPedestalMode = kGauss; | |
89 | fPedestalParam.gauss.mean = mean; | |
90 | fPedestalParam.gauss.sigma = sigma; | |
91 | } | |
92 | //_________________________________________________________________________ | |
93 | void AliMUONSt1ResponseParameter::SetPedestal(const TString& fileName) | |
94 | { | |
95 | // Set pedestal values to those given in a file | |
96 | // --- | |
97 | ||
98 | ifstream file(fileName.Data()); | |
99 | if (file.good()){ | |
100 | fPedestalMode = kFile; | |
101 | for (Int_t ch=0;ch<fgkNofChannels;ch++) { | |
102 | Float_t value; | |
103 | file>>value; | |
104 | fPedestalParam.values[ch] = value; | |
105 | //cout<<"Pedestal["<<i<<"]["<<ch<<"]="<<value<<endl; | |
106 | } | |
107 | file.close(); | |
108 | } else { | |
109 | Warning("SetPedestal",Form("Can't read file %s",fileName.Data())); | |
110 | SetPedestal(150.,10.); | |
111 | } | |
112 | } | |
113 | ||
114 | //_________________________________________________________________________ | |
115 | void AliMUONSt1ResponseParameter::UnSetPedestal() | |
116 | { | |
117 | // Set pedestal values to 0. | |
118 | // --- | |
119 | ||
120 | fPedestalMode=kNone; | |
121 | } | |
122 | ||
123 | //_________________________________________________________________________ | |
124 | void AliMUONSt1ResponseParameter::SetNoise(Double_t val) | |
125 | { | |
126 | // Set Noise values to a constant value | |
127 | // --- | |
128 | ||
129 | fNoiseMode = kValue; | |
130 | fNoiseParam.value = val; | |
131 | } | |
132 | ||
133 | //_________________________________________________________________________ | |
134 | void AliMUONSt1ResponseParameter::SetNoise(Double_t mean,Double_t sigma) | |
135 | { | |
136 | // Set Noise values to a parameterized gaussian | |
137 | // --- | |
138 | ||
139 | fNoiseMode = kGauss; | |
140 | fNoiseParam.gauss.mean = mean; | |
141 | fNoiseParam.gauss.sigma = sigma; | |
142 | } | |
143 | ||
144 | //_________________________________________________________________________ | |
145 | void AliMUONSt1ResponseParameter::SetNoise(const TString& fileName) | |
146 | { | |
147 | // Set Noise values to those given in a file | |
148 | // --- | |
149 | ||
150 | ifstream file(fileName.Data()); | |
151 | if (file.good()){ | |
152 | fNoiseMode = kFile; | |
153 | for (Int_t ch=0;ch<fgkNofChannels;ch++) { | |
154 | Float_t value; | |
155 | file>>value; | |
156 | fNoiseParam.values[ch] = value; | |
157 | //cout<<"Noise["<<i<<"]["<<ch<<"]="<<value<<endl; | |
158 | } | |
159 | file.close(); | |
160 | } else { | |
161 | Warning("SetNoise",Form("Can't read file %s",fileName.Data())); | |
162 | SetNoise(150.,10.); | |
163 | } | |
164 | } | |
165 | ||
166 | //_________________________________________________________________________ | |
167 | void AliMUONSt1ResponseParameter::SetNofSigma(Int_t nofSigma) | |
168 | { | |
169 | // set Number of sigmas to be applied as threshold (for zero suppression) | |
170 | // --- | |
171 | ||
172 | fNofSigma = nofSigma; | |
173 | } | |
174 | ||
175 | //_________________________________________________________________________ | |
176 | void AliMUONSt1ResponseParameter::SetStickyBitOn (Int_t bit,Int_t val) | |
177 | { | |
178 | // In the response, this bit will always be set to 1 (unless <State> is off) | |
179 | // --- | |
180 | ||
181 | if (val) | |
182 | fStickyOn |= (1<<bit); | |
183 | else | |
184 | fStickyOn &= ~(1<<bit); | |
185 | } | |
186 | ||
187 | //_________________________________________________________________________ | |
188 | void AliMUONSt1ResponseParameter::SetStickyBitOff(Int_t bit,Int_t val) | |
189 | { | |
190 | // In the response, this bit will always be set to 0 | |
191 | // --- | |
192 | ||
193 | if (val) | |
194 | fStickyOff |= (1<<bit); | |
195 | else | |
196 | fStickyOff &= ~(1<<bit); | |
197 | } | |
198 | ||
199 | //_________________________________________________________________________ | |
200 | Int_t AliMUONSt1ResponseParameter::ApplyPedestal(Int_t base,Int_t GC) const | |
201 | { | |
202 | // calculate the response to <base>, with respect to the current pedestal | |
203 | // parameters | |
204 | // -- | |
205 | Double_t ped = Choose(fPedestalMode,fPedestalParam,GC); | |
206 | Double_t nse = Choose(fNoiseMode,fNoiseParam,GC); | |
207 | Double_t noise = gRandom->Gaus(0, nse); | |
208 | base+=(Int_t)(noise + ped); | |
209 | if (base-ped-noise*fNofSigma<0) base=0; | |
210 | ||
211 | return base; | |
212 | } | |
213 | //_________________________________________________________________________ | |
214 | Int_t AliMUONSt1ResponseParameter::ApplyStickyBits(Int_t base) const | |
215 | { | |
216 | // set the response to <base>, with respect to the current stickyBits | |
217 | // parameters | |
218 | // -- | |
219 | base |= fStickyOn; | |
220 | base &= (~fStickyOff); | |
221 | return base; | |
222 | } | |
223 | //////////////////// Privates methods | |
224 | //_________________________________________________________________________ | |
225 | ||
226 | Double_t AliMUONSt1ResponseParameter::Choose(TMode mode,TParam param,Int_t GC) const | |
227 | { | |
228 | // Choose a (pedestal/noise) value to be applied following the parameterization rule | |
229 | // --- | |
230 | ||
231 | switch (mode){ | |
232 | case kNone : return 0; | |
233 | case kValue : return param.value; | |
234 | case kGauss : return gRandom->Gaus(param.gauss.mean,param.gauss.sigma); | |
235 | case kFile : return param.values[GC]; | |
236 | } | |
237 | Fatal("Choose","No mode is given"); | |
238 | return 0; | |
239 | } |