]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDQADataMaker.cxx
Included also 3 and 4 prong decays; added variables to ntuple
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
index d2f57889351047bdd4e81a878fb116811d322b1d..d11c6d7922e7eb516dbe6aeecfe5e8b154a3ff3c 100644 (file)
@@ -34,6 +34,7 @@
 #include <TProfile.h>
 #include <TF1.h>
 #include <TCanvas.h>
+#include <TStopwatch.h>
 
 // --- AliRoot header files ---
 #include "AliESDEvent.h"
 #include "AliTRDQADataMaker.h"
 #include "AliTRDdigitsManager.h"
 #include "AliTRDgeometry.h"
-#include "AliTRDdataArrayI.h"
-#include "AliTRDRawStreamTB.h"
-
+#include "AliTRDarrayADC.h"
+#include "AliTRDrawStream.h"
 #include "AliQAChecker.h"
 
 ClassImp(AliTRDQADataMaker)
 
 //____________________________________________________________________________ 
   AliTRDQADataMaker::AliTRDQADataMaker() : 
-  AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
+  AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
 {
   //
   // Default constructor
@@ -86,45 +86,67 @@ AliTRDQADataMaker& AliTRDQADataMaker::operator=(const AliTRDQADataMaker& qadm)
 }
 
 //____________________________________________________________________________ 
-void AliTRDQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
+void AliTRDQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
 {
   //
   // Detector specific actions at end of cycle
   //
+  //TStopwatch watch;
+  //watch.Start();
 
-  //AliInfo(Form("EndOfCycle", "Fitting RecPoints %d", task));
-
-  if (task == AliQA::kRECPOINTS) {
+  //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task))
+  TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
+  if (task == AliQAv1::kRECPOINTS) {
 
     //list->Print();
-
+    
     // Rec points full chambers
     for (Int_t i=0; i<540; i++) {
+       
+      //TH1D *h = ((TH2D*)list->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*)list->At(1))->FindBin(i,xvalue);
+       Double_t value =  ((TH2D*)list->At(1))->GetBinContent(bin);
+       hist->SetBinContent(b, value);
+      }
       
-      TH1D *h = ((TH2D*)list->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
-      if (h->GetSum() < 100) continue; // chamber not present
+      //printf("Sum = %d %f\n", i, hist->GetSum());
+      if (hist->GetSum() < 100) continue; // chamber not present
       
-      h->Fit("landau", "q0", "goff", 10, 180);
-      TF1 *fit = h->GetFunction("landau");
+      hist->Fit("landau", "q0", "goff", 10, 180);
+      TF1 *fit = hist->GetFunction("landau");
       ((TH1D*)list->At(12))->Fill(fit->GetParameter(1));
       ((TH1D*)list->At(13))->Fill(fit->GetParameter(2));
-      delete h;      
     }
-    
+    // time-bin by time-bin
     for (Int_t i=0; i<540; i++) {
+       
+      //TH1D *test = ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);     
+      //if (test->GetSum() < 100) continue;
       
-      TH1D *test = ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);     
-      if (test->GetSum() < 100) continue;
-      
-      //AliInfo(Form("fitting det = %d", i));
+      //AliDebug(AliQAv1::GetQADebugLevel(), Form("fitting det = %d", i));
       
       for(Int_t j=0; j<35; j++) {
        
-       TH1D *h =  ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);     
-       if (h->GetSum() < 50) continue;
+       //TH1D *h =  ((TH3D*)list->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*)list->At(10))->FindBin(i,j,xvalue);
+         Double_t value =  ((TH3D*)list->At(10))->GetBinContent(bin);
+         //printf("v = %f\n", value);
+         hist->SetBinContent(b, value);
+       }
        
-       h->Fit("landau", "q0", "goff", 10, 180);
-       TF1 *fit = h->GetFunction("landau");
+       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/18;
        Int_t det = i%18;
@@ -136,10 +158,13 @@ void AliTRDQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
     }
   }
   
+  delete hist;
+  
   // call the checker
-  AliQAChecker::Instance()->Run(AliQA::kTRD, task, list) ;    
-
+  AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;    
 
+  //watch.Stop();
+  //watch.Print();
 }
 
 //____________________________________________________________________________ 
@@ -220,7 +245,6 @@ void AliTRDQADataMaker::InitDigits()
     hist[i]->Sumw2();
     Add2DigitsList(hist[i], i);
   }
-
 }
 
 //____________________________________________________________________________ 
@@ -247,7 +271,7 @@ void AliTRDQADataMaker::InitRecPoints()
   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, 100, 0, 200);
+                     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, "");
 
@@ -350,7 +374,6 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
 
     // .. in the acceptance
     Int_t sector = GetSector(paramOut->GetAlpha());
-    GetESDsData(1)->Fill(sector);
 
     UInt_t u = 1;
     UInt_t status = track->GetStatus();
@@ -372,8 +395,8 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
 
     for(Int_t b=0; b<knbits; b++) {
       if (bit[b]) {
-       GetESDsData(b*knbits+3)->Fill(pt); 
-       GetESDsData(b*knbits+4)->Fill(extZ);
+       GetESDsData(2*b+3)->Fill(pt); 
+       GetESDsData(2*b+4)->Fill(extZ);
       }
     }
 
@@ -389,6 +412,7 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
     //fSignal->Fill(track->GetTRDsignal());
        
     GetESDsData(18)->Fill(track->GetP(), track->GetTRDsignal());
+    GetESDsData(1)->Fill(sector);
 
     /*
     // PID only
@@ -546,12 +570,12 @@ void AliTRDQADataMaker::MakeDigits(TTree * digits)
 
   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
 
-    AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
+    AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
 
     // This is to take care of switched off super modules
     if (digitsIn->GetNtime() == 0) continue;
 
-    digitsIn->Expand();
+    digitsIn->Expand(); 
 
     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
@@ -562,13 +586,13 @@ void AliTRDQADataMaker::MakeDigits(TTree * digits)
 
     for(Int_t row = 0; row < nRows; row++) 
       for(Int_t col = 0; col < nCols; col++) 
-       for(Int_t time = 0; time < nTbins; time++) {
-
-         Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
-         GetDigitsData(0)->Fill(i);
-         GetDigitsData(1)->Fill(time);
-         GetDigitsData(2)->Fill(signal);
-       }
+       for(Int_t time = 0; time < nTbins; time++) 
+         {
+           Float_t signal = digitsIn->GetData(row,col,time);
+           GetDigitsData(0)->Fill(i);
+           GetDigitsData(1)->Fill(time);
+           GetDigitsData(2)->Fill(signal);
+         }
 
     //delete digitsIn;
   }
@@ -605,14 +629,14 @@ void AliTRDQADataMaker::MakeSDigits(TTree * digits)
   digitsManager->CreateArrays();
   digitsManager->ReadDigits(digits);
 
-  for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
-
-    AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
+  for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
+    {
+    AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
 
     // This is to take care of switched off super modules
     if (digitsIn->GetNtime() == 0) continue;
 
-    digitsIn->Expand();
+    digitsIn->Expand();  
 
     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
@@ -623,15 +647,15 @@ void AliTRDQADataMaker::MakeSDigits(TTree * digits)
 
     for(Int_t row = 0; row < nRows; row++) 
       for(Int_t col = 0; col < nCols; col++) 
-       for(Int_t time = 0; time < nTbins; time++) {
-
-         Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
-         if (signal <= 0) continue;
-         GetSDigitsData(0)->Fill(i);
-         GetSDigitsData(1)->Fill(time);
-         GetSDigitsData(2)->Fill(signal);
-       }
-
+       for(Int_t time = 0; time < nTbins; time++) 
+         {
+           Float_t signal = digitsIn->GetData(row,col,time);
+           if (signal <= 0) continue;
+           GetSDigitsData(0)->Fill(i);
+           GetSDigitsData(1)->Fill(time);
+           GetSDigitsData(2)->Fill(signal);
+         }
+    
     // delete digitsIn;
   }
 
@@ -657,8 +681,7 @@ void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
   const Int_t kMCM = 16;
   //  const Int_t kADC = 22;
 
-  AliTRDRawStreamTB *raw = new AliTRDRawStreamTB(rawReader);
-
+  AliTRDrawStream *raw = new AliTRDrawStream(rawReader);
   raw->SetRawVersion(3);
   raw->Init();
 
@@ -685,6 +708,9 @@ void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
     GetRawsData(3)->Fill(sm);
     GetRawsData(4+sm)->Fill(index);
   }
+
+  delete raw;
+
 }
 
 //____________________________________________________________________________