]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSOnlineSDDInjectors.cxx
Correct formula for phi, in case of current local X <0, in GetLocalXat and GetPhiZat
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSDDInjectors.cxx
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
20 /* $Id$ */
21
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.;
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;
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};
41
42 //______________________________________________________________________
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)
44 {
45   // default constructor
46   SetPositions();
47   SetDefaults();
48   SetTimeStep(fgkDefaultTimeStep);
49 }
50 //______________________________________________________________________
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)
52
53 // standard constructor
54   SetPositions();
55   SetDefaults();
56   SetTimeStep(fgkDefaultTimeStep);
57 }
58 //______________________________________________________________________
59 AliITSOnlineSDDInjectors::~AliITSOnlineSDDInjectors(){
60   // Destructor
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;  
64   if(fParam) delete [] fParam;
65 }
66 //______________________________________________________________________
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 //______________________________________________________________________
79 void AliITSOnlineSDDInjectors::SetPositions(){
80   // 
81   Double_t xLinFromCenterUm[kInjLines]={31860.,17460.,660.};
82   Double_t xAnodeFromCenterUm=35085;
83   for(Int_t i=0;i<kInjLines;i++){
84     fPosition[i]=xAnodeFromCenterUm-xLinFromCenterUm[i];
85     fPosition[i]/=10000.; // from microns to cm
86   }
87 }
88 //______________________________________________________________________
89 void AliITSOnlineSDDInjectors::Reset(){
90   //
91   for(Int_t i=0;i<kInjPads;i++){ 
92     fDriftSpeed[i]=0.;
93     fDriftSpeedErr[i]=0.;
94   }
95   for(Int_t i=0;i<kInjPads;i++){
96     for(Int_t j=0;j<kInjLines;j++){
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();
111   for(Int_t j=0;j<kInjPads;j++) CalcDriftSpeed(j);
112   FitDriftSpeedVsAnode();
113 }
114 //______________________________________________________________________
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 //______________________________________________________________________
159 TGraphErrors* AliITSOnlineSDDInjectors::GetTimeVsDistGraph(Int_t jpad) const{
160   // 
161   const Int_t kPts=kInjLines+1;
162   Float_t x[kPts],y[kPts],ex[kPts],ey[kPts];
163   x[0]=0.;
164   ex[0]=0.;
165   y[0]=fTbZero;
166   ey[0]=0.;
167   for(Int_t i=0;i<kInjLines;i++){
168     x[i+1]=fPosition[i];
169     ex[i+1]=0.;
170     y[i+1]=fCentroid[jpad][i];
171     ey[i+1]=fRMSCentroid[jpad][i];
172   }
173   TGraphErrors *g=new TGraphErrors(4,x,y,ex,ey);
174   return g;
175 }
176
177 //______________________________________________________________________
178 TGraphErrors* AliITSOnlineSDDInjectors::GetDriftSpeedGraph() const{
179   // 
180   Int_t ipt=0;
181   TGraphErrors *g=new TGraphErrors(0);
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]);
186       ipt++;
187     }
188   }
189   return g;
190 }
191 //______________________________________________________________________
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 //______________________________________________________________________
207 void AliITSOnlineSDDInjectors::CalcTimeBinZero(){
208   // Get time zero from trigger signal
209   Double_t tzero=0.,intCont=0.,rmsPeak=0.;
210   Bool_t isTbUsed[256];
211   Int_t nTbUsed=0;
212   for(Int_t i=0;i<256;i++) isTbUsed[i]=0;
213   for(Int_t ian=0;ian<fgkNAnodes;ian++){
214     for(Int_t itb=1;itb<fTbMin[0];itb++){
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);
218       if(cont>fLowThreshold){
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         }
228       }
229     }
230   }
231   if(intCont>0){ 
232     fTbZero=tzero/intCont;
233     fRMSTbZero=TMath::Sqrt(rmsPeak/intCont-fTbZero*fTbZero);
234   }
235   if(nTbUsed==1) fRMSTbZero=0.5; 
236 }
237 //______________________________________________________________________
238 void AliITSOnlineSDDInjectors::FitDriftSpeedVsAnode(){
239   // fits the anode dependence of drift speed with a polynomial function
240   const Int_t kNn=fPolOrder+1;
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];
244
245   for(Int_t k1=0;k1<kNn;k1++){
246     vect[k1]=0;
247     for(Int_t k2=0;k2<kNn;k2++){
248       mat[k1][k2]=0;
249     }
250   }
251   Int_t npts = 0;
252   for(Int_t k1=0;k1<kNn;k1++){
253     for(Int_t jpad=fFirstPadForFit; jpad<=fLastPadForFit; jpad++){
254       Double_t x=(Double_t)GetAnodeNumber(jpad);
255       if(fDriftSpeed[jpad]>0 && GetInjPadStatus(jpad)>fPadStatusCutForFit){
256           vect[k1]+=fDriftSpeed[jpad]*TMath::Power(x,k1)/TMath::Power(fDriftSpeedErr[jpad],2);  
257           if(k1==0) npts++;
258           for(Int_t k2=0;k2<kNn;k2++){
259             mat[k1][k2]+=TMath::Power(x,k1+k2)/TMath::Power(fDriftSpeedErr[jpad],2);
260           }
261       }
262     }
263   }
264   if(npts<fPolOrder+1){ 
265     if(fParam) delete [] fParam;
266     fParam=new Double_t[kNn];
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++){
275       Double_t big=0.;
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             }
286           }
287         }
288       }
289       iPivot[iCol]++;
290       Double_t aux;
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;
300       }
301       indxR[i]=iRow;
302       indxC[i]=iCol;
303       if(mat[iCol][iCol]==0) break;
304       Double_t pivinv=1./mat[iCol][iCol];
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       }    
316     }
317     delete [] iPivot;
318     delete [] indxR;
319     delete [] indxC;
320     
321   
322     if(fParam) delete [] fParam;
323     fParam=new Double_t[kNn];
324     for(Int_t i=0; i<kNn;i++)fParam[i]=vect[i];
325   }
326
327   for(Int_t i=0; i < kNn; i++) delete [] mat[i];
328   delete [] mat;
329   delete [] vect;
330 }
331 //______________________________________________________________________
332 void AliITSOnlineSDDInjectors::CalcDriftSpeed(Int_t jpad){
333   // 
334   Double_t sumY=0,sumX=0,sumXX=0,sumYY=0.,sumXY=0,sumWEI=0.;
335   Int_t npt=0;
336   Double_t y[kInjLines],ey[kInjLines];
337   Double_t tzero=0,erry=0;
338   for(Int_t i=0;i<kInjLines;i++){ 
339     y[i]=fCentroid[jpad][i];
340     ey[i]=fRMSCentroid[jpad][i];
341   }
342   for(Int_t i=0;i<kInjLines;i++){
343     if(fGoodInj[jpad][i] && ey[i]!=0){
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];
351       erry=ey[i]/ey[i]/ey[i];
352       npt++;
353     }
354   }
355   Double_t slope=0.,eslope=0.;
356   if(npt==1){
357     slope=(sumY-tzero)/sumX;
358     eslope=erry/sumX;
359   }
360   if(npt>1){ 
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;
368     }
369     slope=(sumWEI*sumXY-sumY*sumX)/(sumWEI*sumXX-sumX*sumX);
370     eslope=TMath::Sqrt(sumWEI/(sumWEI*sumXX-sumX*sumX));
371   }
372
373   Double_t vel=0,evel=0;
374   if(slope!=0. && fTimeStep>0.){
375     vel=1./slope*10000./fTimeStep;// micron/ns
376     evel=eslope/slope/slope*10000./fTimeStep;// micron/ns
377   }
378   if(vel>fMaxDriftSpeed||vel<fMinDriftSpeed || evel>fMaxDriftSpeedErr){ 
379     vel=0.;
380     evel=0.;
381   }
382   fDriftSpeed[jpad]=vel;
383   fDriftSpeedErr[jpad]=evel;
384 }
385 //______________________________________________________________________
386 Int_t AliITSOnlineSDDInjectors::GetAnodeNumber(Int_t iInjPad) const{
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 
390   Int_t ian=-1;
391   if(iInjPad>=kInjPads) return ian;
392   if(fSide==1){  // right side
393     ian=iInjPad*8;
394     if(iInjPad==32) ian--;
395   }else{         // left side
396     ian=iInjPad*8-1;
397     if(iInjPad==0) ian=0;
398   }
399   return ian;
400 }
401 //______________________________________________________________________
402 Int_t AliITSOnlineSDDInjectors::GetInjPadNumberFromAnode(Int_t nAnode) const{
403   //
404   Int_t iInjPad=-1;
405   if(fSide==1){  // right side
406     if(nAnode%8==0) iInjPad=nAnode/8;
407     if(nAnode==255) iInjPad=32;
408   }else{         // left side
409     if(nAnode%8==7) iInjPad=1+nAnode/8;
410     if(nAnode==0) iInjPad=0;
411   }
412   if(nAnode>=256) iInjPad=-1;
413   return iInjPad;
414 }
415 //______________________________________________________________________
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
423   Int_t istatus=0;
424   if(jpad>=0 && jpad<kInjPads){
425     for(Int_t jlin=0;jlin<kInjLines;jlin++) istatus+=fGoodInj[jpad][jlin]<<jlin;
426   }
427   return istatus;
428 }
429 //______________________________________________________________________
430 void AliITSOnlineSDDInjectors::FindGoodInjectors(){
431   // 
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++){
436         Float_t c1=fHisto->GetBinContent(jjj,ian+1);
437         Float_t c2=fHisto->GetBinContent(jjj+1,ian+1);
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           }
444         }
445       }
446     }
447   }
448 }
449 //______________________________________________________________________
450 void AliITSOnlineSDDInjectors::FindCentroids(){
451   // 
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;
456       Double_t maxcont=0;
457       Int_t ilmax=-1;
458       for(Int_t jjj=fTbMin[jlin];jjj<fTbMax[jlin];jjj++){
459         Double_t cont=fHisto->GetBinContent(jjj,ian+1);
460         if(cont>maxcont){
461           maxcont=cont;
462           ilmax=jjj;
463         }
464       }
465       Double_t intCont=0;
466       Int_t jjj=ilmax;
467       while(1){
468         Double_t cont=fHisto->GetBinContent(jjj,ian+1);
469         if(cont<fLowThreshold) break;
470         if(cont<fgkSaturation){
471           fCentroid[jpad][jlin]+=cont*(Double_t)jjj;
472           fRMSCentroid[jpad][jlin]+=cont*(Double_t)jjj*(Double_t)jjj;
473           intCont+=cont;
474         }
475         jjj--;
476       }
477       jjj=ilmax+1;
478       while(1){
479         Double_t cont=fHisto->GetBinContent(jjj,ian+1);
480         if(cont<fLowThreshold) break;
481         if(cont<fgkSaturation){
482           fCentroid[jpad][jlin]+=cont*float(jjj);
483           fRMSCentroid[jpad][jlin]+=cont*(Double_t)jjj*(Double_t)jjj;
484           intCont+=cont;
485         }
486         jjj++;
487       }
488       if(intCont>0){ 
489         fCentroid[jpad][jlin]/=intCont;
490         fRMSCentroid[jpad][jlin]=TMath::Sqrt(fRMSCentroid[jpad][jlin]/intCont-fCentroid[jpad][jlin]*fCentroid[jpad][jlin])/TMath::Sqrt(intCont);
491       }
492       else{ 
493         fCentroid[jpad][jlin]=0.;
494         fRMSCentroid[jpad][jlin]=0.;
495         fGoodInj[jpad][jlin]=0;
496       }
497       if(fRMSCentroid[jpad][jlin]==0) fGoodInj[jpad][jlin]=0;
498     }
499   }
500 }
501 //______________________________________________________________________
502 void AliITSOnlineSDDInjectors::PrintInjectorStatus(){
503   //
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]);
506   }
507 }
508 //______________________________________________________________________
509 void AliITSOnlineSDDInjectors::PrintCentroids(){
510   //
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]);
513   }
514 }
515 //______________________________________________________________________
516 void AliITSOnlineSDDInjectors::WriteToASCII(Int_t evNumb, UInt_t timeStamp, Int_t optAppend){
517   //
518   Char_t outfilnam[100];
519   sprintf(outfilnam,"SDDinj_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);  
520   FILE* outf;
521   if(optAppend==0){ 
522     outf=fopen(outfilnam,"w");
523     fprintf(outf,"%d\n",fPolOrder);
524   }
525   else outf=fopen(outfilnam,"a");
526   fprintf(outf,"%d   %d   ",evNumb,timeStamp);
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 }