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