]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSOnlineSPDscanAnalyzer.cxx
Removing useless flag.
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDscanAnalyzer.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
16 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////
19 // Author: Henrik Tydesjo                                 //
20 // This class is used in the detector algorithm framework //
21 // to process the data stored in special container files  //
22 // (see AliITSOnlineSPDscan). For instance, minimum       //
23 // threshold values can be extracted.                     //
24 ////////////////////////////////////////////////////////////
25
26 #include "AliITSOnlineSPDscanAnalyzer.h"
27 #include "AliITSOnlineSPDscan.h"
28 #include "AliITSOnlineSPDscanSingle.h"
29 #include "AliITSOnlineSPDscanMultiple.h"
30 #include "AliITSOnlineSPDscanMeanTh.h"
31 #include "AliITSOnlineCalibrationSPDhandler.h"
32 #include "AliITSRawStreamSPD.h"
33 #include <TStyle.h>
34 #include <TMath.h>
35 #include <TLine.h>
36 #include <TF1.h>
37 #include <TGraph.h>
38 #include <TH2F.h>
39 #include <TError.h>
40 #include <iostream>
41 #include <fstream>
42
43 using std::ifstream;
44
45 Double_t itsSpdErrorf(Double_t *x, Double_t *par){
46   if (par[2]<0) par[2]=0;
47   Double_t val = par[2]+(0.12*256*32-par[2])*(0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
48   return val;
49 }
50 //Double_t itsSpdErrorfOrig(Double_t *x, Double_t *par){
51 //  return 0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.));
52 //}
53 //_________________________________________________________________________
54 Double_t itsSpdScurveForMeanTh(Double_t *x, Double_t *par){
55   if (par[2]<0) par[2]=0;
56   Double_t val = 1.- par[2]*(1.-TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
57 //  Double_t val = par[2]+(0.12*256*32-par[2])*(0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
58   return val;
59 }
60
61 //_________________________________________________________________________
62 AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const Char_t *fileName, AliITSOnlineCalibrationSPDhandler *handler, Bool_t readFromGridFile) :
63   fType(99),fDacId(99),fFileName(fileName),fScanObj(NULL),fHandler(handler),fTriggers(NULL),fTPeff(0),fTPeffHS(NULL),fDeadPixel(0),fDeadPixelHS(NULL),fNoisyPixel(0),fNoisyPixelHS(NULL),
64   fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
65   fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
66 {
67   // constructor
68   for (UInt_t chipNr=0; chipNr<11; chipNr++) {
69     for (UInt_t hs=0; hs<6; hs++) {
70       fMeanMultiplicity[hs][chipNr]=NULL;
71       fHitEventEfficiency[hs][chipNr]=NULL;
72     }
73   }
74   for (UInt_t hs=0; hs<6; hs++) {
75     fTPeffChip[hs]=NULL;
76     fDeadPixelChip[hs]=NULL;
77     fNoisyPixelChip[hs]=NULL;
78   }
79
80   for (UInt_t mod=0; mod<240; mod++) {
81     fbModuleScanned[mod]=kFALSE;
82   }
83
84   Init(readFromGridFile);
85 }
86 //_________________________________________________________________________
87 AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const AliITSOnlineSPDscanAnalyzer& handle) :
88   fType(99),fDacId(99),fFileName("."),fScanObj(NULL),fHandler(NULL),fTriggers(NULL),fTPeff(0),fTPeffHS(NULL),fDeadPixel(0),fDeadPixelHS(NULL),fNoisyPixel(0),fNoisyPixelHS(NULL),
89   fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
90   fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
91 {
92   // copy constructor, only copies the filename and params (not the processed data)
93   fFileName=handle.fFileName;
94   fOverWrite=handle.fOverWrite;
95   fNoiseThreshold=handle.fNoiseThreshold;
96   fNoiseMinimumEvents=handle.fNoiseMinimumEvents;
97   fMinNrStepsBeforeIncrease=handle.fMinNrStepsBeforeIncrease;
98   fMinIncreaseFromBaseLine=handle.fMinIncreaseFromBaseLine;
99   fStepDownDacSafe=handle.fStepDownDacSafe;
100   fMaxBaseLineLevel=handle.fMaxBaseLineLevel;
101
102   for (UInt_t chipNr=0; chipNr<11; chipNr++) {
103     for (UInt_t hs=0; hs<6; hs++) {
104       fMeanMultiplicity[hs][chipNr]=NULL;
105       fHitEventEfficiency[hs][chipNr]=NULL;
106     }
107   }
108   for (UInt_t hs=0; hs<6; hs++) {
109     fTPeffChip[hs]=NULL;
110     fDeadPixelChip[hs]=NULL;
111     fNoisyPixelChip[hs]=NULL;
112   }
113
114   for (UInt_t mod=0; mod<240; mod++) {
115     fbModuleScanned[mod]=kFALSE;
116   }
117
118   Init();
119 }
120 //_________________________________________________________________________
121 AliITSOnlineSPDscanAnalyzer::~AliITSOnlineSPDscanAnalyzer() {
122   // destructor
123   for (UInt_t hs=0; hs<6; hs++) {
124     for (UInt_t chipNr=0; chipNr<11; chipNr++) {
125       if (fMeanMultiplicity[hs][chipNr]!=NULL) {
126         delete fMeanMultiplicity[hs][chipNr];
127         fMeanMultiplicity[hs][chipNr]=NULL;
128       }
129       if (fHitEventEfficiency[hs][chipNr]!=NULL) {
130         delete fHitEventEfficiency[hs][chipNr];
131         fHitEventEfficiency[hs][chipNr]=NULL;
132       }
133     }
134   }
135
136   if (fTriggers!=NULL) {
137     delete fTriggers;
138     fTriggers=NULL;
139   }
140
141   DeleteUniformityHistograms();
142
143   if (fScanObj!=NULL) {
144     delete fScanObj;
145     fScanObj=NULL;
146   }
147 }
148 //_________________________________________________________________________
149 AliITSOnlineSPDscanAnalyzer& AliITSOnlineSPDscanAnalyzer::operator=(const AliITSOnlineSPDscanAnalyzer& handle) {
150   // assignment operator, only copies the filename and params (not the processed data)
151   if (this!=&handle) {
152     for (UInt_t hs=0; hs<6; hs++) {
153       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
154         if (fMeanMultiplicity[hs][chipNr]!=NULL) {
155           delete fMeanMultiplicity[hs][chipNr];
156         }
157         if (fHitEventEfficiency[hs][chipNr]!=NULL) {
158           delete fHitEventEfficiency[hs][chipNr];
159         }
160       }
161     }
162     if (fTriggers!=NULL) {
163       delete fTriggers;
164       fTriggers=NULL;
165     }
166
167     DeleteUniformityHistograms();
168
169     if (fScanObj!=NULL) {
170       delete fScanObj;
171       fScanObj=NULL;
172     }
173    
174     fFileName=handle.fFileName;
175     fOverWrite=handle.fOverWrite;
176     fNoiseThreshold=handle.fNoiseThreshold;
177     fNoiseMinimumEvents=handle.fNoiseMinimumEvents;
178     fMinNrStepsBeforeIncrease=handle.fMinNrStepsBeforeIncrease;
179     fMinIncreaseFromBaseLine=handle.fMinIncreaseFromBaseLine;
180     fStepDownDacSafe=handle.fStepDownDacSafe;
181     fMaxBaseLineLevel=handle.fMaxBaseLineLevel;
182
183     for (UInt_t chipNr=0; chipNr<11; chipNr++) {
184       for (UInt_t hs=0; hs<6; hs++) {
185         fMeanMultiplicity[hs][chipNr]=NULL;
186         fHitEventEfficiency[hs][chipNr]=NULL;
187       }
188     }
189     for (UInt_t mod=0; mod<240; mod++) {
190       fbModuleScanned[mod]=kFALSE;
191     }
192
193     fHandler=NULL;
194     
195     fType=99;
196     fDacId=99;
197
198     Init();    
199   }
200   return *this;
201 }
202 //_________________________________________________________________________
203 void AliITSOnlineSPDscanAnalyzer::Init(Bool_t readFromGridFile) {
204   // first checks type of container and then initializes container obj
205   if (!readFromGridFile) {
206     FILE* fp0 = fopen(fFileName.Data(), "r");
207     if (fp0 == NULL) {
208       return;
209     }
210     else {
211       fclose(fp0);
212     }
213   }
214
215   fScanObj = new AliITSOnlineSPDscan(fFileName.Data(),readFromGridFile);
216   fType = fScanObj->GetType();
217   delete fScanObj;
218
219   // init container
220   switch(fType) {
221   case kUNIMA:
222   case kNOISE:
223     fScanObj = new AliITSOnlineSPDscanSingle(fFileName.Data(),readFromGridFile);
224     break;
225   case kMINTH:
226   case kDAC:
227   case kDELAY:
228     fScanObj = new AliITSOnlineSPDscanMultiple(fFileName.Data(),readFromGridFile);
229     fDacId = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacId();
230     break;
231   case kMEANTH:
232     fScanObj = new AliITSOnlineSPDscanMeanTh(fFileName.Data(),readFromGridFile);
233     fDacId = ((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetDacId();
234     break;
235   default:
236     Error("AliITSOnlineSPDscanAnalyzer::Init","Type %d not defined!",fType);
237     fScanObj=NULL;
238     return;
239     break;
240   }
241
242 }
243 //_________________________________________________________________________
244 void AliITSOnlineSPDscanAnalyzer::SetParam(const Char_t *pname, const Char_t *pval) {
245   // set a parameter
246   TString name = pname;
247   TString val = pval;
248   if (name.CompareTo("fOverWrite")==0) {
249     if (val.CompareTo("YES")==0 || val.CompareTo("1")==0) {
250       fOverWrite = kTRUE;
251     }
252     else fOverWrite = kFALSE;
253   }
254   else if (name.CompareTo("fNoiseThreshold")==0) {
255     fNoiseThreshold = val.Atof();
256   }
257   else if (name.CompareTo("fNoiseMinimumEvents")==0) {
258     fNoiseMinimumEvents = val.Atoi();
259   }
260   else if (name.CompareTo("fMinNrStepsBeforeIncrease")==0) {
261     fMinNrStepsBeforeIncrease = val.Atoi();
262   }
263   else if (name.CompareTo("fMinIncreaseFromBaseLine")==0) {
264     fMinIncreaseFromBaseLine = val.Atof();
265   }
266   else if (name.CompareTo("fStepDownDacSafe")==0) {
267     fStepDownDacSafe = val.Atoi();
268   }
269   else if (name.CompareTo("fMaxBaseLineLevel")==0) {
270     fMaxBaseLineLevel = val.Atof();
271   }
272   else {
273     Error("AliITSOnlineSPDscanAnalyzer::SetParam","Parameter %s in configuration file unknown.",name.Data());
274   }
275 }
276 //_________________________________________________________________________
277 void AliITSOnlineSPDscanAnalyzer::ReadParamsFromLocation(const Char_t *dirName) {
278   // opens file (default name) in dir dirName and reads parameters from it
279   TString paramsFileName = Form("%s/standal_params.txt",dirName);
280   ifstream paramsFile;
281   paramsFile.open(paramsFileName, ifstream::in);
282   if (paramsFile.fail()) {
283     printf("No config file (%s) present. Using default tuning parameters.\n",paramsFileName.Data());
284   }
285   else {
286     while(1) {
287       Char_t paramN[50];
288       Char_t paramV[50];
289       paramsFile >> paramN;
290       if (paramsFile.eof()) break;
291       paramsFile >> paramV;
292       SetParam(paramN,paramV);
293       if (paramsFile.eof()) break;
294     }
295     paramsFile.close();
296   }
297 }
298 //_________________________________________________________________________
299 Bool_t AliITSOnlineSPDscanAnalyzer::IsChipPresent(UInt_t hs, UInt_t chipNr) {
300   // is the chip present?
301   if (fScanObj==NULL) {
302     Warning("AliITSOnlineSPDscanAnalyzer::IsChipPresent","No data!");
303     return kFALSE;
304   }
305   return fScanObj->GetChipPresent(hs,chipNr);
306 }
307 //_________________________________________________________________________
308 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels(/*Char_t *oldcalibDir*/) {
309   // process dead pixel data, for uniformity scan, 
310   // NB: This will not be the general way of finding dead pixels.
311   if (fScanObj==NULL) {
312     Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","No data!");
313     return kFALSE;
314   }
315   // should be type kUNIMA
316   if (fType!=kUNIMA) {
317     Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Dead pixels only for scan type %d.",kUNIMA);
318     return kFALSE;
319   }
320   // handler should be initialized
321   if (fHandler==NULL) {
322     Error("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Calibration handler is not initialized!");
323     return kFALSE;
324   }
325
326   UInt_t routerNr = fScanObj->GetRouterNr();
327   UInt_t rowStart = fScanObj->GetRowStart();
328   UInt_t rowEnd   = fScanObj->GetRowEnd();
329   for (UInt_t hs=0; hs<6; hs++) {
330     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
331       if (fScanObj->GetChipPresent(hs,chipNr) && fScanObj->GetAverageMultiplicity(0,hs,chipNr)>0) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
332         if (fOverWrite) {fHandler->ResetDeadForChip(routerNr,hs,chipNr);}
333         for (UInt_t col=0; col<32; col++) {
334           for (UInt_t row=rowStart; row<=rowEnd; row++) {
335             if (col!=1 && col!=9 && col!=17 && col!=25) { //exclude test columns!!!
336               if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
337                 fHandler->SetDeadPixel(routerNr,hs,chipNr,col,row);
338               }
339             }
340           }
341         }
342       }
343     }
344   }
345   return kTRUE;
346 }
347 //_________________________________________________________________________
348 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessUniformity() {
349   // process uniformity scan data (thanks to Roberta Ferretti for providing this method)
350   if (fScanObj==NULL) {
351     Warning("AliITSOnlineSPDscanAnalyzer::ProcessUniformity","No data!");
352     return kFALSE;
353   }
354   // should be type kUNIMA
355   if (fType!=kUNIMA) {
356     Warning("AliITSOnlineSPDscanAnalyzer::ProcessUniformity","Only for scan type %d.",kUNIMA);
357     return kFALSE;
358   }
359
360   CreateUniformityHistograms(); // create all histograms that will be filled here
361
362   //  UInt_t routerNr = fScanObj->GetRouterNr();
363   UInt_t rowStart = fScanObj->GetRowStart();
364   UInt_t rowEnd   = fScanObj->GetRowEnd();
365   UInt_t nrTriggers = fScanObj->GetTriggers(0)/(rowEnd-rowStart+1);
366
367   Float_t pixel100=0;
368   Float_t zeri=0;
369   Float_t pixelN=0;
370   UInt_t numChipsActive=0;
371
372   for (UInt_t hs=0; hs<6; hs++) {
373     Float_t pixel100hs=0;
374     Float_t zerihs=0;
375     Float_t pixelNhs=0;
376     UInt_t numChipsActiveHS=0;
377
378     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
379       Float_t pixel100chip=0;
380       Float_t zerichip=0;
381       Float_t pixelNchip=0;
382
383       if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
384         numChipsActive++;
385         numChipsActiveHS++;
386
387         for (UInt_t col=0; col<32; col++) {
388           for (UInt_t row=rowStart; row<=rowEnd; row++) {
389             if (col!=1 && col!=9 && col!=17 && col!=25) { //exclude test columns!!!
390             
391               if (fScanObj->GetHits(0,hs,chipNr,col,row)==nrTriggers) {   
392                         pixel100++;
393                         pixel100hs++;
394                         pixel100chip++;
395               }
396               if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
397                         zeri++;
398                         zerihs++;
399                         zerichip++;
400               }
401               if (fScanObj->GetHits(0,hs,chipNr,col,row)>nrTriggers) {    
402                         pixelN++;
403                         pixelNhs++;
404                         pixelNchip++;
405               }
406             }
407           }
408         }
409       
410         Float_t tPeffChip=(pixel100chip/(28*(rowEnd-rowStart+1)))*100;
411         fTPeffChip[hs]->Fill(chipNr,tPeffChip);
412         
413         Float_t deadPixelChip=(zerichip/(28*(rowEnd-rowStart+1)))*100;
414         fDeadPixelChip[hs]->Fill(chipNr,deadPixelChip);
415         
416         Float_t noisyPixelChip=(pixelNchip/(28*(rowEnd-rowStart+1)))*100;
417         fNoisyPixelChip[hs]->Fill(chipNr,noisyPixelChip);
418       }
419     }
420     
421     Float_t tPeffHS=(pixel100hs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
422     fTPeffHS->Fill(hs,tPeffHS);
423     
424     Float_t deadPixelHS=(zerihs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
425     fDeadPixelHS->Fill(hs,deadPixelHS);
426     
427     Float_t noisyPixelHS=(pixelNhs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
428     fNoisyPixelHS->Fill(hs,noisyPixelHS);
429   }
430   
431   fTPeff=(pixel100/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
432   fDeadPixel=(zeri/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
433   fNoisyPixel=(pixelN/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
434
435   return kTRUE;
436 }
437 //_________________________________________________________________________
438 void AliITSOnlineSPDscanAnalyzer::CreateUniformityHistograms() {
439   // create uniformity histograms to be filled by "ProcessUniformity" method
440   DeleteUniformityHistograms(); // make sure no old histograms are lying around...
441   UInt_t eq = GetRouterNr();
442   TString label;
443
444   label = Form("Ratio of 'Good' Pixels Per HS (eq %d)",eq);
445   fTPeffHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
446   fTPeffHS->SetXTitle("hs");
447   fTPeffHS->SetYTitle("ratio [%]");
448   fTPeffHS->SetFillColor(kBlue);
449   fTPeffHS->SetStats(0);
450
451   label = Form("Ratio of 'Dead' Pixels Per HS (eq %d)",eq);
452   fDeadPixelHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
453   fDeadPixelHS->SetXTitle("hs");
454   fDeadPixelHS->SetYTitle("ratio [%]");
455   fDeadPixelHS->SetFillColor(kBlue);
456   fDeadPixelHS->SetStats(0);
457
458   label = Form("Ratio of 'Noisy' Pixels Per HS (eq %d)",eq);
459   fNoisyPixelHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
460   fNoisyPixelHS->SetXTitle("hs");
461   fNoisyPixelHS->SetYTitle("ratio [%]");
462   fNoisyPixelHS->SetFillColor(kBlue);
463   fNoisyPixelHS->SetStats(0);
464
465   for (UInt_t hs=0; hs<6; hs++) {
466     label = Form("Ratio of 'Good' Pixels Per Chip (eq %d, hs %d)",eq,hs);
467     fTPeffChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
468     fTPeffChip[hs]->SetXTitle("chip");
469     fTPeffChip[hs]->SetYTitle("ratio [%]");
470     fTPeffChip[hs]->SetFillColor(kBlue);
471     fTPeffChip[hs]->SetStats(0);
472
473     label = Form("Ratio of 'Dead' Pixels Per Chip (eq %d, hs %d)",eq,hs);
474     fDeadPixelChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
475     fDeadPixelChip[hs]->SetXTitle("chip");
476     fDeadPixelChip[hs]->SetYTitle("ratio [%]");
477     fDeadPixelChip[hs]->SetFillColor(kBlue);
478     fDeadPixelChip[hs]->SetStats(0);
479
480     label = Form("Ratio of 'Noisy' Pixels Per Chip (eq %d, hs %d)",eq,hs);
481     fNoisyPixelChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
482     fNoisyPixelChip[hs]->SetXTitle("chip");
483     fNoisyPixelChip[hs]->SetYTitle("ratio [%]");
484     fNoisyPixelChip[hs]->SetFillColor(kBlue);
485     fNoisyPixelChip[hs]->SetStats(0);
486   }
487
488 }
489 //_________________________________________________________________________
490 void AliITSOnlineSPDscanAnalyzer::DeleteUniformityHistograms() {
491   // remove uniformity histograms if they are created
492   if (fTPeffHS!=NULL) {
493     delete fTPeffHS;
494     fTPeffHS=NULL;
495   }
496   if (fDeadPixelHS!=NULL) {
497     delete fDeadPixelHS;
498     fDeadPixelHS=NULL;
499   }
500   if (fNoisyPixelHS!=NULL) {
501     delete fNoisyPixelHS;
502     fNoisyPixelHS=NULL;
503   }
504   for (UInt_t hs=0; hs<6; hs++) {
505     if (fTPeffChip[hs]!=NULL) {
506       delete fTPeffChip[hs];
507       fTPeffChip[hs]=NULL;
508     }
509     if (fDeadPixelChip[hs]!=NULL) {
510       delete fDeadPixelChip[hs];
511       fDeadPixelChip[hs]=NULL;
512     }
513     if (fNoisyPixelChip[hs]!=NULL) {
514       delete fNoisyPixelChip[hs];
515       fNoisyPixelChip[hs]=NULL;
516     }
517   }
518 }
519 //_________________________________________________________________________
520 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels(/*Char_t *oldcalibDir*/) {
521   // process noisy pixel data
522   if (fScanObj==NULL) {
523     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","No data!");
524     return kFALSE;
525   }
526   // should be type kNOISE
527   if (fType != kNOISE) {
528     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Noisy pixels only for scan type %d.",kNOISE);
529     return kFALSE;
530   }
531   // handler should be initialized
532   if (fHandler==NULL) {
533     Error("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Calibration handler is not initialized!");
534     return kFALSE;
535   }
536   // check if enough statistics
537   if (fScanObj->GetTriggers(0)<fNoiseMinimumEvents) {
538     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Process noisy: Too few events.");
539     return kFALSE;
540   }
541
542   UInt_t routerNr = fScanObj->GetRouterNr();
543   for (UInt_t hs=0; hs<6; hs++) {
544     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
545       if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
546         if (fOverWrite) {fHandler->ResetNoisyForChip(routerNr,hs,chipNr);}
547         for (UInt_t col=0; col<32; col++) {
548           for (UInt_t row=0; row<256; row++) {
549             if (fScanObj->GetHitsEfficiency(0,hs,chipNr,col,row)>fNoiseThreshold) {
550               fHandler->SetNoisyPixel(routerNr,hs,chipNr,col,row);
551             }
552           }
553         }
554       }
555     }
556   }
557   return kTRUE;
558 }
559 //_________________________________________________________________________
560 Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) {
561   // get delay
562   if (hs>=6 || chipNr>10) return -1;
563   if (fScanObj==NULL) {
564     Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","No data!");
565     return -1;
566   }
567   // should be type kDELAY or kDAC with id 42 (delay_ctrl)
568   if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) {
569     Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","Delay only for scan type %d or %d and dac_id 42.",kDELAY,kDAC);
570     return -1;
571   }
572   if (fMeanMultiplicity[hs][chipNr]==NULL) {
573     if (!ProcessMeanMultiplicity()) {
574       return -1;
575     }
576   }
577
578   UInt_t maxStep=0;
579   Float_t maxVal=0;
580   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
581     Double_t thisDac;
582     Double_t thisMult;
583     fMeanMultiplicity[hs][chipNr]->GetPoint(step,thisDac,thisMult);
584     if (thisMult > maxVal) {
585       maxVal = thisMult;
586       maxStep = step;
587     }
588   }
589
590   if (maxVal>0) {
591     return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(maxStep);
592   }
593   else {
594     return -1;
595   }
596
597 }
598 //_________________________________________________________________________
599 Int_t AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima(UInt_t hs, UInt_t chipNr) {
600   // in case of a uniformity scan, returns the nr of noisy pixels, (here > 200 hits)
601   if (hs>=6 || chipNr>10) return -1;
602   if (fScanObj==NULL) {
603     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","No data!");
604     return kFALSE;
605   }
606   // should be type kUNIMA
607   if (fType != kUNIMA) {
608     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Noisy pixels Unima only for scan type %d.",kUNIMA);
609     return kFALSE;
610   }
611   if (fScanObj->GetTriggers(0)!=25600) {
612     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Process noisy unima: Incorrect number of events (!=25600.");
613     return kFALSE;
614   }
615
616   Int_t nrNoisy=0;
617   if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
618     for (UInt_t col=0; col<32; col++) {
619       for (UInt_t row=0; row<256; row++) {
620         if (fScanObj->GetHits(0,hs,chipNr,col,row)>200) {
621           nrNoisy++;
622         }
623       }
624     }
625   }
626   else {
627     return -1;
628   }
629   return nrNoisy;
630 }
631 //_________________________________________________________________________
632 Int_t AliITSOnlineSPDscanAnalyzer::FindLastMinThDac(UInt_t hs, UInt_t chipNr) {
633   // returns dac value where fMinIncreaseFromBaseLine reached
634   if (hs>=6 || chipNr>10) return -1;
635   if (fMeanMultiplicity[hs][chipNr]==NULL) {
636     if (!ProcessMeanMultiplicity()) {
637       return -1;
638     }
639   }
640   Double_t firstVal, dummy1;
641   fMeanMultiplicity[hs][chipNr]->GetPoint(0,dummy1,firstVal);
642   UInt_t step=0;
643   while (step<fScanObj->GetNSteps()-1) {
644     Double_t graphVal, dummy2;
645     fMeanMultiplicity[hs][chipNr]->GetPoint(step+1,dummy2,graphVal);
646     if (graphVal>firstVal+fMinIncreaseFromBaseLine) break;
647     step++;
648   }
649   if (step==fScanObj->GetNSteps()-1) return -1;
650   return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step);
651 }
652
653 Int_t AliITSOnlineSPDscanAnalyzer::FindClosestLowerStep(Float_t dacValueInput) {
654   // returns step closest (lower) to a dacvalue 
655   UInt_t step=0;
656   while (step<fScanObj->GetNSteps()-1) {
657     Int_t dacVal = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1);
658     if (dacVal>=dacValueInput) break;
659     step++;
660   }
661   return step;
662 }
663 //_________________________________________________________________________
664 Float_t AliITSOnlineSPDscanAnalyzer::GetCompareLine(UInt_t step, UInt_t hs, UInt_t chipNr, Float_t basePar2) {
665   // returns value to compare mean mult with (when finding min th)
666   if (hs>=6 || chipNr>10) return -1;
667   if (step<fMinNrStepsBeforeIncrease) return -1;
668   Float_t baseLine = basePar2;
669   if (baseLine<0) baseLine=0;
670   Float_t baseAdd;
671   Double_t baseM=0;
672   Double_t baseS=0;
673   Double_t d,m;
674   for (UInt_t st=1;st<2*step/3;st++) { // skip first point...
675     fMeanMultiplicity[hs][chipNr]->GetPoint(st,d,m);
676     baseM+=m-baseLine;
677     baseS+=(m-baseLine)*(m-baseLine);
678   }
679   baseAdd=2*sqrt( baseS/(2*step/3-1) - (baseM/(2*step/3-1))*(baseM/(2*step/3-1)) );
680   baseAdd+=0.03; // magic number
681   if (baseAdd>fMinIncreaseFromBaseLine) baseAdd=fMinIncreaseFromBaseLine;
682   return baseLine + baseAdd;
683 }
684
685 Int_t AliITSOnlineSPDscanAnalyzer::GetMinTh(UInt_t hs, UInt_t chipNr) {
686   // calculates and returns the minimum threshold
687   if (hs>=6 || chipNr>10) return -1;
688   if (fScanObj==NULL) {
689     Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","No data!");
690     return -1;
691   }
692   // should be type  kMINTH  or  kDAC with id 39 (pre_vth)
693   if (fType!=kMINTH && (fType!=kDAC || fDacId!=39)) {
694     Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","MinTh only for scan type %d OR %d with dac_id 39.",kMINTH,kDAC);
695     return -1;
696   }
697   if (fMeanMultiplicity[hs][chipNr]==NULL) {
698     if (!ProcessMeanMultiplicity()) {
699       return -1;
700     }
701   }
702
703   Int_t lastDac = FindLastMinThDac(hs,chipNr);
704   if (lastDac==-1) {
705     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Increase of Mean Multiplicity by %1.2f never reached.",hs,chipNr,fMinIncreaseFromBaseLine);
706     return -1;
707   }
708
709   Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0);
710   TString funcName = Form("Fit minth func HS%d CHIP%d",hs,chipNr);
711   TF1 *minThFunc = new TF1(funcName.Data(),itsSpdErrorf,100,500,3);
712   minThFunc->SetParameter(0,lastDac+10);
713   minThFunc->SetParameter(1,2);
714   minThFunc->SetParameter(2,0);
715   minThFunc->SetParName(0,"Mean");
716   minThFunc->SetParName(1,"Sigma");
717   minThFunc->SetParName(2,"BaseLine");
718   minThFunc->SetLineWidth(1);
719   if (fMeanMultiplicity[hs][chipNr]==NULL) {
720     if (!ProcessMeanMultiplicity()) {
721       return -1;
722     }
723   }
724   fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0","",minDac,lastDac);
725
726   //  Double_t mean = fMinThFunc[hs][chipNr]->GetParameter(0);
727   //  Double_t sigma = fMinThFunc[hs][chipNr]->GetParameter(1);
728   Double_t baseLine = minThFunc->GetParameter(2);
729   delete minThFunc;
730
731   if (baseLine>fMaxBaseLineLevel) {
732     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: BaseLine too large (%1.2f>%1.2f).",hs,chipNr,baseLine,fMaxBaseLineLevel);
733     return -1;
734   }
735   UInt_t step=FindClosestLowerStep(lastDac);
736   Float_t compareLine = GetCompareLine(step,hs,chipNr,baseLine);
737   if (compareLine==-1) {
738     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Not enough steps (%d<%d) before increase to get a compare line.",hs,chipNr,step,fMinNrStepsBeforeIncrease);
739     return -1;
740   }
741
742   Double_t mult, dummy;
743   mult=1000;
744   while (mult > compareLine && step>0) {
745     fMeanMultiplicity[hs][chipNr]->GetPoint(step,dummy,mult);
746     step--;
747   }
748   Int_t minth = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1)-fStepDownDacSafe;
749
750   if (step>0) {
751     return minth;
752   }
753   else {
754     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Did not find a point below the compare line (%f).",hs,chipNr,compareLine);
755     return -1;
756   }
757 }
758 //_________________________________________________________________________
759 TArrayI AliITSOnlineSPDscanAnalyzer::GetMeanTh(UInt_t hs, UInt_t chipNr) {
760   // calculates and returns the mean threshold
761   TArrayI fitresults(4);
762   if (hs>=6 || chipNr>10) return fitresults;
763   if (fScanObj==NULL) {
764     Error("AliITSOnlineSPDscanAnalyzer::GetMeanTh","No data!");
765     return fitresults;
766   }
767   // should be type  kMEANTH  or  kDAC with id 39
768   if (fType!=kMEANTH && (fType!=kDAC || fDacId!=105)) {
769     Error("AliITSOnlineSPDscanAnalyzer::GetMeanTh","MeanTh only for scan type %d OR %d with dac_id 105.",kMEANTH,kDAC);
770     return fitresults;
771   }
772   if (fHitEventEfficiency[hs][chipNr]==NULL) {
773    printf("processing hit efficiency \n");
774     if (!ProcessHitEventEfficiency()) {
775       printf("...not processed!!\n");
776       return fitresults;
777     }
778   }
779   Double_t x,y;
780   fHitEventEfficiency[hs][chipNr]->GetPoint(fHitEventEfficiency[hs][chipNr]->GetN()-1,x,y);
781   Double_t min = x;
782   fHitEventEfficiency[hs][chipNr]->GetPoint(0,x,y);
783   Double_t max = x;
784
785   Double_t mean = 0.5*(min+max);
786   TString funcName = Form("Fit meanth func HS%d CHIP%d",hs,chipNr);
787   TF1 *minThFunc = new TF1(funcName.Data(),itsSpdScurveForMeanTh,min,max,3);
788   minThFunc->SetParameter(0,mean);
789   minThFunc->SetParameter(1,264); //  4 (mV) * 66 (el)
790   minThFunc->SetParLimits(1,100,1000); // minimum value is 1 mV (-> 100 in TPAmplitude)
791   minThFunc->SetParameter(2,0.4);
792   minThFunc->SetParName(0,"Mean");
793   minThFunc->SetParName(1,"Sigma");
794   minThFunc->SetParName(2,"Half");
795   minThFunc->SetLineWidth(1);
796
797   fHitEventEfficiency[hs][chipNr]->Fit(funcName,"Q","",min,max);
798
799   fitresults.AddAt((Int_t)minThFunc->GetParameter(0),0);
800   fitresults.AddAt((Int_t)minThFunc->GetParError(0),1);
801   fitresults.AddAt((Int_t)minThFunc->GetParameter(1),2);
802   fitresults.AddAt((Int_t)minThFunc->GetParError(1),3);
803   TLine *ly = new TLine((Double_t)min,0.5,(Double_t)fitresults.At(0),0.5); ly->SetLineStyle(6);
804   ly->Draw("same");
805   TLine *lx = new TLine((Double_t)fitresults.At(0),0.,(Double_t)fitresults.At(0),0.5);
806   lx->SetLineStyle(6);
807   lx->Draw("same");
808   delete minThFunc;
809   
810   return fitresults;
811 }
812
813 //_________________________________________________________________________
814 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity() {
815   // process mean multiplicity data
816   if (fScanObj==NULL) {
817     Error("AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity","No data!");
818     return kFALSE;
819   }
820   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
821     for (UInt_t hs=0; hs<6; hs++) {
822       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
823         //      if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
824         if (step==0) {
825           if (fMeanMultiplicity[hs][chipNr]!=NULL) {
826             delete fMeanMultiplicity[hs][chipNr];
827           }
828           fMeanMultiplicity[hs][chipNr] = new TGraph();
829         }
830         Float_t multiplMean=fScanObj->GetAverageMultiplicity(step,hs,chipNr);
831         if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
832           fMeanMultiplicity[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),multiplMean);
833         }
834         else {
835           fMeanMultiplicity[hs][chipNr]->SetPoint(step,0,multiplMean);
836         }
837       }
838       //      }
839     }
840   }
841   return kTRUE;
842 }
843 //_________________________________________________________________________
844 TGraph* AliITSOnlineSPDscanAnalyzer::GetMeanMultiplicityG(UInt_t hs, UInt_t chipNr) {
845   // returns mean multiplicity graph
846   if (hs>=6 || chipNr>10) return NULL;
847   if (fMeanMultiplicity[hs][chipNr]==NULL) {
848     if (!ProcessMeanMultiplicity()) {
849       return NULL;
850     }
851   }
852   return fMeanMultiplicity[hs][chipNr];
853 }
854 //_________________________________________________________________________
855 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency() {
856   // process hit event efficiency
857   if (fScanObj==NULL) {
858     Error("AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency","No data!");
859     return kFALSE;
860   }
861   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
862     for (UInt_t hs=0; hs<6; hs++) {
863       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
864         //      if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
865         if (step==0) {
866           if (fHitEventEfficiency[hs][chipNr]!=NULL) {
867             delete fHitEventEfficiency[hs][chipNr];
868           }
869           fHitEventEfficiency[hs][chipNr] = new TGraph();
870         }
871         Float_t efficiency=fScanObj->GetHitEventsEfficiency(step,hs,chipNr);
872         if (fType==kMINTH || fType==kDAC || fType==kDELAY) {
873           fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),efficiency);
874         } else if(fType==kMEANTH){
875           fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetTPAmp(step,hs),efficiency);
876         } else {
877           fHitEventEfficiency[hs][chipNr]->SetPoint(step,0,efficiency);
878         }
879       }
880       //      }
881     }
882   }
883   return kTRUE;
884 }
885 //_________________________________________________________________________
886 TGraph* AliITSOnlineSPDscanAnalyzer::GetHitEventEfficiencyG(UInt_t hs, UInt_t chipNr) {
887   // returns hit event efficiency graph
888   if (hs>=6 || chipNr>10) return NULL;
889   if (fHitEventEfficiency[hs][chipNr]==NULL) {
890     if (!ProcessHitEventEfficiency()) {
891       return NULL;
892     }
893   }
894   return fHitEventEfficiency[hs][chipNr];
895 }
896 //_________________________________________________________________________
897 Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers() {
898   // process nr of triggers data
899   if (fScanObj==NULL) {
900     Error("AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers","No data!");
901     return kFALSE;
902   }
903   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
904     if (step==0) {
905       if (fTriggers!=NULL) {
906         delete fTriggers;
907       }
908       fTriggers = new TGraph();
909     }
910     if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
911       fTriggers->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),fScanObj->GetTriggers(step));
912     }
913     else {
914       fTriggers->SetPoint(step,0,fScanObj->GetTriggers(step));
915     }
916   }
917   return kTRUE;
918 }
919 //_________________________________________________________________________
920 TGraph* AliITSOnlineSPDscanAnalyzer::GetNrTriggersG() {
921   // returns nr of triggers graph
922   if (fTriggers==NULL) {
923     if (!ProcessNrTriggers()) {
924       return NULL;
925     }
926   }
927   return fTriggers;
928 }
929 //_________________________________________________________________________
930 Bool_t AliITSOnlineSPDscanAnalyzer::GetHalfStavePresent(UInt_t hs) {
931   // returns half stave present info
932   if (hs<6 && fScanObj!=NULL) {
933     Int_t chipstatus=0;
934     for (Int_t chip=0; chip<10; chip++) {
935       chipstatus+=fScanObj->GetChipPresent(hs,chip);
936     }
937     if (chipstatus>0) return kTRUE;
938   }
939   return kFALSE;
940 }
941 //_________________________________________________________________________
942 UInt_t AliITSOnlineSPDscanAnalyzer::GetRouterNr() {
943   // returns the router nr of scan obj
944   if (fScanObj!=NULL) return fScanObj->GetRouterNr(); 
945   else return 99;
946 }
947 //_________________________________________________________________________
948 TH2F* AliITSOnlineSPDscanAnalyzer::GetHitMapTot(UInt_t step) {
949   // creates and returns a pointer to a hitmap histo (half sector style a la spdmood)
950   if (fScanObj==NULL) {
951     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapTot","No data!");
952     return NULL;
953   }
954   TString histoname;
955   if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
956     histoname = Form("Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
957   }
958   else {
959     histoname = Form("Router %d ",GetRouterNr());
960   }
961   TH2F* fHitMapTot = new TH2F(histoname.Data(),histoname.Data(),32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5);
962   fHitMapTot->SetNdivisions(-10,"X");
963   fHitMapTot->SetNdivisions(-006,"Y");
964   fHitMapTot->SetTickLength(0,"X");
965   fHitMapTot->SetTickLength(0,"Y");
966   fHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor());
967   fHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor());
968   for (UInt_t hs=0; hs<6; hs++) {
969     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
970       for (UInt_t col=0; col<32; col++) {
971         for (UInt_t row=0; row<256; row++) {
972           fHitMapTot->Fill(chipNr*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
973         }
974       }
975     }
976   }
977   return fHitMapTot;
978 }
979 //_________________________________________________________________________
980 TH2F* AliITSOnlineSPDscanAnalyzer::GetPhysicalHitMapTot(UInt_t step) {
981   // creates and returns a pointer to a hitmap histo (-> 1 equpment opened up)
982
983   if (fScanObj==NULL) {
984     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapTot","No data!");
985     return NULL;
986   }
987   TString histoname;
988   if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
989     histoname = Form("Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
990   }
991   else {
992     histoname = Form("Router %d ",GetRouterNr());
993   }
994   TH2F* hPhysicalHitMapTot = new TH2F(histoname.Data(),histoname.Data(),32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5);
995   hPhysicalHitMapTot->SetNdivisions(-10,"X");
996   hPhysicalHitMapTot->SetNdivisions(-006,"Y");
997   hPhysicalHitMapTot->SetTickLength(0,"X");
998   hPhysicalHitMapTot->SetTickLength(0,"Y");
999   hPhysicalHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor());
1000   hPhysicalHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor());
1001   Int_t correctChip = -1;
1002   for (UInt_t hs=0; hs<6; hs++) {
1003     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
1004     if(GetRouterNr()<10) correctChip = 9-chipNr;
1005     else correctChip=chipNr;
1006       for (UInt_t col=0; col<32; col++) {
1007         for (UInt_t row=0; row<256; row++) {
1008           if(hs<2) hPhysicalHitMapTot->Fill(correctChip*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
1009           else hPhysicalHitMapTot->Fill(correctChip*32+(31-col),(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
1010         }
1011       }
1012     }
1013   }
1014   return hPhysicalHitMapTot;
1015 }
1016
1017 //_________________________________________________________________________
1018 TH2F* AliITSOnlineSPDscanAnalyzer::GetHitMapChip(UInt_t step, UInt_t hs, UInt_t chip) {
1019   // creates and returns a pointer to a hitmap histo (chip style a la spdmood)
1020   if (fScanObj==NULL) {
1021     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapChip","No data!");
1022     return NULL;
1023   }
1024
1025   TString histoName;
1026   TString histoTitle;
1027   histoName = Form("fChipHisto_%d_%d_%d", GetRouterNr(), hs, chip);
1028   histoTitle = Form("Eq ID %d, Half Stave %d, Chip %d ", GetRouterNr(), hs, chip);
1029
1030   TH2F *returnHisto = new TH2F(histoName.Data(), histoTitle.Data(), 32, -0.5, 31.5, 256, -0.5, 255.5);
1031   returnHisto->SetMinimum(0);
1032   for (UInt_t col=0; col<32; col++) {
1033     for (UInt_t row=0; row<256; row++) {
1034       if(hs<2) returnHisto->Fill(31-col,row,fScanObj->GetHits(step,hs,chip,col,row));
1035       else returnHisto->Fill(col,row,fScanObj->GetHits(step,hs,chip,col,row));
1036     }
1037   }
1038
1039   return returnHisto;
1040 }
1041