]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSOnlineSPDscanAnalyzer.cxx
Adding comment lines to class description needed for Root documentation,
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDscanAnalyzer.cxx
CommitLineData
1fd93b67 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 //
23// threshold values can be calculated. //
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 <TF1.h>
36#include <TGraph.h>
37#include <TH2F.h>
38
39Double_t itsSpdErrorf(Double_t *x, Double_t *par){
40 if (par[2]<0) par[2]=0;
41 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.)));
42 return val;
43}
44//Double_t itsSpdErrorfOrig(Double_t *x, Double_t *par){
45// return 0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.));
46//}
47
48
49AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(Char_t *fileName) :
50 fType(99),fDacId(99),fScanObj(NULL),fTriggers(NULL),
51 fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
52 fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(2),fMaxBaseLineLevel(10)
53{
54 // constructor
55 sprintf(fFileName,"%s",fileName);
56 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
57 for (UInt_t hs=0; hs<6; hs++) {
58 fMeanMultiplicity[hs][chipNr]=NULL;
59 fHitEventEfficiency[hs][chipNr]=NULL;
60 }
61 }
62 for (Int_t module=0; module<240; module++) {
63 fHandler[module]=NULL;
64 }
65
66 Init();
67}
68
69AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const AliITSOnlineSPDscanAnalyzer& handle) :
70 fType(99),fDacId(99),fScanObj(NULL),fTriggers(NULL),
71 fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
72 fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(2),fMaxBaseLineLevel(10)
73{
74 // copy constructor, only copies the filename (not the processed data)
75 sprintf(fFileName,"%s",handle.fFileName);
76
77 fScanObj=NULL;
78 fType=99;
79 fDacId=99;
80 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
81 for (UInt_t hs=0; hs<6; hs++) {
82 fMeanMultiplicity[hs][chipNr]=NULL;
83 fHitEventEfficiency[hs][chipNr]=NULL;
84 }
85 }
86 fTriggers=NULL;
87 for (Int_t module=0; module<240; module++) {
88 fHandler[module]=NULL;
89 }
90
91 Init();
92}
93
94AliITSOnlineSPDscanAnalyzer::~AliITSOnlineSPDscanAnalyzer() {
95 // destructor
96 for (UInt_t hs=0; hs<6; hs++) {
97 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
98 if (fMeanMultiplicity[hs][chipNr]!=NULL) {
99 delete fMeanMultiplicity[hs][chipNr];
100 }
101 if (fHitEventEfficiency[hs][chipNr]!=NULL) {
102 delete fHitEventEfficiency[hs][chipNr];
103 }
104 }
105 }
106 if (fTriggers!=NULL) delete fTriggers;
107 if (fScanObj!=NULL) delete fScanObj;
108 for (Int_t module=0; module<240; module++) {
109 if (fHandler[module]!=NULL) {
110 delete fHandler[module];
111 }
112 }
113}
114
115AliITSOnlineSPDscanAnalyzer& AliITSOnlineSPDscanAnalyzer::operator=(const AliITSOnlineSPDscanAnalyzer& handle) {
116 // assignment operator, only copies the filename (not the processed data)
117 if (this!=&handle) {
118 for (UInt_t hs=0; hs<6; hs++) {
119 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
120 if (fMeanMultiplicity[hs][chipNr]!=NULL) {
121 delete fMeanMultiplicity[hs][chipNr];
122 }
123 if (fHitEventEfficiency[hs][chipNr]!=NULL) {
124 delete fHitEventEfficiency[hs][chipNr];
125 }
126 }
127 }
128 if (fTriggers!=NULL) delete fTriggers;
129 if (fScanObj!=NULL) delete fScanObj;
130 for (Int_t module=0; module<240; module++) {
131 if (fHandler[module]!=NULL) {
132 delete fHandler[module];
133 }
134 }
135
136 sprintf(fFileName,"%s",handle.fFileName);
137
138 fScanObj=NULL;
139 fType=99;
140 fDacId=99;
141 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
142 for (UInt_t hs=0; hs<6; hs++) {
143 fMeanMultiplicity[hs][chipNr]=NULL;
144 fHitEventEfficiency[hs][chipNr]=NULL;
145 }
146 }
147 fTriggers=NULL;
148 for (Int_t module=0; module<240; module++) {
149 fHandler[module]=NULL;
150 }
151
152 Init();
153 }
154 return *this;
155}
156
157void AliITSOnlineSPDscanAnalyzer::Init() {
158 // first checks type of container and then initializes container obj
159 FILE* fp0 = fopen(fFileName, "r");
160 if (fp0 == NULL) {
161 return;
162 }
163 else {
164 fclose(fp0);
165 }
166 fScanObj = new AliITSOnlineSPDscan(fFileName);
167 fType = fScanObj->GetType();
168 delete fScanObj;
169
170 // init container
171 switch(fType) {
172 case kUNIMA:
173 case kNOISE:
174 fScanObj = new AliITSOnlineSPDscanSingle(fFileName);
175 break;
176 case kMINTH:
177 case kDAC:
178 case kDELAY:
179 fScanObj = new AliITSOnlineSPDscanMultiple(fFileName);
180 fDacId = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacId();
181 break;
182 case kMEANTH:
183 fScanObj = new AliITSOnlineSPDscanMeanTh(fFileName);
184 fDacId = ((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetDacId();
185 break;
186 default:
187 printf("Type %d not defined!\n",fType);
188 fScanObj=NULL;
189 return;
190 break;
191 }
192
193 // set some default values (these should later be read from text file)
194 fOverWrite=kFALSE;
195 fNoiseThreshold=0.01;
196 fNoiseMinimumEvents=100;
197 fMinNrStepsBeforeIncrease=6;
198 fMinIncreaseFromBaseLine=2;
199 fStepDownDacSafe=2;
200 fMaxBaseLineLevel=10;
201
202}
203
204
205Bool_t AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels(Char_t *oldcalibDir) {
206 // process dead pixel data
207 if (fScanObj==NULL) {
208 printf("No data!\n");
209 return kFALSE;
210 }
211 // should be type kUNIMA
212 if (fType!=kUNIMA) {
213 printf("Dead pixels only for scan type %d\n",kUNIMA);
214 return kFALSE;
215 }
216
217 Int_t nrDead[240];
218 for (Int_t i=0; i<240; i++) {
219 nrDead[i]=0;
220 }
221 UInt_t routerNr = fScanObj->GetRouterNr();
222 UInt_t rowStart = fScanObj->GetRowStart();
223 UInt_t rowEnd = fScanObj->GetRowEnd();
224 for (UInt_t hs=0; hs<6; hs++) {
225 for (UInt_t chipNr=0; chipNr<10; chipNr++) {
226 if (fScanObj->GetChipPresent(hs,chipNr) && fScanObj->GetAverageMultiplicity(0,hs,chipNr)>0) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
227 UInt_t module = AliITSRawStreamSPD::GetModuleNumber(routerNr,hs*2+chipNr/5);
228 if (!fHandler[module]) {
229 fHandler[module] = new AliITSOnlineCalibrationSPDhandler(module);
230 }
231 fHandler[module]->SetFileLocation(oldcalibDir);
232 fHandler[module]->ReadFromFile();
233 if (fOverWrite) {fHandler[module]->ResetDead();}
234 for (UInt_t col=0; col<32; col++) {
235 for (UInt_t row=rowStart; row<=rowEnd; row++) {
236 if (col!=1 && col!=9 && col!=17 && col!=25) { //exclude test columns!!!
237 if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
238 Int_t newCol = 32*(chipNr%5) + col;
239 if (fHandler[module]->SetDeadPixel(newCol,row)) {
240 nrDead[module]++;
241 }
242 }
243 }
244 }
245 }
246 }
247 }
248 }
249 return kTRUE;
250}
251
252
253
254Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels(Char_t *oldcalibDir) {
255 // process noisy pixel data
256 if (fScanObj==NULL) {
257 printf("No data!\n");
258 return kFALSE;
259 }
260 // should be type kNOISE
261 if (fType != kNOISE) {
262 printf("Noisy pixels only for scan type %d\n",kNOISE);
263 return kFALSE;
264 }
265
266 Int_t nrNoisy[240];
267 for (Int_t i=0; i<240; i++) {
268 nrNoisy[i]=0;
269 }
270 if (fScanObj->GetTriggers(0)<fNoiseMinimumEvents) {
271 printf("Error: Process noisy: Too few events.\n");
272 return kFALSE;
273 }
274 UInt_t routerNr = fScanObj->GetRouterNr();
275 for (UInt_t hs=0; hs<6; hs++) {
276 for (UInt_t chipNr=0; chipNr<10; chipNr++) {
277 if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
278 UInt_t module = AliITSRawStreamSPD::GetModuleNumber(routerNr,hs*2+chipNr/5);
279 for (UInt_t col=0; col<32; col++) {
280 for (UInt_t row=0; row<256; row++) {
281 if (fScanObj->GetHitsEfficiency(0,hs,chipNr,col,row)>fNoiseThreshold) {
282 if (!fHandler[module]) {
283 fHandler[module] = new AliITSOnlineCalibrationSPDhandler(module);
284 }
285 fHandler[module]->SetFileLocation(oldcalibDir);
286 fHandler[module]->ReadFromFile();
287 if (fOverWrite) {fHandler[module]->ResetNoisy();}
288 Int_t newCol = 32*(chipNr%5) + col;
289 if (fHandler[module]->SetNoisyPixel(newCol,row)) {
290 nrNoisy[module]++;
291 }
292 }
293 }
294 }
295 }
296 }
297 }
298 return kTRUE;
299}
300
301Bool_t AliITSOnlineSPDscanAnalyzer::SaveDeadNoisyPixels(UInt_t module, Char_t *calibDir) {
302 // save dead and noisy pixels to file in dir calibDir
303 if (fHandler[module]!=NULL) {
304 fHandler[module]->SetFileLocation(calibDir);
305 fHandler[module]->WriteToFile();
306 return kTRUE;
307 }
308 return kFALSE;
309}
310
1fd93b67 311
312
313
f0aa5f6c 314Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) {
315 // get delay
316 if (hs>=6 || chipNr>10) return -1;
317 if (fScanObj==NULL) {
318 printf("No data!\n");
319 return -1;
320 }
321 // should be type kDELAY or kDAC with id 42 (delay_ctrl)
322 if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) {
323 printf("Delay only for scan type %d or %d and dac_id 42\n",kDELAY,kDAC);
324 return -1;
325 }
326 if (fMeanMultiplicity[hs][chipNr]==NULL) {
327 if (!ProcessMeanMultiplicity()) {
328 return -1;
329 }
330 }
331
1fd93b67 332 UInt_t maxStep=0;
333 Float_t maxVal=0;
334 for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
335 Double_t thisDac;
336 Double_t thisMult;
337 fMeanMultiplicity[hs][chipNr]->GetPoint(step,thisDac,thisMult);
338 if (thisMult > maxVal) {
339 maxVal = thisMult;
340 maxStep = step;
341 }
342 }
343
344 if (maxVal>0) {
345 return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(maxStep);
f0aa5f6c 346 }
347 else {
348 return -1;
349 }
1fd93b67 350
f0aa5f6c 351}
352
1fd93b67 353
354// ********** old version of "GetDelay", which fits a gaussian to the meanmult graph
355//Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) {
356// // get delay
357// if (hs>=6 || chipNr>10) return -1;
358// if (fScanObj==NULL) {
359// printf("No data!\n");
360// return -1;
361// }
362// // should be type kDELAY or kDAC with id 42 (delay_ctrl)
363// if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) {
364// printf("Delay only for scan type %d or %d and dac_id 42\n",kDELAY,kDAC);
365// return -1;
366// }
367// if (fMeanMultiplicity[hs][chipNr]==NULL) {
368// if (!ProcessMeanMultiplicity()) {
369// return -1;
370// }
371// }
372//
373// Char_t funcName[30];
374// sprintf(funcName,"Fit delay func HS%d CHIP%d",hs,chipNr);
375// Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0);
376// Int_t maxDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(fScanObj->GetNSteps()-1);
377// TF1* delayFunc = new TF1(funcName,"gaus",minDac,maxDac);
378// fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0");
379// Double_t mean = delayFunc->GetParameter(1);
380// // Double_t sigma = fDelayFunc[hs][chipNr]->GetParameter(2);
381// delete delayFunc;
382// if (mean>minDac && mean<maxDac) {
383// return (Int_t) (mean+0.5);
384// }
385// else {
386// return -1;
387// }
388//}
389
f0aa5f6c 390Int_t AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima(UInt_t hs, UInt_t chipNr) {
391 // in case of a uniformity scan, returns the nr of noisy pixels, (here > 200 hits)
392 if (hs>=6 || chipNr>10) return -1;
393 if (fScanObj==NULL) {
394 printf("No data!\n");
395 return kFALSE;
396 }
397 // should be type kUNIMA
398 if (fType != kUNIMA) {
399 printf("Noisy pixels Unima only for scan type %d\n",kUNIMA);
400 return kFALSE;
401 }
402 if (fScanObj->GetTriggers(0)!=25600) {
403 printf("Error: Process noisy unima: Incorrect number of events (!=25600.\n");
404 return kFALSE;
405 }
406
407 Int_t nrNoisy=0;
408 if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
409 for (UInt_t col=0; col<32; col++) {
410 for (UInt_t row=0; row<256; row++) {
411 if (fScanObj->GetHits(0,hs,chipNr,col,row)>200) {
412 nrNoisy++;
413 }
414 }
415 }
416 }
417 else {
418 return -1;
419 }
420 return nrNoisy;
421}
422
423Int_t AliITSOnlineSPDscanAnalyzer::FindLastMinThDac(UInt_t hs, UInt_t chipNr) {
424 // returns dac value where fMinIncreaseFromBaseLine reached
425 if (hs>=6 || chipNr>10) return -1;
426 if (fMeanMultiplicity[hs][chipNr]==NULL) {
427 if (!ProcessMeanMultiplicity()) {
428 return -1;
429 }
430 }
431 Double_t firstVal, dummy1;
432 fMeanMultiplicity[hs][chipNr]->GetPoint(0,dummy1,firstVal);
433 UInt_t step=0;
434 while (step<fScanObj->GetNSteps()-1) {
435 Double_t graphVal, dummy2;
436 fMeanMultiplicity[hs][chipNr]->GetPoint(step+1,dummy2,graphVal);
437 if (graphVal>firstVal+fMinIncreaseFromBaseLine) break;
438 step++;
439 }
440 if (step==fScanObj->GetNSteps()-1) return -1;
441 return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step);
442}
443
444Int_t AliITSOnlineSPDscanAnalyzer::FindClosestLowerStep(Float_t dacValueInput) {
445 // returns step closest (lower) to a dacvalue
446 UInt_t step=0;
447 while (step<fScanObj->GetNSteps()-1) {
448 Int_t dacVal = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1);
449 if (dacVal>=dacValueInput) break;
450 step++;
451 }
452 return step;
453}
454
455Float_t AliITSOnlineSPDscanAnalyzer::GetCompareLine(UInt_t step, UInt_t hs, UInt_t chipNr, Float_t basePar2) {
456 // returns value to compare mean mult with (when finding min th)
457 if (hs>=6 || chipNr>10) return -1;
458 if (step<fMinNrStepsBeforeIncrease) return -1;
459 Float_t baseLine = basePar2;
460 if (baseLine<0) baseLine=0;
461 Float_t baseAdd;
462 Double_t baseM=0;
463 Double_t baseS=0;
464 Double_t d,m;
465 for (UInt_t st=1;st<2*step/3;st++) { // skip first point...
466 fMeanMultiplicity[hs][chipNr]->GetPoint(st,d,m);
467 baseM+=m-baseLine;
468 baseS+=(m-baseLine)*(m-baseLine);
469 }
470 baseAdd=2*sqrt( baseS/(2*step/3-1) - (baseM/(2*step/3-1))*(baseM/(2*step/3-1)) );
471 baseAdd+=0.03; // magic number
472 if (baseAdd>fMinIncreaseFromBaseLine) baseAdd=fMinIncreaseFromBaseLine;
473 return baseLine + baseAdd;
474}
475
476Int_t AliITSOnlineSPDscanAnalyzer::GetMinTh(UInt_t hs, UInt_t chipNr) {
477 // calculates and returns the minimum threshold
478 if (hs>=6 || chipNr>10) return -1;
479 if (fScanObj==NULL) {
480 printf("No data!\n");
481 return -1;
482 }
483 // should be type kMINTH or kDAC with id 39 (pre_vth)
484 if (fType!=kMINTH && (fType!=kDAC || fDacId!=39)) {
485 printf("MinTh only for scan type %d OR %d with dac_id 39\n",kMINTH,kDAC);
486 return -1;
487 }
488 if (fMeanMultiplicity[hs][chipNr]==NULL) {
489 if (!ProcessMeanMultiplicity()) {
490 return -1;
491 }
492 }
493
494 Int_t lastDac = FindLastMinThDac(hs,chipNr);
495 if (lastDac==-1) {
496 printf("GetMinTh: HS%d, Chip%d: Increase of Mean Multiplicity by %1.2f never reached.\n",hs,chipNr,fMinIncreaseFromBaseLine);
497 return -1;
498 }
499
500 Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0);
501 Char_t funcName[30];
502 sprintf(funcName,"Fit minth func HS%d CHIP%d",hs,chipNr);
503 TF1 *minThFunc = new TF1(funcName,itsSpdErrorf,100,500,3);
504 minThFunc->SetParameter(0,lastDac+10);
505 minThFunc->SetParameter(1,2);
506 minThFunc->SetParameter(2,0);
507 minThFunc->SetParName(0,"Mean");
508 minThFunc->SetParName(1,"Sigma");
509 minThFunc->SetParName(2,"BaseLine");
510 minThFunc->SetLineWidth(1);
511 if (fMeanMultiplicity[hs][chipNr]==NULL) {
512 if (!ProcessMeanMultiplicity()) {
513 return -1;
514 }
515 }
516 fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0","",minDac,lastDac);
517
518 // Double_t mean = fMinThFunc[hs][chipNr]->GetParameter(0);
519 // Double_t sigma = fMinThFunc[hs][chipNr]->GetParameter(1);
520 Double_t baseLine = minThFunc->GetParameter(2);
521 delete minThFunc;
522
523 if (baseLine>fMaxBaseLineLevel) {
524 printf("GetMinTh: HS%d, Chip%d: BaseLine too large (%1.2f>%1.2f)\n",hs,chipNr,baseLine,fMaxBaseLineLevel);
525 return -1;
526 }
527 UInt_t step=FindClosestLowerStep(lastDac);
528 Float_t compareLine = GetCompareLine(step,hs,chipNr,baseLine);
529 if (compareLine==-1) {
530 printf("GetMinTh: HS%d, Chip%d: Not enough steps (%d<%d) before increase to get a compare line.\n",hs,chipNr,step,fMinNrStepsBeforeIncrease);
531 return -1;
532 }
533
534 Double_t mult, dummy;
535 mult=1000;
536 while (mult > compareLine && step>0) {
537 fMeanMultiplicity[hs][chipNr]->GetPoint(step,dummy,mult);
538 step--;
539 }
540 Int_t minth = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1)-fStepDownDacSafe;
541
542 if (step>0) {
543 return minth;
544 }
545 else {
546 printf("GetMinTh: HS%d, Chip%d: Did not find a point below the compare line (%f).\n",hs,chipNr,compareLine);
547 return -1;
548 }
549}
550
551
552
553Bool_t AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity() {
554 // process mean multiplicity data
555 if (fScanObj==NULL) {
556 printf("No data!\n");
557 return kFALSE;
558 }
559 for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
560 for (UInt_t hs=0; hs<6; hs++) {
561 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
562 // if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
563 if (step==0) {
564 if (fMeanMultiplicity[hs][chipNr]!=NULL) {
565 delete fMeanMultiplicity[hs][chipNr];
566 }
567 fMeanMultiplicity[hs][chipNr] = new TGraph();
568 }
569 Float_t multiplMean=fScanObj->GetAverageMultiplicity(step,hs,chipNr);
570 if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
571 fMeanMultiplicity[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),multiplMean);
572 }
573 else {
574 fMeanMultiplicity[hs][chipNr]->SetPoint(step,0,multiplMean);
575 }
576 }
577 // }
578 }
579 }
580 return kTRUE;
581}
582
583TGraph* AliITSOnlineSPDscanAnalyzer::GetMeanMultiplicityG(UInt_t hs, UInt_t chipNr) {
584 // returns mean multiplicity graph
585 if (hs>=6 || chipNr>10) return NULL;
586 if (fMeanMultiplicity[hs][chipNr]==NULL) {
587 if (!ProcessMeanMultiplicity()) {
588 return NULL;
589 }
590 }
591 return fMeanMultiplicity[hs][chipNr];
592}
593
594Bool_t AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency() {
595 // process hit event efficiency
596 if (fScanObj==NULL) {
597 printf("No data!\n");
598 return kFALSE;
599 }
600 for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
601 for (UInt_t hs=0; hs<6; hs++) {
602 for (UInt_t chipNr=0; chipNr<11; chipNr++) {
603 // if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
604 if (step==0) {
605 if (fHitEventEfficiency[hs][chipNr]!=NULL) {
606 delete fHitEventEfficiency[hs][chipNr];
607 }
608 fHitEventEfficiency[hs][chipNr] = new TGraph();
609 }
610 Float_t efficiency=fScanObj->GetHitEventsEfficiency(step,hs,chipNr);
611 if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
612 fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),efficiency);
613 }
614 else {
615 fHitEventEfficiency[hs][chipNr]->SetPoint(step,0,efficiency);
616 }
617 }
618 // }
619 }
620 }
621 return kTRUE;
622}
623
624TGraph* AliITSOnlineSPDscanAnalyzer::GetHitEventEfficiencyG(UInt_t hs, UInt_t chipNr) {
625 // returns hit event efficiency graph
626 if (hs>=6 || chipNr>10) return NULL;
627 if (fHitEventEfficiency[hs][chipNr]==NULL) {
628 if (!ProcessHitEventEfficiency()) {
629 return NULL;
630 }
631 }
632 return fHitEventEfficiency[hs][chipNr];
633}
634
635
636Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers() {
637 // process nr of triggers data
638 if (fScanObj==NULL) {
639 printf("No data!\n");
640 return kFALSE;
641 }
642 for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
643 if (step==0) {
644 if (fTriggers!=NULL) {
645 delete fTriggers;
646 }
647 fTriggers = new TGraph();
648 }
649 if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
650 fTriggers->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),fScanObj->GetTriggers(step));
651 }
652 else {
653 fTriggers->SetPoint(step,0,fScanObj->GetTriggers(step));
654 }
655 }
656 return kTRUE;
657}
658
659TGraph* AliITSOnlineSPDscanAnalyzer::GetNrTriggersG() {
660 // returns nr of triggers graph
661 if (fTriggers==NULL) {
662 if (!ProcessNrTriggers()) {
663 return NULL;
664 }
665 }
666 return fTriggers;
667}
668
669Bool_t AliITSOnlineSPDscanAnalyzer::GetHalfStavePresent(UInt_t hs) {
670 // returns half stave present info
671 if (hs<6 && fScanObj!=NULL) {
672 Int_t chipstatus=0;
673 for (Int_t chip=0; chip<10; chip++) {
674 chipstatus+=fScanObj->GetChipPresent(hs,chip);
675 }
676 if (chipstatus>0) return kTRUE;
677 }
678 return kFALSE;
679}
680
681AliITSOnlineCalibrationSPDhandler* AliITSOnlineSPDscanAnalyzer::GetOnlineCalibrationHandler(UInt_t module) {
682 // returns a pointer to the AliITSOnlineCalibrationSPDhandler
683 if (module<240) return fHandler[module];
684 else return NULL;
685}
686
687UInt_t AliITSOnlineSPDscanAnalyzer::GetRouterNr() {
688 // returns the router nr of scan obj
689 if (fScanObj!=NULL) return fScanObj->GetRouterNr();
690 else return 99;
691}
692
693TH2F* AliITSOnlineSPDscanAnalyzer::GetHitMapTot(UInt_t step) {
694 // creates and returns a pointer to a hitmap histo (half sector style a la spdmood)
695 if (fScanObj==NULL) {
696 printf("No data!\n");
697 return NULL;
698 }
699 Char_t histoname[50];
700 if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
701 sprintf(histoname,"Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
702 }
703 else {
704 sprintf(histoname,"Router %d ",GetRouterNr());
705 }
706 TH2F* fHitMapTot = new TH2F(histoname,histoname,32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5);
707 fHitMapTot->SetNdivisions(-10,"X");
708 fHitMapTot->SetNdivisions(-006,"Y");
709 fHitMapTot->SetTickLength(0,"X");
710 fHitMapTot->SetTickLength(0,"Y");
711 fHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor());
712 fHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor());
713 for (UInt_t hs=0; hs<6; hs++) {
714 for (UInt_t chipNr=0; chipNr<10; chipNr++) {
715 for (UInt_t col=0; col<32; col++) {
716 for (UInt_t row=0; row<256; row++) {
717 fHitMapTot->Fill(chipNr*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
718 }
719 }
720 }
721 }
722 return fHitMapTot;
723}