]>
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 | //______________________________________________________________________ | |
2ca27861 | 43 | AliITSOnlineSDDInjectors::AliITSOnlineSDDInjectors():AliITSOnlineSDD(),fHisto(),fTbZero(0.),fRMSTbZero(0.),fNEvents(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 | //______________________________________________________________________ | |
2ca27861 | 51 | AliITSOnlineSDDInjectors::AliITSOnlineSDDInjectors(Int_t nddl, Int_t ncarlos, Int_t sid):AliITSOnlineSDD(nddl,ncarlos,sid),fHisto(),fTbZero(0.),fRMSTbZero(0.),fNEvents(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 | // | |
2ca27861 | 81 | Double_t xLinFromCenterUm[kInjLines]={31860.,17460.,660.}; |
82 | Double_t xAnodeFromCenterUm=35085; | |
9f026db8 | 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 | //______________________________________________________________________ | |
2ca27861 | 115 | void AliITSOnlineSDDInjectors::AddEvent(TH2F* his){ |
116 | // Add the drift speed from current event to the average value | |
117 | if(fNEvents==0){ | |
118 | for(Int_t i=0;i<kInjPads;i++){ | |
119 | fSumDriftSpeed[i]=0.; | |
120 | fSumSqDriftSpeed[i]=0.; | |
121 | } | |
122 | } | |
123 | Reset(); | |
124 | fHisto=his; | |
125 | FindGoodInjectors(); | |
126 | FindCentroids(); | |
127 | CalcTimeBinZero(); | |
128 | for(Int_t j=0;j<kInjPads;j++){ | |
129 | CalcDriftSpeed(j); | |
130 | fSumDriftSpeed[j]+=fDriftSpeed[j]; | |
131 | fSumSqDriftSpeed[j]+=fDriftSpeed[j]*fDriftSpeed[j]; | |
132 | } | |
133 | ++fNEvents; | |
134 | } | |
135 | //______________________________________________________________________ | |
136 | Double_t AliITSOnlineSDDInjectors::GetRMSDriftSpeed(Int_t ipad) const { | |
137 | // | |
138 | if(fNEvents<=1) return 0.; | |
139 | Double_t mean=fSumDriftSpeed[ipad]/(Double_t)fNEvents; | |
140 | Double_t diff=fSumSqDriftSpeed[ipad]/(Double_t)fNEvents-mean*mean; | |
141 | if(diff<0.) diff=0.; | |
142 | return TMath::Sqrt(diff); | |
143 | } | |
144 | ||
145 | //______________________________________________________________________ | |
146 | void AliITSOnlineSDDInjectors::FitMeanDriftSpeedVsAnode(){ | |
147 | // Calculates | |
148 | if(fNEvents==0) return; | |
149 | for(Int_t i=0;i<kInjPads;i++){ | |
150 | fDriftSpeed[i]=GetMeanDriftSpeed(i); | |
151 | if(fNEvents>1){ | |
152 | Double_t rms=GetRMSDriftSpeed(i); | |
153 | if(rms>0.) fDriftSpeedErr[i]=rms/TMath::Sqrt(fNEvents); | |
154 | } | |
155 | } | |
156 | FitDriftSpeedVsAnode(); | |
157 | } | |
158 | //______________________________________________________________________ | |
9f026db8 | 159 | TGraphErrors* AliITSOnlineSDDInjectors::GetTimeVsDistGraph(Int_t jpad) const{ |
348f80b7 | 160 | // |
9f026db8 | 161 | const Int_t kPts=kInjLines+1; |
162 | Float_t x[kPts],y[kPts],ex[kPts],ey[kPts]; | |
348f80b7 | 163 | x[0]=0.; |
164 | ex[0]=0.; | |
165 | y[0]=fTbZero; | |
166 | ey[0]=0.; | |
9f026db8 | 167 | for(Int_t i=0;i<kInjLines;i++){ |
348f80b7 | 168 | x[i+1]=fPosition[i]; |
169 | ex[i+1]=0.; | |
9f026db8 | 170 | y[i+1]=fCentroid[jpad][i]; |
171 | ey[i+1]=fRMSCentroid[jpad][i]; | |
348f80b7 | 172 | } |
173 | TGraphErrors *g=new TGraphErrors(4,x,y,ex,ey); | |
174 | return g; | |
175 | } | |
9f026db8 | 176 | |
348f80b7 | 177 | //______________________________________________________________________ |
9f026db8 | 178 | TGraphErrors* AliITSOnlineSDDInjectors::GetDriftSpeedGraph() const{ |
348f80b7 | 179 | // |
348f80b7 | 180 | Int_t ipt=0; |
181 | TGraphErrors *g=new TGraphErrors(0); | |
9f026db8 | 182 | for(Int_t i=0;i<kInjPads;i++){ |
183 | if(fDriftSpeed[i]>0){ | |
184 | g->SetPoint(ipt,GetAnodeNumber(i),fDriftSpeed[i]); | |
185 | g->SetPointError(ipt,0,fDriftSpeedErr[i]); | |
348f80b7 | 186 | ipt++; |
187 | } | |
188 | } | |
189 | return g; | |
190 | } | |
191 | //______________________________________________________________________ | |
84df0230 | 192 | TGraphErrors* AliITSOnlineSDDInjectors::GetSelectedDriftSpeedGraph(Int_t minAcceptStatus) const{ |
193 | // TGraphErrors with only pads with status of injector >= minAcceptStatus | |
194 | Int_t ipt=0; | |
195 | TGraphErrors *g=new TGraphErrors(0); | |
196 | for(Int_t i=0;i<kInjPads;i++){ | |
197 | Int_t padStatus = GetInjPadStatus(i); | |
198 | if(fDriftSpeed[i]>0 && padStatus >= minAcceptStatus ){ | |
199 | g->SetPoint(ipt,GetAnodeNumber(i),fDriftSpeed[i]); | |
200 | g->SetPointError(ipt,0,fDriftSpeedErr[i]); | |
201 | ipt++; | |
202 | } | |
203 | } | |
204 | return g; | |
205 | } | |
206 | //______________________________________________________________________ | |
348f80b7 | 207 | void AliITSOnlineSDDInjectors::CalcTimeBinZero(){ |
784a52ed | 208 | // Get time zero from trigger signal |
2ca27861 | 209 | Double_t tzero=0.,intCont=0.,rmsPeak=0.; |
784a52ed | 210 | Bool_t isTbUsed[256]; |
211 | Int_t nTbUsed=0; | |
212 | for(Int_t i=0;i<256;i++) isTbUsed[i]=0; | |
348f80b7 | 213 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
214 | for(Int_t itb=1;itb<fTbMin[0];itb++){ | |
2ca27861 | 215 | Double_t cont=fHisto->GetBinContent(itb,ian+1); |
216 | Double_t contm1=fHisto->GetBinContent(itb+1,ian+1); | |
217 | Double_t contp1=fHisto->GetBinContent(itb-1,ian+1); | |
9f026db8 | 218 | if(cont>fLowThreshold){ |
784a52ed | 219 | if(contm1>fHighThreshold || cont>fHighThreshold || contp1>fHighThreshold){ |
220 | tzero+=cont*float(itb); | |
221 | rmsPeak+=cont*float(itb)*float(itb); | |
222 | intCont+=cont; | |
223 | if(!isTbUsed[itb]){ | |
224 | isTbUsed[itb]=1; | |
225 | ++nTbUsed; | |
226 | } | |
227 | } | |
348f80b7 | 228 | } |
229 | } | |
230 | } | |
784a52ed | 231 | if(intCont>0){ |
232 | fTbZero=tzero/intCont; | |
233 | fRMSTbZero=TMath::Sqrt(rmsPeak/intCont-fTbZero*fTbZero); | |
234 | } | |
235 | if(nTbUsed==1) fRMSTbZero=0.5; | |
348f80b7 | 236 | } |
237 | //______________________________________________________________________ | |
9f026db8 | 238 | void AliITSOnlineSDDInjectors::FitDriftSpeedVsAnode(){ |
239 | // fits the anode dependence of drift speed with a polynomial function | |
4ff6aa93 | 240 | const Int_t kNn=fPolOrder+1; |
2ca27861 | 241 | Double_t **mat = new Double_t*[kNn]; |
242 | for(Int_t i=0; i < kNn; i++) mat[i] = new Double_t[kNn]; | |
243 | Double_t *vect = new Double_t[kNn]; | |
9f026db8 | 244 | |
4ff6aa93 | 245 | for(Int_t k1=0;k1<kNn;k1++){ |
348f80b7 | 246 | vect[k1]=0; |
4ff6aa93 | 247 | for(Int_t k2=0;k2<kNn;k2++){ |
348f80b7 | 248 | mat[k1][k2]=0; |
348f80b7 | 249 | } |
250 | } | |
06bb3583 | 251 | Int_t npts = 0; |
4ff6aa93 | 252 | for(Int_t k1=0;k1<kNn;k1++){ |
9f026db8 | 253 | for(Int_t jpad=fFirstPadForFit; jpad<=fLastPadForFit; jpad++){ |
2ca27861 | 254 | Double_t x=(Double_t)GetAnodeNumber(jpad); |
9f026db8 | 255 | if(fDriftSpeed[jpad]>0 && GetInjPadStatus(jpad)>fPadStatusCutForFit){ |
256 | vect[k1]+=fDriftSpeed[jpad]*TMath::Power(x,k1)/TMath::Power(fDriftSpeedErr[jpad],2); | |
06bb3583 | 257 | if(k1==0) npts++; |
9f026db8 | 258 | for(Int_t k2=0;k2<kNn;k2++){ |
9f026db8 | 259 | mat[k1][k2]+=TMath::Power(x,k1+k2)/TMath::Power(fDriftSpeedErr[jpad],2); |
260 | } | |
261 | } | |
348f80b7 | 262 | } |
263 | } | |
06bb3583 | 264 | if(npts<fPolOrder+1){ |
265 | if(fParam) delete [] fParam; | |
2ca27861 | 266 | fParam=new Double_t[kNn]; |
06bb3583 | 267 | for(Int_t i=0; i<kNn;i++)fParam[i]=0; |
268 | }else{ | |
269 | Int_t *iPivot = new Int_t[kNn]; | |
270 | Int_t *indxR = new Int_t[kNn]; | |
271 | Int_t *indxC = new Int_t[kNn]; | |
272 | for(Int_t i=0;i<kNn;i++) iPivot[i]=0; | |
273 | Int_t iCol=-1,iRow=-1; | |
274 | for(Int_t i=0;i<kNn;i++){ | |
2ca27861 | 275 | Double_t big=0.; |
06bb3583 | 276 | for(Int_t j=0;j<kNn;j++){ |
277 | if(iPivot[j]!=1){ | |
278 | for(Int_t k=0;k<kNn;k++){ | |
279 | if(iPivot[k]==0){ | |
280 | if(TMath::Abs(mat[j][k])>=big){ | |
281 | big=TMath::Abs(mat[j][k]); | |
282 | iRow=j; | |
283 | iCol=k; | |
284 | } | |
285 | } | |
348f80b7 | 286 | } |
287 | } | |
288 | } | |
06bb3583 | 289 | iPivot[iCol]++; |
2ca27861 | 290 | Double_t aux; |
06bb3583 | 291 | if(iRow!=iCol){ |
292 | for(Int_t l=0;l<kNn;l++){ | |
293 | aux=mat[iRow][l]; | |
294 | mat[iRow][l]=mat[iCol][l]; | |
295 | mat[iCol][l]=aux; | |
296 | } | |
297 | aux=vect[iRow]; | |
298 | vect[iRow]=vect[iCol]; | |
299 | vect[iCol]=aux; | |
348f80b7 | 300 | } |
06bb3583 | 301 | indxR[i]=iRow; |
302 | indxC[i]=iCol; | |
303 | if(mat[iCol][iCol]==0) break; | |
2ca27861 | 304 | Double_t pivinv=1./mat[iCol][iCol]; |
06bb3583 | 305 | mat[iCol][iCol]=1; |
306 | for(Int_t l=0;l<kNn;l++) mat[iCol][l]*=pivinv; | |
307 | vect[iCol]*=pivinv; | |
308 | for(Int_t m=0;m<kNn;m++){ | |
309 | if(m!=iCol){ | |
310 | aux=mat[m][iCol]; | |
311 | mat[m][iCol]=0; | |
312 | for(Int_t n=0;n<kNn;n++) mat[m][n]-=mat[iCol][n]*aux; | |
313 | vect[m]-=vect[iCol]*aux; | |
314 | } | |
315 | } | |
348f80b7 | 316 | } |
06bb3583 | 317 | delete [] iPivot; |
318 | delete [] indxR; | |
319 | delete [] indxC; | |
320 | ||
321 | ||
322 | if(fParam) delete [] fParam; | |
2ca27861 | 323 | fParam=new Double_t[kNn]; |
06bb3583 | 324 | for(Int_t i=0; i<kNn;i++)fParam[i]=vect[i]; |
348f80b7 | 325 | } |
348f80b7 | 326 | |
4ff6aa93 | 327 | for(Int_t i=0; i < kNn; i++) delete [] mat[i]; |
348f80b7 | 328 | delete [] mat; |
329 | delete [] vect; | |
330 | } | |
331 | //______________________________________________________________________ | |
9f026db8 | 332 | void AliITSOnlineSDDInjectors::CalcDriftSpeed(Int_t jpad){ |
348f80b7 | 333 | // |
2ca27861 | 334 | Double_t sumY=0,sumX=0,sumXX=0,sumYY=0.,sumXY=0,sumWEI=0.; |
348f80b7 | 335 | Int_t npt=0; |
2ca27861 | 336 | Double_t y[kInjLines],ey[kInjLines]; |
337 | Double_t tzero=0,erry=0; | |
9f026db8 | 338 | for(Int_t i=0;i<kInjLines;i++){ |
339 | y[i]=fCentroid[jpad][i]; | |
340 | ey[i]=fRMSCentroid[jpad][i]; | |
348f80b7 | 341 | } |
9f026db8 | 342 | for(Int_t i=0;i<kInjLines;i++){ |
343 | if(fGoodInj[jpad][i] && ey[i]!=0){ | |
348f80b7 | 344 | sumY+=y[i]/ey[i]/ey[i]; |
345 | sumX+=fPosition[i]/ey[i]/ey[i]; | |
346 | sumXX+=fPosition[i]*fPosition[i]/ey[i]/ey[i]; | |
347 | sumYY+=y[i]*y[i]/ey[i]/ey[i]; | |
348 | sumXY+=fPosition[i]*y[i]/ey[i]/ey[i]; | |
349 | sumWEI+=1./ey[i]/ey[i]; | |
350 | tzero=fTbZero/ey[i]/ey[i]; | |
784a52ed | 351 | erry=ey[i]/ey[i]/ey[i]; |
348f80b7 | 352 | npt++; |
353 | } | |
354 | } | |
2ca27861 | 355 | Double_t slope=0.,eslope=0.; |
784a52ed | 356 | if(npt==1){ |
357 | slope=(sumY-tzero)/sumX; | |
358 | eslope=erry/sumX; | |
359 | } | |
348f80b7 | 360 | if(npt>1){ |
784a52ed | 361 | if(fUseTimeZeroSignal){ |
362 | sumY+=fTbZero/fRMSTbZero/fRMSTbZero; | |
363 | sumX+=0.; | |
364 | sumXX+=0.; | |
365 | sumYY+=fTbZero*fTbZero/fRMSTbZero/fRMSTbZero; | |
366 | sumXY+=0.; | |
367 | sumWEI+=1./fRMSTbZero/fRMSTbZero; | |
53855521 | 368 | } |
784a52ed | 369 | slope=(sumWEI*sumXY-sumY*sumX)/(sumWEI*sumXX-sumX*sumX); |
370 | eslope=TMath::Sqrt(sumWEI/(sumWEI*sumXX-sumX*sumX)); | |
348f80b7 | 371 | } |
784a52ed | 372 | |
2ca27861 | 373 | Double_t vel=0,evel=0; |
784a52ed | 374 | if(slope!=0. && fTimeStep>0.){ |
375 | vel=1./slope*10000./fTimeStep;// micron/ns | |
376 | evel=eslope/slope/slope*10000./fTimeStep;// micron/ns | |
348f80b7 | 377 | } |
9f026db8 | 378 | if(vel>fMaxDriftSpeed||vel<fMinDriftSpeed || evel>fMaxDriftSpeedErr){ |
348f80b7 | 379 | vel=0.; |
380 | evel=0.; | |
381 | } | |
9f026db8 | 382 | fDriftSpeed[jpad]=vel; |
383 | fDriftSpeedErr[jpad]=evel; | |
348f80b7 | 384 | } |
385 | //______________________________________________________________________ | |
9f026db8 | 386 | Int_t AliITSOnlineSDDInjectors::GetAnodeNumber(Int_t iInjPad) const{ |
61606350 | 387 | // Injectors location along anodes: |
388 | // Side left (UP) - channel 0: injectors on anodes 0,7,15,...,247,255 | |
389 | // Side right (DOWN) - channel 1: injectors on anodes 0,8,16,...,248,255 | |
348f80b7 | 390 | Int_t ian=-1; |
9f026db8 | 391 | if(iInjPad>=kInjPads) return ian; |
61606350 | 392 | if(fSide==1){ // right side |
9f026db8 | 393 | ian=iInjPad*8; |
394 | if(iInjPad==32) ian--; | |
61606350 | 395 | }else{ // left side |
9f026db8 | 396 | ian=iInjPad*8-1; |
397 | if(iInjPad==0) ian=0; | |
348f80b7 | 398 | } |
399 | return ian; | |
400 | } | |
84c6e6c0 | 401 | //______________________________________________________________________ |
9f026db8 | 402 | Int_t AliITSOnlineSDDInjectors::GetInjPadNumberFromAnode(Int_t nAnode) const{ |
84c6e6c0 | 403 | // |
9f026db8 | 404 | Int_t iInjPad=-1; |
61606350 | 405 | if(fSide==1){ // right side |
9f026db8 | 406 | if(nAnode%8==0) iInjPad=nAnode/8; |
407 | if(nAnode==255) iInjPad=32; | |
61606350 | 408 | }else{ // left side |
9f026db8 | 409 | if(nAnode%8==7) iInjPad=1+nAnode/8; |
410 | if(nAnode==0) iInjPad=0; | |
84c6e6c0 | 411 | } |
9f026db8 | 412 | if(nAnode>=256) iInjPad=-1; |
413 | return iInjPad; | |
84c6e6c0 | 414 | } |
415 | //______________________________________________________________________ | |
9f026db8 | 416 | Int_t AliITSOnlineSDDInjectors::GetInjPadStatus(Int_t jpad) const{ |
417 | // returns an integer value with status of injector lines for given pad/anode | |
418 | // status=7 --> 111 all injector are good | |
419 | // status=6 --> 110 1st line (close to anodes) is bad, other two are good | |
420 | // .... | |
421 | // status=1 --> 001 only 1st line (close to anodes) good | |
422 | // status=0 --> 000 all lines are bad | |
84c6e6c0 | 423 | Int_t istatus=0; |
9f026db8 | 424 | if(jpad>=0 && jpad<kInjPads){ |
425 | for(Int_t jlin=0;jlin<kInjLines;jlin++) istatus+=fGoodInj[jpad][jlin]<<jlin; | |
84c6e6c0 | 426 | } |
427 | return istatus; | |
428 | } | |
348f80b7 | 429 | //______________________________________________________________________ |
430 | void AliITSOnlineSDDInjectors::FindGoodInjectors(){ | |
431 | // | |
9f026db8 | 432 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
433 | Int_t ian=GetAnodeNumber(jpad); | |
434 | for(Int_t jlin=0;jlin<kInjLines;jlin++){ | |
435 | for(Int_t jjj=fTbMin[jlin];jjj<fTbMax[jlin];jjj++){ | |
348f80b7 | 436 | Float_t c1=fHisto->GetBinContent(jjj,ian+1); |
437 | Float_t c2=fHisto->GetBinContent(jjj+1,ian+1); | |
a7996467 | 438 | // Float_t c3=fHisto->GetBinContent(jjj+2,ian+1); |
439 | if(c1>fLowThreshold && c2>fLowThreshold){ | |
440 | if(c1>fHighThreshold || c2>fHighThreshold){ | |
441 | fGoodInj[jpad][jlin]=1; | |
442 | break; | |
443 | } | |
348f80b7 | 444 | } |
445 | } | |
348f80b7 | 446 | } |
447 | } | |
448 | } | |
449 | //______________________________________________________________________ | |
450 | void AliITSOnlineSDDInjectors::FindCentroids(){ | |
451 | // | |
9f026db8 | 452 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
453 | Int_t ian=GetAnodeNumber(jpad); | |
454 | for(Int_t jlin=0;jlin<kInjLines;jlin++){ | |
455 | if(!fGoodInj[jpad][jlin]) continue; | |
2ca27861 | 456 | Double_t maxcont=0; |
348f80b7 | 457 | Int_t ilmax=-1; |
9f026db8 | 458 | for(Int_t jjj=fTbMin[jlin];jjj<fTbMax[jlin];jjj++){ |
2ca27861 | 459 | Double_t cont=fHisto->GetBinContent(jjj,ian+1); |
348f80b7 | 460 | if(cont>maxcont){ |
461 | maxcont=cont; | |
462 | ilmax=jjj; | |
463 | } | |
464 | } | |
2ca27861 | 465 | Double_t intCont=0; |
348f80b7 | 466 | Int_t jjj=ilmax; |
467 | while(1){ | |
2ca27861 | 468 | Double_t cont=fHisto->GetBinContent(jjj,ian+1); |
9f026db8 | 469 | if(cont<fLowThreshold) break; |
348f80b7 | 470 | if(cont<fgkSaturation){ |
2ca27861 | 471 | fCentroid[jpad][jlin]+=cont*(Double_t)jjj; |
472 | fRMSCentroid[jpad][jlin]+=cont*(Double_t)jjj*(Double_t)jjj; | |
348f80b7 | 473 | intCont+=cont; |
474 | } | |
475 | jjj--; | |
476 | } | |
477 | jjj=ilmax+1; | |
478 | while(1){ | |
2ca27861 | 479 | Double_t cont=fHisto->GetBinContent(jjj,ian+1); |
9f026db8 | 480 | if(cont<fLowThreshold) break; |
348f80b7 | 481 | if(cont<fgkSaturation){ |
9f026db8 | 482 | fCentroid[jpad][jlin]+=cont*float(jjj); |
2ca27861 | 483 | fRMSCentroid[jpad][jlin]+=cont*(Double_t)jjj*(Double_t)jjj; |
348f80b7 | 484 | intCont+=cont; |
485 | } | |
486 | jjj++; | |
487 | } | |
488 | if(intCont>0){ | |
9f026db8 | 489 | fCentroid[jpad][jlin]/=intCont; |
2ca27861 | 490 | fRMSCentroid[jpad][jlin]=TMath::Sqrt(fRMSCentroid[jpad][jlin]/intCont-fCentroid[jpad][jlin]*fCentroid[jpad][jlin])/TMath::Sqrt(intCont); |
348f80b7 | 491 | } |
492 | else{ | |
9f026db8 | 493 | fCentroid[jpad][jlin]=0.; |
494 | fRMSCentroid[jpad][jlin]=0.; | |
495 | fGoodInj[jpad][jlin]=0; | |
348f80b7 | 496 | } |
9f026db8 | 497 | if(fRMSCentroid[jpad][jlin]==0) fGoodInj[jpad][jlin]=0; |
348f80b7 | 498 | } |
499 | } | |
500 | } | |
501 | //______________________________________________________________________ | |
9f026db8 | 502 | void AliITSOnlineSDDInjectors::PrintInjectorStatus(){ |
348f80b7 | 503 | // |
9f026db8 | 504 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
505 | printf("Line%d-Anode%d: %d %d %d\n",jpad,GetAnodeNumber(jpad),fGoodInj[jpad][0],fGoodInj[jpad][1],fGoodInj[jpad][2]); | |
348f80b7 | 506 | } |
507 | } | |
508 | //______________________________________________________________________ | |
509 | void AliITSOnlineSDDInjectors::PrintCentroids(){ | |
510 | // | |
9f026db8 | 511 | for(Int_t jpad=0;jpad<kInjPads;jpad++){ |
512 | 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 | 513 | } |
514 | } | |
515 | //______________________________________________________________________ | |
4c82df4c | 516 | void AliITSOnlineSDDInjectors::WriteToASCII(Int_t evNumb, UInt_t timeStamp, Int_t optAppend){ |
348f80b7 | 517 | // |
518 | Char_t outfilnam[100]; | |
979b5a5f | 519 | sprintf(outfilnam,"SDDinj_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide); |
4c82df4c | 520 | FILE* outf; |
18da6e54 | 521 | if(optAppend==0){ |
522 | outf=fopen(outfilnam,"w"); | |
523 | fprintf(outf,"%d\n",fPolOrder); | |
524 | } | |
4c82df4c | 525 | else outf=fopen(outfilnam,"a"); |
526 | fprintf(outf,"%d %d ",evNumb,timeStamp); | |
348f80b7 | 527 | for(Int_t ic=0;ic<fPolOrder+1;ic++){ |
528 | fprintf(outf,"%G ",fParam[ic]); | |
529 | } | |
530 | fprintf(outf,"\n"); | |
531 | fclose(outf); | |
532 | } |