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