]>
Commit | Line | Data |
---|---|---|
348f80b7 | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, 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 | #include "AliITSOnlineSDDBTP.h" | |
16 | #include <TH2F.h> | |
348f80b7 | 17 | #include <TMath.h> |
18 | ||
19 | ||
20 | /////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // Class used for SDD baseline, noise and gain analysis // | |
23 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
24 | // // | |
25 | /////////////////////////////////////////////////////////////////// | |
26 | ||
27 | ||
28 | ClassImp(AliITSOnlineSDDBTP) | |
29 | //______________________________________________________________________ | |
30 | AliITSOnlineSDDBTP::AliITSOnlineSDDBTP():AliITSOnlineSDD(),fNBaseEvents(0),fNTPEvents(0),fMinBaseline(0.),fMaxBaseline(0.),fMinRawNoise(0.),fMaxRawNoise(0.),fNSigmaNoise(0.),fNSigmaGain(0.) | |
31 | { | |
32 | // default constructor | |
33 | Reset(); | |
34 | SetMinBaseline(); | |
35 | SetMaxBaseline(); | |
36 | SetMinRawNoise(); | |
37 | SetMaxRawNoise(); | |
38 | SetNSigmaNoise(); | |
39 | SetNSigmaGain(); | |
40 | } | |
41 | //______________________________________________________________________ | |
42 | AliITSOnlineSDDBTP::AliITSOnlineSDDBTP(Int_t mod, Int_t sid):AliITSOnlineSDD(mod,sid),fNBaseEvents(0),fNTPEvents(0),fMinBaseline(0.),fMaxBaseline(0.),fMinRawNoise(0.),fMaxRawNoise(0.),fNSigmaNoise(0.),fNSigmaGain(0.) | |
43 | { | |
44 | // default constructor | |
45 | Reset(); | |
46 | SetMinBaseline(); | |
47 | SetMaxBaseline(); | |
48 | SetMinRawNoise(); | |
49 | SetMaxRawNoise(); | |
50 | SetNSigmaNoise(); | |
51 | SetNSigmaGain(); | |
52 | } | |
53 | //______________________________________________________________________ | |
54 | AliITSOnlineSDDBTP::~AliITSOnlineSDDBTP(){ | |
55 | // Destructor | |
56 | } | |
57 | //______________________________________________________________________ | |
58 | void AliITSOnlineSDDBTP::Reset(){ | |
beb262b4 | 59 | // |
348f80b7 | 60 | fNBaseEvents=0; |
61 | fNTPEvents=0; | |
62 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
63 | fGoodAnode[i]=1; | |
64 | fSumBaseline[i]=0.; | |
65 | fSumRawNoise[i]=0.; | |
66 | fSumCMN[i]=0.; | |
67 | fSumTPPeak[i]=0.; | |
68 | fTPPos[i]=0.; | |
69 | } | |
70 | } | |
71 | //______________________________________________________________________ | |
72 | void AliITSOnlineSDDBTP::ValidateAnodes(){ | |
beb262b4 | 73 | // |
348f80b7 | 74 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
75 | fGoodAnode[ian]=1; | |
76 | if(GetAnodeBaseline(ian)>fMaxBaseline || GetAnodeBaseline(ian)<fMinBaseline) fGoodAnode[ian]=0; | |
77 | if(GetAnodeRawNoise(ian)>fMaxRawNoise || GetAnodeRawNoise(ian)<fMinRawNoise) fGoodAnode[ian]=0; | |
78 | if(GetAnodeRawNoise(ian)>fNSigmaNoise*CalcMeanRawNoise()) fGoodAnode[ian]=0; | |
79 | } | |
80 | if(fNTPEvents>0){ | |
81 | Float_t meang,rmsg; | |
82 | StatGain(meang,rmsg); | |
83 | Float_t lowlim=meang-fNSigmaGain*rmsg; | |
84 | Float_t hilim=meang+fNSigmaGain*rmsg; | |
85 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
86 | if(!fGoodAnode[ian]) continue; | |
87 | if(GetChannelGain(ian)<lowlim||GetChannelGain(ian)>hilim) fGoodAnode[ian]=0; | |
88 | } | |
89 | } | |
90 | } | |
91 | ||
92 | //______________________________________________________________________ | |
93 | void AliITSOnlineSDDBTP::AddTPEvent(TH2F* hrawd, Float_t xDAC){ | |
94 | // | |
95 | if(fNBaseEvents==0) return; | |
96 | fNTPEvents++; | |
97 | Float_t tbmax=(Float_t)hrawd->GetNbinsX(); | |
98 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
99 | Float_t auxmax=0.; | |
100 | Int_t auxtb=0; | |
101 | if(!fGoodAnode[ian]) continue; | |
102 | for(Int_t itb=0;itb<tbmax;itb++){ | |
103 | Float_t cnt=hrawd->GetBinContent(itb+1,ian+1); | |
104 | if(cnt>auxmax){ | |
105 | auxmax=cnt; | |
106 | auxtb=itb; | |
107 | } | |
108 | } | |
109 | fSumTPPeak[ian]+=(auxmax-GetAnodeBaseline(ian))/xDAC; | |
110 | fTPPos[ian]+=auxtb; | |
111 | } | |
112 | } | |
113 | //______________________________________________________________________ | |
114 | void AliITSOnlineSDDBTP::AddBaseEvent(TH2F* hrawd){ | |
115 | // | |
116 | fNBaseEvents++; | |
117 | Float_t tbmax=(Float_t)hrawd->GetNbinsX(); | |
118 | Float_t sum[fgkNAnodes]; | |
119 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
120 | Float_t sumQ=0.; | |
121 | sum[ian]=0.; | |
122 | for(Int_t itb=0;itb<tbmax;itb++){ | |
123 | sum[ian]+=hrawd->GetBinContent(itb+1,ian+1); | |
124 | sumQ+=TMath::Power(hrawd->GetBinContent(itb+1,ian+1),2); | |
125 | } | |
126 | sum[ian]/=tbmax; | |
127 | sumQ/=tbmax; | |
128 | fSumBaseline[ian]+=sum[ian]; | |
129 | fSumRawNoise[ian]+=sumQ; | |
130 | if(fNBaseEvents==1) ValidateAnodes(); | |
131 | } | |
132 | ||
133 | ||
beb262b4 | 134 | const Int_t kTbmax=int(tbmax); |
135 | Float_t *cmnEven = new Float_t[kTbmax]; | |
136 | Float_t *cmnOdd = new Float_t[kTbmax]; | |
348f80b7 | 137 | for(Int_t itb=0;itb<tbmax;itb++){ |
138 | Float_t sumEven=0., sumOdd=0.; | |
139 | Int_t countEven=0,countOdd=0; | |
140 | for(Int_t ian=0;ian<fgkNAnodes;ian+=2){ | |
141 | if(!fGoodAnode[ian]) continue; | |
142 | sumEven+=hrawd->GetBinContent(itb+1,ian+1)-sum[ian]; | |
143 | countEven++; | |
144 | } | |
145 | for(Int_t ian=1;ian<fgkNAnodes;ian+=2){ | |
146 | if(!fGoodAnode[ian]) continue; | |
147 | sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-sum[ian]; | |
148 | countOdd++; | |
149 | } | |
150 | cmnEven[itb]=sumEven/countEven; | |
151 | cmnOdd[itb]=sumOdd/countOdd; | |
152 | } | |
153 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
154 | Float_t num=0.,den=0.; | |
155 | if(!fGoodAnode[ian]) continue; | |
156 | for(Int_t itb=0;itb<tbmax;itb++){ | |
157 | Float_t cmnCoef=cmnOdd[itb]; | |
158 | if(ian%2==0) cmnCoef=cmnEven[itb]; | |
159 | num+=(hrawd->GetBinContent(itb+1,ian+1)-sum[ian])*cmnCoef; | |
160 | den+=TMath::Power(cmnCoef,2); | |
161 | } | |
162 | if(den!=0) fSumCMN[ian]+=num/den; | |
163 | } | |
164 | delete [] cmnEven; | |
165 | delete [] cmnOdd; | |
166 | } | |
167 | //______________________________________________________________________ | |
beb262b4 | 168 | Float_t AliITSOnlineSDDBTP::CalcMeanRawNoise() const{ |
348f80b7 | 169 | // |
170 | Float_t meanns=0.; | |
171 | Int_t cnt=0; | |
172 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
173 | if(!fGoodAnode[ian]) continue; | |
174 | meanns+=GetAnodeRawNoise(ian); | |
175 | cnt++; | |
176 | } | |
177 | if(cnt>0) meanns/=(Float_t)cnt; | |
178 | return meanns; | |
179 | } | |
180 | //______________________________________________________________________ | |
181 | void AliITSOnlineSDDBTP::StatGain(Float_t &mean, Float_t &rms){ | |
beb262b4 | 182 | // |
348f80b7 | 183 | Float_t sum=0.,sumq=0.; |
184 | Int_t cnt=0; | |
185 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
186 | if(!fGoodAnode[ian]) continue; | |
187 | sum+=GetChannelGain(ian); | |
188 | sumq+=TMath::Power(GetChannelGain(ian),2); | |
189 | cnt++; | |
190 | } | |
191 | if(cnt>0){ | |
192 | mean=sum/(Float_t)cnt; | |
193 | rms=TMath::Sqrt(sumq/(Float_t)cnt-mean*mean); | |
194 | }else{ | |
195 | mean=0.; | |
196 | rms=0.; | |
197 | } | |
198 | return; | |
199 | } | |
200 | //______________________________________________________________________ | |
e44f571c | 201 | void AliITSOnlineSDDBTP::WriteToASCII(){ |
348f80b7 | 202 | // |
203 | Char_t outfilnam[100]; | |
204 | sprintf(outfilnam,"SDDbase_mod%03d_sid%d.data",fModuleId,fSide); | |
205 | FILE* outf=fopen(outfilnam,"w"); | |
206 | Float_t corrnoise=2.; | |
207 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
208 | fprintf(outf,"%d %d %8.3f %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),corrnoise,GetChannelGain(ian)); | |
209 | } | |
210 | fclose(outf); | |
211 | } |