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 ////////////////////////////////////////////////////////////////////////////
38 #include "AliRawReader.h"
40 #include "AliTRDrawStreamOld.h"
41 #include "AliTRDqaBlackEvents.h"
43 ClassImp(AliTRDqaBlackEvents)
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
47 AliTRDqaBlackEvents::AliTRDqaBlackEvents()
83 // to create the histograms call Init()
86 for (Int_t i = 0; i < kDET; i++) {
97 fnEntriesRMDist[i] = 0x0;
100 fErrorLocHC[i] = 0x0;
101 fErrorLocMCM[i] = 0x0;
102 fErrorLocADC[i] = 0x0;
104 for (Int_t i = 0; i < 3; i++) {
112 for (Int_t i = 0; i < 2; i++) {
117 for (Int_t i = 0; i < kSM; i++) {
118 fSmNoiseRms[i] = 0x0;
119 fSmNoiseFit[i] = 0x0;
122 for (Int_t i = 0; i < kSM+1; i++) {
126 for (Int_t i = 0; i < 1000; i++) {
129 for (Int_t i = 0; i < kDET*kROB*kMCM; i++) {
130 fFullSignal[i] = 0x0;
133 //strncpy(fRefFileName,"",256);
137 ///////////////////////////////////////////////////////////////////////////////////////////////////
139 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
175 // to create the histograms call Init()
178 for (Int_t i = 0; i < kDET; i++) {
182 fNPointDist[i] = 0x0;
188 fnEntriesRM[i] = 0x0;
189 fnEntriesRMDist[i] = 0x0;
191 fChNoiseRes[i] = 0x0;
192 fErrorLocHC[i] = 0x0;
193 fErrorLocMCM[i] = 0x0;
194 fErrorLocADC[i] = 0x0;
196 for (Int_t i = 0; i < 3; i++) {
204 for (Int_t i = 0; i < 2; i++) {
209 for (Int_t i = 0; i < kSM; i++) {
210 fSmNoiseRms[i] = 0x0;
211 fSmNoiseFit[i] = 0x0;
214 for (Int_t i = 0; i < kSM+1; i++) {
218 for (Int_t i = 0; i < 1000; i++) {
221 for (Int_t i = 0; i < kDET*kROB*kMCM; i++) {
222 fFullSignal[i] = 0x0;
225 //strncpy(fRefFileName,"",256);
229 ///////////////////////////////////////////////////////////////////////////////////////////////////
231 void AliTRDqaBlackEvents::Init()
234 // creates histograms
238 //Info("Init", "Statring");
242 // histograms for chambers
243 for(Int_t det=0; det<kDET; det++) {
245 fNPoint[det] = new TH2D(Form("entries_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
246 //fData[det] = new TH3F(Form("data_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
248 // pedestal noise maps using RMS and Fit
249 fChPed[det] = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
250 fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
252 //fChPed[det] = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
253 //fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
255 // distribution per detector
256 fPed[det] = new TH1D(Form("pedDist_%d", det), ";pedestals (ADC counts)", 100, 5, 15);
257 fNoise[det] = new TH1D(Form("noiseDist_%d", det), ";noise (ADC counts)", 100, 0, 5);
258 fSignal[det] = new TH1D(Form("signal_%d", det), ";signal (ADC counts)", 100, -0.5, 99.5);
259 fChPP[det] = new TH1D(Form("pp_%d", det), ";pp (ADC)", 200, -0.5, 199.5);
261 fnEntriesRM[det] = new TH2D(Form("entriesRM_%d", det), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);
263 // histograms after reference subtraction
264 fChPedRes[det] = new TH2D(Form("pedRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
265 fChNoiseRes[det] = new TH2D(Form("noiseRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
269 fErrorLocMCM[det] = new TH2D(Form("errorLocMCM_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
270 fErrorLocADC[det] = new TH2D(Form("errorLocADC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
271 fErrorLocHC[det] = new TH2D(Form("errorLocHC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
274 // histogram for each MCM
275 for(Int_t i=0; i < kDET * kROB * kMCM; i++)
278 // histograms from the whole detector
279 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);
280 fDetRob = new TH2D("DetRob", ";detector;ROB", kDET, -0.5, 539.5, 8, -0.5, 7.5);
281 fTBEvent = new TH2D("tbEvent", ";event ID;time bin", 100, -0.5, 99.5, 30, -0.5, 29.5);
283 // errors statistics and location
284 fErrorHC = new TH1D("errorHC", ";error ID;", 18, -3.5, 14.5);
285 fErrorMCM = new TH1D("errorMCM", ";error ID;", 18, -3.5, 14.5);
286 fErrorADC = new TH1D("errorADC", ";error ID;", 18, -3.5, 14.5);
288 fErrorSMHC = new TH1D("errorSM_HC", ";SM id", 18, -0.5, 17.5);
289 fErrorSMMCM = new TH1D("errorSM_MCM", ";SM id", 18, -0.5, 17.5);
290 fErrorSMADC = new TH1D("errorSM_ADC", ";SM id", 18, -0.5, 17.5);
293 fErrorGraphHC = new TGraph();
294 fErrorGraphMCM = new TGraph();
295 fErrorGraphADC = new TGraph();
297 fGraphMCM = new TGraph();
299 for(Int_t i=0; i<3; i++) {
300 fGraphPP[i] = new TGraph();
304 fMapMCM = new TH2D("mapMCM", ";det;mcm", 540, -0.5, 539.5, kROB*kMCM, -0.5, kROB*kMCM-0.5);
305 fFracMCM = new TH1D("fracMCM", ";frequency", 100, 0, 1);
308 fErrorGraphHC->GetHistogram()->SetTitle("fraction of events with HC error;event number");
309 fErrorGraphMCM->GetHistogram()->SetTitle("fraction of events with MCM error;event number;");
310 fErrorGraphADC->GetHistogram()->SetTitle("fraction of events with ADC error;event number;");
313 fSMHCped = new TH2D("smHcPed", ";super module;half chamber", 18, -0.5, 17.5, 60, -0.5, 59.5);
316 const char *linkName[3] = {"smLink", "smBeaf", "smData"};
317 const char *linkGrName[3] = {"grSmLink", "grSmBeaf", "grSmData"};
318 for(Int_t i=0; i<3; i++) {
319 fSMLink[i] = new TH2D(linkName[i], ";super module;link", 18, -0.5, 17.5, 60, -0.5, 59.5);
320 fGrLink[i] = new TGraph();
321 fGrLink[i]->SetName(linkGrName[i]);
324 //fZSsize = new TH1D("zssizeSingle", ";threshold;nADC", 40, -0.5, 39.5);
327 //Info("Init", "Done");
329 // number of ADC channels fired per SM and in total
330 for(Int_t sm=0; sm<kSM+1; sm++)
331 fNumberADC[sm] = new TGraph();
334 fNoiseTotal = new TH1D("noiseTotal", "noise (ADC)", 250, 0, 10);
335 fPP = new TH1D("peakPeak", "p-p (ADC)", 200, -0.5, 199.5);
337 for(Int_t sm=0; sm<kSM; sm++) {
338 fSmNoiseRms[sm] = new TH1D(Form("noiseRms_sm%d", sm), ";noise from RMS (ADC)", 100, 0, 10);
339 fSmNoiseFit[sm] = new TH1D(Form("noiseFit_sm%d", sm), ";noise frim Fit (ADC)", 100, 0, 10);
340 fSmPP[sm] = new TH1D(Form("peakPeak_sm%d", sm), ";peak-peak (ADC)", 200, -0.5, 199.5);
343 // event number consistancy
344 for(Int_t i=0; i<1000; i++) {
345 fEvNoDist[i] = new TH1D(Form("mcmEvDist_%d", i), ";#Delta Events", 201, -100.5, 100.5);
349 fMcmTracks = new TObjArray();
352 for(Int_t det=0; det<kDET; det++)
353 for(Int_t row=0; row<kROW; row++)
354 for(Int_t pad=0; pad<kPAD; pad++)
355 for(Int_t ch=0; ch<kCH; ch++) {
356 fDataDirect[det][row][pad][ch] = 0;
357 fSignalDirect[det][ch] = 0; // overdone
362 ///////////////////////////////////////////////////////////////////////////////////////////////////
364 void AliTRDqaBlackEvents::Reset()
367 // Resets the histograms
370 for(Int_t i=0; i<kDET; i++) {
373 fChNoise[i]->Reset();
378 ///////////////////////////////////////////////////////////////////////////////////////////////////
380 void AliTRDqaBlackEvents::SetRefFile(const char *filename) {
382 //strncpy(fRefFileName,filename,256);
383 fRefFileName = filename;
387 ///////////////////////////////////////////////////////////////////////////////////////////////////
389 void AliTRDqaBlackEvents::ReadRefHists(Int_t det) {
391 // Read the reference histograms
398 if (fRefFileName) file = TFile::Open(fRefFileName);
401 fRefHistPed = (TH2D*)file->Get(Form("ped_%d",det));
402 fRefHistNoise = (TH2D*)file->Get(Form("noise_%d", det));
404 if (file) file->Close();
407 ///////////////////////////////////////////////////////////////////////////////////////////////////
409 void AliTRDqaBlackEvents::StartEvent()
415 // clear the mcm data
416 for(Int_t i=0; i < kDET * kROB * kMCM; i++) {
417 if (fFullSignal[i]) fFullSignal[i]->Reset();
421 for(Int_t i=0; i<2; i++) {
428 Int_t ppThresh[3] = {10, 20, 40};
429 for(Int_t i=0; i<3; i++) {
430 fppThresh[i] = ppThresh[i];
435 for(Int_t sm=0; sm<kSM+1; sm++) fnADCinSM[sm] = 0;
437 if (fRefEv > 0) fRefEv++;
438 fEvNoDist[999]->Reset(); // keep only the last event
442 ///////////////////////////////////////////////////////////////////////////////////////////////////
444 void AliTRDqaBlackEvents::AddBuffer(AliTRDrawStreamOld *data, AliRawReader * const reader)
447 //printf ("try to read data\n");
448 Int_t nextBuff = data->NextBuffer();
449 //printf("done ...\n");
451 if (nextBuff == 0) return;
453 Int_t sm = reader->GetEquipmentId() - 1024;
454 //printf("reading SM %d\n", sm);
455 AliInfo(Form("reading SM %d", sm));
457 if (sm < 0 || sm > 17) return;
459 // lopp over stacks, links ...
461 for (Int_t istack = 0; istack < 5; istack++) {
462 for (Int_t ilink = 0; ilink < 12; ilink++) {
464 //printf("HC = %d %d\n", istack, ilink);
466 Int_t det = sm * 30 + istack * 6 + ilink/2;
468 // check if data delivered
469 if (!(data->IsLinkActiveInStack(istack, ilink))) continue;
470 fSMLink[0]->Fill(sm, istack * 12 + ilink);
473 // check if beaf-beaf
474 if (data->GetLinkMonitorError(istack, ilink)) {
475 fSMLink[1]->Fill(sm, istack * 12 + ilink);
480 // fill histogram with HC header errors
484 nErrHc = FillBits(fErrorHC, data->GetH0ErrorCode(istack, ilink), 0);
485 if (!nErrHc) fErrorHC->Fill(-3);
488 nErrHc = FillBits(fErrorHC, data->GetH1ErrorCode(istack, ilink), 2);
489 if (!nErrHc) fErrorHC->Fill(-2);
492 nErrHc = FillBits(fErrorHC, data->GetHCErrorCode(istack, ilink), 4);
493 if (!nErrHc) fErrorHC->Fill(-1);
500 fErrorSMHC->Fill(sm);
503 // data integrity protection
505 //if (data->GetHCErrorCode(istack, ilink) > 0) continue;
506 if (data->GetH0ErrorCode(istack, ilink) > 0) continue;
507 if (data->GetH1ErrorCode(istack, ilink) > 0) continue;
509 fSMLink[2]->Fill(sm, istack * 12 + ilink);
513 for (Int_t imcm = 0; imcm < data->GetHCMCMmax(istack, ilink); imcm++ ){
515 //printf("mcm = %d %d %d\n", istack, ilink, imcm);
517 // fill MCM error code
520 Int_t nErrMcmTot = 0;
522 nErrMcm = FillBits(fErrorMCM, data->GetMCMhdErrorCode(istack, ilink, imcm), 0);
523 if (!nErrMcm) fErrorMCM->Fill(-3);
524 nErrMcmTot += nErrMcm;
526 nErrMcm = FillBits(fErrorMCM, data->GetMCMADCMaskErrorCode(istack, ilink, imcm), 5);
527 if (!nErrMcm) fErrorMCM->Fill(-2);
528 nErrMcmTot += nErrMcm;
530 nErrMcm = FillBits(fErrorMCM, data->GetMCMErrorCode(istack, ilink, imcm), 10);
531 if (!nErrMcm) fErrorMCM->Fill(-1);
532 nErrMcmTot += nErrMcm;
536 if (nErrMcmTot > 0) {
538 fErrorSMMCM->Fill(sm);
542 if ( (data->GetMCMhdErrorCode(istack,ilink,imcm)) & 2 ) continue;
543 //if ((data->GetMCMADCMaskErrorCode(istack,ilink,imcm))) continue;
544 //if ((data->GetMCMErrorCode(istack,ilink,imcm))) continue;
546 Int_t mcmEvent = data->GetEventNumber(istack, ilink, imcm);
548 // set the reference event number
551 printf("Reference Event Number = %d (%d %d %d)\n", fRefEv, istack, ilink, imcm);
554 // fill event distribution
555 if (!(fnEvents%10)) {
556 fEvNoDist[fnEvents/10]->Fill(mcmEvent - fRefEv);
559 fEvNoDist[999]->Fill(mcmEvent - fRefEv);
561 Int_t mcm = data->GetMCM(istack, ilink, imcm);
562 Int_t rob = data->GetROB(istack, ilink, imcm);
564 // create a structure for an MCM if needed
565 Int_t mcmIndex = det * (kMCM * kROB) + rob * kMCM + mcm;
566 if (fCreateFull && !fFullSignal[mcmIndex])
567 fFullSignal[mcmIndex] =
568 new TH2S(Form("mcm_%d_%d_%d_%d_%d", sm, istack, ilink/2, rob, mcm),
569 Form("mcm-%d-%d-%d-%d-%d;ADC;time bin", sm, istack, ilink/2, rob, mcm),
570 21, -0.5, 20.5, 30, -0.5, 29.5);
573 //Int_t zsADC[21][40];
575 for(Int_t ina=0; ina<21; ina++)
576 for(Int_t th=0; th<40; th++)
580 // first loop over ADC chanels
582 for (Int_t iadc=0; iadc < data->GetADCcount(istack, ilink, imcm); iadc++) {
584 //printf("ADC = %d\n", iadc);
587 // fill ADC error bits
588 Int_t nErrAdc = FillBits(fErrorADC, data->GetADCErrorCode(), 0);
589 if (!nErrAdc) fErrorADC->Fill(-1);
594 fErrorSMADC->Fill(sm);
598 if ((data->GetADCErrorCode(istack,ilink,imcm,iadc))) continue;
603 Int_t *sig = data->GetSignalDirect(istack, ilink, imcm, iadc);
605 //Int_t adc = data->GetADCnumber(istack, ilink, imcm, iadc);
606 Int_t row = data->GetRow(istack, ilink, imcm);
607 Int_t col = data->GetCol(istack, ilink, imcm, iadc);
609 // loop over Time Bins and fill histograms
610 for(Int_t k=0; k < data->GetNumberOfTimeBins(istack, ilink); k++) {
612 //fSignal[det]->Fill(sig[k]);
613 //fData[det]->Fill(row, col, sig[k]); // slow
615 if ((sig[k] >=0) && (sig[k] < kCH)) {
616 fSignalDirect[det][sig[k]]++;
617 fDataDirect[det][row][col][sig[k]]++; // direct data
621 minV = (minV < sig[k]) ? minV : sig[k];
622 maxV = (maxV > sig[k]) ? maxV : sig[k];
624 // check for active MCMs
625 if (fCreateFull && fFullSignal[mcmIndex]) {
626 if (sig[k] > fThresh || sig[k] < 0) fFullCounter[mcmIndex]++;
627 //if (sm == 0 && istack == 0 && ilink/2 == 1 && rob == 1 && mcm == 15) fFullCounter[mcmIndex]++; // special
628 //fFullSignal[mcmIndex]->Fill(adc, k, sig[k]); // slow
631 // zero suppresion tests
633 for(Int_t th=0; th<40; th++) {
636 if (iadc > 0) zsADC[iadc-1][th] = 1;
637 if (iadc < 10) zsADC[iadc+1][th] = 1;
649 Int_t adcPP = maxV - minV;
650 //if (adcPP == 100) fFullCounter[mcmIndex] += 10;
653 fChPP[det]->Fill(adcPP);
654 fSmPP[sm]->Fill(adcPP);
656 for(Int_t i=0; i<3; i++) {
657 if ((adcPP) > fppThresh[i]) fnPP[i]++;
665 for(Int_t th=0; th<40; th++) {
667 for(Int_t ins=0; ins<21; ins++)
668 nnADC += zsADC[ins][th];
669 fZSsize->Fill(th, nnADC);
675 if (fCreateFull && fFullSignal[mcmIndex] && (fFullCounter[mcmIndex] > fCount)) {
677 for (Int_t iadc=0; iadc < data->GetADCcount(istack, ilink, imcm); iadc++) {
680 if ((data->GetADCErrorCode(istack,ilink,imcm,iadc))) continue;
682 //Int_t row = data->GetRow(istack, ilink, imcm);
683 //Int_t col = data->GetCol(istack, ilink, imcm, iadc);
684 Int_t adc = data->GetADCnumber(istack, ilink, imcm, iadc);
686 Int_t *sig = data->GetSignalDirect(istack, ilink, imcm, iadc);
688 // loop over Time Bins and fill histograms
689 for(Int_t k=0; k < data->GetNumberOfTimeBins(istack, ilink); k++) {
690 fFullSignal[mcmIndex]->Fill(adc, k, sig[k]); // slow
699 // printf("end of loops\n");
703 ///////////////////////////////////////////////////////////////////////////////////////////////////
705 void AliTRDqaBlackEvents::FinishEvent()
708 // Processing at the end of the current event
711 for(Int_t i=0; i<3; i++) {
712 fGraphPP[i]->SetPoint(fnEvents, fnEvents, fnPP[i]);
715 // trend of the number of links
716 for(Int_t i=0; i<3; i++) {
717 fGrLink[i]->SetPoint(fnEvents, fnEvents, fnLink[i]);
720 // save interesting histos
721 Int_t mcmTrackCandidate = 0;
722 for(Int_t i = 0; i < kDET * kROB * kMCM; i++) {
723 if ((fFullCounter[i] > fCount) && fFullSignal[i] && CheckMCM(i) ) {
725 fMcmTracks->AddLast(fFullSignal[i]->Clone(Form("event_%d_%s", fnEvents, fFullSignal[i]->GetName())));
728 Int_t mcmTrackletDet = i/(kROB * kMCM);
729 Int_t mcmTrackletMcm = i%(kROB * kMCM);
730 fMapMCM->Fill(mcmTrackletDet, mcmTrackletMcm);
734 fGraphMCM->SetPoint(fnEvents, fnEvents, mcmTrackCandidate);
735 AliInfo(Form("Number of MCM track candidates = %d\n", mcmTrackCandidate));
738 // update fraction of error graphs
741 err = (fnErrorHC[0] > 0)? 100.*fnErrorHC[1]/fnErrorHC[0] : -1;
742 fErrorGraphHC->SetPoint(fnEvents, fnEvents, err);
744 err = (fnErrorMCM[0] > 0)? 100.*fnErrorMCM[1]/fnErrorMCM[0] : -1;
745 fErrorGraphMCM->SetPoint(fnEvents, fnEvents, err);
747 err = (fnErrorADC[0] > 0)? 100.*fnErrorADC[1]/fnErrorADC[0] : -1;
748 fErrorGraphADC->SetPoint(fnEvents, fnEvents, err);
750 // number of fired ADC per SM
751 for(Int_t sm=0; sm<kSM+1; sm++)
752 fNumberADC[sm]->SetPoint(fnEvents, fnEvents, fnADCinSM[sm]);
757 ///////////////////////////////////////////////////////////////////////////////////////////////////
759 void AliTRDqaBlackEvents::Process(const char *filename)
766 //strncpy(fn,filename,256);
768 //AliInfo(Form("FILENAME = %s (%s)\n", filename, fn));
772 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
773 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
774 fit->SetParameters(1e3, 10, 1);
776 for(Int_t det=0; det<kDET; det++) {
778 //AliInfo(Form("processing chamber %d\n", det));
781 //if (fData[det]->GetSum() < 10) continue;
782 //if (fDataDirect[det][10][10][10] < 20) continue;
786 // rewrite signal-direct
787 for(Int_t ch=0; ch<kCH; ch++) {
788 fSignal[det]->Fill(ch, fSignalDirect[det][ch]);
791 // read reference distributions
794 //for(Int_t row=0; row<fData[det]->GetXaxis()->GetNbins(); row++) {
795 //for(Int_t pad=0; pad<fData[det]->GetYaxis()->GetNbins(); pad++) {
797 for(Int_t row=0; row<kROW; row++) {
798 for(Int_t pad=0; pad<kPAD; pad++) {
800 // project the histogramm
802 //for(Int_t bb=0; bb<50; bb++) {
803 for(Int_t bb=0; bb<kCH; bb++) {
804 //Int_t dataBin = fData[det]->FindBin(row, pad, bb);
805 //Double_t v = fData[det]->GetBinContent(dataBin);
806 hist->SetBinContent(bb+1, fDataDirect[det][row][pad][bb]);
809 Int_t bin = fChPed[det]->FindBin(row, pad);
811 if (hist->GetSum() > 1) {
814 Double_t ped = 0, noise = 0;
817 fit->SetParameters(1e3, 10, 1);
818 hist->Fit(fit, "q0", "goff", 0, 20);
819 TF1 *f = hist->GetFunction("fit");
820 ped = TMath::Abs(f->GetParameter(1));
821 noise = TMath::Abs(f->GetParameter(2));
822 fSmNoiseFit[det/30]->Fill(noise);
824 ped = hist->GetMean();
825 noise = hist->GetRMS();
826 fSmNoiseRms[det/30]->Fill(noise);
828 // AliInfo(Form("data %f %f %f\n", hist->GetSum(), ped, noise));
831 fChPed[det]->SetBinContent(bin, ped);
832 fChNoise[det]->SetBinContent(bin, noise);
833 fNoiseTotal->Fill(noise);
835 // subtract reference values
837 Double_t refnoise = 0;
839 if (fRefHistPed) refped = fRefHistPed->GetBinContent(bin);
840 if (fRefHistPed) refnoise = fRefHistPed->GetBinContent(bin);
841 // Original code, should it not be fRefHistNoise->GetBinContent(bin)
842 // instead of fRefHistPed->GetBinContent(bin) (CBL) ???
843 //if (fRefHistNoise) refnoise = fRefHistPed->GetBinContent(bin);
845 fChPedRes[det]->SetBinContent(bin, ped-refped);
846 fChNoiseRes[det]->SetBinContent(bin, noise-refnoise);
848 fPed[det]->Fill(ped);
849 fNoise[det]->Fill(noise);
853 Int_t hc = (pad < kPAD/2) ? 2* (det % 30) : 2* (det % 30) + 1;
854 if (ped > 9. && ped < 11) fSMHCped->Fill(sm, hc, 1./1152.); // number of pads in HC
858 // not enought data found
859 fChPed[det]->SetBinContent(bin, 0);
860 fChNoise[det]->SetBinContent(bin, 0);
861 fChPedRes[det]->SetBinContent(bin, 0);
862 fChNoiseRes[det]->SetBinContent(bin, 0);
871 //AliInfo(Form("Number of events = %d\n", fnEvents));
873 // normalize number of entries histos
875 for(Int_t i=0; i<kDET; i++) {
876 if (!map[i]) continue;
877 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
878 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
879 Int_t dataBin = fNPoint[i]->FindBin(j, k);
880 Double_t v = fNPoint[i]->GetBinContent(dataBin);
881 if (v > max) max = (Int_t)v;
886 char entriesDistName[100];
888 for(Int_t i=0; i<kDET; i++) {
890 if (!map[i]) continue;
892 snprintf(entriesDistName,100,"entriesDist_%d",i);
893 fNPointDist[i] = new TH1D(entriesDistName, ";number of events", max+2, -0.5, max+1.5);
895 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
896 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
897 Int_t dataBin = fNPoint[i]->FindBin(j, k);
898 Double_t v = fNPoint[i]->GetBinContent(dataBin);
899 //if (v > fnEvents) AliInfo(Form("N = %d V = %lf\n", fnEvents, v));
900 fNPointDist[i]->Fill(v);
904 fNPoint[i]->Scale(1./fnEvents);
908 for(Int_t i=0; i<kDET; i++) {
909 fnEntriesRM[i]->SetMaximum(fnEvents * 1.5);
914 //AliInfo(Form("FILENAME 2 = %s (%d)\n", fn, fn));
915 TFile *file = new TFile(filename, "recreate");
916 for(Int_t det = 0; det < kDET; det++) {
917 if (!map[det]) continue;
918 fChPed[det]->Write();
919 fChNoise[det]->Write();
920 fNPoint[det]->Write();
921 fNPointDist[det]->Write();
923 fNoise[det]->Write();
924 fSignal[det]->Write();
925 fnEntriesRM[det]->Write();
928 fChPedRes[det]->Write();
929 fChNoiseRes[det]->Write();
932 fErrorLocMCM[det]->SetMinimum(0);
933 fErrorLocMCM[det]->SetMaximum(fnEvents);
934 fErrorLocMCM[det]->Write();
936 fErrorLocADC[det]->SetMinimum(0);
937 fErrorLocADC[det]->SetMaximum(fnEvents);
938 fErrorLocADC[det]->Write();
941 for(Int_t sm=0; sm<kSM; sm++) {
942 fSmNoiseRms[sm]->Write();
943 fSmNoiseFit[sm]->Write();
950 for(Int_t i=0; i < kDET * kROB * kMCM; i++) {
951 if (fFullSignal[i] && fFullCounter[i] > fCount) {
952 fFullSignal[i]->Write();
957 AliInfo(Form("Number of saved MCMs = %d\n", nMcm));
960 AliInfo(Form("Number of tracks = %d\n", fMcmTracks->GetEntries()));
962 // permanently problematic MCMs
963 for(Int_t det=0; det<kDET; det++) {
964 for(Int_t mcm=0; mcm<kROB*kMCM; mcm++) {
966 Int_t mRob = mcm / kMCM;
967 Int_t mMcm = mcm % kMCM;
968 Int_t bin = fMapMCM->FindBin(det, mcm);
969 Double_t frac = 1. * fMapMCM->GetBinContent(bin) / fnEvents;
970 fFracMCM->Fill(frac);
973 AliInfo(Form("{%d, %d, %d, %f}, \n", det, mRob, mMcm, frac));
989 fErrorSMMCM->Write();
990 fErrorSMADC->Write();
993 fErrorGraphHC->Write("trendErrorHC");
994 fErrorGraphMCM->Write("trendErrorMCM");
995 fErrorGraphADC->Write("trendErrorADC");
997 fGraphMCM->Write("trendMCM");
999 for(Int_t i=0; i<3; i++) {
1000 fGraphPP[i]->Write(Form("fracPP_%d", i));
1003 //fZSsize->Scale(1./fnEvents);
1006 fMapMCM->SetMaximum(fnEvents);
1012 for(Int_t i=0; i<3; i++ ) {
1013 fSMLink[i]->Write();
1014 fGrLink[i]->Write();
1017 for(Int_t sm=0; sm<kSM; sm++)
1018 fNumberADC[sm]->Write(Form("nADCinSM%d",sm));
1020 fNumberADC[kSM]->Write("nADCinEvent");
1022 fNoiseTotal->Write();
1025 for(Int_t i=0; i<1000; i++) {
1026 if (fEvNoDist[i]->GetSum() > 0) fEvNoDist[i]->Write();
1034 ///////////////////////////////////////////////////////////////////////////////////////////////////
1036 Int_t AliTRDqaBlackEvents::CheckMCM(Int_t /*index*/) const {
1038 // Checks a single MCM
1043 // static Int_t data[21][3] = {
1067 // for(Int_t i=0; i<21; i++) {
1068 // Int_t wIndex = data[i][0] * kROB*kMCM + data[i][1] * kMCM + data[i][2];
1069 // if (index == wIndex) return 0;
1075 ///////////////////////////////////////////////////////////////////////////////////////////////////
1083 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
1086 // Draw raport for one chamber:
1087 // pedestal map, noise map, distribution of pedestal and noise
1090 // name of the file with histograms (created with Process())
1091 // detector Id (0 - 539)
1094 // setup global style
1095 gStyle->SetPalette(1);
1096 gStyle->SetOptStat(0);
1097 gStyle->SetPadTopMargin(0.02);
1098 gStyle->SetPadBottomMargin(0.05);
1100 TFile *file = new TFile(filename, "READ");
1102 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
1103 c->SetVertical(kFALSE);
1104 c->Divide(3,1, 0.01, 0.01);
1107 TPad *mPad = (TPad*) gPad;
1108 mPad->Divide(1,2,0.01,0.01);
1111 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
1114 h2->SetTitle(";Z direction;#phi direction");
1118 h2 = (TH2D*)file->Get(Form("noise_%d",det));
1119 h2->SetMinimum(fMinNoise);
1120 h2->SetMaximum(fMaxNoise);
1121 h2->SetTitle(";Z direction;#phi direction");
1126 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
1131 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
1135 TF1 *f = h1->GetFunction("gaus");
1136 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
1137 TLatex *ll = new TLatex(2, 100, tt);
1138 ll->SetTextSize(0.06);
1142 ///////////////////////////////////////////////////////////////////////////////////////////////////
1144 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
1150 gStyle->SetPalette(1);
1151 gStyle->SetOptStat(0);
1153 gStyle->SetPadTopMargin(0.02);
1154 //gStyle->SetPadBottomMargin(0.05);
1155 //gStyle->SetPadLeftMargin(0.02);
1156 //gStyle->SetPadRightMargin(0.02);
1158 TFile *file = new TFile(filename, "READ");
1160 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
1161 c->SetVertical(kFALSE);
1162 c->Divide(5, 6, 0.001, 0.01);
1164 for(Int_t i=0; i<30; i++) {
1166 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
1168 h2->SetMinimum(fMinNoise);
1169 h2->SetMaximum(fMaxNoise);
1171 // to be replaced by the official calculation
1174 Int_t index = (5-layer)*5 + stack + 1;
1175 //AliInfo(Form("%d %d %d %d\n", i, stack, layer, index));
1177 gPad->SetBottomMargin(0.02);
1178 gPad->SetTopMargin(0.02);
1184 ///////////////////////////////////////////////////////////////////////////////////////////////////
1186 Int_t AliTRDqaBlackEvents::FillBits(TH1D *hist, Int_t code, Int_t offset) {
1193 for(Int_t i=0; i<8; i++) {
1195 hist->Fill(i+offset);
1204 ///////////////////////////////////////////////////////////////////////////////////////////////////