From e508dc19cf5d254b9463475f581d238c3d4a35a3 Mon Sep 17 00:00:00 2001 From: cblume Date: Thu, 3 Jul 2008 17:11:57 +0000 Subject: [PATCH] QA update by Sylwester --- TRD/AliTRDqaBlackEvents.cxx | 532 +++++++++++++++++++++++++++++---- TRD/AliTRDqaBlackEvents.h | 69 ++++- TRD/AliTRDqaBuildReference.cxx | 76 +++++ TRD/AliTRDqaBuildReference.h | 39 +++ TRD/AliTRDqaRecPoints.cxx | 454 ++++++++++++++++++++++++++++ TRD/AliTRDqaRecPoints.h | 54 ++++ 6 files changed, 1160 insertions(+), 64 deletions(-) create mode 100644 TRD/AliTRDqaBuildReference.cxx create mode 100644 TRD/AliTRDqaBuildReference.h create mode 100644 TRD/AliTRDqaRecPoints.cxx create mode 100644 TRD/AliTRDqaRecPoints.h diff --git a/TRD/AliTRDqaBlackEvents.cxx b/TRD/AliTRDqaBlackEvents.cxx index 0e779a7eb5d..6afb55e101d 100644 --- a/TRD/AliTRDqaBlackEvents.cxx +++ b/TRD/AliTRDqaBlackEvents.cxx @@ -10,7 +10,7 @@ * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * + * provided "as is without express or implied warranty. * **************************************************************************/ /* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */ @@ -34,6 +34,7 @@ #include "TPad.h" #include "TLatex.h" #include "TStyle.h" +#include "TGraph.h" #include "AliTRDgeometry.h" #include "AliTRDrawStreamTB.h" @@ -52,14 +53,36 @@ AliTRDqaBlackEvents::AliTRDqaBlackEvents() ,fOccupancy(0) ,fDetRob(0) ,fTBEvent(0) - ,fFitType(0) + ,fRefHistPed(0) + ,fRefHistNoise(0) + ,fErrorHC(0) + ,fErrorMCM(0) + ,fErrorADC(0) + ,fErrorSMHC(0) + ,fErrorSMMCM(0) + ,fErrorSMADC(0) + ,fErrorGraphHC(0) + ,fErrorGraphMCM(0) + ,fErrorGraphADC(0) + ,fGraphMCM(0) + ,fMcmTracks(0) + ,fMapMCM(0) + ,fFracMCM(0) + ,fSMHCped(0) + ,fSMHCerr(0) + ,fNoiseTotal(0) + ,fPP(0) ,fMinNoise(0.5) - ,fMaxNoise(2) + ,fMaxNoise(2) + ,fFitType(0) + // ,fRefFileName("") { // // Constructor // to create the histograms call Init() // + + strcpy(fRefFileName, ""); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -73,14 +96,35 @@ AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa) ,fOccupancy(0) ,fDetRob(0) ,fTBEvent(0) - ,fFitType(0) + ,fRefHistNoise(0) + ,fErrorHC(0) + ,fErrorMCM(0) + ,fErrorADC(0) + ,fErrorSMHC(0) + ,fErrorSMMCM(0) + ,fErrorSMADC(0) + ,fErrorGraphHC(0) + ,fErrorGraphMCM(0) + ,fErrorGraphADC(0) + ,fGraphMCM(0) + ,fMcmTracks(0) + ,fMapMCM(0) + ,fFracMCM(0) + ,fSMHCped(0) + ,fSMHCerr(0) + ,fNoiseTotal(0) + ,fPP(0) ,fMinNoise(0.5) ,fMaxNoise(2) + ,fFitType(0) + //,fRefFileName("") { // // Copy constructor // to create the histograms call Init() // + + strcpy(fRefFileName, ""); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -97,17 +141,35 @@ void AliTRDqaBlackEvents::Init() fnEvents = 0; // histograms for chambers - for(Int_t i=0; iGetHistogram()->SetTitle("Error HC;event number;fraction with error (%)"); + fErrorGraphMCM->GetHistogram()->SetTitle("Error MCM;event number;fraction with error (%)"); + fErrorGraphADC->GetHistogram()->SetTitle("Error ADC;event number;fraction with error (%)"); + + + fSMHCped = new TH2D("smHcPed", ";super module;half chamber", 18, -0.5, 17.5, 60, -0.5, 59.5); + //fSMHCerr = 0; + //Info("Init", "Done"); + + // number of ADC channels fired per SM and in total + for(Int_t sm=0; smGet(Form("ped_%d",det)); + fRefHistNoise = (TH2D*)file->Get(Form("noise_%d", det)); + + if (file) file->Close(); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) @@ -153,14 +284,48 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) for(Int_t k=0; kReset(); + fFullCounter[i] = 0; + } + Int_t nb = 0; - Int_t rob_last = -1; - Int_t mcm_last = -1; - Int_t sm_01 = -1; + + Int_t lastdet = -1; + Int_t lastside = -1; + Int_t lastmcm = -1; + + Int_t rob_last = -1; + Int_t mcm_last = -1; + + Int_t nGoodHC = 0; + Int_t nGoodMCM = 0; + Int_t nGoodADC = 0; + + Int_t nErrorHC = 0; + Int_t nErrorMCM = 0; + Int_t nErrorADC = 0; + + + //Int_t adc_last = -1; + // Int_t sm_01 = -1; + + // number of ADCs per SM + Int_t nADCinSM[kSM+1]; + for(Int_t sm=0; smNext()) { + Int_t sm = data->GetSM(); + Int_t layer = data->GetLayer(); + Int_t stack = data->GetStack(); + Int_t det = data->GetDet(); + Int_t side = data->GetSide(); Int_t row = data->GetRow(); Int_t col = data->GetCol(); @@ -169,23 +334,65 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) Int_t mcm = data->GetMCM(); Int_t adc = data->GetADC(); + Int_t *sig = data->GetSignals(); nb++; - // ugly hook - if (det == 0 && row == 0 && col == 0) { - if (sm_01 > -1) printf("\t\t\t!!! !!! second data set !!! !!!\n"); - sm_01++; - } - - det += sm_01 * 30; /// ugly - + nADCinSM[sm]++; + nADCinSM[kSM]++; + // memory coruption protection if (det<0 || det>=kDET) continue; + // check errors + + // tests + //fErrorHC->Fill(data->GetHCErrorCode()); + if (data->GetMCMErrorCode() > 0) fErrorLocMCM[det]->Fill(row, col); + if (data->GetADCErrorCode() > 0) fErrorLocADC[det]->Fill(row, col); + + // new HC found + if ((det + side*kDET) != (lastdet + lastside*kDET)) { + Int_t code = data->GetHCErrorCode(); + // if (code) { + fErrorHC->Fill(code); + + if (code) fErrorSMHC->Fill(sm); + if (code) nErrorHC++; + nGoodHC++; + + //Int_t mask = 1; + //for(Int_t cc = 0; cc < 3; cc++) { + // if (code & mask) fErrorHC->Fill(cc); + // cc *= 2; + // } + //} + } + lastdet = det; + lastside = side; + + // new MCM found + if (mcm != lastmcm){ + Int_t code = data->GetMCMErrorCode(); + fErrorMCM->Fill(code); + + if (code) fErrorSMMCM->Fill(sm); + if (code) nErrorMCM++; + nGoodMCM++; + } + lastmcm = mcm; + + // new ADC channel found + Int_t code = data->GetADCErrorCode(); + fErrorADC->Fill(code); + if (code) fErrorSMADC->Fill(sm); + if (code) nErrorADC++; + nGoodADC++; + + // end of error checking + // check the ROBs fDetRob->Fill(det, rob, 1./(kMCM*18)); - isUsed[det][row][col]++; // check if mcm signal is continuus @@ -202,32 +409,51 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) // create a structure for an MCM if needed Int_t mcmIndex = det * (kMCM * kROB) + rob * kMCM + mcm; if (fCreateFull && !fFullSignal[mcmIndex]) - fFullSignal[mcmIndex] = new TH2S(Form("mcm_%d_%d_%d", det, rob, mcm), - Form("mcm-%d-%d-%d;ADC;time bin", det, rob,mcm), + fFullSignal[mcmIndex] = new TH2S(Form("mcm_%d_%d_%d_%d_%d", sm, stack, layer, rob, mcm), + Form("mcm-%d-%d-%d-%d-%d;ADC;time bin", sm, stack, layer, rob, mcm), 21, -0.5, 20.5, 30, -0.5, 29.5); // loop over Time Bins and fill histograms + Int_t minV = 1024; + Int_t maxV = 0; + for(Int_t k=0; kGetADCErrorCode() > 0) continue; + + //if (col == 0 || col == 143) + //printf("TB: %d %d %d\n", row, col, sig[k]); + //if (sig[k] < 1) //printf("det = %d rob = %d mcm = %d adc = %d k = %d S = %d\n", det, rob, mcm, adc, k, sig[k]); fSignal[det]->Fill(sig[k]); fData[det]->Fill(row, col, sig[k]); + minV = (minV < sig[k]) ? minV : sig[k]; + maxV = (maxV > sig[k]) ? maxV : sig[k]; + + // check if data strange enought if (fCreateFull && fFullSignal[mcmIndex]) { + //if (sm == 17 && ) + //if (det != 29) { if (sig[k] > fThresh || sig[k] < 1) fFullCounter[mcmIndex]++; + //if (sig[k] < 1) fFullCounter[mcmIndex] = 0; // remove austrian flag + //} fFullSignal[mcmIndex]->Fill(adc, k, sig[k]); } // noisy chamber - if (det == 29) { + if (det == 29 && col > 7) { fTBEvent->Fill(fnEvents, k, sig[k]); } - } + + fPP->Fill(maxV-minV); + fChPP[det]->Fill(maxV-minV); + fSmPP[sm]->Fill(maxV-minV); } // is the dead-alive status changing during the run @@ -237,6 +463,41 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) fOccupancy->Fill(isUsed[i][j][k]); } + // save interesting histos + Int_t mcmTrackCandidate = 0; + for(Int_t i = 0; i < kDET * kROB * kMCM; i++) { + if (fFullCounter[i] && fFullSignal[i] && CheckMCM(i) ) { + + fMcmTracks->AddLast(fFullSignal[i]->Clone(Form("event_%d_%s", fnEvents, fFullSignal[i]->GetName()))); + mcmTrackCandidate++; + + Int_t mcmTrackletDet = i/(kROB * kMCM); + Int_t mcmTrackletMcm = i%(kROB * kMCM); + fMapMCM->Fill(mcmTrackletDet, mcmTrackletMcm); + } + } + + fGraphMCM->SetPoint(fnEvents, fnEvents, mcmTrackCandidate); + printf("Number of MCM track candidates = %d\n", mcmTrackCandidate); + + + // update fraction of error graphs + Double_t err; + + err = (nGoodHC > 0)? 100.*nErrorHC/nGoodHC : -1; + fErrorGraphHC->SetPoint(fnEvents, fnEvents, err); + + err = (nGoodMCM > 0)? 100.*nErrorMCM/nGoodMCM : -1; + fErrorGraphMCM->SetPoint(fnEvents, fnEvents, err); + + err = (nGoodADC > 0)? 100.*nErrorADC/nGoodADC : -1; + fErrorGraphADC->SetPoint(fnEvents, fnEvents, err); + + // number of fired ADC per SM + for(Int_t sm=0; smSetPoint(fnEvents, fnEvents, nADCinSM[sm]); + + fnEvents++; return nb; } @@ -248,6 +509,11 @@ void AliTRDqaBlackEvents::Process(const char *filename) // // Process something // + + char fn[256]; + strcpy(fn, filename); + + //printf("FILENAME = %s (%s)\n", filename, fn); Int_t map[kDET]; @@ -255,28 +521,29 @@ void AliTRDqaBlackEvents::Process(const char *filename) TF1 *fit = new TF1("fit", "gaus(0)", 0, 20); fit->SetParameters(1e3, 10, 1); - for(Int_t i=0; iGetSum() < 10) continue; - map[i] = 1; + for(Int_t det=0; detGetSum() < 10) continue; + map[det] = 1; - for(Int_t j=0; jGetXaxis()->GetNbins(); j++) { - for(Int_t k=0; kGetYaxis()->GetNbins(); k++) { + // read reference distributions + ReadRefHists(det); + + for(Int_t row=0; rowGetXaxis()->GetNbins(); row++) { + for(Int_t pad=0; padGetYaxis()->GetNbins(); pad++) { // project the histogramm hist->Reset(); for(Int_t bb=0; bb<50; bb++) { - Int_t dataBin = fData[i]->FindBin(j, k, bb); - Double_t v = fData[i]->GetBinContent(dataBin); + Int_t dataBin = fData[det]->FindBin(row, pad, bb); + Double_t v = fData[det]->GetBinContent(dataBin); hist->SetBinContent(bb+1, v); } - //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1); - - Int_t bin = fChPed[i]->FindBin(j, k); + Int_t bin = fChPed[det]->FindBin(row, pad); if (hist->GetSum() > 1) { @@ -288,20 +555,44 @@ void AliTRDqaBlackEvents::Process(const char *filename) TF1 *f = hist->GetFunction("fit"); ped = TMath::Abs(f->GetParameter(1)); noise = TMath::Abs(f->GetParameter(2)); + fSmNoiseFit[det/30]->Fill(noise); } else { ped = hist->GetMean(); noise = hist->GetRMS(); + fSmNoiseRms[det/30]->Fill(noise); + //if (pad == 0) + // printf("data %f %f %f\n", hist->GetSum(), ped, noise); } - fChPed[i]->SetBinContent(bin, ped); - fChNoise[i]->SetBinContent(bin, noise); + fChPed[det]->SetBinContent(bin, ped); + fChNoise[det]->SetBinContent(bin, noise); + fNoiseTotal->Fill(noise); + + // subtract reference values + Double_t refped = 0; + Double_t refnoise = 0; - fPed[i]->Fill(ped); - fNoise[i]->Fill(noise); + if (fRefHistPed) refped = fRefHistPed->GetBinContent(bin); + if (fRefHistNoise) refnoise = fRefHistPed->GetBinContent(bin); + + fChPedRes[det]->SetBinContent(bin, ped-refped); + fChNoiseRes[det]->SetBinContent(bin, noise-refnoise); + + fPed[det]->Fill(ped); + fNoise[det]->Fill(noise); + + // fill SM-HC plot + Int_t sm = det / 30; + Int_t hc = (pad < kPAD/2) ? 2* (det % 30) : 2* (det % 30) + 1; + if (ped > 9. && ped < 11) fSMHCped->Fill(sm, hc, 1./1152.); // number of pads in HC } else { - fChPed[i]->SetBinContent(bin, 0); - fChNoise[i]->SetBinContent(bin, 0); + + // not enought data found + fChPed[det]->SetBinContent(bin, 0); + fChNoise[det]->SetBinContent(bin, 0); + fChPedRes[det]->SetBinContent(bin, 0); + fChNoiseRes[det]->SetBinContent(bin, 0); } //delete hist; @@ -309,7 +600,8 @@ void AliTRDqaBlackEvents::Process(const char *filename) } } - Info("Process", "Number of events = %d", fnEvents); + + //printf("Number of events = %d\n", fnEvents); // normalize number of entries histos Int_t max = 0; @@ -325,7 +617,7 @@ void AliTRDqaBlackEvents::Process(const char *filename) } char entriesDistName[100]; - + for(Int_t i=0; iWrite(); - fChNoise[i]->Write(); - fNPoint[i]->Write(); - fNPointDist[i]->Write(); - fPed[i]->Write(); - fNoise[i]->Write(); - fSignal[i]->Write(); - fnEntriesRM[i]->Write(); + //printf("FILENAME 2 = %s (%d)\n", fn, fn); + TFile *file = new TFile(fn, "recreate"); + for(Int_t det = 0; det < kDET; det++) { + if (!map[det]) continue; + fChPed[det]->Write(); + fChNoise[det]->Write(); + fNPoint[det]->Write(); + fNPointDist[det]->Write(); + fPed[det]->Write(); + fNoise[det]->Write(); + fSignal[det]->Write(); + fnEntriesRM[det]->Write(); + fChPP[det]->Write(); + + fChPedRes[det]->Write(); + fChNoiseRes[det]->Write(); + + // save error hists + fErrorLocMCM[det]->SetMinimum(0); + fErrorLocMCM[det]->SetMaximum(fnEvents); + fErrorLocMCM[det]->Write(); + + fErrorLocADC[det]->SetMinimum(0); + fErrorLocADC[det]->SetMaximum(fnEvents); + fErrorLocADC[det]->Write(); + } + + for(Int_t sm=0; smWrite(); + fSmNoiseFit[sm]->Write(); + fSmPP[sm]->Write(); } + + Int_t nMcm = 0; for(Int_t i=0; i < kDET * kROB * kMCM; i++) { if (fFullSignal[i] && fFullCounter[i] > fCount) { @@ -374,16 +688,112 @@ void AliTRDqaBlackEvents::Process(const char *filename) } printf("Number of saved MCMs = %d\n", nMcm); + + fMcmTracks->Write(); + printf("Number of tracks = %d\n", fMcmTracks->GetEntries()); + + // permanently problematic MCMs + for(Int_t det=0; detFindBin(det, mcm); + Double_t frac = 1. * fMapMCM->GetBinContent(bin) / fnEvents; + fFracMCM->Fill(frac); + + if (frac > 0.7) { + printf("{%d, %d, %d}, \n", det, mRob, mMcm, frac); + } + } + } + + fOccupancy->Write(); fDetRob->Write(); fTBEvent->Write(); + + // error hists + fErrorHC->Write(); + fErrorMCM->Write(); + fErrorADC->Write(); + + fErrorSMHC->Write(); + fErrorSMMCM->Write(); + fErrorSMADC->Write(); + + // write graphs + fErrorGraphHC->Write("trendErrorHC"); + fErrorGraphMCM->Write("trendErrorMCM"); + fErrorGraphADC->Write("trendErrorADC"); + + fGraphMCM->Write("trendMCM"); + + fMapMCM->SetMaximum(fnEvents); + fMapMCM->Write(); + fFracMCM->Write(); + + fSMHCped->Write(); + + for(Int_t sm=0; smWrite(Form("nADCinSM%d",sm)); + + fNumberADC[kSM]->Write("nADCinEvent"); + + fNoiseTotal->Write(); + fPP->Write(); + file->Close(); delete file; } /////////////////////////////////////////////////////////////////////////////////////////////////// +Int_t AliTRDqaBlackEvents::CheckMCM(Int_t index) { + + return 1; + + static Int_t data[21][3] = { + {1, 0, 1}, + {242, 0, 0}, + {242, 0, 1}, + {242, 0, 2}, + {242, 0, 4}, + {242, 0, 5}, + {242, 0, 6}, + {242, 0, 8}, + {242, 0, 12}, + {251, 7, 7}, + {254, 3, 11}, + {259, 3, 14}, + {260, 1, 9}, + {260, 3, 15}, + {273, 1, 7}, + {273, 1, 15}, + {276, 5, 11}, + {280, 6, 2}, + {299, 6, 4}, + {511, 2, 9}, + {517, 7, 15} + }; + + for(Int_t i=0; i<21; i++) { + Int_t wIndex = data[i][0] * kROB*kMCM + data[i][1] * kMCM + data[i][2]; + if (index == wIndex) return 0; + } + + return 1; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + + + + + + + void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h) { // diff --git a/TRD/AliTRDqaBlackEvents.h b/TRD/AliTRDqaBlackEvents.h index f90d3f82fe8..f663ac0b160 100644 --- a/TRD/AliTRDqaBlackEvents.h +++ b/TRD/AliTRDqaBlackEvents.h @@ -20,6 +20,8 @@ class TH1D; class TH2D; class TH2S; class TH3F; +class TGraph; +class TObjArray; class AliTRDrawStreamTB; class AliTRDqaBlackEvents : public TObject { @@ -45,6 +47,8 @@ class AliTRDqaBlackEvents : public TObject { void SetNoiseLevel(Double_t min, Double_t max) {fMinNoise = min; fMaxNoise = max;} void SetFitMethod(Int_t fit) {fFitType = fit;} + void SetRefFile(const char *filename); + void DrawChamber(const char *filename, Int_t det, Int_t w=700, Int_t h=400); //void ScanChamber(const char *filename, Int_t first, Int_t last); void DrawSm(const char *filename, Int_t sm, Int_t w=900, Int_t h=700); @@ -62,6 +66,9 @@ class AliTRDqaBlackEvents : public TObject { Int_t fThresh; // threshold to analyze MCM data Int_t fCount; // minimum number of entries above threshold + Char_t fRefFileName[256]; // name of the file with reference distributions + + // geometry constants enum { kDET = 540, @@ -70,7 +77,8 @@ class AliTRDqaBlackEvents : public TObject { kADC = 21, kTB = 30, kCOL = 16, - kPAD = 144 + kPAD = 144, + kSM = 18 }; // histograms per detector @@ -82,6 +90,7 @@ class AliTRDqaBlackEvents : public TObject { TH1D *fPed[kDET]; // reconstructed pedestals distribution (on hist per chamber) TH1D *fNoise[kDET]; // reconstructed noise distribution (on hist per chamber) + TH1D *fChPP[kDET]; // peak to peak for each chamber TH1D *fNPointDist[kDET]; // distributin of the number of points TH2D *fChPed[kDET]; // Some histograms TH2D *fChNoise[kDET]; // Some histograms @@ -91,16 +100,70 @@ class AliTRDqaBlackEvents : public TObject { TH2D *fnEntriesRM[kDET]; // number of entries for ROB - MCM TH1D *fnEntriesRMDist[kDET]; // distribtion of number of entries per ROB-MCM + // after reference subtraction + TH2D *fChPedRes[kDET]; // histograms after reference subtraction + TH2D *fChNoiseRes[kDET]; // histograms after reference subtraction + + TH2D *fTBEvent; // coherent noise + + TH2D *fRefHistPed; // reference distributions + TH2D *fRefHistNoise; // reference distributions + TH2S *fFullSignal[kDET*kROB*kMCM]; // one histogram per MCM Short_t fFullCounter[kDET*kROB*kMCM]; // counts a number of entries with high signal - TH2D *fTBEvent; // coherent noise + // error codes + TH1D *fErrorHC; // number of errors HC + TH1D *fErrorMCM; // number of errors MCM + TH1D *fErrorADC; // number of errors ADC + + TH1D *fErrorSMHC; // number of errors in HC per SM + TH1D *fErrorSMMCM; // number of errors in MCM per SM + TH1D *fErrorSMADC; // number of errors in ADC per SM + TH2D *fErrorLocHC[kDET]; // location of errors + TH2D *fErrorLocMCM[kDET]; // location + TH2D *fErrorLocADC[kDET]; // errors in ADC - Int_t fFitType; + // error fraction + TGraph *fErrorGraphHC; + TGraph *fErrorGraphMCM; + TGraph *fErrorGraphADC; + + TGraph *fGraphMCM; // number of strange MCMs detected + // mcm trackles + TObjArray *fMcmTracks; + + // problematic MCMs + TH2D *fMapMCM; + TH1D *fFracMCM; + + // full detector view + TH2D *fSMHCped; + TH2D *fSMHCerr; + + // number of fired ADC channels in total and per SM + TGraph *fNumberADC[kSM+1]; + + //Int_t fChkDe + + TH1D *fNoiseTotal; + TH1D *fPP; + + TH1D *fSmNoiseRms[kSM]; + TH1D *fSmNoiseFit[kSM]; + TH1D *fSmPP[kSM]; + + // Double_t fMinNoise; // Minimum noise Double_t fMaxNoise; // Maximum noise + Int_t fFitType; + + // private function + void ReadRefHists(Int_t det); + Int_t CheckMCM(Int_t index); + ClassDef(AliTRDqaBlackEvents,0) // QA for black events diff --git a/TRD/AliTRDqaBuildReference.cxx b/TRD/AliTRDqaBuildReference.cxx new file mode 100644 index 00000000000..de3b8fa611b --- /dev/null +++ b/TRD/AliTRDqaBuildReference.cxx @@ -0,0 +1,76 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaBuildReference.cxx 26344 2008-06-03 10:28:50Z cblume $ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// Build the reference histograms // +// // +// Author: // +// Sylwester Radomski (radomski@physi.uni-heidelberg.de) // +// // +//////////////////////////////////////////////////////////////////////////// + +#include "TH1D.h" +#include "TFile.h" + +#include "AliTRDqaBuildReference.h" + +////////////////////////////////////////////////////////////////////////////////////// + +void AliTRDqaBuildReference::BuildRefHistos(TFile *file) const +{ + // + // Build the reference histograms + // + + // check + if (!file) return; + if (file->IsZombie()) return; + + // recpoints + Int_t cd = file->cd("TRD/RecPoints"); + if (cd) { + + // MPV distribution + + TH1D *r = new TH1D("qaTRD_recPoints_ampMPV_ref", "", 150, 0, 150); + for(Int_t i=0; iGetNbinsX(); i++) { + Double_t x = r->GetBinCenter(i+1); + if (x < 10 || x > 70) r->Fill(x, 1); + else if (x < 25 || x > 55) r->Fill(x, 0.5); + } + + r->Fill(-1e3, 1); + r->Fill(1e3, 1); + + // number of clusters + r = new TH1D("qaTRD_recPoints_nCls_ref", "", 500, -0.5, 499.5); + for(Int_t i=0; iGetNbinsX(); i++) { + Double_t x = r->GetBinCenter(i+1); + if ( (i+4)%22 > 9 || i < 10) r->Fill(x, 0.5); + if (x > 350) r->Fill(x, 1); + } + + file->Write(); + } + + // esds + +} + + +////////////////////////////////////////////////////////////////////////////////////// diff --git a/TRD/AliTRDqaBuildReference.h b/TRD/AliTRDqaBuildReference.h new file mode 100644 index 00000000000..f9afdff214b --- /dev/null +++ b/TRD/AliTRDqaBuildReference.h @@ -0,0 +1,39 @@ +#ifndef ALITRDQABUILDREFERENCE_H +#define ALITRDQABUILDREFERENCE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaBuildReference.h 23387 2008-01-17 17:25:16Z cblume $ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// Build the reference histograms // +// // +// Author: // +// Sylwester Radomski (radomski@physi.uni-heidelberg.de) // +// // +//////////////////////////////////////////////////////////////////////////// + +class TFile; +class TH1D; + +class AliTRDqaBuildReference: public TObject { + + public: + + AliTRDqaBuildReference() {} // ctor + AliTRDqaBuildReference(const AliTRDqaBuildReference& qadm):TObject(qadm) {} + AliTRDqaBuildReference& operator = (const AliTRDqaBuildReference& qadm) + { *(new(this) AliTRDqaBuildReference(qadm)); + return *this; } + virtual ~AliTRDqaBuildReference() {;} // dtor + + void BuildRefHistos(TFile *file) const; + Double_t CalculateQuality(TH1D* /*measured*/, TH1D* /*reference*/) const {return 1.;} + + private: + + ClassDef(AliTRDqaBuildReference,1) // Creates the TRD QA data + +}; +#endif diff --git a/TRD/AliTRDqaRecPoints.cxx b/TRD/AliTRDqaRecPoints.cxx new file mode 100644 index 00000000000..90780f4c23c --- /dev/null +++ b/TRD/AliTRDqaRecPoints.cxx @@ -0,0 +1,454 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaRecPoints.cxx 23387 2008-01-17 17:25:16Z cblume $ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// Produces the data needed to calculate the quality assurance. // +// All data must be mergeable objects. // +// // +// Author: // +// Sylwester Radomski (radomski@physi.uni-heidelberg.de) // +// // +//////////////////////////////////////////////////////////////////////////// + +// --- ROOT system --- +#include +#include +#include +#include +#include +#include +#include +#include + +// --- AliRoot header files --- +#include "AliESDEvent.h" +#include "AliLog.h" +#include "AliTRDcluster.h" +#include "AliTRDqaRecPoints.h" +#include "AliTRDgeometry.h" +#include "AliTRDdataArrayI.h" + +#include "AliQAChecker.h" + +ClassImp(AliTRDqaRecPoints) + +//____________________________________________________________________________ + +AliTRDqaRecPoints::AliTRDqaRecPoints() : + TObject(), + fnEvents(0), + fHist(0), + fnPad(0), + fRef(0) +{ + // + // Default constructor + // + +} + +//____________________________________________________________________________ + +AliTRDqaRecPoints::AliTRDqaRecPoints(const AliTRDqaRecPoints &/*qa*/) : + TObject(), + fnEvents(0), + fHist(0), + fnPad(0), + fRef(0) +{ + // + // Copy constructor + // + +} + +//____________________________________________________________________________ +void AliTRDqaRecPoints::Process(const char* filename) +{ + // + // Detector specific actions at end of cycle + // + //TStopwatch watch; + //watch.Start(); + + AliInfo("End of TRD cycle"); + + //if (task == AliQA::kRECPOINTS) { + + TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5); + //fHist->Print(); + + // fill detector map; + for(int i=0; i<540; i++) { + Double_t v = ((TH1D*)fHist->At(0))->GetBinContent(i+1); + Int_t sm = i/30; + Int_t det = i%30; + + TH2D *detMap = (TH2D*)fHist->At(87); + Int_t bin = detMap->FindBin(sm, det); + detMap->SetBinContent(bin, v); + } + + + // Rec points full chambers + for (Int_t i=0; i<540; i++) { + + //AliInfo(Form("I = %d", i)); + + //TH1D *h = ((TH2D*)fHist->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1); + hist->Reset(); + for(Int_t b=1; bGetXaxis()->GetNbins()-1; b++) { + Double_t xvalue = hist->GetBinCenter(b); + Int_t bin = ((TH2D*)fHist->At(1))->FindBin(i,xvalue); + Double_t value = ((TH2D*)fHist->At(1))->GetBinContent(bin); + hist->SetBinContent(b, value); + } + + //printf("Sum = %d %f\n", i, hist->GetSum()); + if (hist->GetSum() < 100) continue; // chamber not present + + hist->Fit("landau", "q0", "goff", 10, 180); + TF1 *fit = hist->GetFunction("landau"); + ((TH1D*)fHist->At(12))->Fill(fit->GetParameter(1)); + ((TH1D*)fHist->At(13))->Fill(fit->GetParameter(2)); + } + + // time-bin by time-bin sm by sm + for(Int_t i=0; i<18; i++) { // loop over super-modules + + for(Int_t j=0; j<35; j++) { // loop over time bins + + //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1); + hist->Reset(); + for(Int_t b=1; bGetXaxis()->GetNbins()-1; b++) { + Double_t xvalue = hist->GetBinCenter(b); + Double_t svalue = 0; + + for(Int_t det=i*30; det<(i+1)*30; det++) { // loop over detectors + Int_t bin = ((TH3D*)fHist->At(10))->FindBin(det,j,xvalue); + Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin); + svalue += value; + } + //printf("v = %f\n", value); + hist->SetBinContent(b, svalue); + } + + if (hist->GetSum() < 100) continue; + //printf("fitting %d %d %f\n", i, j, hist->GetSum()); + + hist->Fit("landau", "q0", "goff", 10, 180); + TF1 *fit = hist->GetFunction("landau"); + + TH1D *h1 = (TH1D*)fHist->At(14+18+i); + Int_t bin = h1->FindBin(j); + // printf("%d %d %d\n", det, j, bin); + h1->SetBinContent(bin, TMath::Abs(fit->GetParameter(1))); + } + } + + + // time-bin by time-bin chamber by chamber + + for (Int_t i=0; i<540; i++) { + + //TH1D *test = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35); + //if (test->GetSum() < 100) continue; + + //AliInfo(Form("fitting det = %d", i)); + + for(Int_t j=0; j<35; j++) { + + //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1); + hist->Reset(); + for(Int_t b=1; bGetXaxis()->GetNbins()-1; b++) { + Double_t xvalue = hist->GetBinCenter(b); + Int_t bin = ((TH3D*)fHist->At(10))->FindBin(i,j,xvalue); + Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin); + //printf("v = %f\n", value); + hist->SetBinContent(b, value); + } + + if (hist->GetSum() < 100) continue; + //printf("fitting %d %d %f\n", i, j, hist->GetSum()); + + hist->Fit("landau", "q0", "goff", 10, 180); + TF1 *fit = hist->GetFunction("landau"); + + Int_t sm = i/30; + Int_t det = i%30; + TH2D *h2 = (TH2D*)fHist->At(14+sm); + Int_t bin = h2->FindBin(det,j); + // printf("%d %d %d\n", det, j, bin); + h2->SetBinContent(bin, TMath::Abs(fit->GetParameter(1))); + h2->SetBinError(bin,fit->GetParError(1)); + } + } + + if (hist) delete hist; + + + TFile *outFile = new TFile(filename, "RECREATE"); + outFile->mkdir("TRD"); + gDirectory->cd("TRD"); + gDirectory->mkdir("RecPoints"); + gDirectory->cd("RecPoints"); + fHist->Write(); + + if (fRef) { + for(Int_t i=0; i<540; i++) { + //fRefHist[i]->Scale(1./fnEvents); + fRefHist[i]->Write(); + } + } + + outFile->Close(); + +} + +//____________________________________________________________________________ + +void AliTRDqaRecPoints::Init() +{ + // + // Create Reconstructed Points histograms in RecPoints subdir + // + + //const Int_t kNhist = 14 + 4 * 18 + 2; + const Int_t kNhist = 88+2*18+1; + TH1 *hist[kNhist]; + + hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5); + hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5); + hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5); + + hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1); + hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1); + hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1); + hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1); + + hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5); + hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5); + hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5); + + hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal", + 540, -0.5, 539.5, 35, -0.5, 34.5, 200, -0.5, 199.5); + hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity" + , 120, -0.6, 0.6, -1.2, 1.2, ""); + + hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 150, 0, 150); + hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 200, 0, 200); + + // chamber by chamber + for(Int_t i=0; i<18; i++) { + hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"), + 30, -0.5, 29.5, 35, -0.5, 34.5); + hist[14+i]->SetMinimum(20); + hist[14+i]->SetMaximum(40); + } + + // time bin by time bin sm-by-sm + for(Int_t i=0; i<18; i++) { + hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i), + Form("sm%d;time bin;signal"), + 35, -0.5, 34.5); + + hist[14+18+i]->SetMaximum(120); + } + + // str = 50 + for(Int_t i=0; i<18; i++) { + hist[50+i] = new TH1D(Form("qaTRD_recPoints_nCls_sm%d",i), + Form("sm%d;time bin;number of clusters",i), + 35, -0.5, 34.5); + } + + // str = 68 + for(Int_t i=0; i<18; i++) { + hist[68+i] = new TH1D(Form("qaTRD_recPoints_totalCharge_sm%d", i), + Form("sm%d;time bin;total charge", i), + 35, -0.5, 34.5); + } + + hist[86] = new TH1D("qaTRD_recPoints_signal", ";amplitude", 200, -0.5, 199.5); + hist[87] = new TH2D("qaTRD_recPoints_detMap", ";sm;chamber", 18, -0.5, 17.5, 30, -0.5, 29.5); + + for(Int_t i=0; i<18; i++) + hist[88+i] = new TH2D(Form("qaTRD_recPoints_XY_sm%d", i), + Form("SM%d;Y;X",i), 240, -60, 60, 200, 290, 370); + + for(Int_t i=0; i<18; i++) + hist[106+i] = new TH2D(Form("qaTRD_recPoints_XPad_sm%d", i), + Form("SM%d;Y;X",i), 144, -0.5, 143.5, 200, 290, 370); + + + hist[124] = new TH1D("qRef", "ref", 100, 0, 1e4); + + fHist = new TObjArray(200); + for(Int_t i=0; iSumw2(); + fHist->AddAt(hist[i], i); + } + + // reference histograms + if (fRef) { + for(Int_t i=0; i<540; i++) { + fRefHist[i] = new TH2D(Form("refRecPoints_sm%d", i), "", + 16, -0.5, 15.5, 144, -0.5, 143.5); //, 30, -0.5, 29.5); + } + } else { + + TFile *refFile = new TFile("outRef.root"); + refFile->cd("TRD/RecPoints"); + + for(Int_t i=0; i<540; i++) { + fRefHist[i] = (TH2D*)gDirectory->Get(Form("refRecPoints_sm%d", i)); + } + } +} + +//____________________________________________________________________________ + +void AliTRDqaRecPoints::AddEvent(TTree * clustersTree) +{ + // + // Makes data from RecPoints + // + + // Info("MakeRecPoints", "making"); + + Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster))); + TObjArray *clusterArray = new TObjArray(nsize+1000); + + TBranch *branch = clustersTree->GetBranch("TRDcluster"); + if (!branch) { + AliError("Can't get the branch !"); + return; + } + branch->SetAddress(&clusterArray); + + // Loop through all entries in the tree + Int_t nEntries = (Int_t) clustersTree->GetEntries(); + Int_t nbytes = 0; + AliTRDcluster *c = 0; + Int_t nDet[540]; + for (Int_t i=0; i<540; i++) nDet[i] = 0; + + for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { + + //printf("Entry = %d\n", iEntry); + + // Import the tree + nbytes += clustersTree->GetEvent(iEntry); + + // Get the number of points in the detector + Int_t nCluster = clusterArray->GetEntriesFast(); + + // Loop through all TRD digits + for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { + c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster); + + Int_t iDet = c->GetDetector(); + if (iDet < 0 || iDet > 539) continue; + + + Int_t iSM = iDet / 30; + //Int_t iStack = iDet % 30; + Int_t nPad = c->GetNPads(); + + if (fnPad && nPad != fnPad) continue; + + //if (iSM == 0 && iStack == 29) continue; + //if (iSM == 8 && iStack == 11) continue; + //if (iSM == 8 && iStack == 7) continue; + + Int_t padRow = c->GetPadRow(); + Int_t padCol = c->GetPadCol(); + //Int_t timeBin = c->GetPadTime(); + + Double_t refQ = 0; + + if (fRef) { + fRefHist[iDet]->Fill(padRow, padCol, c->GetQ()); + } else { + Int_t bin = fRefHist[iDet]->FindBin(padRow, padCol); + refQ = fRefHist[iDet]->GetBinContent(bin); + //printf("bin = %d\n", bin); + } + + ((TH1D*)fHist->At(124))->Fill(refQ); + //printf("ref Q = %lf\n", refQ); + + Double_t charge = c->GetQ() - (refQ / (490. * 30)); + if (charge < 0) continue; + + if (charge > 20) { + ((TH2D*)fHist->At(88+iSM))->Fill(c->GetY(), c->GetX()); + ((TH2D*)fHist->At(106+iSM))->Fill(c->GetPadCol(), c->GetX()); + } + + nDet[iDet]++; + ((TH1D*)fHist->At(0))->Fill(iDet); + ((TH1D*)fHist->At(86))->Fill(charge); + ((TH1D*)fHist->At(1))->Fill(iDet, charge); + ((TH1D*)fHist->At(2))->Fill(c->GetNPads()); + if (c->GetNPads() < 6) + ((TH1D*)fHist->At(1+c->GetNPads()))->Fill(c->GetCenter()); + + //if (c->GetPadTime() < 5) + ((TH2D*)fHist->At(7))->Fill(padRow, c->GetPadCol()); + ((TH1D*)fHist->At(8))->Fill(c->GetPadTime()); + + ((TH3D*)fHist->At(10))->Fill(iDet, c->GetPadTime(), charge); + + ((TH1D*)fHist->At(50+iSM))->Fill(c->GetPadTime()); + ((TH1D*)fHist->At(68+iSM))->Fill(c->GetPadTime(), charge); + + // PRF for 2pad + //if (c->GetNPads() == 2) { + Short_t *sig = c->GetSignals(); + Double_t frac = -10; + + if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0) + frac = 1. * sig[4] / (sig[3] + sig[4]); + + if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0) + frac = -1. * sig[2] / (sig[2] + sig[3]); + + if (frac > -10) ((TProfile*)fHist->At(11))->Fill(c->GetCenter(), frac); + + //} + } + } + + for(Int_t i=0; i<540; i++) + if (nDet[i] > 0) ((TH1D*)fHist->At(9))->Fill(nDet[i]); + + delete clusterArray; + + /* + TFile *outFile = new TFile("outQA.root", "RECREATE"); + outFile->mkdir("TRD"); + gDirectory->cd("TRD"); + gDirectory->mkdir("RecPoints"); + gDirectory->cd("RecPoints"); + fHist->Write(); + outFile->Close(); + */ +} + +//____________________________________________________________________________ diff --git a/TRD/AliTRDqaRecPoints.h b/TRD/AliTRDqaRecPoints.h new file mode 100644 index 00000000000..9d11e722e68 --- /dev/null +++ b/TRD/AliTRDqaRecPoints.h @@ -0,0 +1,54 @@ +#ifndef ALITRDQARECPOINTS_H +#define ALITRDQARECPOINTS_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaRecPoints.h 23387 2008-01-17 17:25:16Z cblume $ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// QA of black events // +// // +// Author: // +// Sylwester Radomski (radomski@physi.uni-heidelberg.de) // +// // +//////////////////////////////////////////////////////////////////////////// + +#include "TObject.h" + +class TH1; +class TH1D; +class TH3D; +class TObjArray; + +class AliTRDqaRecPoints : public TObject { + + public: + + AliTRDqaRecPoints(); + AliTRDqaRecPoints(const AliTRDqaRecPoints &qa); + ~AliTRDqaRecPoints() {} + AliTRDqaRecPoints& operator = (const AliTRDqaRecPoints& /*qa*/) { return *this; }; + + void Init(); + void Reset() {} + void AddEvent(TTree *tree); + void Process(const char* filename); + + void SetNPad(Int_t nPad) {fnPad = nPad;} + void CreateRef(Int_t ref) {fRef = ref;} + + private: + + Int_t fnEvents; // number of events processed + TObjArray *fHist; // histograms + + TH2D *fRefHist[540]; // reference histograms + + Int_t fnPad; // something + Int_t fRef; // something else + + ClassDef(AliTRDqaRecPoints,0) // QA for black events + +}; +#endif -- 2.39.3