]>
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 "AliITSOnlineSDDInjectors.h" | |
16 | #include <TH2F.h> | |
17 | #include <TGraphErrors.h> | |
18 | #include <TMath.h> | |
19 | ||
4c82df4c | 20 | /* $Id$ */ |
21 | ||
348f80b7 | 22 | /////////////////////////////////////////////////////////////////// |
23 | // // | |
24 | // Implementation of the class used for SDD injector analysis // | |
25 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
26 | // // | |
27 | /////////////////////////////////////////////////////////////////// | |
28 | ||
29 | ClassImp(AliITSOnlineSDDInjectors) | |
30 | ||
31 | const Float_t AliITSOnlineSDDInjectors::fgkSaturation = 1008.; | |
9f026db8 | 32 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultLThreshold = 5.; |
33 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultHThreshold = 25.; | |
34 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultMinSpeed = 5.5; | |
35 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultMaxSpeed = 9.0; | |
36 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultMaxErr = 1.5; | |
37 | const Int_t AliITSOnlineSDDInjectors::fgkDefaultPolOrder = 3; | |
f4e26d31 | 38 | const Float_t AliITSOnlineSDDInjectors::fgkDefaultTimeStep = 50.; |
39 | const UShort_t AliITSOnlineSDDInjectors::fgkDefaultTbMin[kInjLines] = {10,50,100}; | |
40 | const UShort_t AliITSOnlineSDDInjectors::fgkDefaultTbMax[kInjLines] = {20,70,120}; | |
348f80b7 | 41 | |
42 | //______________________________________________________________________ | |
784a52ed | 43 | AliITSOnlineSDDInjectors::AliITSOnlineSDDInjectors():AliITSOnlineSDD(),fHisto(),fTbZero(0.),fRMSTbZero(0.),fParam(),fPolOrder(0),fMinDriftSpeed(0.),fMaxDriftSpeed(0.),fMaxDriftSpeedErr(0.),fLowThreshold(0.),fHighThreshold(0.),fFirstPadForFit(0),fLastPadForFit(0),fPadStatusCutForFit(0),fTimeStep(0.),fUseTimeZeroSignal(kFALSE) |
348f80b7 | 44 | { |
45 | // default constructor | |
348f80b7 | 46 | SetPositions(); |
9f026db8 | 47 | SetDefaults(); |
f4e26d31 | 48 | SetTimeStep(fgkDefaultTimeStep); |
348f80b7 | 49 | } |
50 | //______________________________________________________________________ | |
784a52ed | 51 | AliITSOnlineSDDInjectors::AliITSOnlineSDDInjectors(Int_t nddl, Int_t ncarlos, Int_t sid):AliITSOnlineSDD(nddl,ncarlos,sid),fHisto(),fTbZero(0.),fRMSTbZero(0.),fParam(),fPolOrder(0),fMinDriftSpeed(0.),fMaxDriftSpeed(0.),fMaxDriftSpeedErr(0.),fLowThreshold(0.),fHighThreshold(0.),fFirstPadForFit(0),fLastPadForFit(0),fPadStatusCutForFit(0),fTimeStep(0.),fUseTimeZeroSignal(kFALSE) |
beb262b4 | 52 | { |
53 | // standard constructor | |
348f80b7 | 54 | SetPositions(); |
9f026db8 | 55 | SetDefaults(); |
f4e26d31 | 56 | SetTimeStep(fgkDefaultTimeStep); |
348f80b7 | 57 | } |
58 | //______________________________________________________________________ | |
59 | AliITSOnlineSDDInjectors::~AliITSOnlineSDDInjectors(){ | |
60 | // Destructor | |
19f1458a | 61 | // fHisto should not be deleted here because it points to an histo created |
62 | // by the external code which calls the method AnalyzeEvent | |
63 | // if(fHisto) delete fHisto; | |
348f80b7 | 64 | if(fParam) delete [] fParam; |
65 | } | |
66 | //______________________________________________________________________ | |
9f026db8 | 67 | void AliITSOnlineSDDInjectors::SetDefaults(){ |
68 | for(Int_t i=0;i<kInjLines;i++) | |
69 | SetInjLineRange(i,fgkDefaultTbMin[i],fgkDefaultTbMax[i]); | |
70 | SetThresholds(fgkDefaultLThreshold,fgkDefaultHThreshold); | |
71 | SetPolOrder(fgkDefaultPolOrder); | |
72 | SetMinDriftSpeed(fgkDefaultMinSpeed); | |
73 | SetMaxDriftSpeed(fgkDefaultMaxSpeed); | |
74 | SetMaxDriftSpeedErr(fgkDefaultMaxErr); | |
75 | SetFitLimits(1,kInjPads-2); // exclude first and last pad | |
76 | SetPadStatusCutForFit(); | |
77 | } | |
78 | //______________________________________________________________________ | |
348f80b7 | 79 | void AliITSOnlineSDDInjectors::SetPositions(){ |
80 | // | |
9f026db8 | 81 | Float_t xLinFromCenterUm[kInjLines]={31860.,17460.,660.}; |
82 | Float_t xAnodeFromCenterUm=35085; | |
83 | for(Int_t i=0;i<kInjLines;i++){ | |
84 | fPosition[i]=xAnodeFromCenterUm-xLinFromCenterUm[i]; | |
348f80b7 | 85 | fPosition[i]/=10000.; // from microns to cm |
86 | } | |
87 | } | |
88 | //______________________________________________________________________ | |
89 | void AliITSOnlineSDDInjectors::Reset(){ | |
beb262b4 | 90 | // |
9f026db8 | 91 | for(Int_t i=0;i<kInjPads;i++){ |
92 | fDriftSpeed[i]=0.; | |
93 | fDriftSpeedErr[i]=0.; | |
348f80b7 | 94 | } |
9f026db8 | 95 | for(Int_t i=0;i<kInjPads;i++){ |
96 | for(Int_t j=0;j<kInjLines;j++){ | |
348f80b7 | 97 | fGoodInj[i][j]=0; |
98 | fCentroid[i][j]=0.; | |
99 | fRMSCentroid[i][j]=0.; | |
100 | } | |
101 | } | |
102 | } | |
103 | //______________________________________________________________________ | |
104 | void AliITSOnlineSDDInjectors::AnalyzeEvent(TH2F* his){ | |
105 | // | |
106 | Reset(); | |
107 | fHisto=his; | |
108 | FindGoodInjectors(); | |
109 | FindCentroids(); | |
110 | CalcTimeBinZero(); | |
9f026db8 | 111 | for(Int_t j=0;j<kInjPads;j++) CalcDriftSpeed(j); |
112 | FitDriftSpeedVsAnode(); | |
348f80b7 | 113 | } |
114 | //______________________________________________________________________ | |
9f026db8 | 115 | TGraphErrors* AliITSOnlineSDDInjectors::GetTimeVsDistGraph(Int_t jpad) const{ |
348f80b7 | 116 | // |
9f026db8 | 117 | const Int_t kPts=kInjLines+1; |
118 | Float_t x[kPts],y[kPts],ex[kPts],ey[kPts]; | |
348f80b7 | 119 | x[0]=0.; |
120 | ex[0]=0.; | |
121 | y[0]=fTbZero; | |
122 | ey[0]=0.; | |
9f026db8 | 123 | for(Int_t i=0;i<kInjLines;i++){ |
348f80b7 | 124 | x[i+1]=fPosition[i]; |
125 | ex[i+1]=0.; | |
9f026db8 | 126 | y[i+1]=fCentroid[jpad][i]; |
127 | ey[i+1]=fRMSCentroid[jpad][i]; | |
348f80b7 | 128 | } |
129 | TGraphErrors *g=new TGraphErrors(4,x,y,ex,ey); | |
130 | return g; | |
131 | } | |
9f026db8 | 132 | |
348f80b7 | 133 | //______________________________________________________________________ |
9f026db8 | 134 | TGraphErrors* AliITSOnlineSDDInjectors::GetDriftSpeedGraph() const{ |
348f80b7 | 135 | // |
348f80b7 | 136 | Int_t ipt=0; |
137 | TGraphErrors *g=new TGraphErrors(0); | |
9f026db8 | 138 | for(Int_t i=0;i<kInjPads;i++){ |
139 | if(fDriftSpeed[i]>0){ | |
140 | g->SetPoint(ipt,GetAnodeNumber(i),fDriftSpeed[i]); | |
141 | g->SetPointError(ipt,0,fDriftSpeedErr[i]); | |
348f80b7 | 142 | ipt++; |
143 | } | |
144 | } | |
145 | return g; | |
146 | } | |
147 | //______________________________________________________________________ | |
84df0230 | 148 | TGraphErrors* AliITSOnlineSDDInjectors::GetSelectedDriftSpeedGraph(Int_t minAcceptStatus) const{ |
149 | // TGraphErrors with only pads with status of injector >= minAcceptStatus | |
150 | Int_t ipt=0; | |
151 | TGraphErrors *g=new TGraphErrors(0); | |
152 | for(Int_t i=0;i<kInjPads;i++){ | |
153 | Int_t padStatus = GetInjPadStatus(i); | |
154 | if(fDriftSpeed[i]>0 && padStatus >= minAcceptStatus ){ | |
155 | g->SetPoint(ipt,GetAnodeNumber(i),fDriftSpeed[i]); | |
156 | g->SetPointError(ipt,0,fDriftSpeedErr[i]); | |
157 | ipt++; | |
158 | } | |
159 | } | |
160 | return g; | |
161 | } | |
162 | //______________________________________________________________________ | |
348f80b7 | 163 | void AliITSOnlineSDDInjectors::CalcTimeBinZero(){ |
784a52ed | 164 | // Get time zero from trigger signal |
165 | Float_t tzero=0.,intCont=0.,rmsPeak=0.; | |
166 | Bool_t isTbUsed[256]; | |
167 | Int_t nTbUsed=0; | |
168 | for(Int_t i=0;i<256;i++) isTbUsed[i]=0; | |
348f80b7 | 169 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
170 | for(Int_t itb=1;itb<fTbMin[0];itb++){ | |
171 | Float_t cont=fHisto->GetBinContent(itb,ian+1); | |
784a52ed | 172 | Float_t contm1=fHisto->GetBinContent(itb+1,ian+1); |
173 | Float_t contp1=fHisto->GetBinContent(itb-1,ian+1); | |
9f026db8 | 174 | if(cont>fLowThreshold){ |
784a52ed | 175 | if(contm1>fHighThreshold || cont>fHighThreshold || contp1>fHighThreshold){ |
176 | tzero+=cont*float(itb); | |
177 | rmsPeak+=cont*float(itb)*float(itb); | |
178 | intCont+=cont; | |
179 | if(!isTbUsed[itb]){ | |
180 | isTbUsed[itb]=1; | |
181 | ++nTbUsed; | |
182 | } | |
183 | } | |
348f80b7 | 184 | } |
185 | } | |
186 | } | |
784a52ed | 187 | if(intCont>0){ |
188 | fTbZero=tzero/intCont; | |
189 | fRMSTbZero=TMath::Sqrt(rmsPeak/intCont-fTbZero*fTbZero); | |
190 | } | |
191 | if(nTbUsed==1) fRMSTbZero=0.5; | |
348f80b7 | 192 | } |
193 | //______________________________________________________________________ | |
9f026db8 | 194 | void AliITSOnlineSDDInjectors::FitDriftSpeedVsAnode(){ |
195 | // fits the anode dependence of drift speed with a polynomial function | |
4ff6aa93 | 196 | const Int_t kNn=fPolOrder+1; |
197 | Float_t **mat = new Float_t*[kNn]; | |
198 | for(Int_t i=0; i < kNn; i++) mat[i] = new Float_t[kNn]; | |
199 | Float_t *vect = new Float_t[kNn]; | |
9f026db8 | 200 | |
4ff6aa93 | 201 | for(Int_t k1=0;k1<kNn;k1++){ |
348f80b7 | 202 | vect[k1]=0; |
4ff6aa93 | 203 | for(Int_t k2=0;k2<kNn;k2++){ |
348f80b7 | 204 | mat[k1][k2]=0; |
348f80b7 | 205 | } |
206 | } | |
06bb3583 | 207 | Int_t npts = 0; |
4ff6aa93 | 208 | for(Int_t k1=0;k1<kNn;k1++){ |
9f026db8 | 209 | for(Int_t jpad=fFirstPadForFit; jpad<=fLastPadForFit; jpad++){ |
210 | Float_t x=(Float_t)GetAnodeNumber(jpad); | |
211 | if(fDriftSpeed[jpad]>0 && GetInjPadStatus(jpad)>fPadStatusCutForFit){ | |
212 | vect[k1]+=fDriftSpeed[jpad]*TMath::Power(x,k1)/TMath::Power(fDriftSpeedErr[jpad],2); | |
06bb3583 | 213 | if(k1==0) npts++; |
9f026db8 | 214 | for(Int_t k2=0;k2<kNn;k2++){ |
9f026db8 | 215 | mat[k1][k2]+=TMath::Power(x,k1+k2)/TMath::Power(fDriftSpeedErr[jpad],2); |
216 | } | |
217 | } | |
348f80b7 | 218 | } |
219 | } | |
06bb3583 | 220 | if(npts<fPolOrder+1){ |
221 | if(fParam) delete [] fParam; | |
222 | fParam=new Float_t[kNn]; | |
223 | for(Int_t i=0; i<kNn;i++)fParam[i]=0; | |
224 | }else{ | |
225 | Int_t *iPivot = new Int_t[kNn]; | |
226 | Int_t *indxR = new Int_t[kNn]; | |
227 | Int_t *indxC = new Int_t[kNn]; | |
228 | for(Int_t i=0;i<kNn;i++) iPivot[i]=0; | |
229 | Int_t iCol=-1,iRow=-1; | |
230 | for(Int_t i=0;i<kNn;i++){ | |
231 | Float_t big=0.; | |
232 | for(Int_t j=0;j<kNn;j++){ | |
233 | if(iPivot[j]!=1){ | |
234 | for(Int_t k=0;k<kNn;k++){ | |
235 | if(iPivot[k]==0){ | |
236 | if(TMath::Abs(mat[j][k])>=big){ | |
237 | big=TMath::Abs(mat[j][k]); | |
238 | iRow=j; | |
239 | iCol=k; | |
240 | } | |
241 | } | |
348f80b7 | 242 | } |
243 | } | |
244 | } | |
06bb3583 | 245 | iPivot[iCol]++; |
246 | Float_t aux; | |
247 | if(iRow!=iCol){ | |
248 | for(Int_t l=0;l<kNn;l++){ | |
249 | aux=mat[iRow][l]; | |
250 | mat[iRow][l]=mat[iCol][l]; | |
251 | mat[iCol][l]=aux; | |
252 | } | |
253 | aux=vect[iRow]; | |
254 | vect[iRow]=vect[iCol]; | |
255 | vect[iCol]=aux; | |
348f80b7 | 256 | } |
06bb3583 | 257 | indxR[i]=iRow; |
258 | indxC[i]=iCol; | |
259 | if(mat[iCol][iCol]==0) break; | |
260 | Float_t pivinv=1./mat[iCol][iCol]; | |
261 | mat[iCol][iCol]=1; | |
262 | for(Int_t l=0;l<kNn;l++) mat[iCol][l]*=pivinv; | |
263 | vect[iCol]*=pivinv; | |
264 | for(Int_t m=0;m<kNn;m++){ | |
265 | if(m!=iCol){ | |
266 | aux=mat[m][iCol]; | |
267 | mat[m][iCol]=0; | |
268 | for(Int_t n=0;n<kNn;n++) mat[m][n]-=mat[iCol][n]*aux; | |
269 | vect[m]-=vect[iCol]*aux; | |
270 | } | |
271 | } | |
348f80b7 | 272 | } |
06bb3583 | 273 | delete [] iPivot; |
274 | delete [] indxR; | |
275 | delete [] indxC; | |
276 | ||
277 | ||
278 | if(fParam) delete [] fParam; | |
279 | fParam=new Float_t[kNn]; | |
280 | for(Int_t i=0; i<kNn;i++)fParam[i]=vect[i]; | |
348f80b7 | 281 | } |
348f80b7 | 282 | |
4ff6aa93 | 283 | for(Int_t i=0; i < kNn; i++) delete [] mat[i]; |
348f80b7 | 284 | delete [] mat; |
285 | delete [] vect; | |
286 | } | |
287 | //______________________________________________________________________ | |
9f026db8 | 288 | void AliITSOnlineSDDInjectors::CalcDriftSpeed(Int_t jpad){ |
348f80b7 | 289 | // |
290 | Float_t sumY=0,sumX=0,sumXX=0,sumYY=0.,sumXY=0,sumWEI=0.; | |
291 | Int_t npt=0; | |
9f026db8 | 292 | Float_t y[kInjLines],ey[kInjLines]; |
348f80b7 | 293 | Float_t tzero=0,erry=0; |
9f026db8 | 294 | for(Int_t i=0;i<kInjLines;i++){ |
295 | y[i]=fCentroid[jpad][i]; | |
296 | ey[i]=fRMSCentroid[jpad][i]; | |
348f80b7 | 297 | } |
9f026db8 | 298 | for(Int_t i=0;i<kInjLines;i++){ |
299 | if(fGoodInj[jpad][i] && ey[i]!=0){ | |
348f80b7 | 300 | sumY+=y[i]/ey[i]/ey[i]; |
301 | sumX+=fPosition[i]/ey[i]/ey[i]; | |
302 | sumXX+=fPosition[i]*fPosition[i]/ey[i]/ey[i]; | |
303 | sumYY+=y[i]*y[i]/ey[i]/ey[i]; | |
304 | sumXY+=fPosition[i]*y[i]/ey[i]/ey[i]; | |
305 | sumWEI+=1./ey[i]/ey[i]; | |
306 | tzero=fTbZero/ey[i]/ey[i]; | |
784a52ed | 307 | erry=ey[i]/ey[i]/ey[i]; |
348f80b7 | 308 | npt++; |
309 | } | |
310 | } | |
784a52ed | 311 | Float_t slope=0.,eslope=0.; |
312 | if(npt==1){ | |
313 | slope=(sumY-tzero)/sumX; | |
314 | eslope=erry/sumX; | |
315 | } | |
348f80b7 | 316 | if(npt>1){ |
784a52ed | 317 | if(fUseTimeZeroSignal){ |
318 | sumY+=fTbZero/fRMSTbZero/fRMSTbZero; | |
319 | sumX+=0.; | |
320 | sumXX+=0.; | |
321 | sumYY+=fTbZero*fTbZero/fRMSTbZero/fRMSTbZero; | |
322 | sumXY+=0.; | |
323 | sumWEI+=1./fRMSTbZero/fRMSTbZero; | |
53855521 | 324 | } |
784a52ed | 325 | slope=(sumWEI*sumXY-sumY*sumX)/(sumWEI*sumXX-sumX*sumX); |
326 | eslope=TMath::Sqrt(sumWEI/(sumWEI*sumXX-sumX*sumX)); | |
348f80b7 | 327 | } |
784a52ed | 328 | |
329 | Float_t vel=0,evel=0; | |
330 | if(slope!=0. && fTimeStep>0.){ | |
331 | vel=1./slope*10000./fTimeStep;// micron/ns | |
332 | evel=eslope/slope/slope*10000./fTimeStep;// micron/ns | |
348f80b7 | 333 | } |
9f026db8 | 334 | if(vel>fMaxDriftSpeed||vel<fMinDriftSpeed || evel>fMaxDriftSpeedErr){ |
348f80b7 | 335 | vel=0.; |
336 | evel=0.; | |
337 | } | |
9f026db8 | 338 | fDriftSpeed[jpad]=vel; |
339 | fDriftSpeedErr[jpad]=evel; | |
348f80b7 | 340 | } |
341 | //______________________________________________________________________ | |
9f026db8 | 342 | Int_t AliITSOnlineSDDInjectors::GetAnodeNumber(Int_t iInjPad) const{ |
61606350 | 343 | // Injectors location along anodes: |
344 | // Side left (UP) - channel 0: injectors on anodes 0,7,15,...,247,255 | |
345 | // Side right (DOWN) - channel 1: injectors on anodes 0,8,16,...,248,255 | |
348f80b7 | 346 | Int_t ian=-1; |
9f026db8 | 347 | if(iInjPad>=kInjPads) return ian; |
61606350 | 348 | if(fSide==1){ // right side |
9f026db8 | 349 | ian=iInjPad*8; |
350 | if(iInjPad==32) ian--; | |
61606350 | 351 | }else{ // left side |
9f026db8 | 352 | ian=iInjPad*8-1; |
353 | if(iInjPad==0) ian=0; | |
348f80b7 | 354 | } |
355 | return ian; | |
356 | } | |
84c6e6c0 | 357 | //______________________________________________________________________ |
9f026db8 | 358 | Int_t AliITSOnlineSDDInjectors::GetInjPadNumberFromAnode(Int_t nAnode) const{ |
84c6e6c0 | 359 | // |
9f026db8 | 360 | Int_t iInjPad=-1; |
61606350 | 361 | if(fSide==1){ // right side |
9f026db8 | 362 | if(nAnode%8==0) iInjPad=nAnode/8; |
363 | if(nAnode==255) iInjPad=32; | |
61606350 | 364 | }else{ // left side |
9f026db8 | 365 | if(nAnode%8==7) iInjPad=1+nAnode/8; |
366 | if(nAnode==0) iInjPad=0; | |
84c6e6c0 | 367 | } |
9f026db8 | 368 | if(nAnode>=256) iInjPad=-1; |
369 | return iInjPad; | |
84c6e6c0 | 370 | } |
371 | //______________________________________________________________________ | |
9f026db8 | 372 | Int_t AliITSOnlineSDDInjectors::GetInjPadStatus(Int_t jpad) const{ |
373 | // returns an integer value with status of injector lines for given pad/anode | |
374 | // status=7 --> 111 all injector are good | |
375 | // status=6 --> 110 1st line (close to anodes) is bad, other two are good | |
376 | // .... | |
377 | // status=1 --> 001 only 1st line (close to anodes) good | |
378 | // status=0 --> 000 all lines are bad | |
84c6e6c0 | 379 | Int_t istatus=0; |
9f026db8 | 380 | if(jpad>=0 && jpad<kInjPads){ |
381 | for(Int_t jlin=0;jlin<kInjLines;jlin++) istatus+=fGoodInj[jpad][jlin]<<jlin; | |
84c6e6c0 | 382 | } |
383 | return istatus; | |
384 | } | |
348f80b7 | 385 | //______________________________________________________________________ |
386 | void AliITSOnlineSDDInjectors::FindGoodInjectors(){ | |
387 | // | |
9f026db8 | 388 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
389 | Int_t ian=GetAnodeNumber(jpad); | |
390 | for(Int_t jlin=0;jlin<kInjLines;jlin++){ | |
391 | for(Int_t jjj=fTbMin[jlin];jjj<fTbMax[jlin];jjj++){ | |
348f80b7 | 392 | Float_t c1=fHisto->GetBinContent(jjj,ian+1); |
393 | Float_t c2=fHisto->GetBinContent(jjj+1,ian+1); | |
a7996467 | 394 | // Float_t c3=fHisto->GetBinContent(jjj+2,ian+1); |
395 | if(c1>fLowThreshold && c2>fLowThreshold){ | |
396 | if(c1>fHighThreshold || c2>fHighThreshold){ | |
397 | fGoodInj[jpad][jlin]=1; | |
398 | break; | |
399 | } | |
348f80b7 | 400 | } |
401 | } | |
348f80b7 | 402 | } |
403 | } | |
404 | } | |
405 | //______________________________________________________________________ | |
406 | void AliITSOnlineSDDInjectors::FindCentroids(){ | |
407 | // | |
9f026db8 | 408 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
409 | Int_t ian=GetAnodeNumber(jpad); | |
410 | for(Int_t jlin=0;jlin<kInjLines;jlin++){ | |
411 | if(!fGoodInj[jpad][jlin]) continue; | |
348f80b7 | 412 | Float_t maxcont=0; |
413 | Int_t ilmax=-1; | |
9f026db8 | 414 | for(Int_t jjj=fTbMin[jlin];jjj<fTbMax[jlin];jjj++){ |
348f80b7 | 415 | Float_t cont=fHisto->GetBinContent(jjj,ian+1); |
416 | if(cont>maxcont){ | |
417 | maxcont=cont; | |
418 | ilmax=jjj; | |
419 | } | |
420 | } | |
421 | Float_t intCont=0; | |
422 | Int_t jjj=ilmax; | |
423 | while(1){ | |
424 | Float_t cont=fHisto->GetBinContent(jjj,ian+1); | |
9f026db8 | 425 | if(cont<fLowThreshold) break; |
348f80b7 | 426 | if(cont<fgkSaturation){ |
9f026db8 | 427 | fCentroid[jpad][jlin]+=cont*(Float_t)jjj; |
784a52ed | 428 | fRMSCentroid[jpad][jlin]+=cont*(Float_t)jjj*(Float_t)jjj; |
348f80b7 | 429 | intCont+=cont; |
430 | } | |
431 | jjj--; | |
432 | } | |
433 | jjj=ilmax+1; | |
434 | while(1){ | |
435 | Float_t cont=fHisto->GetBinContent(jjj,ian+1); | |
9f026db8 | 436 | if(cont<fLowThreshold) break; |
348f80b7 | 437 | if(cont<fgkSaturation){ |
9f026db8 | 438 | fCentroid[jpad][jlin]+=cont*float(jjj); |
784a52ed | 439 | fRMSCentroid[jpad][jlin]+=cont*(Float_t)jjj*(Float_t)jjj; |
348f80b7 | 440 | intCont+=cont; |
441 | } | |
442 | jjj++; | |
443 | } | |
444 | if(intCont>0){ | |
9f026db8 | 445 | fCentroid[jpad][jlin]/=intCont; |
446 | fRMSCentroid[jpad][jlin]=TMath::Sqrt(fRMSCentroid[jpad][jlin]/intCont-fCentroid[jpad][jlin]*fCentroid[jpad][jlin]); | |
348f80b7 | 447 | } |
448 | else{ | |
9f026db8 | 449 | fCentroid[jpad][jlin]=0.; |
450 | fRMSCentroid[jpad][jlin]=0.; | |
451 | fGoodInj[jpad][jlin]=0; | |
348f80b7 | 452 | } |
9f026db8 | 453 | if(fRMSCentroid[jpad][jlin]==0) fGoodInj[jpad][jlin]=0; |
348f80b7 | 454 | } |
455 | } | |
456 | } | |
457 | //______________________________________________________________________ | |
9f026db8 | 458 | void AliITSOnlineSDDInjectors::PrintInjectorStatus(){ |
348f80b7 | 459 | // |
9f026db8 | 460 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
461 | printf("Line%d-Anode%d: %d %d %d\n",jpad,GetAnodeNumber(jpad),fGoodInj[jpad][0],fGoodInj[jpad][1],fGoodInj[jpad][2]); | |
348f80b7 | 462 | } |
463 | } | |
464 | //______________________________________________________________________ | |
465 | void AliITSOnlineSDDInjectors::PrintCentroids(){ | |
466 | // | |
9f026db8 | 467 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
468 | printf("Line%d-Anode%d: %f+-%f %f+-%f %f+-%f\n",jpad,GetAnodeNumber(jpad),fCentroid[jpad][0],fRMSCentroid[jpad][0],fCentroid[jpad][1],fRMSCentroid[jpad][1],fCentroid[jpad][2],fRMSCentroid[jpad][2]); | |
348f80b7 | 469 | } |
470 | } | |
471 | //______________________________________________________________________ | |
4c82df4c | 472 | void AliITSOnlineSDDInjectors::WriteToASCII(Int_t evNumb, UInt_t timeStamp, Int_t optAppend){ |
348f80b7 | 473 | // |
474 | Char_t outfilnam[100]; | |
979b5a5f | 475 | sprintf(outfilnam,"SDDinj_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide); |
4c82df4c | 476 | FILE* outf; |
18da6e54 | 477 | if(optAppend==0){ |
478 | outf=fopen(outfilnam,"w"); | |
479 | fprintf(outf,"%d\n",fPolOrder); | |
480 | } | |
4c82df4c | 481 | else outf=fopen(outfilnam,"a"); |
482 | fprintf(outf,"%d %d ",evNumb,timeStamp); | |
348f80b7 | 483 | for(Int_t ic=0;ic<fPolOrder+1;ic++){ |
484 | fprintf(outf,"%G ",fParam[ic]); | |
485 | } | |
486 | fprintf(outf,"\n"); | |
487 | fclose(outf); | |
488 | } |