+/**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ * *\r
+ * Author: The ALICE Off-line Project. *\r
+ * Contributors are mentioned in the code where appropriate. *\r
+ * *\r
+ * Permission to use, copy, modify and distribute this software and its *\r
+ * documentation strictly for non-commercial purposes is hereby granted *\r
+ * without fee, provided that the abovĂ…\9be copyright notice appears in all *\r
+ * copies and that both the copyright notice and this permission notice *\r
+ * appear in the supporting documentation. The authors make no claims *\r
+ * about the suitability of this software for any purpose. It is *\r
+ * provided "as is" without express or implied warranty. *\r
+ **************************************************************************/\r
+\r
+/* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */\r
+\r
+////////////////////////////////////////////////////////////////////////////\r
+// //\r
+// QA of black events //\r
+// //\r
+// Author: //\r
+// Sylwester Radomski (radomski@physi.uni-heidelberg.de) //\r
+// //\r
+////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "TH1D.h"\r
+#include "TH2D.h"\r
+#include "TH3D.h"\r
+#include "TF1.h"\r
+#include "TFile.h"\r
+#include "TCanvas.h"\r
+#include "TPad.h"\r
+#include "TLatex.h"\r
+#include "TStyle.h"\r
+\r
+#include "AliTRDgeometry.h"\r
+#include "AliTRDrawStreamTB.h"\r
+#include "AliTRDqaBlackEvents.h"\r
+\r
+ClassImp(AliTRDqaBlackEvents)\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+AliTRDqaBlackEvents::AliTRDqaBlackEvents() \r
+ :TObject() \r
+ ,fMinNoise(0.5)\r
+ ,fMaxNoise(2) \r
+{\r
+ //\r
+ // Constructor \r
+ // to create the histograms call Init()\r
+ //\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa) \r
+ :TObject(qa) \r
+ ,fMinNoise(0.5)\r
+ ,fMaxNoise(2) \r
+{\r
+ //\r
+ // Copy constructor \r
+ // to create the histograms call Init()\r
+ //\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::Init() \r
+{\r
+ //\r
+ // creates histograms \r
+ // \r
+\r
+ //TFile *file = new \r
+ //Info("Init", "Statring");\r
+\r
+ for(Int_t i=0; i<540; i++) {\r
+ fData[i] = new TH3D(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);\r
+ fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 150, -0.5, 149.5);\r
+ fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+ fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals", 100, 0, 20);\r
+ fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise", 100, 0, 5); \r
+ fSignal[i] = new TH1D(Form("signal_%d", i), "", 100, -0.5, 99.5);\r
+ }\r
+\r
+ //Info("Init", "Done");\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::Reset() \r
+{\r
+ //\r
+ // Resets the histograms\r
+ //\r
+\r
+ for(Int_t i=0; i<540; i++) {\r
+ fData[i]->Reset();\r
+ fChPed[i]->Reset();\r
+ fChNoise[i]->Reset();\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) \r
+{\r
+ //\r
+ // Add an event\r
+ //\r
+\r
+ Int_t nb = 0;\r
+ while (data->Next()) {\r
+\r
+ Int_t det = data->GetDet();\r
+ Int_t *sig = data->GetSignals();\r
+ nb++;\r
+\r
+ if (det<0 || det>=540) continue;\r
+ \r
+ for(Int_t k=0; k<30; k++) {\r
+ fSignal[det]->Fill(sig[k]);\r
+ //if(sig[k]>13) printf("timebin: %d signal: %d\n",k,sig[k]); \r
+ fData[det]->Fill(data->GetRow(), data->GetCol(), sig[k]);\r
+ }\r
+ }\r
+\r
+ return nb;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::Process(const char *filename) \r
+{\r
+ //\r
+ // Process something\r
+ //\r
+\r
+ Int_t map[540];\r
+ \r
+ TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);\r
+ TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);\r
+ fit->SetParameters(1e3, 10, 1);\r
+ \r
+ for(Int_t i=0; i<540; i++) {\r
+ \r
+ map[i] = 0;\r
+ if (fData[i]->GetSum() < 100) continue;\r
+ map[i] = 1;\r
+\r
+ Info("process", "processing chamber %d", i);\r
+\r
+ for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {\r
+ for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {\r
+ \r
+ // project the histogramm\r
+ hist->Reset();\r
+ for(Int_t bb=0; bb<50; bb++) {\r
+ Int_t dataBin = fData[i]->FindBin(j, k, bb);\r
+ Double_t v = fData[i]->GetBinContent(dataBin);\r
+ hist->SetBinContent(bb+1, v);\r
+ }\r
+\r
+ //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);\r
+ \r
+ Int_t bin = fChPed[i]->FindBin(j, k);\r
+\r
+ if (hist->GetSum() > 10) {\r
+ hist->Fit(fit, "q0", "goff", 0, 20);\r
+ TF1 *f = hist->GetFunction("fit");\r
+ Double_t ped = TMath::Abs(f->GetParameter(1));\r
+ Double_t noise = TMath::Abs(f->GetParameter(2));\r
+\r
+ fChPed[i]->SetBinContent(bin, ped);\r
+ fChNoise[i]->SetBinContent(bin, noise);\r
+ \r
+ fPed[i]->Fill(ped);\r
+ fNoise[i]->Fill(noise);\r
+\r
+ } else {\r
+ fChPed[i]->SetBinContent(bin, 10);\r
+ fChNoise[i]->SetBinContent(bin, 1);\r
+ }\r
+ \r
+ //delete hist;\r
+ }\r
+ }\r
+ }\r
+\r
+ TFile *file = new TFile(filename, "UPDATE");\r
+ for(Int_t i=0; i<540; i++) {\r
+ if (!map[i]) continue; \r
+ fChPed[i]->Write();\r
+ fChNoise[i]->Write();\r
+ fPed[i]->Write();\r
+ fNoise[i]->Write();\r
+ fSignal[i]->Write();\r
+ }\r
+ file->Close();\r
+ delete file;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h) \r
+{\r
+ //\r
+ // Draw raport for one chamber: \r
+ // pedestal map, noise map, distribution of pedestal and noise\r
+ // \r
+ // input:\r
+ // name of the file with histograms (created with Process())\r
+ // detector Id (0 - 539)\r
+ // \r
+\r
+ // setup global style\r
+ gStyle->SetPalette(1);\r
+ gStyle->SetOptStat(0);\r
+ gStyle->SetPadTopMargin(0.02);\r
+ gStyle->SetPadBottomMargin(0.05);\r
+\r
+ TFile *file = new TFile(filename, "READ");\r
+\r
+ TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);\r
+ c->SetVertical(kFALSE);\r
+ c->Divide(3,1, 0.01, 0.01);\r
+ c->cd(3);\r
+ \r
+ TPad *mPad = (TPad*) gPad;\r
+ mPad->Divide(1,2,0.01,0.01);\r
+ \r
+ c->cd(1);\r
+ TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));\r
+ h2->SetMinimum(5);\r
+ h2->SetMaximum(15);\r
+ h2->SetTitle(";Z direction;#phi direction");\r
+ h2->Draw("colz");\r
+ \r
+ c->cd(2);\r
+ h2 = (TH2D*)file->Get(Form("noise_%d",det));\r
+ h2->SetMinimum(fMinNoise);\r
+ h2->SetMaximum(fMaxNoise);\r
+ h2->SetTitle(";Z direction;#phi direction");\r
+ h2->Draw("colz");\r
+ \r
+ mPad->cd(1);\r
+ //gPad->SetLogy();\r
+ TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));\r
+ h1->Draw();\r
+ \r
+ mPad->cd(2);\r
+ gPad->SetLogy();\r
+ h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));\r
+ h1->Draw(); \r
+ \r
+ h1->Fit("gaus");\r
+ TF1 *f = h1->GetFunction("gaus");\r
+ const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));\r
+ TLatex *ll = new TLatex(2, 100, tt);\r
+ ll->SetTextSize(0.06);\r
+ ll->Draw();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h) \r
+{\r
+ //\r
+ // ????????????\r
+ //\r
+ \r
+ gStyle->SetPalette(1);\r
+ gStyle->SetOptStat(0);\r
+ \r
+ gStyle->SetPadTopMargin(0.02);\r
+ //gStyle->SetPadBottomMargin(0.05); \r
+ //gStyle->SetPadLeftMargin(0.02); \r
+ //gStyle->SetPadRightMargin(0.02);\r
+\r
+ TFile *file = new TFile(filename, "READ");\r
+\r
+ TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);\r
+ c->SetVertical(kFALSE);\r
+ c->Divide(5, 6, 0.001, 0.01);\r
+ \r
+ for(Int_t i=0; i<30; i++) {\r
+ \r
+ TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));\r
+ if (!h2) continue;\r
+ h2->SetMinimum(fMinNoise);\r
+ h2->SetMaximum(fMaxNoise);\r
+\r
+ // to be replaced by the official calculation\r
+ Int_t stack = i/6;\r
+ Int_t layer = i%6;\r
+ Int_t index = (5-layer)*5 + stack + 1;\r
+ //printf("%d %d %d %d\n", i, stack, layer, index);\r
+ c->cd(index);\r
+ gPad->SetBottomMargin(0.02);\r
+ gPad->SetTopMargin(0.02);\r
+\r
+ h2->Draw("col");\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r