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.
26 // Included in AliRoot 2003/01/28
33 #include "AliMUONSt1ResponseParameter.h"
35 ClassImp(AliMUONSt1ResponseParameter);
37 //_________________________________________________________________________
38 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter()
41 // default constructor
42 fPedestalMode = kNone;
46 fStickyOn=fStickyOff=0;
49 //_________________________________________________________________________
50 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter(const TString& name,const TString& title)
54 fPedestalMode = kNone;
58 fStickyOn=fStickyOff=0;
61 //_________________________________________________________________________
62 AliMUONSt1ResponseParameter::~AliMUONSt1ResponseParameter()
67 //_________________________________________________________________________
68 void AliMUONSt1ResponseParameter::SetState(Bool_t state)
70 // If set to off, no information will be available from the electronics
76 //_________________________________________________________________________
77 void AliMUONSt1ResponseParameter::SetPedestal(Double_t val)
79 // Set pedestal values to a constant
82 fPedestalMode = kValue;
83 fPedestalParam.value = val;
86 //_________________________________________________________________________
87 void AliMUONSt1ResponseParameter::SetPedestal(Double_t mean,Double_t sigma)
89 // Set pedestal values to a parameterized gaussian
92 fPedestalMode = kGauss;
93 fPedestalParam.gauss.mean = mean;
94 fPedestalParam.gauss.sigma = sigma;
96 //_________________________________________________________________________
97 void AliMUONSt1ResponseParameter::SetPedestal(const TString& fileName)
99 // Set pedestal values to those given in a file
102 ifstream file(fileName.Data());
104 fPedestalMode = kFile;
105 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
108 fPedestalParam.values[ch] = value;
109 //cout<<"Pedestal["<<i<<"]["<<ch<<"]="<<value<<endl;
113 Warning("SetPedestal",Form("Can't read file %s",fileName.Data()));
114 SetPedestal(150.,10.);
118 //_________________________________________________________________________
119 void AliMUONSt1ResponseParameter::UnSetPedestal()
121 // Set pedestal values to 0.
127 //_________________________________________________________________________
128 void AliMUONSt1ResponseParameter::SetNoise(Double_t val)
130 // Set Noise values to a constant value
134 fNoiseParam.value = val;
137 //_________________________________________________________________________
138 void AliMUONSt1ResponseParameter::SetNoise(Double_t mean,Double_t sigma)
140 // Set Noise values to a parameterized gaussian
144 fNoiseParam.gauss.mean = mean;
145 fNoiseParam.gauss.sigma = sigma;
148 //_________________________________________________________________________
149 void AliMUONSt1ResponseParameter::SetNoise(const TString& fileName)
151 // Set Noise values to those given in a file
154 ifstream file(fileName.Data());
157 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
160 fNoiseParam.values[ch] = value;
161 //cout<<"Noise["<<i<<"]["<<ch<<"]="<<value<<endl;
165 Warning("SetNoise",Form("Can't read file %s",fileName.Data()));
170 //_________________________________________________________________________
171 void AliMUONSt1ResponseParameter::SetNofSigma(Int_t nofSigma)
173 // set Number of sigmas to be applied as threshold (for zero suppression)
176 fNofSigma = nofSigma;
179 //_________________________________________________________________________
180 void AliMUONSt1ResponseParameter::SetStickyBitOn (Int_t bit,Int_t val)
182 // In the response, this bit will always be set to 1 (unless <State> is off)
186 fStickyOn |= (1<<bit);
188 fStickyOn &= ~(1<<bit);
191 //_________________________________________________________________________
192 void AliMUONSt1ResponseParameter::SetStickyBitOff(Int_t bit,Int_t val)
194 // In the response, this bit will always be set to 0
198 fStickyOff |= (1<<bit);
200 fStickyOff &= ~(1<<bit);
203 //_________________________________________________________________________
204 Int_t AliMUONSt1ResponseParameter::ApplyPedestal(Int_t base,Int_t GC) const
206 // calculate the response to <base>, with respect to the current pedestal
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;
217 //_________________________________________________________________________
218 Int_t AliMUONSt1ResponseParameter::ApplyStickyBits(Int_t base) const
220 // set the response to <base>, with respect to the current stickyBits
224 base &= (~fStickyOff);
227 //////////////////// Privates methods
228 //_________________________________________________________________________
230 Double_t AliMUONSt1ResponseParameter::Choose(TMode mode,TParam param,Int_t GC) const
232 // Choose a (pedestal/noise) value to be applied following the parameterization rule
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];
241 Fatal("Choose","No mode is given");