]>
Commit | Line | Data |
---|---|---|
7f347565 | 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 | **************************************************************************/ | |
e44f571c | 15 | #include <TFile.h> |
7f347565 | 16 | #include "AliITSOnlineSDDCMN.h" |
17 | #include "AliLog.h" | |
18 | #include <TH2F.h> | |
19 | #include <TMath.h> | |
20 | ||
21 | ||
22 | /////////////////////////////////////////////////////////////////// | |
23 | // // | |
24 | // Implementation of the class used for analysis of SDD noise // | |
25 | // corrected for common mode // | |
26 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
27 | // // | |
28 | /////////////////////////////////////////////////////////////////// | |
29 | ||
30 | ||
31 | ClassImp(AliITSOnlineSDDCMN) | |
32 | //______________________________________________________________________ | |
33 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN():AliITSOnlineSDD(),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
34 | { | |
35 | // default constructor | |
36 | Reset(); | |
37 | SetMinNoise(); | |
38 | SetMaxNoise(); | |
39 | SetNSigmaNoise(); | |
40 | } | |
41 | //______________________________________________________________________ | |
42 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN(Int_t mod, Int_t sid):AliITSOnlineSDD(mod,sid),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
43 | { | |
44 | // default constructor | |
45 | Reset(); | |
46 | SetMinNoise(); | |
47 | SetMaxNoise(); | |
48 | SetNSigmaNoise(); | |
49 | } | |
50 | //______________________________________________________________________ | |
51 | AliITSOnlineSDDCMN::~AliITSOnlineSDDCMN(){ | |
52 | // Destructor | |
53 | } | |
54 | //______________________________________________________________________ | |
55 | void AliITSOnlineSDDCMN::Reset(){ | |
beb262b4 | 56 | // |
7f347565 | 57 | fNEvents=0; |
58 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
59 | fGoodAnode[i]=1; | |
60 | fBaseline[i]=0.; | |
3083967f | 61 | fRawNoise[i]=0.; |
7f347565 | 62 | fCMN[i]=0.; |
63 | fSumCorrNoise[i]=0.; | |
64 | } | |
65 | ReadBaselines(); | |
66 | } | |
67 | //______________________________________________________________________ | |
68 | void AliITSOnlineSDDCMN::ReadBaselines(){ | |
69 | // assume baselines and good anodes are taken from previous run | |
70 | Char_t basfilnam[100]; | |
71 | sprintf(basfilnam,"SDDbase_step1_mod%03d_sid%d.data",fModuleId,fSide); | |
72 | FILE* basf=fopen(basfilnam,"r"); | |
73 | if(basf==0){ | |
74 | AliWarning("Baselinefile not present, Set all baselines to 50\n"); | |
75 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
76 | fBaseline[ian]=50.; | |
d8303ac8 | 77 | fEqBaseline[ian]=50; |
78 | fOffsetBaseline[ian]=0; | |
7f347565 | 79 | fGoodAnode[ian]=1; |
80 | } | |
81 | return; | |
82 | } | |
d8303ac8 | 83 | Int_t n,ok,eqbase,offbase; |
7f347565 | 84 | Float_t base,rms,cmn,corrnoi; |
85 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
d8303ac8 | 86 | fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi); |
7f347565 | 87 | fGoodAnode[ian]=ok; |
88 | fBaseline[ian]=base; | |
d8303ac8 | 89 | fEqBaseline[ian]=eqbase; |
90 | fOffsetBaseline[ian]=offbase; | |
7f347565 | 91 | fRawNoise[ian]=rms; |
92 | fCMN[ian]=cmn; | |
93 | } | |
94 | fclose(basf); | |
95 | } | |
96 | //______________________________________________________________________ | |
97 | void AliITSOnlineSDDCMN::ValidateAnodes(){ | |
beb262b4 | 98 | // |
7f347565 | 99 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
100 | if(!fGoodAnode[ian]) continue; | |
101 | if(GetAnodeCorrNoise(ian)>fMaxCorrNoise || GetAnodeCorrNoise(ian)<fMinCorrNoise) fGoodAnode[ian]=0; | |
102 | if(GetAnodeCorrNoise(ian)>fNSigmaNoise*CalcMeanNoise()) fGoodAnode[ian]=0; | |
103 | } | |
104 | } | |
105 | ||
106 | //______________________________________________________________________ | |
107 | void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){ | |
108 | // | |
109 | fNEvents++; | |
4ff6aa93 | 110 | const Int_t kTimeBins=fLastGoodTB-fFirstGoodTB+1; |
7f347565 | 111 | TH2F* hcorrd=new TH2F("hcorrd","",hrawd->GetNbinsX(),hrawd->GetXaxis()->GetXmin(),hrawd->GetXaxis()->GetXmax(),hrawd->GetNbinsY(),hrawd->GetYaxis()->GetXmin(),hrawd->GetYaxis()->GetXmax()); |
750296dd | 112 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
7f347565 | 113 | Float_t sumEven=0., sumOdd=0.; |
114 | Int_t countEven=0, countOdd=0; | |
115 | for(Int_t ian=0;ian<fgkNAnodes;ian+=2){ | |
116 | if(!fGoodAnode[ian]) continue; | |
117 | sumEven+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
118 | countEven++; | |
119 | } | |
120 | for(Int_t ian=1;ian<fgkNAnodes;ian+=2){ | |
121 | if(!fGoodAnode[ian]) continue; | |
122 | sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
123 | countOdd++; | |
124 | } | |
125 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
126 | if(!fGoodAnode[ian]) continue; | |
127 | Float_t meanN; | |
128 | if(ian%2==0) meanN=sumEven/(Float_t)countEven; | |
129 | else meanN=sumOdd/(Float_t)countOdd; | |
130 | Float_t cntCorr=hrawd->GetBinContent(itb+1,ian+1)-fCMN[ian]*meanN; | |
131 | hcorrd->SetBinContent(itb+1,ian+1,cntCorr); | |
132 | } | |
133 | } | |
134 | ||
135 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
136 | if(!fGoodAnode[ian]) continue; | |
137 | Float_t sumQ=0.; | |
750296dd | 138 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
7f347565 | 139 | sumQ+=TMath::Power(hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian],2); |
140 | } | |
4ff6aa93 | 141 | fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/(Float_t)kTimeBins); |
7f347565 | 142 | } |
143 | delete hcorrd; | |
144 | } | |
145 | //______________________________________________________________________ | |
beb262b4 | 146 | Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{ |
7f347565 | 147 | // |
148 | Float_t meanns=0.; | |
149 | Int_t cnt=0; | |
150 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
151 | if(!fGoodAnode[ian]) continue; | |
152 | meanns+=GetAnodeCorrNoise(ian); | |
153 | cnt++; | |
154 | } | |
155 | if(cnt>0) meanns/=(Float_t)cnt; | |
156 | return meanns; | |
157 | } | |
158 | //______________________________________________________________________ | |
e44f571c | 159 | void AliITSOnlineSDDCMN::WriteToASCII(){ |
7f347565 | 160 | // |
161 | Char_t outfilnam[100]; | |
162 | sprintf(outfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide); | |
163 | FILE* outf=fopen(outfilnam,"w"); | |
164 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
d8303ac8 | 165 | fprintf(outf,"%d %d %8.3f %d %d %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeEqualizedBaseline(ian),GetAnodeBaselineOffset(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian)); |
7f347565 | 166 | } |
167 | fclose(outf); | |
168 | } | |
4ff6aa93 | 169 | |
170 | //______________________________________________________________________ | |
171 | TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const { | |
172 | // | |
173 | Char_t hisnam[20]; | |
174 | sprintf(hisnam,"hb%03ds%d",fModuleId,fSide); | |
175 | TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5); | |
176 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
177 | h->SetBinContent(ian+1,GetAnodeBaseline(ian)); | |
178 | } | |
179 | return h; | |
180 | } | |
181 | //______________________________________________________________________ | |
182 | TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const { | |
183 | // | |
184 | Char_t hisnam[20]; | |
185 | sprintf(hisnam,"hn%03ds%d",fModuleId,fSide); | |
186 | TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5); | |
187 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
188 | h->SetBinContent(ian+1,GetAnodeRawNoise(ian)); | |
189 | } | |
190 | return h; | |
191 | } | |
192 | //______________________________________________________________________ | |
193 | TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const { | |
194 | // | |
195 | Char_t hisnam[20]; | |
196 | sprintf(hisnam,"hc%03ds%d",fModuleId,fSide); | |
197 | TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5); | |
198 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
199 | h->SetBinContent(ian+1,GetAnodeCorrNoise(ian)); | |
200 | } | |
201 | return h; | |
202 | } | |
203 | //______________________________________________________________________ | |
204 | TH1F* AliITSOnlineSDDCMN::GetBaselineHisto() const { | |
205 | // | |
206 | Char_t hisnam[20]; | |
207 | sprintf(hisnam,"hdb%03ds%d",fModuleId,fSide); | |
208 | TH1F* h=new TH1F(hisnam,"",100,0.,150.); | |
209 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
210 | h->Fill(GetAnodeBaseline(ian)); | |
211 | } | |
212 | return h; | |
213 | } | |
214 | //______________________________________________________________________ | |
215 | TH1F* AliITSOnlineSDDCMN::GetRawNoiseHisto() const { | |
216 | // | |
217 | Char_t hisnam[20]; | |
218 | sprintf(hisnam,"hdn%03ds%d",fModuleId,fSide); | |
219 | TH1F* h=new TH1F(hisnam,"",100,0.,8.); | |
220 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
221 | h->Fill(GetAnodeRawNoise(ian)); | |
222 | } | |
223 | return h; | |
224 | } | |
225 | //______________________________________________________________________ | |
226 | TH1F* AliITSOnlineSDDCMN::GetCorrNoiseHisto() const { | |
227 | // | |
228 | Char_t hisnam[20]; | |
229 | sprintf(hisnam,"hdc%03ds%d",fModuleId,fSide); | |
230 | TH1F* h=new TH1F(hisnam,"",100,0.,8.); | |
231 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
232 | h->Fill(GetAnodeCorrNoise(ian)); | |
233 | } | |
234 | return h; | |
235 | } | |
e44f571c | 236 | //______________________________________________________________________ |
237 | Bool_t AliITSOnlineSDDCMN::WriteToROOT(TFile *fil){ | |
3083967f | 238 | // |
e44f571c | 239 | if(fil==0){ |
240 | AliWarning("Invalid pointer to ROOT file"); | |
241 | return kFALSE; | |
242 | } | |
243 | Char_t hisnam[20]; | |
244 | fil->cd(); | |
245 | sprintf(hisnam,"hgood%03ds%d",fModuleId,fSide); | |
246 | TH1F hgood(hisnam,"",256,-0.5,255.5); | |
247 | sprintf(hisnam,"hbase%03ds%d",fModuleId,fSide); | |
248 | TH1F hbase(hisnam,"",256,-0.5,255.5); | |
249 | sprintf(hisnam,"hnois%03ds%d",fModuleId,fSide); | |
250 | TH1F hnois(hisnam,"",256,-0.5,255.5); | |
251 | sprintf(hisnam,"hcmn%03ds%d",fModuleId,fSide); | |
252 | TH1F hcmn(hisnam,"",256,-0.5,255.5); | |
253 | sprintf(hisnam,"hcorn%03ds%d",fModuleId,fSide); | |
254 | TH1F hcorn(hisnam,"",256,-0.5,255.5); | |
255 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
256 | hgood.SetBinContent(ian+1,float(IsAnodeGood(ian))); | |
257 | hbase.SetBinContent(ian+1,GetAnodeBaseline(ian)); | |
258 | hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian)); | |
259 | hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian)); | |
260 | hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian)); | |
261 | } | |
262 | hgood.Write(); | |
263 | hbase.Write(); | |
264 | hnois.Write(); | |
265 | hcmn.Write(); | |
266 | hcorn.Write(); | |
267 | return kTRUE; | |
268 | } |