]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
QA update by Sylwester
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Jul 2008 17:11:57 +0000 (17:11 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Jul 2008 17:11:57 +0000 (17:11 +0000)
TRD/AliTRDqaBlackEvents.cxx
TRD/AliTRDqaBlackEvents.h
TRD/AliTRDqaBuildReference.cxx [new file with mode: 0644]
TRD/AliTRDqaBuildReference.h [new file with mode: 0644]
TRD/AliTRDqaRecPoints.cxx [new file with mode: 0644]
TRD/AliTRDqaRecPoints.h [new file with mode: 0644]

index 0e779a7eb5d34e7c313494b9408e00b42ae02f80..6afb55e101d368b3c607226b858edee43990124c 100644 (file)
@@ -10,7 +10,7 @@
  * 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
+ * provided "as is without express or implied warranty.                  *\r
  **************************************************************************/\r
 \r
 /* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */\r
@@ -34,6 +34,7 @@
 #include "TPad.h"\r
 #include "TLatex.h"\r
 #include "TStyle.h"\r
+#include "TGraph.h"\r
 \r
 #include "AliTRDgeometry.h"\r
 #include "AliTRDrawStreamTB.h"\r
@@ -52,14 +53,36 @@ AliTRDqaBlackEvents::AliTRDqaBlackEvents()
   ,fOccupancy(0)\r
   ,fDetRob(0)\r
   ,fTBEvent(0)\r
-  ,fFitType(0)\r
+  ,fRefHistPed(0)\r
+  ,fRefHistNoise(0)\r
+  ,fErrorHC(0)\r
+  ,fErrorMCM(0)\r
+  ,fErrorADC(0)\r
+  ,fErrorSMHC(0)\r
+  ,fErrorSMMCM(0)\r
+  ,fErrorSMADC(0)\r
+  ,fErrorGraphHC(0)\r
+  ,fErrorGraphMCM(0)\r
+  ,fErrorGraphADC(0)\r
+  ,fGraphMCM(0)\r
+  ,fMcmTracks(0)\r
+  ,fMapMCM(0)\r
+  ,fFracMCM(0)\r
+  ,fSMHCped(0)\r
+  ,fSMHCerr(0)\r
+  ,fNoiseTotal(0)\r
+  ,fPP(0)\r
   ,fMinNoise(0.5)\r
-  ,fMaxNoise(2) \r
+  ,fMaxNoise(2)\r
+  ,fFitType(0) \r
+  //  ,fRefFileName("")\r
 {\r
   //\r
   // Constructor \r
   // to create the histograms call Init()\r
   //\r
+\r
+  strcpy(fRefFileName, "");\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////////////////////////////\r
@@ -73,14 +96,35 @@ AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
   ,fOccupancy(0)\r
   ,fDetRob(0)\r
   ,fTBEvent(0)\r
-  ,fFitType(0)\r
+  ,fRefHistNoise(0)\r
+  ,fErrorHC(0)\r
+  ,fErrorMCM(0)\r
+  ,fErrorADC(0)\r
+  ,fErrorSMHC(0)\r
+  ,fErrorSMMCM(0)\r
+  ,fErrorSMADC(0)\r
+  ,fErrorGraphHC(0)\r
+  ,fErrorGraphMCM(0)\r
+  ,fErrorGraphADC(0)\r
+  ,fGraphMCM(0)\r
+  ,fMcmTracks(0)\r
+  ,fMapMCM(0)\r
+  ,fFracMCM(0)\r
+  ,fSMHCped(0)\r
+  ,fSMHCerr(0)\r
+  ,fNoiseTotal(0)\r
+  ,fPP(0)\r
   ,fMinNoise(0.5)\r
   ,fMaxNoise(2) \r
+  ,fFitType(0)\r
+   //,fRefFileName("")\r
 {\r
   //\r
   // Copy constructor \r
   // to create the histograms call Init()\r
   //\r
+  \r
+  strcpy(fRefFileName, "");\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////////////////////////////\r
@@ -97,17 +141,35 @@ void AliTRDqaBlackEvents::Init()
   fnEvents = 0;\r
 \r
   // histograms for chambers\r
-  for(Int_t i=0; i<kDET; i++) {\r
-    fNPoint[i]  = new TH2D(Form("entries_%d", i), "",  16, -0.5, 15.5, 144, -0.5, 143.5);\r
-    fData[i]    = new TH3F(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, 144, -0.5, 143.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 (ADC counts)", 100, 5, 15);\r
+  for(Int_t det=0; det<kDET; det++) {\r
+\r
+    fNPoint[det]  = new TH2D(Form("entries_%d", det), "",  16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    fData[det]    = new TH3F(Form("data_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);\r
+\r
+    // pedestal noise maps using RMS and Fit\r
+    fChPed[det]   = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    \r
+    //fChPed[det]   = new TH2D(Form("ped_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    //fChNoise[det] = new TH2D(Form("noise_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);    \r
+\r
+    // distribution per detector\r
+    fPed[det]     = new TH1D(Form("pedDist_%d", det), ";pedestals (ADC counts)", 100, 5, 15);\r
+    fNoise[det]   = new TH1D(Form("noiseDist_%d", det), ";noise (ADC counts)", 100, 0, 5); \r
+    fSignal[det]  = new TH1D(Form("signal_%d", det), ";signal (ADC counts)", 100, -0.5, 99.5);\r
+    fChPP[det]    = new TH1D(Form("pp_%d", det), ";pp (ADC)", 200, -0.5, 199.5);\r
 \r
-    fNoise[i]   = new TH1D(Form("noiseDist_%d", i), ";noise (ADC counts)", 100, 0, 5); \r
-    fSignal[i]  = new TH1D(Form("signal_%d", i), ";signal (ADC counts)", 100, -0.5, 99.5);\r
+    fnEntriesRM[det] = new TH2D(Form("entriesRM_%d", det), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);\r
+    \r
+    // histograms after reference subtraction\r
+    fChPedRes[det]    = new TH2D(Form("pedRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    fChNoiseRes[det]  = new TH2D(Form("noiseRef_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
 \r
-    fnEntriesRM[i] = new TH2D(Form("entriesRM_%d", i), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);\r
+\r
+    // error codes\r
+    fErrorLocMCM[det] = new TH2D(Form("errorLocMCM_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
+    fErrorLocADC[det] = new TH2D(Form("errorLocADC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);    \r
+    fErrorLocHC[det]  = new TH2D(Form("errorLocHC_%d", det), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
   }\r
 \r
   // histogram for each MCM\r
@@ -119,7 +181,51 @@ void AliTRDqaBlackEvents::Init()
   fDetRob    = new TH2D("DetRob", ";detector;ROB", kDET, -0.5, 539.5, 8, -0.5, 7.5);\r
   fTBEvent   = new TH2D("tbEvent", ";event ID;time bin", 100, -0.5, 99.5, 30, -0.5, 29.5);\r
 \r
+  // errors statistics and location\r
+  fErrorHC  = new TH1D("errorHC", ";error ID;", 7, -0.5, 6.5);\r
+  fErrorMCM = new TH1D("errorMCM", ";error ID;", 7, -0.5, 6.5);\r
+  fErrorADC = new TH1D("errorADC", ";error ID;", 7, -0.5, 6.5);\r
+  \r
+  fErrorSMHC  = new TH1D("errorSM_HC", ";SM id", 18, -0.5, 17.5);\r
+  fErrorSMMCM = new TH1D("errorSM_MCM", ";SM id", 18, -0.5, 17.5);\r
+  fErrorSMADC = new TH1D("errorSM_ADC", ";SM id", 18, -0.5, 17.5);\r
+\r
+\r
+  fErrorGraphHC  = new TGraph();\r
+  fErrorGraphMCM = new TGraph();\r
+  fErrorGraphADC = new TGraph();\r
+\r
+  fGraphMCM = new TGraph();\r
+  \r
+  fMapMCM = new TH2D("mapMCM", ";det;mcm", 540, -0.5, 539.5, kROB*kMCM, -0.5, kROB*kMCM-0.5);\r
+  fFracMCM = new TH1D("fracMCM", ";frequency", 100, 0, 1);\r
+  \r
+\r
+  fErrorGraphHC->GetHistogram()->SetTitle("Error HC;event number;fraction with error (%)");\r
+  fErrorGraphMCM->GetHistogram()->SetTitle("Error MCM;event number;fraction with error (%)");\r
+  fErrorGraphADC->GetHistogram()->SetTitle("Error ADC;event number;fraction with error (%)"); \r
+\r
+\r
+  fSMHCped = new TH2D("smHcPed", ";super module;half chamber", 18, -0.5, 17.5, 60, -0.5, 59.5);\r
+  //fSMHCerr = 0;\r
+\r
   //Info("Init", "Done");\r
+\r
+  // number of ADC channels fired per SM and in total\r
+  for(Int_t sm=0; sm<kSM+1; sm++)\r
+    fNumberADC[sm] = new TGraph();\r
+\r
+  //\r
+  fNoiseTotal = new TH1D("noiseTotal", "noise (ADC)", 250, 0, 10);\r
+  fPP = new TH1D("peakPeak", "p-p (ADC)", 200, -0.5, 199.5);\r
+\r
+  for(Int_t sm=0; sm<kSM; sm++) {\r
+    fSmNoiseRms[sm] = new TH1D(Form("noiseRms_sm%d", sm), ";noise from RMS (ADC)", 100, 0, 10);\r
+    fSmNoiseFit[sm] = new TH1D(Form("noiseFit_sm%d", sm), ";noise frim Fit (ADC)", 100, 0, 10);\r
+    fSmPP[sm] = new TH1D(Form("peakPeak_sm%d", sm), ";peak-peak (ADC)", 200, -0.5, 199.5); \r
+  }\r
+\r
+  fMcmTracks = new TObjArray();\r
 }\r
 \r
 \r
@@ -138,6 +244,31 @@ void AliTRDqaBlackEvents::Reset()
   }\r
 }\r
 \r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::SetRefFile(const char *filename) {\r
+  \r
+  strcpy(fRefFileName, filename);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+void AliTRDqaBlackEvents::ReadRefHists(Int_t det) {\r
+  \r
+  fRefHistPed = 0;\r
+  fRefHistNoise = 0;\r
+  \r
+  TFile *file = 0;\r
+  if (fRefFileName) TFile::Open(fRefFileName);\r
+  if (!file) return;\r
+\r
+  fRefHistPed   = (TH2D*)file->Get(Form("ped_%d",det));\r
+  fRefHistNoise = (TH2D*)file->Get(Form("noise_%d", det));\r
+\r
+  if (file) file->Close();\r
+}\r
+\r
 ///////////////////////////////////////////////////////////////////////////////////////////////////\r
 \r
 Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) \r
@@ -153,14 +284,48 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
       for(Int_t k=0; k<kPAD; k++)\r
        isUsed[i][j][k] = 0;\r
   \r
+\r
+  // clear the mcm data\r
+  for(Int_t i=0; i < kDET * kROB * kMCM; i++) {\r
+    if (fFullSignal[i]) fFullSignal[i]->Reset();\r
+    fFullCounter[i] = 0;\r
+  }\r
+\r
   Int_t nb = 0;\r
-  Int_t rob_last = -1;\r
-  Int_t mcm_last = -1;\r
-  Int_t sm_01 = -1;\r
+  \r
+  Int_t lastdet  = -1;\r
+  Int_t lastside = -1;\r
+  Int_t lastmcm  = -1;\r
+\r
+  Int_t rob_last  = -1;\r
+  Int_t mcm_last  = -1;\r
+\r
+  Int_t nGoodHC  = 0;\r
+  Int_t nGoodMCM = 0;\r
+  Int_t nGoodADC = 0;\r
+\r
+  Int_t nErrorHC  = 0;\r
+  Int_t nErrorMCM = 0;\r
+  Int_t nErrorADC = 0;\r
+  \r
+\r
+  //Int_t adc_last  = -1;\r
+  // Int_t sm_01  = -1;\r
+  \r
+  // number of ADCs per SM\r
+  Int_t nADCinSM[kSM+1];\r
+  for(Int_t sm=0; sm<kSM+1; sm++) nADCinSM[sm] = 0;\r
+\r
+\r
 \r
   while (data->Next()) {\r
 \r
+    Int_t sm  = data->GetSM();\r
+    Int_t layer = data->GetLayer();\r
+    Int_t stack = data->GetStack();\r
+\r
     Int_t det = data->GetDet();\r
+    Int_t side = data->GetSide();\r
 \r
     Int_t row = data->GetRow();\r
     Int_t col = data->GetCol();\r
@@ -169,23 +334,65 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
     Int_t mcm = data->GetMCM();\r
     Int_t adc = data->GetADC();\r
 \r
\r
     Int_t *sig = data->GetSignals();\r
     nb++;\r
 \r
-    // ugly hook\r
-    if (det == 0 && row == 0 && col == 0) {\r
-      if (sm_01 > -1) printf("\t\t\t!!! !!! second data set !!! !!!\n");\r
-      sm_01++; \r
-    }\r
-\r
-    det += sm_01 * 30;   /// ugly\r
-\r
+    nADCinSM[sm]++;\r
+    nADCinSM[kSM]++;\r
+    \r
     // memory coruption protection\r
     if (det<0 || det>=kDET) continue;\r
     \r
+    // check errors\r
+   \r
+    // tests\r
+    //fErrorHC->Fill(data->GetHCErrorCode());\r
+    if (data->GetMCMErrorCode() > 0) fErrorLocMCM[det]->Fill(row, col);\r
+    if (data->GetADCErrorCode() > 0) fErrorLocADC[det]->Fill(row, col);    \r
+\r
+    // new HC found\r
+    if ((det + side*kDET) != (lastdet + lastside*kDET)) {\r
+      Int_t code = data->GetHCErrorCode();\r
+      // if (code) { \r
+      fErrorHC->Fill(code);\r
+      \r
+      if (code) fErrorSMHC->Fill(sm);\r
+      if (code) nErrorHC++;\r
+      nGoodHC++;\r
+\r
+      //Int_t mask = 1;\r
+      //for(Int_t cc = 0; cc < 3; cc++) {\r
+      //  if (code & mask) fErrorHC->Fill(cc);\r
+      //  cc *= 2;\r
+      //       }\r
+      //}\r
+    }\r
+    lastdet  = det;\r
+    lastside = side;\r
+    \r
+    // new MCM found  \r
+    if (mcm != lastmcm){\r
+      Int_t code = data->GetMCMErrorCode();\r
+      fErrorMCM->Fill(code);\r
+\r
+      if (code) fErrorSMMCM->Fill(sm);\r
+      if (code) nErrorMCM++;\r
+      nGoodMCM++;\r
+    }\r
+    lastmcm = mcm;\r
+    \r
+    // new ADC channel found\r
+    Int_t code = data->GetADCErrorCode();\r
+    fErrorADC->Fill(code);\r
+    if (code) fErrorSMADC->Fill(sm);\r
+    if (code) nErrorADC++;\r
+    nGoodADC++;\r
+\r
+    // end of error checking\r
+    \r
     // check the ROBs\r
     fDetRob->Fill(det, rob, 1./(kMCM*18));\r
-\r
     isUsed[det][row][col]++;\r
 \r
     // check if mcm signal is continuus\r
@@ -202,32 +409,51 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
     // create a structure for an MCM if needed\r
     Int_t mcmIndex = det * (kMCM * kROB) + rob * kMCM + mcm;\r
     if (fCreateFull && !fFullSignal[mcmIndex])\r
-      fFullSignal[mcmIndex] = new TH2S(Form("mcm_%d_%d_%d", det, rob, mcm), \r
-                                      Form("mcm-%d-%d-%d;ADC;time bin", det, rob,mcm),\r
+      fFullSignal[mcmIndex] = new TH2S(Form("mcm_%d_%d_%d_%d_%d", sm, stack, layer, rob, mcm), \r
+                                      Form("mcm-%d-%d-%d-%d-%d;ADC;time bin", sm, stack, layer, rob, mcm),\r
                                       21, -0.5, 20.5, 30, -0.5, 29.5);\r
     \r
 \r
     // loop over Time Bins and fill histograms\r
+    Int_t minV = 1024;\r
+    Int_t maxV = 0;\r
+\r
     for(Int_t k=0; k<kTB; k++) { /// to be corrected\r
 \r
+      //if (data->GetADCErrorCode() > 0) continue;\r
+\r
+      //if (col == 0 || col == 143)\r
+      //printf("TB: %d %d %d\n", row, col, sig[k]);\r
+\r
       //if (sig[k] < 1) \r
       //printf("det = %d rob = %d mcm = %d adc = %d k = %d S = %d\n", det, rob, mcm, adc, k, sig[k]);\r
       \r
       fSignal[det]->Fill(sig[k]);\r
       fData[det]->Fill(row, col, sig[k]);\r
       \r
+      minV = (minV < sig[k]) ? minV : sig[k];\r
+      maxV = (maxV > sig[k]) ? maxV : sig[k];\r
+\r
+\r
       // check if data strange enought\r
       if (fCreateFull && fFullSignal[mcmIndex]) {\r
+       //if (sm == 17 && )\r
+       //if (det != 29) {\r
        if (sig[k] > fThresh || sig[k] < 1) fFullCounter[mcmIndex]++;\r
+       //if (sig[k] < 1) fFullCounter[mcmIndex] = 0; // remove austrian flag \r
+       //}\r
        fFullSignal[mcmIndex]->Fill(adc, k, sig[k]);\r
       }\r
       \r
       // noisy chamber\r
-      if (det == 29) {\r
+      if (det == 29 && col > 7) {\r
        fTBEvent->Fill(fnEvents, k, sig[k]);\r
       }\r
-\r
     }\r
+    \r
+    fPP->Fill(maxV-minV);\r
+    fChPP[det]->Fill(maxV-minV);\r
+    fSmPP[sm]->Fill(maxV-minV);\r
   }\r
   \r
   // is the dead-alive status changing during the run\r
@@ -237,6 +463,41 @@ Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
        fOccupancy->Fill(isUsed[i][j][k]);\r
   }\r
 \r
+  // save interesting histos\r
+  Int_t mcmTrackCandidate = 0;\r
+  for(Int_t i = 0; i < kDET * kROB * kMCM; i++) { \r
+    if (fFullCounter[i] && fFullSignal[i] && CheckMCM(i) )  {\r
+      \r
+      fMcmTracks->AddLast(fFullSignal[i]->Clone(Form("event_%d_%s", fnEvents, fFullSignal[i]->GetName())));\r
+      mcmTrackCandidate++;\r
+      \r
+      Int_t mcmTrackletDet = i/(kROB * kMCM);  \r
+      Int_t mcmTrackletMcm = i%(kROB * kMCM);\r
+      fMapMCM->Fill(mcmTrackletDet, mcmTrackletMcm);\r
+    }\r
+  }\r
+  \r
+  fGraphMCM->SetPoint(fnEvents, fnEvents, mcmTrackCandidate);\r
+  printf("Number of MCM track candidates = %d\n", mcmTrackCandidate);\r
+  \r
+\r
+  // update fraction of error graphs\r
+  Double_t err;\r
+\r
+  err = (nGoodHC > 0)? 100.*nErrorHC/nGoodHC : -1;\r
+  fErrorGraphHC->SetPoint(fnEvents, fnEvents, err);\r
+  \r
+  err = (nGoodMCM > 0)? 100.*nErrorMCM/nGoodMCM : -1;\r
+  fErrorGraphMCM->SetPoint(fnEvents, fnEvents, err);\r
+  \r
+  err = (nGoodADC > 0)? 100.*nErrorADC/nGoodADC : -1;\r
+  fErrorGraphADC->SetPoint(fnEvents, fnEvents, err);\r
+\r
+  // number of fired ADC per SM\r
+  for(Int_t sm=0; sm<kSM+1; sm++) \r
+    fNumberADC[sm]->SetPoint(fnEvents, fnEvents, nADCinSM[sm]);\r
+\r
+\r
   fnEvents++;\r
   return nb;\r
 }\r
@@ -248,6 +509,11 @@ void AliTRDqaBlackEvents::Process(const char *filename)
   //\r
   // Process something\r
   //\r
+  \r
+  char fn[256];\r
+  strcpy(fn, filename);\r
+  \r
+  //printf("FILENAME = %s (%s)\n", filename, fn);\r
 \r
   Int_t map[kDET];\r
   \r
@@ -255,28 +521,29 @@ void AliTRDqaBlackEvents::Process(const char *filename)
   TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);\r
   fit->SetParameters(1e3, 10, 1);\r
     \r
-  for(Int_t i=0; i<kDET; i++) {\r
-    \r
-    map[i] = 0;\r
-    if (fData[i]->GetSum() < 10) continue;\r
-    map[i] = 1;\r
+  for(Int_t det=0; det<kDET; det++) {\r
+\r
+    //printf("processing chamber %d\n", det);   \r
 \r
-    Info("process", "processing chamber %d", i);\r
+    map[det] = 0;\r
+    if (fData[det]->GetSum() < 10) continue;\r
+    map[det] = 1;\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
+    // read reference distributions\r
+    ReadRefHists(det);\r
+\r
+    for(Int_t row=0; row<fData[det]->GetXaxis()->GetNbins(); row++) {\r
+      for(Int_t pad=0; pad<fData[det]->GetYaxis()->GetNbins(); pad++) {\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
+         Int_t dataBin = fData[det]->FindBin(row, pad, bb);\r
+         Double_t v = fData[det]->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
+       Int_t bin = fChPed[det]->FindBin(row, pad);\r
 \r
        if (hist->GetSum() > 1) {\r
          \r
@@ -288,20 +555,44 @@ void AliTRDqaBlackEvents::Process(const char *filename)
            TF1 *f = hist->GetFunction("fit");\r
            ped = TMath::Abs(f->GetParameter(1));\r
            noise = TMath::Abs(f->GetParameter(2));\r
+           fSmNoiseFit[det/30]->Fill(noise);\r
          } else {\r
            ped = hist->GetMean();\r
            noise = hist->GetRMS();\r
+           fSmNoiseRms[det/30]->Fill(noise);\r
+           //if (pad == 0)\r
+           //  printf("data %f %f %f\n", hist->GetSum(), ped, noise);\r
          }\r
 \r
-         fChPed[i]->SetBinContent(bin, ped);\r
-         fChNoise[i]->SetBinContent(bin, noise);\r
+         fChPed[det]->SetBinContent(bin, ped);\r
+         fChNoise[det]->SetBinContent(bin, noise);\r
+         fNoiseTotal->Fill(noise);\r
+\r
+         // subtract reference values\r
+         Double_t refped = 0;\r
+         Double_t refnoise = 0;\r
          \r
-         fPed[i]->Fill(ped);\r
-         fNoise[i]->Fill(noise);\r
+         if (fRefHistPed)   refped   = fRefHistPed->GetBinContent(bin);\r
+         if (fRefHistNoise) refnoise = fRefHistPed->GetBinContent(bin);\r
+\r
+         fChPedRes[det]->SetBinContent(bin, ped-refped);\r
+         fChNoiseRes[det]->SetBinContent(bin, noise-refnoise);\r
+         \r
+         fPed[det]->Fill(ped);\r
+         fNoise[det]->Fill(noise);\r
+\r
+         // fill SM-HC plot\r
+         Int_t sm = det / 30;\r
+         Int_t hc = (pad < kPAD/2) ? 2* (det % 30) : 2* (det % 30) + 1;\r
+         if (ped > 9. && ped < 11) fSMHCped->Fill(sm, hc, 1./1152.); // number of pads in HC\r
 \r
        } else {\r
-         fChPed[i]->SetBinContent(bin, 0);\r
-         fChNoise[i]->SetBinContent(bin, 0);\r
+         \r
+         // not enought data found \r
+         fChPed[det]->SetBinContent(bin, 0);\r
+         fChNoise[det]->SetBinContent(bin, 0);\r
+         fChPedRes[det]->SetBinContent(bin, 0);\r
+         fChNoiseRes[det]->SetBinContent(bin, 0);\r
        }\r
        \r
        //delete hist;\r
@@ -309,7 +600,8 @@ void AliTRDqaBlackEvents::Process(const char *filename)
     }\r
   }\r
 \r
-  Info("Process", "Number of events = %d", fnEvents);\r
+\r
+  //printf("Number of events = %d\n", fnEvents);\r
 \r
   // normalize number of entries histos\r
   Int_t max = 0;\r
@@ -325,7 +617,7 @@ void AliTRDqaBlackEvents::Process(const char *filename)
   }\r
   \r
   char entriesDistName[100];\r
-  \r
+\r
   for(Int_t i=0; i<kDET; i++) {\r
     \r
     if (!map[i]) continue;\r
@@ -352,19 +644,41 @@ void AliTRDqaBlackEvents::Process(const char *filename)
 \r
   // save histograms\r
 \r
-  TFile *file = new TFile(filename, "recreate");\r
-  for(Int_t i=0; i<kDET; i++) {\r
-    if (!map[i]) continue; \r
-    fChPed[i]->Write();\r
-    fChNoise[i]->Write();\r
-    fNPoint[i]->Write();\r
-    fNPointDist[i]->Write();\r
-    fPed[i]->Write();\r
-    fNoise[i]->Write();\r
-    fSignal[i]->Write();\r
-    fnEntriesRM[i]->Write();\r
+  //printf("FILENAME 2 = %s (%d)\n", fn, fn);\r
+  TFile *file = new TFile(fn, "recreate");\r
+  for(Int_t det = 0; det < kDET; det++) {\r
+    if (!map[det]) continue; \r
+    fChPed[det]->Write();\r
+    fChNoise[det]->Write();\r
+    fNPoint[det]->Write();\r
+    fNPointDist[det]->Write();\r
+    fPed[det]->Write();\r
+    fNoise[det]->Write();\r
+    fSignal[det]->Write();\r
+    fnEntriesRM[det]->Write();\r
+    fChPP[det]->Write();\r
+\r
+    fChPedRes[det]->Write();\r
+    fChNoiseRes[det]->Write();\r
+\r
+    // save error hists\r
+    fErrorLocMCM[det]->SetMinimum(0);\r
+    fErrorLocMCM[det]->SetMaximum(fnEvents);\r
+    fErrorLocMCM[det]->Write();\r
+\r
+    fErrorLocADC[det]->SetMinimum(0);\r
+    fErrorLocADC[det]->SetMaximum(fnEvents);\r
+    fErrorLocADC[det]->Write();\r
+  }\r
+\r
+  for(Int_t sm=0; sm<kSM; sm++) {\r
+    fSmNoiseRms[sm]->Write();\r
+    fSmNoiseFit[sm]->Write();\r
+    fSmPP[sm]->Write();\r
   }\r
 \r
+\r
+\r
   Int_t nMcm = 0;\r
   for(Int_t i=0; i < kDET * kROB * kMCM; i++) {\r
     if (fFullSignal[i] && fFullCounter[i] > fCount) {\r
@@ -374,16 +688,112 @@ void AliTRDqaBlackEvents::Process(const char *filename)
   }\r
 \r
   printf("Number of saved MCMs = %d\n", nMcm);\r
+  \r
+  fMcmTracks->Write();\r
+  printf("Number of tracks = %d\n", fMcmTracks->GetEntries());\r
+  \r
+  // permanently problematic MCMs\r
+  for(Int_t det=0; det<kDET; det++) {\r
+    for(Int_t mcm=0; mcm<kROB*kMCM; mcm++) {\r
+      \r
+      Int_t mRob = mcm / kMCM;\r
+      Int_t mMcm = mcm % kMCM;\r
+      Int_t bin = fMapMCM->FindBin(det, mcm);\r
+      Double_t frac = 1. * fMapMCM->GetBinContent(bin) / fnEvents;     \r
+      fFracMCM->Fill(frac);\r
+      \r
+      if (frac > 0.7) {\r
+       printf("{%d, %d, %d}, \n", det, mRob, mMcm, frac);\r
+      }      \r
+    }\r
+  }\r
+\r
+\r
 \r
   fOccupancy->Write();\r
   fDetRob->Write();\r
   fTBEvent->Write();\r
+  \r
+  // error hists\r
+  fErrorHC->Write();\r
+  fErrorMCM->Write();\r
+  fErrorADC->Write();\r
+\r
+  fErrorSMHC->Write();\r
+  fErrorSMMCM->Write();\r
+  fErrorSMADC->Write();  \r
+  \r
+  // write graphs\r
+  fErrorGraphHC->Write("trendErrorHC");\r
+  fErrorGraphMCM->Write("trendErrorMCM");\r
+  fErrorGraphADC->Write("trendErrorADC");\r
+  \r
+  fGraphMCM->Write("trendMCM");\r
+\r
+  fMapMCM->SetMaximum(fnEvents);\r
+  fMapMCM->Write();\r
+  fFracMCM->Write();\r
+  \r
+  fSMHCped->Write();\r
+\r
+  for(Int_t sm=0; sm<kSM; sm++)\r
+    fNumberADC[sm]->Write(Form("nADCinSM%d",sm));\r
+  \r
+  fNumberADC[kSM]->Write("nADCinEvent");\r
+\r
+  fNoiseTotal->Write();\r
+  fPP->Write();\r
+\r
   file->Close();\r
   delete file;\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////////////////////////////\r
 \r
+Int_t AliTRDqaBlackEvents::CheckMCM(Int_t index) {\r
+  \r
+  return 1;\r
+  \r
+  static Int_t data[21][3] = {\r
+    {1, 0, 1}, \r
+    {242, 0, 0}, \r
+    {242, 0, 1}, \r
+    {242, 0, 2}, \r
+    {242, 0, 4}, \r
+    {242, 0, 5}, \r
+    {242, 0, 6}, \r
+    {242, 0, 8}, \r
+    {242, 0, 12}, \r
+    {251, 7, 7}, \r
+    {254, 3, 11}, \r
+    {259, 3, 14}, \r
+    {260, 1, 9}, \r
+    {260, 3, 15}, \r
+    {273, 1, 7}, \r
+    {273, 1, 15}, \r
+    {276, 5, 11}, \r
+    {280, 6, 2}, \r
+    {299, 6, 4}, \r
+    {511, 2, 9}, \r
+    {517, 7, 15}\r
+  };\r
+  \r
+  for(Int_t i=0; i<21; i++) {\r
+    Int_t wIndex = data[i][0] * kROB*kMCM + data[i][1] * kMCM + data[i][2];\r
+    if (index == wIndex) return 0;\r
+  }\r
+\r
+  return 1;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h) \r
 {\r
   //\r
index f90d3f82fe82333e47333869ddf9411909acf0f8..f663ac0b160a0e719291ac3d180961a5f8e67b51 100644 (file)
@@ -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 (file)
index 0000000..de3b8fa
--- /dev/null
@@ -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; i<r->GetNbinsX(); 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; i<r->GetNbinsX(); 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 (file)
index 0000000..f9afdff
--- /dev/null
@@ -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 (file)
index 0000000..90780f4
--- /dev/null
@@ -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 <TClonesArray.h>
+#include <TFile.h> 
+#include <TH1D.h> 
+#include <TH2D.h>
+#include <TH3D.h>
+#include <TProfile.h>
+#include <TF1.h>
+#include <TCanvas.h>
+
+// --- 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; b<hist->GetXaxis()->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; b<hist->GetXaxis()->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; b<hist->GetXaxis()->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; i<kNhist; i++) {
+    //hist[i]->Sumw2();
+    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 (file)
index 0000000..9d11e72
--- /dev/null
@@ -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