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.
32 #include "AliMUONSt1ResponseParameter.h"
34 ClassImp(AliMUONSt1ResponseParameter);
36 //_________________________________________________________________________
37 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter()
40 // default constructor
41 fPedestalMode = kNone;
45 fStickyOn=fStickyOff=0;
48 //_________________________________________________________________________
49 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter(const TString& name,const TString& title)
53 fPedestalMode = kNone;
57 fStickyOn=fStickyOff=0;
60 //_________________________________________________________________________
61 AliMUONSt1ResponseParameter::~AliMUONSt1ResponseParameter()
66 //_________________________________________________________________________
67 void AliMUONSt1ResponseParameter::SetState(Bool_t state)
69 // If set to off, no information will be available from the electronics
75 //_________________________________________________________________________
76 void AliMUONSt1ResponseParameter::SetPedestal(Double_t val)
78 // Set pedestal values to a constant
81 fPedestalMode = kValue;
82 fPedestalParam.value = val;
85 //_________________________________________________________________________
86 void AliMUONSt1ResponseParameter::SetPedestal(Double_t mean,Double_t sigma)
88 // Set pedestal values to a parameterized gaussian
91 fPedestalMode = kGauss;
92 fPedestalParam.gauss.mean = mean;
93 fPedestalParam.gauss.sigma = sigma;
95 //_________________________________________________________________________
96 void AliMUONSt1ResponseParameter::SetPedestal(const TString& fileName)
98 // Set pedestal values to those given in a file
101 ifstream file(fileName.Data());
103 fPedestalMode = kFile;
104 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
107 fPedestalParam.values[ch] = value;
108 //cout<<"Pedestal["<<i<<"]["<<ch<<"]="<<value<<endl;
112 Warning("SetPedestal",Form("Can't read file %s",fileName.Data()));
113 SetPedestal(150.,10.);
117 //_________________________________________________________________________
118 void AliMUONSt1ResponseParameter::UnSetPedestal()
120 // Set pedestal values to 0.
126 //_________________________________________________________________________
127 void AliMUONSt1ResponseParameter::SetNoise(Double_t val)
129 // Set Noise values to a constant value
133 fNoiseParam.value = val;
136 //_________________________________________________________________________
137 void AliMUONSt1ResponseParameter::SetNoise(Double_t mean,Double_t sigma)
139 // Set Noise values to a parameterized gaussian
143 fNoiseParam.gauss.mean = mean;
144 fNoiseParam.gauss.sigma = sigma;
147 //_________________________________________________________________________
148 void AliMUONSt1ResponseParameter::SetNoise(const TString& fileName)
150 // Set Noise values to those given in a file
153 ifstream file(fileName.Data());
156 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
159 fNoiseParam.values[ch] = value;
160 //cout<<"Noise["<<i<<"]["<<ch<<"]="<<value<<endl;
164 Warning("SetNoise",Form("Can't read file %s",fileName.Data()));
169 //_________________________________________________________________________
170 void AliMUONSt1ResponseParameter::SetNofSigma(Int_t nofSigma)
172 // set Number of sigmas to be applied as threshold (for zero suppression)
175 fNofSigma = nofSigma;
178 //_________________________________________________________________________
179 void AliMUONSt1ResponseParameter::SetStickyBitOn (Int_t bit,Int_t val)
181 // In the response, this bit will always be set to 1 (unless <State> is off)
185 fStickyOn |= (1<<bit);
187 fStickyOn &= ~(1<<bit);
190 //_________________________________________________________________________
191 void AliMUONSt1ResponseParameter::SetStickyBitOff(Int_t bit,Int_t val)
193 // In the response, this bit will always be set to 0
197 fStickyOff |= (1<<bit);
199 fStickyOff &= ~(1<<bit);
202 //_________________________________________________________________________
203 Int_t AliMUONSt1ResponseParameter::ApplyPedestal(Int_t base,Int_t GC) const
205 // calculate the response to <base>, with respect to the current pedestal
208 Double_t ped = Choose(fPedestalMode,fPedestalParam,GC);
209 Double_t nse = Choose(fNoiseMode,fNoiseParam,GC);
210 Double_t noise = gRandom->Gaus(0, nse);
211 base+=(Int_t)(noise + ped);
212 if (base-ped-noise*fNofSigma<0) base=0;
216 //_________________________________________________________________________
217 Int_t AliMUONSt1ResponseParameter::ApplyStickyBits(Int_t base) const
219 // set the response to <base>, with respect to the current stickyBits
223 base &= (~fStickyOff);
226 //////////////////// Privates methods
227 //_________________________________________________________________________
229 Double_t AliMUONSt1ResponseParameter::Choose(TMode mode,TParam param,Int_t GC) const
231 // Choose a (pedestal/noise) value to be applied following the parameterization rule
235 case kNone : return 0;
236 case kValue : return param.value;
237 case kGauss : return gRandom->Gaus(param.gauss.mean,param.gauss.sigma);
238 case kFile : return param.values[GC];
240 Fatal("Choose","No mode is given");