New class for the analysis of black events
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Jan 2008 16:36:34 +0000 (16:36 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Jan 2008 16:36:34 +0000 (16:36 +0000)
TRD/AliTRDqaBlackEvents.cxx [new file with mode: 0644]
TRD/AliTRDqaBlackEvents.h [new file with mode: 0644]
TRD/Macros/AliTRDanalyzeBlackEventsLHC.C [new file with mode: 0644]
TRD/TRDbaseLinkDef.h
TRD/libTRDbase.pkg

diff --git a/TRD/AliTRDqaBlackEvents.cxx b/TRD/AliTRDqaBlackEvents.cxx
new file mode 100644 (file)
index 0000000..a62cfad
--- /dev/null
@@ -0,0 +1,311 @@
+/**************************************************************************\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
diff --git a/TRD/AliTRDqaBlackEvents.h b/TRD/AliTRDqaBlackEvents.h
new file mode 100644 (file)
index 0000000..04d951b
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef ALITRDQABLACKEVENTS_H
+#define ALITRDQABLACKEVENTS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTRDqaBlackEvents.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 TH1D;
+class TH2D;
+class TH3D;
+class AliTRDrawStreamTB;
+
+class AliTRDqaBlackEvents : public TObject {
+
+ public:
+  
+  AliTRDqaBlackEvents();
+  AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa);
+  ~AliTRDqaBlackEvents() {}
+  AliTRDqaBlackEvents& operator = (const AliTRDqaBlackEvents& /*qa*/) { return *this; };
+
+  void Init();
+  void Reset();
+  Int_t AddEvent(AliTRDrawStreamTB *data);
+  void Process(const char* filename);
+  
+  //TH2D *GetChamberPedestal(Int_t sm, Int_t layer, Int_t stack) {return 0;}
+  TH2D *GetChamberPedestal(Int_t det) {return fChPed[det];}
+  
+  //TH2D *GetChamberNoise(Int_t sm, Int_t layer, Int_t stack) {return 0;}
+  TH2D *GetChamberNoise(Int_t det) {return fChNoise[det];}
+  
+  void SetNoiseLevel(Double_t min, Double_t max) {fMinNoise = min; fMaxNoise = max;}
+
+  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);
+
+ private:
+
+  TH1D *fPed[540];      // Some histograms
+  TH1D *fNoise[540];    // Some histograms
+  TH2D *fChPed[540];    // Some histograms
+  TH2D *fChNoise[540];  // Some histograms
+  TH3D *fData[540];     // Some histograms
+  TH1D *fSignal[540];   // Some histograms
+
+  Double_t fMinNoise;   // Minimum noise
+  Double_t fMaxNoise;   // Maximum noise
+
+  ClassDef(AliTRDqaBlackEvents,0) // QA for black events  
+
+};
+#endif
diff --git a/TRD/Macros/AliTRDanalyzeBlackEventsLHC.C b/TRD/Macros/AliTRDanalyzeBlackEventsLHC.C
new file mode 100644 (file)
index 0000000..82b3e6a
--- /dev/null
@@ -0,0 +1,38 @@
+
+void AliTRDanalyzeBlackEventsLHC(const char *filename) {
+
+
+  AliRawReaderRoot *reader = new AliRawReaderRoot(filename, 0);
+  reader->SelectEquipment(0, 1024, 1041);
+  reader->Select("TRD");
+  reader->SelectEvents(7);
+
+  //AliTRDRawStreamTB::SupressWarnings(kTRUE);
+  //AliTRDrawStreamTB::SetForceCleanDataOnly();
+  AliTRDrawStreamTB::AllowCorruptedData();
+
+  AliTRDrawStreamTB *raw = new AliTRDrawStreamTB(reader); 
+  //raw->Init();
+  //raw->SetRawVersion(3);
+
+  AliTRDqaBlackEvents *qa = new AliTRDqaBlackEvents();
+  qa->Init();
+
+  int counter = 0;
+  while (reader->NextEvent()) {
+    cout << "next event " << counter++ <<  endl;
+    cout << qa->AddEvent(raw) << endl;
+  }
+
+  cout << "Processing" << endl;
+  qa->Process("qaTRD_black.root");
+}
+
+// drawing 
+//
+// AliTRDqaBlackEvents qa;
+// qa.DrawSm("qaTRD_black.root", 0);
+//
+// qa.DrawChamber("qaTRD_black.root", 2);
+//
+
index 6ef9238..b428a03 100644 (file)
@@ -56,6 +56,7 @@
 #pragma link C++ class  AliTRDalignment+;
 
 #pragma link C++ class  AliTRDQAChecker+;
+#pragma link C++ class  AliTRDqaBlackEvents+;
 
 #pragma link C++ class  AliTRDCalibraFillHisto+;
 #pragma link C++ class  AliTRDCalibraFit+;
index a9110b4..0b44d38 100644 (file)
@@ -40,6 +40,7 @@ SRCS= AliTRDarrayI.cxx \
       AliTRDCalibraVdriftLinearFit.cxx \
       AliTRDCalibPadStatus.cxx \
       AliTRDQAChecker.cxx \
+      AliTRDqaBlackEvents.cxx \
       AliTRDPreprocessor.cxx \
       AliTRDDataDCS.cxx \
       AliTRDSensor.cxx \