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