]>
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 | **************************************************************************/ | |
3083967f | 15 | #include <TFile.h> |
348f80b7 | 16 | #include "AliITSOnlineSDDTP.h" |
7f347565 | 17 | #include "AliLog.h" |
348f80b7 | 18 | #include <TH2F.h> |
19 | #include <TMath.h> | |
20 | ||
21 | ||
22 | /////////////////////////////////////////////////////////////////// | |
23 | // // | |
24 | // Implemetation of the class SDD Test Pulse analysis // | |
25 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
26 | // // | |
27 | /////////////////////////////////////////////////////////////////// | |
28 | ||
29 | ||
30 | ClassImp(AliITSOnlineSDDTP) | |
31 | ||
32 | //______________________________________________________________________ | |
e7610d19 | 33 | AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fDAC(0.),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.) |
348f80b7 | 34 | { |
35 | // default constructor | |
36 | Reset(); | |
37 | SetNSigmaGain(); | |
750296dd | 38 | SetNSigmaNoise(); |
348f80b7 | 39 | } |
40 | //______________________________________________________________________ | |
e7610d19 | 41 | AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t nddl, Int_t ncarlos, Int_t sid, Float_t xDAC):AliITSOnlineSDD(nddl,ncarlos,sid),fDAC(xDAC),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.) |
348f80b7 | 42 | { |
43 | // standard constructor | |
44 | Reset(); | |
45 | SetNSigmaGain(); | |
750296dd | 46 | SetNSigmaNoise(); |
348f80b7 | 47 | } |
48 | //______________________________________________________________________ | |
49 | AliITSOnlineSDDTP::~AliITSOnlineSDDTP(){ | |
50 | // Destructor | |
51 | } | |
52 | //______________________________________________________________________ | |
53 | void AliITSOnlineSDDTP::Reset(){ | |
776c19a3 | 54 | // reset all counters |
348f80b7 | 55 | for(Int_t i=0;i<fgkNAnodes;i++){ |
750296dd | 56 | fNEvents[i]=0; |
348f80b7 | 57 | fGoodAnode[i]=1; |
58 | fBaseline[i]=0.; | |
3083967f | 59 | fCMN[i]=0.; |
60 | fRawNoise[i]=0.; | |
61 | fCorrNoise[i]=0.; | |
348f80b7 | 62 | fSumTPPeak[i]=0.; |
63 | fTPPos[i]=0.; | |
64 | } | |
65 | ReadBaselines(); | |
66 | } | |
67 | ||
68 | //______________________________________________________________________ | |
69 | void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){ | |
776c19a3 | 70 | // analyzes current event and sum its contribution to the various counters |
348f80b7 | 71 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
72 | Float_t auxmax=0.; | |
73 | Int_t auxtb=0; | |
74 | if(!fGoodAnode[ian]) continue; | |
750296dd | 75 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
348f80b7 | 76 | Float_t cnt=hrawd->GetBinContent(itb+1,ian+1); |
77 | if(cnt>auxmax){ | |
78 | auxmax=cnt; | |
79 | auxtb=itb; | |
80 | } | |
81 | } | |
750296dd | 82 | if(auxmax>fBaseline[ian]+fNSigmaNoise*fRawNoise[ian]){ |
83 | fSumTPPeak[ian]+=auxmax-fBaseline[ian]; | |
84 | fTPPos[ian]+=auxtb; | |
85 | fNEvents[ian]++; | |
86 | } | |
348f80b7 | 87 | } |
88 | } | |
89 | //______________________________________________________________________ | |
90 | void AliITSOnlineSDDTP::ReadBaselines(){ | |
91 | // assume baselines and good anodes are taken from previous run | |
2c4e6a6a | 92 | TString basfilnam; |
93 | basfilnam.Form("SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide); | |
94 | FILE* basf=fopen(basfilnam.Data(),"r"); | |
348f80b7 | 95 | if(basf==0){ |
2f0c3b74 | 96 | AliWarning(Form("Baseline file not present (ddl %d carlos %d side %d, Set all baselines to 20",fDDL,fCarlos,fSide)); |
348f80b7 | 97 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
2f0c3b74 | 98 | fBaseline[ian]=20.; |
99 | fEqBaseline[ian]=20; | |
d8303ac8 | 100 | fOffsetBaseline[ian]=0; |
348f80b7 | 101 | fGoodAnode[ian]=1; |
102 | } | |
103 | return; | |
104 | } | |
c28423fc | 105 | Int_t check = fscanf(basf,"%d\n",&fHighThreshold); |
106 | if(check<1)AliError("Error while reading file with baselines"); | |
107 | check = fscanf(basf,"%d\n",&fLowThreshold); | |
108 | if(check<1)AliError("Error while reading file with baselines"); | |
d8303ac8 | 109 | Int_t n,ok,eqbase,offbase; |
348f80b7 | 110 | Float_t base,rms,cmn,corrnoi; |
111 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
c28423fc | 112 | check = fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi); |
113 | if(check<1)AliError("Error while reading file with baselines"); | |
348f80b7 | 114 | fBaseline[ian]=base; |
d8303ac8 | 115 | fEqBaseline[ian]=eqbase; |
116 | fOffsetBaseline[ian]=offbase; | |
348f80b7 | 117 | fGoodAnode[ian]=ok; |
3083967f | 118 | fRawNoise[ian]=rms; |
119 | fCMN[ian]=cmn; | |
120 | fCorrNoise[ian]=corrnoi; | |
348f80b7 | 121 | } |
122 | fclose(basf); | |
123 | } | |
124 | ||
3083967f | 125 | //______________________________________________________________________ |
126 | Bool_t AliITSOnlineSDDTP::IsModuleGood() const{ | |
127 | // | |
128 | // Check if there is at least 1 good anode | |
129 | // | |
130 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
131 | if(fGoodAnode[ian]) return kTRUE; | |
132 | } | |
133 | return kFALSE; | |
134 | } | |
348f80b7 | 135 | //______________________________________________________________________ |
136 | void AliITSOnlineSDDTP::ValidateAnodes(){ | |
776c19a3 | 137 | // tag good/bad channels |
348f80b7 | 138 | Float_t meang,rmsg; |
139 | StatGain(meang,rmsg); | |
348f80b7 | 140 | Float_t lowlim=meang-fNSigmaGain*rmsg; |
141 | Float_t hilim=meang+fNSigmaGain*rmsg; | |
142 | ||
143 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
144 | if(!fGoodAnode[ian]) continue; | |
145 | if(GetChannelGain(ian)<lowlim||GetChannelGain(ian)>hilim) fGoodAnode[ian]=0; | |
146 | } | |
147 | } | |
148 | ||
149 | ||
150 | //______________________________________________________________________ | |
776c19a3 | 151 | void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t &rms) const { |
152 | // compute average gain and rms | |
348f80b7 | 153 | Float_t sum=0.,sumq=0.; |
154 | Int_t cnt=0; | |
155 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
156 | if(!fGoodAnode[ian]) continue; | |
750296dd | 157 | if(fNEvents[ian]==0) continue; |
a8cd2ab2 | 158 | Float_t chgain=GetChannelGain(ian); |
159 | sum+=chgain; | |
160 | sumq+=chgain*chgain; | |
348f80b7 | 161 | cnt++; |
162 | } | |
163 | if(cnt>0){ | |
164 | mean=sum/(Float_t)cnt; | |
9b8481e1 | 165 | Float_t variance=sumq/(Float_t)cnt-mean*mean; |
166 | if(variance>0.) rms=TMath::Sqrt(variance); | |
167 | else rms = 0; | |
348f80b7 | 168 | }else{ |
169 | mean=0.; | |
170 | rms=0.; | |
171 | } | |
172 | return; | |
173 | } | |
174 | ||
175 | //______________________________________________________________________ | |
e44f571c | 176 | void AliITSOnlineSDDTP::WriteToASCII(){ |
776c19a3 | 177 | // writes parameters of each channel into an ASCII file |
178 | // to be sent to FXS by the DA and processed by the SHUTTLE | |
179 | ||
2c4e6a6a | 180 | TString outfilnam; |
181 | outfilnam.Form("SDDbase_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide); | |
182 | FILE* outf=fopen(outfilnam.Data(),"w"); | |
979b5a5f | 183 | fprintf(outf,"%d %d %d\n",fCarlos,fSide,IsModuleGood()); |
e7610d19 | 184 | fprintf(outf,"%d\n",fHighThreshold); |
185 | fprintf(outf,"%d\n",fLowThreshold); | |
348f80b7 | 186 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
d8303ac8 | 187 | fprintf(outf,"%d %d %8.3f %d %d %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeEqualizedBaseline(ian),GetAnodeBaselineOffset(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian),GetChannelGain(ian)); |
348f80b7 | 188 | } |
189 | fclose(outf); | |
190 | } | |
3083967f | 191 | //______________________________________________________________________ |
e5b2f7f2 | 192 | TH1F* AliITSOnlineSDDTP::GetBaselineAnodeHisto() const { |
776c19a3 | 193 | // produce histogram with baseline vs. anode number |
2c4e6a6a | 194 | TString hisnam; |
195 | hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide); | |
196 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 197 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
198 | h->SetBinContent(ian+1,GetAnodeBaseline(ian)); | |
199 | } | |
200 | return h; | |
201 | } | |
202 | //______________________________________________________________________ | |
203 | TH1F* AliITSOnlineSDDTP::GetRawNoiseAnodeHisto() const { | |
776c19a3 | 204 | // produce histogram with raw noise vs. anode number |
2c4e6a6a | 205 | TString hisnam; |
206 | hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide); | |
207 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 208 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
209 | h->SetBinContent(ian+1,GetAnodeRawNoise(ian)); | |
210 | } | |
211 | return h; | |
212 | } | |
213 | //______________________________________________________________________ | |
214 | TH1F* AliITSOnlineSDDTP::GetCorrNoiseAnodeHisto() const { | |
776c19a3 | 215 | // produce histogram with corrected noise vs. anode number |
2c4e6a6a | 216 | TString hisnam; |
217 | hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide); | |
218 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 219 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
220 | h->SetBinContent(ian+1,GetAnodeCorrNoise(ian)); | |
221 | } | |
222 | return h; | |
223 | } | |
224 | //______________________________________________________________________ | |
225 | TH1F* AliITSOnlineSDDTP::GetCMNCoefAnodeHisto() const { | |
776c19a3 | 226 | // produce histogram with coefficients for common mode noise subtraction |
2c4e6a6a | 227 | TString hisnam; |
228 | hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide); | |
229 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 230 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
231 | h->SetBinContent(ian+1,GetAnodeCommonMode(ian)); | |
232 | } | |
233 | return h; | |
234 | } | |
235 | //______________________________________________________________________ | |
236 | TH1F* AliITSOnlineSDDTP::GetStatusAnodeHisto() const { | |
776c19a3 | 237 | // produce histogram with status bit of each anode |
2c4e6a6a | 238 | TString hisnam; |
239 | hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide); | |
240 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 241 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
242 | h->SetBinContent(ian+1,float(IsAnodeGood(ian))); | |
243 | } | |
244 | return h; | |
245 | } | |
246 | //______________________________________________________________________ | |
247 | TH1F* AliITSOnlineSDDTP::GetGainAnodeHisto() const { | |
776c19a3 | 248 | // produce histogram with gain vs. anode number |
2c4e6a6a | 249 | TString hisnam; |
250 | hisnam.Form("hgain%02dc%02ds%d",fDDL,fCarlos,fSide); | |
251 | TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5); | |
e5b2f7f2 | 252 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
253 | h->SetBinContent(ian+1,GetChannelGain(ian)); | |
254 | } | |
255 | return h; | |
256 | } | |
257 | //______________________________________________________________________ | |
3083967f | 258 | Bool_t AliITSOnlineSDDTP::WriteToROOT(TFile *fil){ |
776c19a3 | 259 | // writes output into a root file |
3083967f | 260 | if(fil==0){ |
261 | AliWarning("Invalid pointer to ROOT file"); | |
262 | return kFALSE; | |
263 | } | |
2c4e6a6a | 264 | TString hisnam; |
3083967f | 265 | fil->cd(); |
2c4e6a6a | 266 | hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide); |
267 | TH1F hgood(hisnam.Data(),"",256,-0.5,255.5); | |
268 | hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide); | |
269 | TH1F hbase(hisnam.Data(),"",256,-0.5,255.5); | |
270 | hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide); | |
271 | TH1F hnois(hisnam.Data(),"",256,-0.5,255.5); | |
272 | hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide); | |
273 | TH1F hcmn(hisnam.Data(),"",256,-0.5,255.5); | |
274 | hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide); | |
275 | TH1F hcorn(hisnam.Data(),"",256,-0.5,255.5); | |
276 | hisnam.Form("hgain%02dc%02ds%d",fDDL,fCarlos,fSide); | |
277 | TH1F hgain(hisnam.Data(),"",256,-0.5,255.5); | |
278 | hisnam.Form("htptb%02dc%02ds%d",fDDL,fCarlos,fSide); | |
279 | TH1F htptb(hisnam.Data(),"",256,-0.5,255.5); | |
3083967f | 280 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
281 | hgood.SetBinContent(ian+1,float(IsAnodeGood(ian))); | |
282 | hbase.SetBinContent(ian+1,GetAnodeBaseline(ian)); | |
283 | hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian)); | |
284 | hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian)); | |
285 | hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian)); | |
286 | hgain.SetBinContent(ian+1,GetChannelGain(ian)); | |
a7996467 | 287 | htptb.SetBinContent(ian+1,GetTimeBinTPPeak(ian)); |
3083967f | 288 | } |
289 | hgood.Write(); | |
290 | hbase.Write(); | |
291 | hnois.Write(); | |
292 | hcmn.Write(); | |
293 | hcorn.Write(); | |
294 | hgain.Write(); | |
a7996467 | 295 | htptb.Write(); |
3083967f | 296 | return kTRUE; |
297 | } | |
348f80b7 | 298 |