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