Moving required CMake version from 2.8.4 to 2.8.8
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDscanAnalyzer.cxx
CommitLineData
4ee23d3d 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
f0aa5f6c 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 //
6727e2db 23// threshold values can be extracted. //
f0aa5f6c 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>
f652c3be 35#include <TLine.h>
f0aa5f6c 36#include <TF1.h>
37#include <TGraph.h>
38#include <TH2F.h>
53ae21ce 39#include <TError.h>
6727e2db 40#include <iostream>
41#include <fstream>
f0aa5f6c 42
fe7d86eb 43using std::ifstream;
44
f0aa5f6c 45Double_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//}
f652c3be 53//_________________________________________________________________________
54Double_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}
f0aa5f6c 60
de12e454 61//_________________________________________________________________________
6ddf3d66 62AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const Char_t *fileName, AliITSOnlineCalibrationSPDhandler *handler, Bool_t readFromGridFile) :
de12e454 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),
f0aa5f6c 64 fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
6727e2db 65 fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
f0aa5f6c 66{
67 // constructor
f0aa5f6c 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 }
de12e454 74 for (UInt_t hs=0; hs<6; hs++) {
75 fTPeffChip[hs]=NULL;
76 fDeadPixelChip[hs]=NULL;
77 fNoisyPixelChip[hs]=NULL;
78 }
79
6727e2db 80 for (UInt_t mod=0; mod<240; mod++) {
81 fbModuleScanned[mod]=kFALSE;
f0aa5f6c 82 }
83
6ddf3d66 84 Init(readFromGridFile);
f0aa5f6c 85}
de12e454 86//_________________________________________________________________________
f0aa5f6c 87AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const AliITSOnlineSPDscanAnalyzer& handle) :
de12e454 88 fType(99),fDacId(99),fFileName("."),fScanObj(NULL),fHandler(NULL),fTriggers(NULL),fTPeff(0),fTPeffHS(NULL),fDeadPixel(0),fDeadPixelHS(NULL),fNoisyPixel(0),fNoisyPixelHS(NULL),
f0aa5f6c 89 fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
6727e2db 90 fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
f0aa5f6c 91{
6727e2db 92 // copy constructor, only copies the filename and params (not the processed data)
53ae21ce 93 fFileName=handle.fFileName;
6727e2db 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;
f0aa5f6c 101
f0aa5f6c 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 }
de12e454 108 for (UInt_t hs=0; hs<6; hs++) {
109 fTPeffChip[hs]=NULL;
110 fDeadPixelChip[hs]=NULL;
111 fNoisyPixelChip[hs]=NULL;
112 }
113
6727e2db 114 for (UInt_t mod=0; mod<240; mod++) {
115 fbModuleScanned[mod]=kFALSE;
f0aa5f6c 116 }
117
118 Init();
119}
de12e454 120//_________________________________________________________________________
f0aa5f6c 121AliITSOnlineSPDscanAnalyzer::~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];
de12e454 127 fMeanMultiplicity[hs][chipNr]=NULL;
f0aa5f6c 128 }
129 if (fHitEventEfficiency[hs][chipNr]!=NULL) {
130 delete fHitEventEfficiency[hs][chipNr];
de12e454 131 fHitEventEfficiency[hs][chipNr]=NULL;
f0aa5f6c 132 }
133 }
134 }
f0aa5f6c 135
de12e454 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//_________________________________________________________________________
f0aa5f6c 149AliITSOnlineSPDscanAnalyzer& AliITSOnlineSPDscanAnalyzer::operator=(const AliITSOnlineSPDscanAnalyzer& handle) {
6727e2db 150 // assignment operator, only copies the filename and params (not the processed data)
f0aa5f6c 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 }
de12e454 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 }
f0aa5f6c 173
53ae21ce 174 fFileName=handle.fFileName;
6727e2db 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;
f0aa5f6c 182
f0aa5f6c 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 }
6727e2db 189 for (UInt_t mod=0; mod<240; mod++) {
190 fbModuleScanned[mod]=kFALSE;
f0aa5f6c 191 }
de12e454 192
6727e2db 193 fHandler=NULL;
f0aa5f6c 194
6727e2db 195 fType=99;
196 fDacId=99;
197
f0aa5f6c 198 Init();
199 }
200 return *this;
201}
de12e454 202//_________________________________________________________________________
6ddf3d66 203void AliITSOnlineSPDscanAnalyzer::Init(Bool_t readFromGridFile) {
f0aa5f6c 204 // first checks type of container and then initializes container obj
6ddf3d66 205 if (!readFromGridFile) {
206 FILE* fp0 = fopen(fFileName.Data(), "r");
207 if (fp0 == NULL) {
208 return;
209 }
210 else {
211 fclose(fp0);
212 }
f0aa5f6c 213 }
6ddf3d66 214
215 fScanObj = new AliITSOnlineSPDscan(fFileName.Data(),readFromGridFile);
f0aa5f6c 216 fType = fScanObj->GetType();
217 delete fScanObj;
218
219 // init container
220 switch(fType) {
221 case kUNIMA:
222 case kNOISE:
6ddf3d66 223 fScanObj = new AliITSOnlineSPDscanSingle(fFileName.Data(),readFromGridFile);
f0aa5f6c 224 break;
225 case kMINTH:
226 case kDAC:
227 case kDELAY:
6ddf3d66 228 fScanObj = new AliITSOnlineSPDscanMultiple(fFileName.Data(),readFromGridFile);
f0aa5f6c 229 fDacId = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacId();
230 break;
231 case kMEANTH:
6ddf3d66 232 fScanObj = new AliITSOnlineSPDscanMeanTh(fFileName.Data(),readFromGridFile);
f0aa5f6c 233 fDacId = ((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetDacId();
234 break;
235 default:
53ae21ce 236 Error("AliITSOnlineSPDscanAnalyzer::Init","Type %d not defined!",fType);
f0aa5f6c 237 fScanObj=NULL;
238 return;
239 break;
240 }
241
f0aa5f6c 242}
de12e454 243//_________________________________________________________________________
53ae21ce 244void 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) {
6727e2db 249 if (val.CompareTo("YES")==0 || val.CompareTo("1")==0) {
53ae21ce 250 fOverWrite = kTRUE;
251 }
6727e2db 252 else fOverWrite = kFALSE;
53ae21ce 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}
de12e454 276//_________________________________________________________________________
6727e2db 277void 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}
de12e454 298//_________________________________________________________________________
4f88491f 299Bool_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;
6727e2db 304 }
4f88491f 305 return fScanObj->GetChipPresent(hs,chipNr);
6727e2db 306}
de12e454 307//_________________________________________________________________________
6727e2db 308Bool_t AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels(/*Char_t *oldcalibDir*/) {
53ae21ce 309 // process dead pixel data, for uniformity scan,
310 // NB: This will not be the general way of finding dead pixels.
f0aa5f6c 311 if (fScanObj==NULL) {
53ae21ce 312 Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","No data!");
f0aa5f6c 313 return kFALSE;
314 }
315 // should be type kUNIMA
316 if (fType!=kUNIMA) {
53ae21ce 317 Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Dead pixels only for scan type %d.",kUNIMA);
f0aa5f6c 318 return kFALSE;
319 }
6727e2db 320 // handler should be initialized
321 if (fHandler==NULL) {
322 Error("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Calibration handler is not initialized!");
323 return kFALSE;
324 }
f0aa5f6c 325
f0aa5f6c 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!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4f88491f 332 if (fOverWrite) {fHandler->ResetDeadForChip(routerNr,hs,chipNr);}
f0aa5f6c 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) {
6727e2db 337 fHandler->SetDeadPixel(routerNr,hs,chipNr,col,row);
f0aa5f6c 338 }
339 }
340 }
341 }
342 }
343 }
344 }
345 return kTRUE;
346}
de12e454 347//_________________________________________________________________________
348Bool_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 }
f0aa5f6c 359
de12e454 360 CreateUniformityHistograms(); // create all histograms that will be filled here
f0aa5f6c 361
de12e454 362 // UInt_t routerNr = fScanObj->GetRouterNr();
363 UInt_t rowStart = fScanObj->GetRowStart();
364 UInt_t rowEnd = fScanObj->GetRowEnd();
f652c3be 365 UInt_t nrTriggers = fScanObj->GetTriggers(0)/(rowEnd-rowStart+1);
de12e454 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++;
f0aa5f6c 386
de12e454 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
f652c3be 391 if (fScanObj->GetHits(0,hs,chipNr,col,row)==nrTriggers) {
de12e454 392 pixel100++;
393 pixel100hs++;
394 pixel100chip++;
395 }
396 if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
397 zeri++;
398 zerihs++;
399 zerichip++;
400 }
f652c3be 401 if (fScanObj->GetHits(0,hs,chipNr,col,row)>nrTriggers) {
de12e454 402 pixelN++;
403 pixelNhs++;
404 pixelNchip++;
405 }
406 }
407 }
408 }
409
f652c3be 410 Float_t tPeffChip=(pixel100chip/(28*(rowEnd-rowStart+1)))*100;
411 fTPeffChip[hs]->Fill(chipNr,tPeffChip);
de12e454 412
f652c3be 413 Float_t deadPixelChip=(zerichip/(28*(rowEnd-rowStart+1)))*100;
414 fDeadPixelChip[hs]->Fill(chipNr,deadPixelChip);
de12e454 415
f652c3be 416 Float_t noisyPixelChip=(pixelNchip/(28*(rowEnd-rowStart+1)))*100;
417 fNoisyPixelChip[hs]->Fill(chipNr,noisyPixelChip);
de12e454 418 }
419 }
420
f652c3be 421 Float_t tPeffHS=(pixel100hs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
422 fTPeffHS->Fill(hs,tPeffHS);
de12e454 423
f652c3be 424 Float_t deadPixelHS=(zerihs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
425 fDeadPixelHS->Fill(hs,deadPixelHS);
de12e454 426
f652c3be 427 Float_t noisyPixelHS=(pixelNhs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
428 fNoisyPixelHS->Fill(hs,noisyPixelHS);
de12e454 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//_________________________________________________________________________
438void 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//_________________________________________________________________________
490void 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//_________________________________________________________________________
6727e2db 520Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels(/*Char_t *oldcalibDir*/) {
f0aa5f6c 521 // process noisy pixel data
522 if (fScanObj==NULL) {
53ae21ce 523 Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","No data!");
f0aa5f6c 524 return kFALSE;
525 }
526 // should be type kNOISE
527 if (fType != kNOISE) {
53ae21ce 528 Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Noisy pixels only for scan type %d.",kNOISE);
f0aa5f6c 529 return kFALSE;
530 }
6727e2db 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
f0aa5f6c 537 if (fScanObj->GetTriggers(0)<fNoiseMinimumEvents) {
53ae21ce 538 Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Process noisy: Too few events.");
f0aa5f6c 539 return kFALSE;
540 }
6727e2db 541
f0aa5f6c 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!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4f88491f 546 if (fOverWrite) {fHandler->ResetNoisyForChip(routerNr,hs,chipNr);}
f0aa5f6c 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) {
6727e2db 550 fHandler->SetNoisyPixel(routerNr,hs,chipNr,col,row);
f0aa5f6c 551 }
552 }
553 }
554 }
555 }
556 }
557 return kTRUE;
558}
de12e454 559//_________________________________________________________________________
f0aa5f6c 560Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) {
561 // get delay
562 if (hs>=6 || chipNr>10) return -1;
563 if (fScanObj==NULL) {
53ae21ce 564 Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","No data!");
f0aa5f6c 565 return -1;
566 }
567 // should be type kDELAY or kDAC with id 42 (delay_ctrl)
568 if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) {
53ae21ce 569 Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","Delay only for scan type %d or %d and dac_id 42.",kDELAY,kDAC);
f0aa5f6c 570 return -1;
571 }
572 if (fMeanMultiplicity[hs][chipNr]==NULL) {
573 if (!ProcessMeanMultiplicity()) {
574 return -1;
575 }
576 }
577
1fd93b67 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);
f0aa5f6c 592 }
593 else {
594 return -1;
595 }
1fd93b67 596
f0aa5f6c 597}
de12e454 598//_________________________________________________________________________
f0aa5f6c 599Int_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) {
53ae21ce 603 Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","No data!");
f0aa5f6c 604 return kFALSE;
605 }
606 // should be type kUNIMA
607 if (fType != kUNIMA) {
53ae21ce 608 Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Noisy pixels Unima only for scan type %d.",kUNIMA);
f0aa5f6c 609 return kFALSE;
610 }
611 if (fScanObj->GetTriggers(0)!=25600) {
53ae21ce 612 Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Process noisy unima: Incorrect number of events (!=25600.");
f0aa5f6c 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}
de12e454 631//_________________________________________________________________________
f0aa5f6c 632Int_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
653Int_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}
de12e454 663//_________________________________________________________________________
f0aa5f6c 664Float_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
685Int_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) {
53ae21ce 689 Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","No data!");
f0aa5f6c 690 return -1;
691 }
692 // should be type kMINTH or kDAC with id 39 (pre_vth)
693 if (fType!=kMINTH && (fType!=kDAC || fDacId!=39)) {
53ae21ce 694 Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","MinTh only for scan type %d OR %d with dac_id 39.",kMINTH,kDAC);
f0aa5f6c 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) {
53ae21ce 705 Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Increase of Mean Multiplicity by %1.2f never reached.",hs,chipNr,fMinIncreaseFromBaseLine);
f0aa5f6c 706 return -1;
707 }
708
709 Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0);
53ae21ce 710 TString funcName = Form("Fit minth func HS%d CHIP%d",hs,chipNr);
711 TF1 *minThFunc = new TF1(funcName.Data(),itsSpdErrorf,100,500,3);
f0aa5f6c 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) {
53ae21ce 732 Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: BaseLine too large (%1.2f>%1.2f).",hs,chipNr,baseLine,fMaxBaseLineLevel);
f0aa5f6c 733 return -1;
734 }
735 UInt_t step=FindClosestLowerStep(lastDac);
736 Float_t compareLine = GetCompareLine(step,hs,chipNr,baseLine);
737 if (compareLine==-1) {
53ae21ce 738 Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Not enough steps (%d<%d) before increase to get a compare line.",hs,chipNr,step,fMinNrStepsBeforeIncrease);
f0aa5f6c 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 {
53ae21ce 754 Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Did not find a point below the compare line (%f).",hs,chipNr,compareLine);
f0aa5f6c 755 return -1;
756 }
757}
de12e454 758//_________________________________________________________________________
1e954f66 759TArrayI AliITSOnlineSPDscanAnalyzer::GetMeanTh(UInt_t hs, UInt_t chipNr) {
f652c3be 760 // calculates and returns the mean threshold
1e954f66 761 TArrayI fitresults(4);
762 if (hs>=6 || chipNr>10) return fitresults;
f652c3be 763 if (fScanObj==NULL) {
764 Error("AliITSOnlineSPDscanAnalyzer::GetMeanTh","No data!");
1e954f66 765 return fitresults;
f652c3be 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);
1e954f66 770 return fitresults;
f652c3be 771 }
772 if (fHitEventEfficiency[hs][chipNr]==NULL) {
773 printf("processing hit efficiency \n");
774 if (!ProcessHitEventEfficiency()) {
775 printf("...not processed!!\n");
1e954f66 776 return fitresults;
f652c3be 777 }
778 }
779 Double_t x,y;
780 fHitEventEfficiency[hs][chipNr]->GetPoint(fHitEventEfficiency[hs][chipNr]->GetN()-1,x,y);
1e954f66 781 Double_t min = x;
f652c3be 782 fHitEventEfficiency[hs][chipNr]->GetPoint(0,x,y);
1e954f66 783 Double_t max = x;
f652c3be 784
1e954f66 785 Double_t mean = 0.5*(min+max);
f652c3be 786 TString funcName = Form("Fit meanth func HS%d CHIP%d",hs,chipNr);
787 TF1 *minThFunc = new TF1(funcName.Data(),itsSpdScurveForMeanTh,min,max,3);
1e954f66 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)
f652c3be 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);
f652c3be 796
1e954f66 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);
f652c3be 804 ly->Draw("same");
1e954f66 805 TLine *lx = new TLine((Double_t)fitresults.At(0),0.,(Double_t)fitresults.At(0),0.5);
f652c3be 806 lx->SetLineStyle(6);
807 lx->Draw("same");
808 delete minThFunc;
1e954f66 809
810 return fitresults;
f652c3be 811}
812
813//_________________________________________________________________________
f0aa5f6c 814Bool_t AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity() {
815 // process mean multiplicity data
816 if (fScanObj==NULL) {
53ae21ce 817 Error("AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity","No data!");
f0aa5f6c 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}
de12e454 843//_________________________________________________________________________
f0aa5f6c 844TGraph* 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}
de12e454 854//_________________________________________________________________________
f0aa5f6c 855Bool_t AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency() {
856 // process hit event efficiency
857 if (fScanObj==NULL) {
53ae21ce 858 Error("AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency","No data!");
f0aa5f6c 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);
1e954f66 872 if (fType==kMINTH || fType==kDAC || fType==kDELAY) {
f0aa5f6c 873 fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),efficiency);
1e954f66 874 } else if(fType==kMEANTH){
875 fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetTPAmp(step,hs),efficiency);
876 } else {
f0aa5f6c 877 fHitEventEfficiency[hs][chipNr]->SetPoint(step,0,efficiency);
878 }
879 }
880 // }
881 }
882 }
883 return kTRUE;
884}
de12e454 885//_________________________________________________________________________
f0aa5f6c 886TGraph* 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}
de12e454 896//_________________________________________________________________________
f0aa5f6c 897Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers() {
898 // process nr of triggers data
899 if (fScanObj==NULL) {
53ae21ce 900 Error("AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers","No data!");
f0aa5f6c 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}
de12e454 919//_________________________________________________________________________
f0aa5f6c 920TGraph* AliITSOnlineSPDscanAnalyzer::GetNrTriggersG() {
921 // returns nr of triggers graph
922 if (fTriggers==NULL) {
923 if (!ProcessNrTriggers()) {
924 return NULL;
925 }
926 }
927 return fTriggers;
928}
de12e454 929//_________________________________________________________________________
f0aa5f6c 930Bool_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}
de12e454 941//_________________________________________________________________________
f0aa5f6c 942UInt_t AliITSOnlineSPDscanAnalyzer::GetRouterNr() {
943 // returns the router nr of scan obj
944 if (fScanObj!=NULL) return fScanObj->GetRouterNr();
945 else return 99;
946}
de12e454 947//_________________________________________________________________________
f0aa5f6c 948TH2F* 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) {
53ae21ce 951 Error("AliITSOnlineSPDscanAnalyzer::GetHitMapTot","No data!");
f0aa5f6c 952 return NULL;
953 }
53ae21ce 954 TString histoname;
f0aa5f6c 955 if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
53ae21ce 956 histoname = Form("Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
f0aa5f6c 957 }
958 else {
53ae21ce 959 histoname = Form("Router %d ",GetRouterNr());
f0aa5f6c 960 }
53ae21ce 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);
f0aa5f6c 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++) {
1e954f66 972 fHitMapTot->Fill(chipNr*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
f0aa5f6c 973 }
974 }
975 }
976 }
977 return fHitMapTot;
978}
de12e454 979//_________________________________________________________________________
1e954f66 980TH2F* 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//_________________________________________________________________________
6727e2db 1018TH2F* 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);
1e954f66 1028 histoTitle = Form("Eq ID %d, Half Stave %d, Chip %d ", GetRouterNr(), hs, chip);
6727e2db 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++) {
8897dce2 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));
6727e2db 1036 }
1037 }
1038
1039 return returnHisto;
1040}
de12e454 1041