]>
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 "AliITSOnlineSDDBase.h" | |
16 | #include <TH2F.h> | |
17 | #include <TMath.h> | |
18 | ||
19 | ||
20 | /////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // Implementation of the class used for SDD baselines // | |
23 | // and noise analysis // | |
24 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////// | |
27 | ||
e7610d19 | 28 | /* $Id$ */ |
29 | ||
30 | const Int_t AliITSOnlineSDDBase::fgkMaxCorr=63; // 6 but correction | |
348f80b7 | 31 | |
32 | ClassImp(AliITSOnlineSDDBase) | |
33 | //______________________________________________________________________ | |
e7610d19 | 34 | AliITSOnlineSDDBase::AliITSOnlineSDDBase():AliITSOnlineSDD(),fNEvents(0),fMinBaseline(0.),fMaxBaseline(0.),fMinRawNoise(0.),fMaxRawNoise(0.),fNSigmaNoise(0.),fGoldenBaseline(0.),fLowThrFact(0.),fHighThrFact(0.) |
348f80b7 | 35 | { |
36 | // default constructor | |
37 | Reset(); | |
38 | SetMinBaseline(); | |
39 | SetMaxBaseline(); | |
40 | SetMinRawNoise(); | |
41 | SetMaxRawNoise(); | |
42 | SetNSigmaNoise(); | |
e7610d19 | 43 | SetGoldenBaselineValue(); |
44 | SetZeroSuppThresholds(); | |
348f80b7 | 45 | } |
46 | //______________________________________________________________________ | |
e7610d19 | 47 | AliITSOnlineSDDBase::AliITSOnlineSDDBase(Int_t nddl, Int_t ncarlos, Int_t sid):AliITSOnlineSDD(nddl,ncarlos,sid),fNEvents(0),fMinBaseline(0.),fMaxBaseline(0.),fMinRawNoise(0.),fMaxRawNoise(0.),fNSigmaNoise(0.),fGoldenBaseline(0.),fLowThrFact(0.),fHighThrFact(0.) |
348f80b7 | 48 | { |
49 | // default constructor | |
50 | Reset(); | |
51 | SetMinBaseline(); | |
52 | SetMaxBaseline(); | |
53 | SetMinRawNoise(); | |
54 | SetMaxRawNoise(); | |
55 | SetNSigmaNoise(); | |
e7610d19 | 56 | SetGoldenBaselineValue(); |
57 | SetZeroSuppThresholds(); | |
348f80b7 | 58 | } |
59 | //______________________________________________________________________ | |
60 | AliITSOnlineSDDBase::~AliITSOnlineSDDBase(){ | |
61 | // Destructor | |
62 | } | |
63 | //______________________________________________________________________ | |
64 | void AliITSOnlineSDDBase::Reset(){ | |
beb262b4 | 65 | // |
348f80b7 | 66 | fNEvents=0; |
67 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
68 | fGoodAnode[i]=1; | |
69 | fSumBaseline[i]=0.; | |
70 | fSumRawNoise[i]=0.; | |
71 | fSumCMN[i]=0.; | |
72 | } | |
73 | } | |
74 | //______________________________________________________________________ | |
75 | void AliITSOnlineSDDBase::ValidateAnodes(){ | |
beb262b4 | 76 | // |
348f80b7 | 77 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
78 | fGoodAnode[ian]=1; | |
79 | if(GetAnodeBaseline(ian)>fMaxBaseline || GetAnodeBaseline(ian)<fMinBaseline) fGoodAnode[ian]=0; | |
f2c71038 | 80 | else if(GetAnodeRawNoise(ian)>fMaxRawNoise || GetAnodeRawNoise(ian)<fMinRawNoise) fGoodAnode[ian]=0; |
81 | else if(GetAnodeRawNoise(ian)>fNSigmaNoise*CalcMeanRawNoise()) fGoodAnode[ian]=0; | |
348f80b7 | 82 | } |
83 | } | |
84 | ||
85 | //______________________________________________________________________ | |
86 | void AliITSOnlineSDDBase::AddEvent(TH2F* hrawd){ | |
87 | // | |
88 | fNEvents++; | |
4ff6aa93 | 89 | const Int_t kTimeBins=fLastGoodTB-fFirstGoodTB+1; |
348f80b7 | 90 | Float_t sum[fgkNAnodes]; |
91 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
92 | Float_t sumQ=0.; | |
93 | sum[ian]=0.; | |
750296dd | 94 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
348f80b7 | 95 | sum[ian]+=hrawd->GetBinContent(itb+1,ian+1); |
96 | sumQ+=TMath::Power(hrawd->GetBinContent(itb+1,ian+1),2); | |
97 | } | |
4ff6aa93 | 98 | sum[ian]/=(Float_t)kTimeBins; |
99 | sumQ/=(Float_t)kTimeBins; | |
348f80b7 | 100 | fSumBaseline[ian]+=sum[ian]; |
101 | fSumRawNoise[ian]+=sumQ; | |
348f80b7 | 102 | } |
103 | ||
f2c71038 | 104 | if(fNEvents==1) ValidateAnodes(); |
348f80b7 | 105 | |
4ff6aa93 | 106 | Float_t *cmnEven = new Float_t[kTimeBins]; |
107 | Float_t *cmnOdd = new Float_t[kTimeBins]; | |
750296dd | 108 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
348f80b7 | 109 | Float_t sumEven=0., sumOdd=0.; |
110 | Int_t countEven=0,countOdd=0; | |
111 | for(Int_t ian=0;ian<fgkNAnodes;ian+=2){ | |
112 | if(!fGoodAnode[ian]) continue; | |
113 | sumEven+=hrawd->GetBinContent(itb+1,ian+1)-sum[ian]; | |
114 | countEven++; | |
115 | } | |
116 | for(Int_t ian=1;ian<fgkNAnodes;ian+=2){ | |
117 | if(!fGoodAnode[ian]) continue; | |
118 | sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-sum[ian]; | |
119 | countOdd++; | |
120 | } | |
750296dd | 121 | if(countEven>0) cmnEven[itb]=sumEven/countEven; |
122 | if(countOdd>0) cmnOdd[itb]=sumOdd/countOdd; | |
348f80b7 | 123 | } |
124 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
125 | Float_t num=0.,den=0.; | |
126 | if(!fGoodAnode[ian]) continue; | |
750296dd | 127 | for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){ |
348f80b7 | 128 | Float_t cmnCoef=cmnOdd[itb]; |
129 | if(ian%2==0) cmnCoef=cmnEven[itb]; | |
130 | num+=(hrawd->GetBinContent(itb+1,ian+1)-sum[ian])*cmnCoef; | |
131 | den+=TMath::Power(cmnCoef,2); | |
132 | } | |
133 | if(den!=0) fSumCMN[ian]+=num/den; | |
134 | } | |
135 | ||
136 | delete [] cmnEven; | |
137 | delete [] cmnOdd; | |
138 | } | |
139 | //______________________________________________________________________ | |
e7610d19 | 140 | void AliITSOnlineSDDBase::GetMinAndMaxBaseline(Float_t &basMin, Float_t &basMax) const { |
141 | // fills mininum and maximum baseline values | |
142 | basMin=1008.; | |
143 | basMax=0.; | |
144 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
145 | if(!fGoodAnode[ian]) continue; | |
146 | Float_t bas=GetAnodeBaseline(ian); | |
147 | if(bas>0 && bas < basMin) basMin=bas; | |
148 | if(bas>0 && bas > basMax) basMax=bas; | |
149 | } | |
150 | } | |
151 | //______________________________________________________________________ | |
d8303ac8 | 152 | Float_t AliITSOnlineSDDBase::GetMinimumBaseline() const { |
3f8beb0b | 153 | // returns anode with minum baseline value in hybrid |
d8303ac8 | 154 | Float_t basMin=1008.; |
155 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
3f8beb0b | 156 | if(!fGoodAnode[ian]) continue; |
d8303ac8 | 157 | Float_t bas=GetAnodeBaseline(ian); |
158 | if(bas>0 && bas < basMin) basMin=bas; | |
159 | } | |
160 | return basMin; | |
161 | } | |
162 | //______________________________________________________________________ | |
beb262b4 | 163 | Float_t AliITSOnlineSDDBase::CalcMeanRawNoise() const{ |
348f80b7 | 164 | // |
165 | Float_t meanns=0.; | |
166 | Int_t cnt=0; | |
167 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
168 | if(!fGoodAnode[ian]) continue; | |
169 | meanns+=GetAnodeRawNoise(ian); | |
170 | cnt++; | |
171 | } | |
172 | if(cnt>0) meanns/=(Float_t)cnt; | |
173 | return meanns; | |
174 | } | |
175 | //______________________________________________________________________ | |
e44f571c | 176 | void AliITSOnlineSDDBase::WriteToASCII(){ |
348f80b7 | 177 | // |
178 | Char_t outfilnam[100]; | |
e7610d19 | 179 | Float_t basMin,basMax; |
180 | GetMinAndMaxBaseline(basMin,basMax); | |
181 | Float_t finalVal=basMin; | |
182 | if(basMin>fGoldenBaseline && basMax<fGoldenBaseline+fgkMaxCorr) finalVal=fGoldenBaseline; | |
183 | if(basMax<basMin+fgkMaxCorr && basMax>fGoldenBaseline+fgkMaxCorr) finalVal=basMax-fgkMaxCorr; | |
184 | ||
185 | Float_t avNoise=CalcMeanRawNoise(); | |
186 | Int_t thrL=(Int_t)(finalVal+fLowThrFact*avNoise+0.5); | |
187 | Int_t thrH=(Int_t)(finalVal+fHighThrFact*avNoise+0.5); | |
188 | ||
979b5a5f | 189 | sprintf(outfilnam,"SDDbase_step1_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide); |
348f80b7 | 190 | FILE* outf=fopen(outfilnam,"w"); |
e7610d19 | 191 | fprintf(outf,"%d\n",thrH); |
192 | fprintf(outf,"%d\n",thrL); | |
348f80b7 | 193 | Float_t corrnoise=2.; |
194 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
d8303ac8 | 195 | Float_t bas=GetAnodeBaseline(ian); |
e7610d19 | 196 | Int_t corr=(Int_t)(bas-finalVal+0.5); |
197 | if(corr>fgkMaxCorr) corr=fgkMaxCorr; // only 6 bits in jtag for correction | |
3f8beb0b | 198 | if(corr<0) corr=0; // avoid negative numbers |
e7610d19 | 199 | fprintf(outf,"%d %d %11.6f %d %d %11.6f %11.6f %11.6f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),(Int_t)finalVal,corr,GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),corrnoise); |
348f80b7 | 200 | } |
201 | fclose(outf); | |
202 | } |