1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * withount fee, provided thats the abov 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 **************************************************************************/
16 /* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // QA of black events //
23 // Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
25 ////////////////////////////////////////////////////////////////////////////
39 #include "AliRawReader.h"
41 #include "AliTRDrawStreamOld.h"
42 #include "AliTRDqaBlackEvents.h"
44 ClassImp(AliTRDqaBlackEvents)
46 ///////////////////////////////////////////////////////////////////////////////////////////////////
48 AliTRDqaBlackEvents::AliTRDqaBlackEvents()
84 // to create the histograms call Init()
87 for (Int_t i = 0; i < kDET; i++) {
98 fnEntriesRMDist[i] = 0x0;
100 fChNoiseRes[i] = 0x0;
101 fErrorLocHC[i] = 0x0;
102 fErrorLocMCM[i] = 0x0;
103 fErrorLocADC[i] = 0x0;
105 for (Int_t i = 0; i < 3; i++) {
113 for (Int_t i = 0; i < 2; i++) {
118 for (Int_t i = 0; i < kSM; i++) {
119 fSmNoiseRms[i] = 0x0;
120 fSmNoiseFit[i] = 0x0;
123 for (Int_t i = 0; i < kSM+1; i++) {
127 for (Int_t i = 0; i < 1000; i++) {
130 for (Int_t i = 0; i < kDET*kROB*kMCM; i++) {
131 fFullSignal[i] = 0x0;
134 //strncpy(fRefFileName,"",256);
138 ///////////////////////////////////////////////////////////////////////////////////////////////////
140 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
176 // to create the histograms call Init()
179 for (Int_t i = 0; i < kDET; i++) {
183 fNPointDist[i] = 0x0;
189 fnEntriesRM[i] = 0x0;
190 fnEntriesRMDist[i] = 0x0;
192 fChNoiseRes[i] = 0x0;
193 fErrorLocHC[i] = 0x0;
194 fErrorLocMCM[i] = 0x0;
195 fErrorLocADC[i] = 0x0;
197 for (Int_t i = 0; i < 3; i++) {
205 for (Int_t i = 0; i < 2; i++) {
210 for (Int_t i = 0; i < kSM; i++) {
211 fSmNoiseRms[i] = 0x0;
212 fSmNoiseFit[i] = 0x0;
215 for (Int_t i = 0; i < kSM+1; i++) {
219 for (Int_t i = 0; i < 1000; i++) {
222 for (Int_t i = 0; i < kDET*kROB*kMCM; i++) {
223 fFullSignal[i] = 0x0;
226 //strncpy(fRefFileName,"",256);
230 ///////////////////////////////////////////////////////////////////////////////////////////////////
232 void AliTRDqaBlackEvents::Init()
235 // creates histograms
239 //Info("Init", "Statring");
243 // histograms for chambers
244 for(Int_t det=0; det<kDET; det++) {
246 fNPoint[det] = new TH2D(Form("entries_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
247 //fData[det] = new TH3F(Form("data_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
249 // pedestal noise maps using RMS and Fit
250 fChPed[det] = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
251 fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
253 //fChPed[det] = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
254 //fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
256 // distribution per detector
257 fPed[det] = new TH1D(Form("pedDist_%d", det), ";pedestals (ADC counts)", 100, 5, 15);
258 fNoise[det] = new TH1D(Form("noiseDist_%d", det), ";noise (ADC counts)", 100, 0, 5);
259 fSignal[det] = new TH1D(Form("signal_%d", det), ";signal (ADC counts)", 100, -0.5, 99.5);
260 fChPP[det] = new TH1D(Form("pp_%d", det), ";pp (ADC)", 200, -0.5, 199.5);
262 fnEntriesRM[det] = new TH2D(Form("entriesRM_%d", det), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);
264 // histograms after reference subtraction
265 fChPedRes[det] = new TH2D(Form("pedRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
266 fChNoiseRes[det] = new TH2D(Form("noiseRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
270 fErrorLocMCM[det] = new TH2D(Form("errorLocMCM_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
271 fErrorLocADC[det] = new TH2D(Form("errorLocADC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
272 fErrorLocHC[det] = new TH2D(Form("errorLocHC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
275 // histogram for each MCM
276 for(Int_t i=0; i < kDET * kROB * kMCM; i++)
279 // histograms from the whole detector
280 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);
281 fDetRob = new TH2D("DetRob", ";detector;ROB", kDET, -0.5, 539.5, 8, -0.5, 7.5);
282 fTBEvent = new TH2D("tbEvent", ";event ID;time bin", 100, -0.5, 99.5, 30, -0.5, 29.5);
284 // errors statistics and location
285 fErrorHC = new TH1D("errorHC", ";error ID;", 18, -3.5, 14.5);
286 fErrorMCM = new TH1D("errorMCM", ";error ID;", 18, -3.5, 14.5);
287 fErrorADC = new TH1D("errorADC", ";error ID;", 18, -3.5, 14.5);
289 fErrorSMHC = new TH1D("errorSM_HC", ";SM id", 18, -0.5, 17.5);
290 fErrorSMMCM = new TH1D("errorSM_MCM", ";SM id", 18, -0.5, 17.5);
291 fErrorSMADC = new TH1D("errorSM_ADC", ";SM id", 18, -0.5, 17.5);
294 fErrorGraphHC = new TGraph();
295 fErrorGraphMCM = new TGraph();
296 fErrorGraphADC = new TGraph();
298 fGraphMCM = new TGraph();
300 for(Int_t i=0; i<3; i++) {
301 fGraphPP[i] = new TGraph();
305 fMapMCM = new TH2D("mapMCM", ";det;mcm", 540, -0.5, 539.5, kROB*kMCM, -0.5, kROB*kMCM-0.5);
306 fFracMCM = new TH1D("fracMCM", ";frequency", 100, 0, 1);
309 fErrorGraphHC->GetHistogram()->SetTitle("fraction of events with HC error;event number");
310 fErrorGraphMCM->GetHistogram()->SetTitle("fraction of events with MCM error;event number;");
311 fErrorGraphADC->GetHistogram()->SetTitle("fraction of events with ADC error;event number;");
314 fSMHCped = new TH2D("smHcPed", ";super module;half chamber", 18, -0.5, 17.5, 60, -0.5, 59.5);
317 const char *linkName[3] = {"smLink", "smBeaf", "smData"};
318 const char *linkGrName[3] = {"grSmLink", "grSmBeaf", "grSmData"};
319 for(Int_t i=0; i<3; i++) {
320 fSMLink[i] = new TH2D(linkName[i], ";super module;link", 18, -0.5, 17.5, 60, -0.5, 59.5);
321 fGrLink[i] = new TGraph();
322 fGrLink[i]->SetName(linkGrName[i]);
325 //fZSsize = new TH1D("zssizeSingle", ";threshold;nADC", 40, -0.5, 39.5);
328 //Info("Init", "Done");
330 // number of ADC channels fired per SM and in total
331 for(Int_t sm=0; sm<kSM+1; sm++)
332 fNumberADC[sm] = new TGraph();
335 fNoiseTotal = new TH1D("noiseTotal", "noise (ADC)", 250, 0, 10);
336 fPP = new TH1D("peakPeak", "p-p (ADC)", 200, -0.5, 199.5);
338 for(Int_t sm=0; sm<kSM; sm++) {
339 fSmNoiseRms[sm] = new TH1D(Form("noiseRms_sm%d", sm), ";noise from RMS (ADC)", 100, 0, 10);
340 fSmNoiseFit[sm] = new TH1D(Form("noiseFit_sm%d", sm), ";noise frim Fit (ADC)", 100, 0, 10);
341 fSmPP[sm] = new TH1D(Form("peakPeak_sm%d", sm), ";peak-peak (ADC)", 200, -0.5, 199.5);
344 // event number consistancy
345 for(Int_t i=0; i<1000; i++) {
346 fEvNoDist[i] = new TH1D(Form("mcmEvDist_%d", i), ";#Delta Events", 201, -100.5, 100.5);
350 fMcmTracks = new TObjArray();
353 for(Int_t det=0; det<kDET; det++)
354 for(Int_t row=0; row<kROW; row++)
355 for(Int_t pad=0; pad<kPAD; pad++)
356 for(Int_t ch=0; ch<kCH; ch++) {
357 fDataDirect[det][row][pad][ch] = 0;
358 fSignalDirect[det][ch] = 0; // overdone
363 ///////////////////////////////////////////////////////////////////////////////////////////////////
365 void AliTRDqaBlackEvents::Reset()
368 // Resets the histograms
371 for(Int_t i=0; i<kDET; i++) {
374 fChNoise[i]->Reset();
379 ///////////////////////////////////////////////////////////////////////////////////////////////////
381 void AliTRDqaBlackEvents::SetRefFile(const char *filename) {
383 //strncpy(fRefFileName,filename,256);
384 fRefFileName = filename;
388 ///////////////////////////////////////////////////////////////////////////////////////////////////
390 void AliTRDqaBlackEvents::ReadRefHists(Int_t det) {
392 // Read the reference histograms
399 if (fRefFileName) file = TFile::Open(fRefFileName);
402 fRefHistPed = (TH2D*)file->Get(Form("ped_%d",det));
403 fRefHistNoise = (TH2D*)file->Get(Form("noise_%d", det));
405 if (file) file->Close();
408 ///////////////////////////////////////////////////////////////////////////////////////////////////
410 void AliTRDqaBlackEvents::StartEvent()
416 // clear the mcm data
417 for(Int_t i=0; i < kDET * kROB * kMCM; i++) {
418 if (fFullSignal[i]) fFullSignal[i]->Reset();
422 for(Int_t i=0; i<2; i++) {
429 Int_t ppThresh[3] = {10, 20, 40};
430 for(Int_t i=0; i<3; i++) {
431 fppThresh[i] = ppThresh[i];
436 for(Int_t sm=0; sm<kSM+1; sm++) fnADCinSM[sm] = 0;
438 if (fRefEv > 0) fRefEv++;
439 fEvNoDist[999]->Reset(); // keep only the last event
443 ///////////////////////////////////////////////////////////////////////////////////////////////////
445 void AliTRDqaBlackEvents::AddBuffer(AliTRDrawStreamOld *data, AliRawReader * const reader)
448 //printf ("try to read data\n");
449 Int_t nextBuff = data->NextBuffer();
450 //printf("done ...\n");
452 if (nextBuff == 0) return;
454 Int_t sm = reader->GetEquipmentId() - 1024;
455 //printf("reading SM %d\n", sm);
456 AliInfo(Form("reading SM %d", sm));
458 if (sm < 0 || sm > 17) return;
460 // lopp over stacks, links ...
462 for (Int_t istack = 0; istack < 5; istack++) {
463 for (Int_t ilink = 0; ilink < 12; ilink++) {
465 //printf("HC = %d %d\n", istack, ilink);
467 Int_t det = sm * 30 + istack * 6 + ilink/2;
469 // check if data delivered
470 if (!(data->IsLinkActiveInStack(istack, ilink))) continue;
471 fSMLink[0]->Fill(sm, istack * 12 + ilink);
474 // check if beaf-beaf
475 if (data->GetLinkMonitorError(istack, ilink)) {
476 fSMLink[1]->Fill(sm, istack * 12 + ilink);
481 // fill histogram with HC header errors
485 nErrHc = FillBits(fErrorHC, data->GetH0ErrorCode(istack, ilink), 0);
486 if (!nErrHc) fErrorHC->Fill(-3);
489 nErrHc = FillBits(fErrorHC, data->GetH1ErrorCode(istack, ilink), 2);
490 if (!nErrHc) fErrorHC->Fill(-2);
493 nErrHc = FillBits(fErrorHC, data->GetHCErrorCode(istack, ilink), 4);
494 if (!nErrHc) fErrorHC->Fill(-1);
501 fErrorSMHC->Fill(sm);
504 // data integrity protection
506 //if (data->GetHCErrorCode(istack, ilink) > 0) continue;
507 if (data->GetH0ErrorCode(istack, ilink) > 0) continue;
508 if (data->GetH1ErrorCode(istack, ilink) > 0) continue;
510 fSMLink[2]->Fill(sm, istack * 12 + ilink);
514 for (Int_t imcm = 0; imcm < data->GetHCMCMmax(istack, ilink); imcm++ ){
516 //printf("mcm = %d %d %d\n", istack, ilink, imcm);
518 // fill MCM error code
521 Int_t nErrMcmTot = 0;
523 nErrMcm = FillBits(fErrorMCM, data->GetMCMhdErrorCode(istack, ilink, imcm), 0);
524 if (!nErrMcm) fErrorMCM->Fill(-3);
525 nErrMcmTot += nErrMcm;
527 nErrMcm = FillBits(fErrorMCM, data->GetMCMADCMaskErrorCode(istack, ilink, imcm), 5);
528 if (!nErrMcm) fErrorMCM->Fill(-2);
529 nErrMcmTot += nErrMcm;
531 nErrMcm = FillBits(fErrorMCM, data->GetMCMErrorCode(istack, ilink, imcm), 10);
532 if (!nErrMcm) fErrorMCM->Fill(-1);
533 nErrMcmTot += nErrMcm;
537 if (nErrMcmTot > 0) {
539 fErrorSMMCM->Fill(sm);
543 if ( (data->GetMCMhdErrorCode(istack,ilink,imcm)) & 2 ) continue;
544 //if ((data->GetMCMADCMaskErrorCode(istack,ilink,imcm))) continue;
545 //if ((data->GetMCMErrorCode(istack,ilink,imcm))) continue;
547 Int_t mcmEvent = data->GetEventNumber(istack, ilink, imcm);
549 // set the reference event number
552 printf("Reference Event Number = %d (%d %d %d)\n", fRefEv, istack, ilink, imcm);
555 // fill event distribution
556 if (!(fnEvents%10)) {
557 fEvNoDist[fnEvents/10]->Fill(mcmEvent - fRefEv);
560 fEvNoDist[999]->Fill(mcmEvent - fRefEv);
562 Int_t mcm = data->GetMCM(istack, ilink, imcm);
563 Int_t rob = data->GetROB(istack, ilink, imcm);
565 // create a structure for an MCM if needed
566 Int_t mcmIndex = det * (kMCM * kROB) + rob * kMCM + mcm;
567 if (fCreateFull && !fFullSignal[mcmIndex])
568 fFullSignal[mcmIndex] =
569 new TH2S(Form("mcm_%d_%d_%d_%d_%d", sm, istack, ilink/2, rob, mcm),
570 Form("mcm-%d-%d-%d-%d-%d;ADC;time bin", sm, istack, ilink/2, rob, mcm),
571 21, -0.5, 20.5, 30, -0.5, 29.5);
574 //Int_t zsADC[21][40];
576 for(Int_t ina=0; ina<21; ina++)
577 for(Int_t th=0; th<40; th++)
581 // first loop over ADC chanels
583 for (Int_t iadc=0; iadc < data->GetADCcount(istack, ilink, imcm); iadc++) {
585 //printf("ADC = %d\n", iadc);
588 // fill ADC error bits
589 Int_t nErrAdc = FillBits(fErrorADC, data->GetADCErrorCode(), 0);
590 if (!nErrAdc) fErrorADC->Fill(-1);
595 fErrorSMADC->Fill(sm);
599 if ((data->GetADCErrorCode(istack,ilink,imcm,iadc))) continue;
604 Int_t *sig = data->GetSignalDirect(istack, ilink, imcm, iadc);
606 //Int_t adc = data->GetADCnumber(istack, ilink, imcm, iadc);
607 Int_t row = data->GetRow(istack, ilink, imcm);
608 Int_t col = data->GetCol(istack, ilink, imcm, iadc);
610 // loop over Time Bins and fill histograms
611 for(Int_t k=0; k < data->GetNumberOfTimeBins(istack, ilink); k++) {
613 //fSignal[det]->Fill(sig[k]);
614 //fData[det]->Fill(row, col, sig[k]); // slow
616 if ((sig[k] >=0) && (sig[k] < kCH)) {
617 fSignalDirect[det][sig[k]]++;
618 fDataDirect[det][row][col][sig[k]]++; // direct data
622 minV = (minV < sig[k]) ? minV : sig[k];
623 maxV = (maxV > sig[k]) ? maxV : sig[k];
625 // check for active MCMs
626 if (fCreateFull && fFullSignal[mcmIndex]) {
627 if (sig[k] > fThresh || sig[k] < 0) fFullCounter[mcmIndex]++;
628 //if (sm == 0 && istack == 0 && ilink/2 == 1 && rob == 1 && mcm == 15) fFullCounter[mcmIndex]++; // special
629 //fFullSignal[mcmIndex]->Fill(adc, k, sig[k]); // slow
632 // zero suppresion tests
634 for(Int_t th=0; th<40; th++) {
637 if (iadc > 0) zsADC[iadc-1][th] = 1;
638 if (iadc < 10) zsADC[iadc+1][th] = 1;
650 Int_t adcPP = maxV - minV;
651 //if (adcPP == 100) fFullCounter[mcmIndex] += 10;
654 fChPP[det]->Fill(adcPP);
655 fSmPP[sm]->Fill(adcPP);
657 for(Int_t i=0; i<3; i++) {
658 if ((adcPP) > fppThresh[i]) fnPP[i]++;
666 for(Int_t th=0; th<40; th++) {
668 for(Int_t ins=0; ins<21; ins++)
669 nnADC += zsADC[ins][th];
670 fZSsize->Fill(th, nnADC);
676 if (fCreateFull && fFullSignal[mcmIndex] && (fFullCounter[mcmIndex] > fCount)) {
678 for (Int_t iadc=0; iadc < data->GetADCcount(istack, ilink, imcm); iadc++) {
681 if ((data->GetADCErrorCode(istack,ilink,imcm,iadc))) continue;
683 //Int_t row = data->GetRow(istack, ilink, imcm);
684 //Int_t col = data->GetCol(istack, ilink, imcm, iadc);
685 Int_t adc = data->GetADCnumber(istack, ilink, imcm, iadc);
687 Int_t *sig = data->GetSignalDirect(istack, ilink, imcm, iadc);
689 // loop over Time Bins and fill histograms
690 for(Int_t k=0; k < data->GetNumberOfTimeBins(istack, ilink); k++) {
691 fFullSignal[mcmIndex]->Fill(adc, k, sig[k]); // slow
700 // printf("end of loops\n");
704 ///////////////////////////////////////////////////////////////////////////////////////////////////
706 void AliTRDqaBlackEvents::FinishEvent()
709 // Processing at the end of the current event
712 for(Int_t i=0; i<3; i++) {
713 fGraphPP[i]->SetPoint(fnEvents, fnEvents, fnPP[i]);
716 // trend of the number of links
717 for(Int_t i=0; i<3; i++) {
718 fGrLink[i]->SetPoint(fnEvents, fnEvents, fnLink[i]);
721 // save interesting histos
722 Int_t mcmTrackCandidate = 0;
723 for(Int_t i = 0; i < kDET * kROB * kMCM; i++) {
724 if ((fFullCounter[i] > fCount) && fFullSignal[i] && CheckMCM(i) ) {
726 fMcmTracks->AddLast(fFullSignal[i]->Clone(Form("event_%d_%s", fnEvents, fFullSignal[i]->GetName())));
729 Int_t mcmTrackletDet = i/(kROB * kMCM);
730 Int_t mcmTrackletMcm = i%(kROB * kMCM);
731 fMapMCM->Fill(mcmTrackletDet, mcmTrackletMcm);
735 fGraphMCM->SetPoint(fnEvents, fnEvents, mcmTrackCandidate);
736 AliInfo(Form("Number of MCM track candidates = %d\n", mcmTrackCandidate));
739 // update fraction of error graphs
742 err = (fnErrorHC[0] > 0)? 100.*fnErrorHC[1]/fnErrorHC[0] : -1;
743 fErrorGraphHC->SetPoint(fnEvents, fnEvents, err);
745 err = (fnErrorMCM[0] > 0)? 100.*fnErrorMCM[1]/fnErrorMCM[0] : -1;
746 fErrorGraphMCM->SetPoint(fnEvents, fnEvents, err);
748 err = (fnErrorADC[0] > 0)? 100.*fnErrorADC[1]/fnErrorADC[0] : -1;
749 fErrorGraphADC->SetPoint(fnEvents, fnEvents, err);
751 // number of fired ADC per SM
752 for(Int_t sm=0; sm<kSM+1; sm++)
753 fNumberADC[sm]->SetPoint(fnEvents, fnEvents, fnADCinSM[sm]);
758 ///////////////////////////////////////////////////////////////////////////////////////////////////
760 void AliTRDqaBlackEvents::Process(const char *filename)
767 //strncpy(fn,filename,256);
769 //AliInfo(Form("FILENAME = %s (%s)\n", filename, fn));
773 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
774 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
775 fit->SetParameters(1e3, 10, 1);
777 for(Int_t det=0; det<kDET; det++) {
779 //AliInfo(Form("processing chamber %d\n", det));
782 //if (fData[det]->GetSum() < 10) continue;
783 //if (fDataDirect[det][10][10][10] < 20) continue;
787 // rewrite signal-direct
788 for(Int_t ch=0; ch<kCH; ch++) {
789 fSignal[det]->Fill(ch, fSignalDirect[det][ch]);
792 // read reference distributions
795 //for(Int_t row=0; row<fData[det]->GetXaxis()->GetNbins(); row++) {
796 //for(Int_t pad=0; pad<fData[det]->GetYaxis()->GetNbins(); pad++) {
798 for(Int_t row=0; row<kROW; row++) {
799 for(Int_t pad=0; pad<kPAD; pad++) {
801 // project the histogramm
803 //for(Int_t bb=0; bb<50; bb++) {
804 for(Int_t bb=0; bb<kCH; bb++) {
805 //Int_t dataBin = fData[det]->FindBin(row, pad, bb);
806 //Double_t v = fData[det]->GetBinContent(dataBin);
807 hist->SetBinContent(bb+1, fDataDirect[det][row][pad][bb]);
810 Int_t bin = fChPed[det]->FindBin(row, pad);
812 if (hist->GetSum() > 1) {
815 Double_t ped = 0, noise = 0;
818 fit->SetParameters(1e3, 10, 1);
819 hist->Fit(fit, "q0", "goff", 0, 20);
820 TF1 *f = hist->GetFunction("fit");
821 ped = TMath::Abs(f->GetParameter(1));
822 noise = TMath::Abs(f->GetParameter(2));
823 fSmNoiseFit[det/30]->Fill(noise);
825 ped = hist->GetMean();
826 noise = hist->GetRMS();
827 fSmNoiseRms[det/30]->Fill(noise);
829 // AliInfo(Form("data %f %f %f\n", hist->GetSum(), ped, noise));
832 fChPed[det]->SetBinContent(bin, ped);
833 fChNoise[det]->SetBinContent(bin, noise);
834 fNoiseTotal->Fill(noise);
836 // subtract reference values
838 Double_t refnoise = 0;
840 if (fRefHistPed) refped = fRefHistPed->GetBinContent(bin);
841 if (fRefHistPed) refnoise = fRefHistPed->GetBinContent(bin);
842 // Original code, should it not be fRefHistNoise->GetBinContent(bin)
843 // instead of fRefHistPed->GetBinContent(bin) (CBL) ???
844 //if (fRefHistNoise) refnoise = fRefHistPed->GetBinContent(bin);
846 fChPedRes[det]->SetBinContent(bin, ped-refped);
847 fChNoiseRes[det]->SetBinContent(bin, noise-refnoise);
849 fPed[det]->Fill(ped);
850 fNoise[det]->Fill(noise);
854 Int_t hc = (pad < kPAD/2) ? 2* (det % 30) : 2* (det % 30) + 1;
855 if (ped > 9. && ped < 11) fSMHCped->Fill(sm, hc, 1./1152.); // number of pads in HC
859 // not enought data found
860 fChPed[det]->SetBinContent(bin, 0);
861 fChNoise[det]->SetBinContent(bin, 0);
862 fChPedRes[det]->SetBinContent(bin, 0);
863 fChNoiseRes[det]->SetBinContent(bin, 0);
872 //AliInfo(Form("Number of events = %d\n", fnEvents));
874 // normalize number of entries histos
876 for(Int_t i=0; i<kDET; i++) {
877 if (!map[i]) continue;
878 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
879 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
880 Int_t dataBin = fNPoint[i]->FindBin(j, k);
881 Double_t v = fNPoint[i]->GetBinContent(dataBin);
882 if (v > max) max = (Int_t)v;
887 char entriesDistName[100];
889 for(Int_t i=0; i<kDET; i++) {
891 if (!map[i]) continue;
893 snprintf(entriesDistName,100,"entriesDist_%d",i);
894 fNPointDist[i] = new TH1D(entriesDistName, ";number of events", max+2, -0.5, max+1.5);
896 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
897 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
898 Int_t dataBin = fNPoint[i]->FindBin(j, k);
899 Double_t v = fNPoint[i]->GetBinContent(dataBin);
900 //if (v > fnEvents) AliInfo(Form("N = %d V = %lf\n", fnEvents, v));
901 fNPointDist[i]->Fill(v);
905 fNPoint[i]->Scale(1./fnEvents);
909 for(Int_t i=0; i<kDET; i++) {
910 fnEntriesRM[i]->SetMaximum(fnEvents * 1.5);
915 //AliInfo(Form("FILENAME 2 = %s (%d)\n", fn, fn));
916 TFile *file = new TFile(filename, "recreate");
917 for(Int_t det = 0; det < kDET; det++) {
918 if (!map[det]) continue;
919 fChPed[det]->Write();
920 fChNoise[det]->Write();
921 fNPoint[det]->Write();
922 fNPointDist[det]->Write();
924 fNoise[det]->Write();
925 fSignal[det]->Write();
926 fnEntriesRM[det]->Write();
929 fChPedRes[det]->Write();
930 fChNoiseRes[det]->Write();
933 fErrorLocMCM[det]->SetMinimum(0);
934 fErrorLocMCM[det]->SetMaximum(fnEvents);
935 fErrorLocMCM[det]->Write();
937 fErrorLocADC[det]->SetMinimum(0);
938 fErrorLocADC[det]->SetMaximum(fnEvents);
939 fErrorLocADC[det]->Write();
942 for(Int_t sm=0; sm<kSM; sm++) {
943 fSmNoiseRms[sm]->Write();
944 fSmNoiseFit[sm]->Write();
951 for(Int_t i=0; i < kDET * kROB * kMCM; i++) {
952 if (fFullSignal[i] && fFullCounter[i] > fCount) {
953 fFullSignal[i]->Write();
958 AliInfo(Form("Number of saved MCMs = %d\n", nMcm));
961 AliInfo(Form("Number of tracks = %d\n", fMcmTracks->GetEntries()));
963 // permanently problematic MCMs
964 for(Int_t det=0; det<kDET; det++) {
965 for(Int_t mcm=0; mcm<kROB*kMCM; mcm++) {
967 Int_t mRob = mcm / kMCM;
968 Int_t mMcm = mcm % kMCM;
969 Int_t bin = fMapMCM->FindBin(det, mcm);
970 Double_t frac = 1. * fMapMCM->GetBinContent(bin) / fnEvents;
971 fFracMCM->Fill(frac);
974 AliInfo(Form("{%d, %d, %d, %f}, \n", det, mRob, mMcm, frac));
990 fErrorSMMCM->Write();
991 fErrorSMADC->Write();
994 fErrorGraphHC->Write("trendErrorHC");
995 fErrorGraphMCM->Write("trendErrorMCM");
996 fErrorGraphADC->Write("trendErrorADC");
998 fGraphMCM->Write("trendMCM");
1000 for(Int_t i=0; i<3; i++) {
1001 fGraphPP[i]->Write(Form("fracPP_%d", i));
1004 //fZSsize->Scale(1./fnEvents);
1007 fMapMCM->SetMaximum(fnEvents);
1013 for(Int_t i=0; i<3; i++ ) {
1014 fSMLink[i]->Write();
1015 fGrLink[i]->Write();
1018 for(Int_t sm=0; sm<kSM; sm++)
1019 fNumberADC[sm]->Write(Form("nADCinSM%d",sm));
1021 fNumberADC[kSM]->Write("nADCinEvent");
1023 fNoiseTotal->Write();
1026 for(Int_t i=0; i<1000; i++) {
1027 if (fEvNoDist[i]->GetSum() > 0) fEvNoDist[i]->Write();
1035 ///////////////////////////////////////////////////////////////////////////////////////////////////
1037 Int_t AliTRDqaBlackEvents::CheckMCM(Int_t /*index*/) const {
1039 // Checks a single MCM
1044 // static Int_t data[21][3] = {
1068 // for(Int_t i=0; i<21; i++) {
1069 // Int_t wIndex = data[i][0] * kROB*kMCM + data[i][1] * kMCM + data[i][2];
1070 // if (index == wIndex) return 0;
1076 ///////////////////////////////////////////////////////////////////////////////////////////////////
1084 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
1087 // Draw raport for one chamber:
1088 // pedestal map, noise map, distribution of pedestal and noise
1091 // name of the file with histograms (created with Process())
1092 // detector Id (0 - 539)
1095 // setup global style
1096 gStyle->SetPalette(1);
1097 gStyle->SetOptStat(0);
1098 gStyle->SetPadTopMargin(0.02);
1099 gStyle->SetPadBottomMargin(0.05);
1101 TFile *file = new TFile(filename, "READ");
1103 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
1104 c->SetVertical(kFALSE);
1105 c->Divide(3,1, 0.01, 0.01);
1108 TPad *mPad = (TPad*) gPad;
1109 mPad->Divide(1,2,0.01,0.01);
1112 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
1115 h2->SetTitle(";Z direction;#phi direction");
1119 h2 = (TH2D*)file->Get(Form("noise_%d",det));
1120 h2->SetMinimum(fMinNoise);
1121 h2->SetMaximum(fMaxNoise);
1122 h2->SetTitle(";Z direction;#phi direction");
1127 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
1132 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
1136 TF1 *f = h1->GetFunction("gaus");
1137 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
1138 TLatex *ll = new TLatex(2, 100, tt);
1139 ll->SetTextSize(0.06);
1143 ///////////////////////////////////////////////////////////////////////////////////////////////////
1145 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
1151 gStyle->SetPalette(1);
1152 gStyle->SetOptStat(0);
1154 gStyle->SetPadTopMargin(0.02);
1155 //gStyle->SetPadBottomMargin(0.05);
1156 //gStyle->SetPadLeftMargin(0.02);
1157 //gStyle->SetPadRightMargin(0.02);
1159 TFile *file = new TFile(filename, "READ");
1161 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
1162 c->SetVertical(kFALSE);
1163 c->Divide(5, 6, 0.001, 0.01);
1165 for(Int_t i=0; i<30; i++) {
1167 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
1169 h2->SetMinimum(fMinNoise);
1170 h2->SetMaximum(fMaxNoise);
1172 // to be replaced by the official calculation
1175 Int_t index = (5-layer)*5 + stack + 1;
1176 //AliInfo(Form("%d %d %d %d\n", i, stack, layer, index));
1178 gPad->SetBottomMargin(0.02);
1179 gPad->SetTopMargin(0.02);
1185 ///////////////////////////////////////////////////////////////////////////////////////////////////
1187 Int_t AliTRDqaBlackEvents::FillBits(TH1D *hist, Int_t code, Int_t offset) {
1194 for(Int_t i=0; i<8; i++) {
1196 hist->Fill(i+offset);
1205 ///////////////////////////////////////////////////////////////////////////////////////////////////