1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
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.
29 #include "AliMUONSt1ResponseParameter.h"
31 ClassImp(AliMUONSt1ResponseParameter);
33 //_________________________________________________________________________
34 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter()
37 // default constructor
38 fPedestalMode = kNone;
42 fStickyOn=fStickyOff=0;
45 //_________________________________________________________________________
46 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter(const TString& name,const TString& title)
50 fPedestalMode = kNone;
54 fStickyOn=fStickyOff=0;
57 //_________________________________________________________________________
58 AliMUONSt1ResponseParameter::~AliMUONSt1ResponseParameter()
63 //_________________________________________________________________________
64 void AliMUONSt1ResponseParameter::SetState(Bool_t state)
66 // If set to off, no information will be available from the electronics
72 //_________________________________________________________________________
73 void AliMUONSt1ResponseParameter::SetPedestal(Double_t val)
75 // Set pedestal values to a constant
78 fPedestalMode = kValue;
79 fPedestalParam.value = val;
82 //_________________________________________________________________________
83 void AliMUONSt1ResponseParameter::SetPedestal(Double_t mean,Double_t sigma)
85 // Set pedestal values to a parameterized gaussian
88 fPedestalMode = kGauss;
89 fPedestalParam.gauss.mean = mean;
90 fPedestalParam.gauss.sigma = sigma;
92 //_________________________________________________________________________
93 void AliMUONSt1ResponseParameter::SetPedestal(const TString& fileName)
95 // Set pedestal values to those given in a file
98 ifstream file(fileName.Data());
100 fPedestalMode = kFile;
101 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
104 fPedestalParam.values[ch] = value;
105 //cout<<"Pedestal["<<i<<"]["<<ch<<"]="<<value<<endl;
109 Warning("SetPedestal",Form("Can't read file %s",fileName.Data()));
110 SetPedestal(150.,10.);
114 //_________________________________________________________________________
115 void AliMUONSt1ResponseParameter::UnSetPedestal()
117 // Set pedestal values to 0.
123 //_________________________________________________________________________
124 void AliMUONSt1ResponseParameter::SetNoise(Double_t val)
126 // Set Noise values to a constant value
130 fNoiseParam.value = val;
133 //_________________________________________________________________________
134 void AliMUONSt1ResponseParameter::SetNoise(Double_t mean,Double_t sigma)
136 // Set Noise values to a parameterized gaussian
140 fNoiseParam.gauss.mean = mean;
141 fNoiseParam.gauss.sigma = sigma;
144 //_________________________________________________________________________
145 void AliMUONSt1ResponseParameter::SetNoise(const TString& fileName)
147 // Set Noise values to those given in a file
150 ifstream file(fileName.Data());
153 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
156 fNoiseParam.values[ch] = value;
157 //cout<<"Noise["<<i<<"]["<<ch<<"]="<<value<<endl;
161 Warning("SetNoise",Form("Can't read file %s",fileName.Data()));
166 //_________________________________________________________________________
167 void AliMUONSt1ResponseParameter::SetNofSigma(Int_t nofSigma)
169 // set Number of sigmas to be applied as threshold (for zero suppression)
172 fNofSigma = nofSigma;
175 //_________________________________________________________________________
176 void AliMUONSt1ResponseParameter::SetStickyBitOn (Int_t bit,Int_t val)
178 // In the response, this bit will always be set to 1 (unless <State> is off)
182 fStickyOn |= (1<<bit);
184 fStickyOn &= ~(1<<bit);
187 //_________________________________________________________________________
188 void AliMUONSt1ResponseParameter::SetStickyBitOff(Int_t bit,Int_t val)
190 // In the response, this bit will always be set to 0
194 fStickyOff |= (1<<bit);
196 fStickyOff &= ~(1<<bit);
199 //_________________________________________________________________________
200 Int_t AliMUONSt1ResponseParameter::ApplyPedestal(Int_t base,Int_t GC) const
202 // calculate the response to <base>, with respect to the current pedestal
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;
213 //_________________________________________________________________________
214 Int_t AliMUONSt1ResponseParameter::ApplyStickyBits(Int_t base) const
216 // set the response to <base>, with respect to the current stickyBits
220 base &= (~fStickyOff);
223 //////////////////// Privates methods
224 //_________________________________________________________________________
226 Double_t AliMUONSt1ResponseParameter::Choose(TMode mode,TParam param,Int_t GC) const
228 // Choose a (pedestal/noise) value to be applied following the parameterization rule
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];
237 Fatal("Choose","No mode is given");