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"
36 ClassImp(AliMUONSt1ResponseParameter)
38 //_________________________________________________________________________
39 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter()
42 // default constructor
43 fPedestalMode = kNone;
47 fStickyOn=fStickyOff=0;
50 //_________________________________________________________________________
51 AliMUONSt1ResponseParameter::AliMUONSt1ResponseParameter(const TString& name,const TString& title)
55 fPedestalMode = kNone;
59 fStickyOn=fStickyOff=0;
62 //_________________________________________________________________________
63 AliMUONSt1ResponseParameter::~AliMUONSt1ResponseParameter()
68 //_________________________________________________________________________
69 void AliMUONSt1ResponseParameter::SetState(Bool_t state)
71 // If set to off, no information will be available from the electronics
77 //_________________________________________________________________________
78 void AliMUONSt1ResponseParameter::SetPedestal(Double_t val)
80 // Set pedestal values to a constant
83 fPedestalMode = kValue;
84 fPedestalParam.value = val;
87 //_________________________________________________________________________
88 void AliMUONSt1ResponseParameter::SetPedestal(Double_t mean,Double_t sigma)
90 // Set pedestal values to a parameterized gaussian
93 fPedestalMode = kGauss;
94 fPedestalParam.gauss.mean = mean;
95 fPedestalParam.gauss.sigma = sigma;
97 //_________________________________________________________________________
98 void AliMUONSt1ResponseParameter::SetPedestal(const TString& fileName)
100 // Set pedestal values to those given in a file
103 ifstream file(fileName.Data());
105 fPedestalMode = kFile;
106 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
109 fPedestalParam.values[ch] = value;
110 //cout<<"Pedestal["<<i<<"]["<<ch<<"]="<<value<<endl;
114 AliWarning(Form("Can't read file %s",fileName.Data()));
115 SetPedestal(150.,10.);
119 //_________________________________________________________________________
120 void AliMUONSt1ResponseParameter::UnSetPedestal()
122 // Set pedestal values to 0.
128 //_________________________________________________________________________
129 void AliMUONSt1ResponseParameter::SetNoise(Double_t val)
131 // Set Noise values to a constant value
135 fNoiseParam.value = val;
138 //_________________________________________________________________________
139 void AliMUONSt1ResponseParameter::SetNoise(Double_t mean,Double_t sigma)
141 // Set Noise values to a parameterized gaussian
145 fNoiseParam.gauss.mean = mean;
146 fNoiseParam.gauss.sigma = sigma;
149 //_________________________________________________________________________
150 void AliMUONSt1ResponseParameter::SetNoise(const TString& fileName)
152 // Set Noise values to those given in a file
155 ifstream file(fileName.Data());
158 for (Int_t ch=0;ch<fgkNofChannels;ch++) {
161 fNoiseParam.values[ch] = value;
162 //cout<<"Noise["<<i<<"]["<<ch<<"]="<<value<<endl;
166 AliWarning(Form("Can't read file %s",fileName.Data()));
171 //_________________________________________________________________________
172 void AliMUONSt1ResponseParameter::SetNofSigma(Int_t nofSigma)
174 // set Number of sigmas to be applied as threshold (for zero suppression)
177 fNofSigma = nofSigma;
180 //_________________________________________________________________________
181 void AliMUONSt1ResponseParameter::SetStickyBitOn (Int_t bit,Int_t val)
183 // In the response, this bit will always be set to 1 (unless <State> is off)
187 fStickyOn |= (1<<bit);
189 fStickyOn &= ~(1<<bit);
192 //_________________________________________________________________________
193 void AliMUONSt1ResponseParameter::SetStickyBitOff(Int_t bit,Int_t val)
195 // In the response, this bit will always be set to 0
199 fStickyOff |= (1<<bit);
201 fStickyOff &= ~(1<<bit);
204 //_________________________________________________________________________
205 Int_t AliMUONSt1ResponseParameter::ApplyPedestal(Int_t base,Int_t GC) const
207 // calculate the response to <base>, with respect to the current pedestal
210 Double_t ped = Choose(fPedestalMode,fPedestalParam,GC);
211 Double_t nse = Choose(fNoiseMode,fNoiseParam,GC);
212 Double_t noise = gRandom->Gaus(0, nse);
213 base+=(Int_t)(noise + ped);
214 if (base-ped-noise*fNofSigma<0) base=0;
218 //_________________________________________________________________________
219 Int_t AliMUONSt1ResponseParameter::ApplyStickyBits(Int_t base) const
221 // set the response to <base>, with respect to the current stickyBits
225 base &= (~fStickyOff);
228 //////////////////// Privates methods
229 //_________________________________________________________________________
231 Double_t AliMUONSt1ResponseParameter::Choose(TMode mode,TParam param,Int_t GC) const
233 // Choose a (pedestal/noise) value to be applied following the parameterization rule
237 case kNone : return 0;
238 case kValue : return param.value;
239 case kGauss : return gRandom->Gaus(param.gauss.mean,param.gauss.sigma);
240 case kFile : return param.values[GC];
242 AliFatal("No mode is given");