]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0QADataMaker.cxx
Changes to compile with Root6 on macosx64
[u/mrichter/AliRoot.git] / T0 / AliT0QADataMaker.cxx
index 356de0ee56761f94d2b2011deb43d4d1a538a778..e1d635e75c57cdb8c4048e34c7c32cc20ac28653 100644 (file)
 
 //---
 //  Produces the data needed to calculate the quality assurance. 
-//  All data must be mergeable objects.
-//  A. Mastroserio
+//  T0 QA for Hits, Digits, RAW and RecPoints
+//  Alla.Maevskaya@cern.ch
+//  
 //---
 
 // --- ROOT system ---
 #include <TClonesArray.h>
 #include <TFile.h> 
 #include <TH1F.h> 
-#include <TH2F.h>
-#include <TH1I.h> 
 #include <TDirectory.h>
-#include <Riostream.h>
 // --- Standard library ---
 
 // --- AliRoot header files ---
-#include "AliESDCaloCluster.h"
 #include "AliESDEvent.h"
 #include "AliLog.h"
-#include "AliT0digit.h"
+#include "AliT0digit.h" 
 #include "AliT0hit.h"
 #include "AliT0RecPoint.h"
 #include "AliT0QADataMaker.h"
 #include "AliQAChecker.h"
+#include "AliT0RawReader.h"
 
 ClassImp(AliT0QADataMaker)
            
 //____________________________________________________________________________ 
   AliT0QADataMaker::AliT0QADataMaker() : 
-  AliQADataMaker(AliQA::GetDetName(AliQA::kT0), "T0 Quality Assurance Data Maker")
-  //  fhHitsTime(0x0),
-  // fhHitsAmp(0x0),
-  // fhHitsEff(0x0),
-  //  fhDigCFD(0x0),
-  //  fhDigLEDamp(0x0),
-  //  fhDigQTC(0x0),
-  // fhDigMean(0x0),
-  //  fhDigEff(0x0),
-  //  fhRecCFD(0x0),
-  //  fhRecLEDamp(0x0),
-  //  fhRecQTC(0x0),
-  //  fhRecMean(0x0),
-  //  fhRecEff(0x0),
-  //  fhESDMean(0x0),
-  //  fhESDVertex(0x0)
+  AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kT0), "T0 Quality Assurance Data Maker")
 
 {
   // ctor
@@ -83,20 +66,6 @@ ClassImp(AliT0QADataMaker)
 //____________________________________________________________________________ 
 AliT0QADataMaker::AliT0QADataMaker(const AliT0QADataMaker& qadm) :
   AliQADataMaker() 
- //  fhHitsTime(0x0),
- // fhHitsEff(0x0),
-  //  fhDigCFD(0x0),
-  //  fhDigLEDamp(0x0),
-  //  fhDigQTC(0x0),
-  // fhDigMean(0x0),
-  // fhDigEff(0x0),
-  //  fhRecCFD(0x0),
-  //  fhRecLEDamp(0x0),
-  //  fhRecQTC(0x0),
-  // fhRecMean(0x0),
-  // fhRecEff(0x0),
-  // //  fhESDMean(0x0),
-  // fhESDVertex(0x0)
 {
   //copy ctor 
   /*
@@ -122,11 +91,11 @@ AliT0QADataMaker& AliT0QADataMaker::operator = (const AliT0QADataMaker& qadm )
   return *this;
 }
 //____________________________________________________________________________
-void AliT0QADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
+void AliT0QADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
 {
   //Detector specific actions at end of cycle
   // do the QA checking
-  AliQAChecker::Instance()->Run(AliQA::kT0, task, list) ;
+  AliQAChecker::Instance()->Run(AliQAv1::kT0, task, list) ;
 }
 
 //____________________________________________________________________________
@@ -141,15 +110,15 @@ void AliT0QADataMaker::InitHits()
 {
   // create Hits histograms in Hits subdir
   TString timename;
-  timename ="hHitTime";
   TH1F *    fhHitsTime[24];
   for (Int_t i=0; i<24; i++)
     {
+      timename ="hHitTime";
       timename += i;
-      if(i<12)  fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2,3);
+      if(i<12)  fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2000,3000);
       else  
-       fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12,13);
-      Add2HitsList( fhHitsTime[i],i);
+       fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12000,13000);
+       Add2HitsList( fhHitsTime[i],i);
     }
   /*
   TH2F *fhHitsEffA = new TH2F("hHitsEffA", "Hits Efficiency A side", 25,-0.5,24.5, 100,12,13 );
@@ -157,6 +126,8 @@ void AliT0QADataMaker::InitHits()
   TH2F *fhHitsEffC = new TH2F("hHitsEffC", "Hits Efficiency C side", 25,-0.5,24.5, 100,2,3 );
   Add2HitsList(fhHitsEffC,1);
   */
+  //
+  ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -176,22 +147,22 @@ void AliT0QADataMaker::InitDigits()
   */
   
   TString timename, ampname, qtcname;
-  timename ="hDigCFD";
-  ampname = "hDigLED";
-  qtcname = "hDigQTC";
 
   TH1F *fhDigCFD[24]; TH1F * fhDigLEDamp[24]; TH1F *fhDigQTC[24];
 
   for (Int_t i=0; i<24; i++)
     {
+      timename ="hDigCFD";
+      ampname = "hDigLED";
+      qtcname = "hDigQTC";
       timename += i;
       ampname += i;
       qtcname += i;
-      fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
+      fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
       Add2DigitsList( fhDigCFD[i],i);
-      fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
+      fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
       Add2DigitsList( fhDigLEDamp[i],i+24);
-      fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
+      fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
       Add2DigitsList( fhDigQTC[i],i+48);
      }
   
@@ -199,7 +170,39 @@ void AliT0QADataMaker::InitDigits()
   Add2DigitsList( fhDigEff,72);
   TH1F* fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
   Add2DigitsList( fhDigMean,73);
+  //
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line  
+}
+
+//____________________________________________________________________________ 
+void AliT0QADataMaker::InitRaws()
+{
+  // create Raw histograms in Raw subdir
+  printf("   AliT0QADataMaker::InitRaws() started\n");
+  TString timename, ampname, qtcname;
+
+  TH1F *fhRawCFD[24]; TH1F * fhRawLEDamp[24]; TH1F *fhRawQTC[24];
+
+  for (Int_t i=0; i<24; i++)
+    {
+      timename ="hRawCFD";
+      ampname = "hRawLED";
+      qtcname = "hRawQTC";
+      timename += i;
+      ampname += i;
+      qtcname += i;
+      fhRawCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
+      Add2RawsList( fhRawCFD[i],i);
+      fhRawLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
+      Add2RawsList( fhRawLEDamp[i],i+24);
+      fhRawQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
+      Add2RawsList( fhRawQTC[i],i+48);
+     }
   
+  TH1F* fhRawMean = new TH1F("hRawMean","online mean signal", 100,500,600);
+  Add2RawsList( fhRawMean,72);
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line  
 }
 
 //____________________________________________________________________________ 
@@ -208,70 +211,97 @@ void AliT0QADataMaker::InitRecPoints()
 {
   // create cluster histograms in RecPoint subdir
   /* 
- TH2F * fhRecCFD = new TH2F("fhRecCFD", " CFD reconstructed",25,-0.5,24.5,100,12,13);
-  Add2DigitsList( fhRecCFD,0);
-  TH2F *fhRecLEDamp = new TH2F("fhRecLEDamp", " amplitude LED reconstructed",25,-0.5,24.5,100,1000,1000);
-  Add2DigitsList( fhRecLEDamp,1);
- TH2F * fhRecQTC = new TH2F("fhRecQTC", " amplitude QTC reconstructed",25,-0.5,24.5,100,1000,1000);
-  Add2DigitsList( fhRecQTC,2);
- TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
-  Add2DigitsList( fhRecMean,3);
    TH2F * fhRecCFD = new TH2F("fhRecCFD", " CFD reconstructed",25,-0.5,24.5,100,12,13);
+     Add2DigitsList( fhRecCFD,0);
+     TH2F *fhRecLEDamp = new TH2F("fhRecLEDamp", " amplitude LED reconstructed",25,-0.5,24.5,100,1000,1000);
+     Add2DigitsList( fhRecLEDamp,1);
    TH2F * fhRecQTC = new TH2F("fhRecQTC", " amplitude QTC reconstructed",25,-0.5,24.5,100,1000,1000);
+     Add2DigitsList( fhRecQTC,2);
    TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
+     Add2DigitsList( fhRecMean,3);
   */ 
   
   TString timename,ampname, qtcname;
-  timename ="hRecCFD";
-  ampname = "hRecLED";
-  qtcname = "hRecQTC";
   TH1F *fhRecCFD[24]; TH1F *fhRecLEDAmp[24];  TH1F * fhRecQTC[24];
   for (Int_t i=0; i<24; i++)
     {
+      timename ="hRecCFD";
+      ampname = "hRecLED";
+      qtcname = "hRecQTC";
       timename += i;
       ampname += i;
       qtcname += i;
-      fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
+      fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,0,1000);
      Add2RecPointsList ( fhRecCFD[i],i);
-      fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
+      fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,0,200);
     Add2RecPointsList ( fhRecLEDAmp[i],i+24);
-      fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
+      fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,0,200);
     Add2RecPointsList ( fhRecQTC[i],i+48);
      }
-   
+  
   TH1F *fhRecEff = new TH1F("hRecEff","Efficiency rec.points",25,-0.5,24.5);
- Add2RecPointsList ( fhRecEff,72);
 Add2RecPointsList ( fhRecEff,72);
   TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
- Add2RecPointsList( fhRecMean,73);
-  
+  Add2RecPointsList( fhRecMean,73);
+  //
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line  
 }
 //____________________________________________________________________________
 void AliT0QADataMaker::InitESDs()
 {
   //create ESDs histograms in ESDs subdir
-  TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,500,600);
+  TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,0,100);
   Add2ESDsList(fhESDMean, 0) ;
- TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
 TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
   Add2ESDsList(fhESDVertex, 1) ;
-
-
+  //
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line  
 }
 //____________________________________________________________________________
-void AliT0QADataMaker::MakeHits(TObject * data)
+
+void AliT0QADataMaker::MakeHits(TTree *hitTree)
 {
   //fills QA histos for Hits
-  TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
-  if (!hits){
-    AliError("Wrong type of hits container") ; 
+  TClonesArray * hits = new TClonesArray("AliT0hit", 1000);
+  
+  TBranch * branch = hitTree->GetBranch("T0") ;
+  if ( ! branch ) {
+    AliWarning("T0 branch in Hit Tree not found") ;
   } else {
-    TIter next(hits); 
-    AliT0hit * hit ; 
-    while ( (hit = dynamic_cast<AliT0hit *>(next())) ) {
-      Int_t pmt=hit->Pmt();
-      GetHitsData(pmt)->Fill(pmt,hit->Time()) ;
+
+   if (branch) {
+      branch->SetAddress(&hits);
+    }else{
+      AliError("Branch T0 hit not found");
+      exit(111);
+    } 
+    Int_t ntracks    = (Int_t) hitTree->GetEntries();
+    
+    if (ntracks<=0) return;
+    // Start loop on tracks in the hits containers
+    for (Int_t track=0; track<ntracks;track++) {
+      branch->GetEntry(track);
+      Int_t nhits = hits->GetEntriesFast();
+      for (Int_t ihit=0;ihit<nhits;ihit++) 
+       {
+         AliT0hit  * startHit   = (AliT0hit*) hits->UncheckedAt(ihit);
+         if (!startHit) {
+           AliError("The unchecked hit doesn't exist");
+           break;
+         }
+         Int_t pmt=startHit->Pmt();
+         FillHitsData(pmt-1,startHit->Time()) ;
+       }
     }
-  } 
+  }
+  //
+  IncEvCountCycleHits();
+  IncEvCountTotalHits();
+  //
 }
 
 //____________________________________________________________________________
-void AliT0QADataMaker::MakeDigits( TObject * data)
+void AliT0QADataMaker::MakeDigits( TTree *digitsTree)
 {
   //fills QA histos for Digits
  
@@ -281,39 +311,97 @@ void AliT0QADataMaker::MakeDigits( TObject * data)
   TArrayI *digQT1 = new TArrayI(24);
   Int_t refpoint=0;
 
-  TClonesArray * digits = dynamic_cast<TClonesArray *>(data) ; 
-  
-  if ( !digits) {
-    AliError("Wrong type of digits container") ; 
-  } else {
-    TIter next(digits) ; 
-    AliT0digit * digit ; 
-    while ( (digit = dynamic_cast<AliT0digit *>(next())) ) {
-      digit->GetTimeCFD(*digCFD);
-      digit->GetTimeLED(*digLED);
-      digit->GetQT0(*digQT0);
-      digit->GetQT1(*digQT1);
-      refpoint =  digit->RefPoint();
-      for (Int_t i=0; i<24; i++)
-       {
-         if (digCFD->At(i)>0) {
-           Int_t cfd=digCFD->At(i)- refpoint;
-           GetDigitsData(i) ->Fill(i,cfd);
-           GetDigitsData(i+24) -> Fill(i, digLED->At(i) - digCFD->At(i));
-           GetDigitsData(i+48) -> Fill(i, digQT1->At(i) - digQT0->At(i));
-           //      fhDigEff->Fill(i);
-         }
-       }  
-    }
+   TBranch *brDigits=digitsTree->GetBranch("T0");
+  AliT0digit *fDigits = new AliT0digit() ;
+  if (brDigits) {
+    brDigits->SetAddress(&fDigits);
+  }else{
+    AliError(Form("EXEC Branch T0 digits not found"));
+    delete digCFD;
+    delete digLED;
+    delete digQT0;
+    delete digQT1;
+    return;
   }
+  
+  digitsTree->GetEvent(0);
+  digitsTree->GetEntry(0);
+  brDigits->GetEntry(0);
+  fDigits->GetTimeCFD(*digCFD);
+  fDigits->GetTimeLED(*digLED);
+  fDigits->GetQT0(*digQT0);
+  fDigits->GetQT1(*digQT1);
+  refpoint = fDigits->RefPoint();
+   for (Int_t i=0; i<24; i++)
+    {
+      if (digCFD->At(i)>0) {
+       Int_t cfd=digCFD->At(i)- refpoint;
+       FillDigitsData(i,cfd);
+       FillDigitsData(i+24, digLED->At(i) - digCFD->At(i));
+       FillDigitsData(i+48, digQT1->At(i) - digQT0->At(i));
+      }
+    }  
+      
   delete digCFD;
   delete digLED;
   delete digQT0;
   delete digQT1;
-
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
+  //
 }
 
 
+//____________________________________________________________________________
+void AliT0QADataMaker::MakeRaws( AliRawReader* rawReader)
+{
+  Int_t allData[110][5];
+  for (Int_t i0=0; i0<105; i0++)
+    {
+      for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
+    }
+  //fills QA histos for RAW
+
+    AliT0RawReader *start = new AliT0RawReader(rawReader);  
+    start->Next();
+    for (Int_t i=0; i<105; i++) 
+      for (Int_t iHit=0; iHit<5; iHit++)
+       allData[i][iHit]= start->GetData(i,iHit);
+    
+   
+    for (Int_t ik = 0; ik<24; ik+=2){
+      for (Int_t iHt=0; iHt<5; iHt++){
+       Int_t cc = ik/2;
+       if(allData[cc+1][iHt]!=0){
+        FillRawsData(cc,allData[cc+1][iHt]-allData[0][0]);
+       if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0)
+         FillRawsData(cc+48,allData[ik+26][iHt]-allData[ik+25][iHt]);
+       if(allData[cc+13][iHt]!=0 )
+         FillRawsData(cc+24,allData[cc+13][iHt]-allData[cc+1][iHt]);
+       }
+      }
+    }
+    
+    for (Int_t ik = 24; ik<48; ik+=2) {
+      for (Int_t iHt=0; iHt<5; iHt++) {
+       Int_t cc = ik/2;
+       if(allData[cc+45][iHt]!=0) {
+         FillRawsData(cc,allData[cc+1][iHt]-allData[0][0]);
+         if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0)
+           FillRawsData(cc+48,allData[ik+57][iHt]-allData[ik+58][iHt]);
+         if(allData[cc+57][iHt]!=0 )
+           FillRawsData(cc+48,allData[cc+57][iHt]-allData[cc+45][iHt]);
+       }
+      }
+    }
+    delete start;
+    //
+    IncEvCountCycleRaws();
+    IncEvCountTotalRaws();
+    //
+}
+
 //____________________________________________________________________________
 void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
 {
@@ -328,21 +416,23 @@ void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
   if (brRec) {
     brRec->SetAddress(&frecpoints);
   }else{
-    cerr<<"EXEC Branch T0 rec not found"<<endl;
-    // exit(111);
-    return;
+      AliError(Form("EXEC Branch T0 rec not found "));
+      return;
   } 
     
   brRec->GetEntry(0);
   
   for ( Int_t i=0; i<24; i++) {
-    GetRecPointsData(i) -> Fill(frecpoints -> GetTime(i)); 
-    GetRecPointsData(i+24) -> Fill(frecpoints -> GetAmp(i));
-    GetRecPointsData(i+48) -> Fill(frecpoints->AmpLED(i));
+    FillRecPointsData(i,frecpoints -> GetTime(i)); 
+    FillRecPointsData(i+24,frecpoints -> GetAmp(i));
+    FillRecPointsData(i+48,frecpoints->AmpLED(i));
     //  if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
   }
-     GetRecPointsData(72) ->Fill(frecpoints->GetMeanTime());
-  
+  FillRecPointsData(72,frecpoints->GetMeanTime());
+  //
+  IncEvCountCycleRecPoints();
+  IncEvCountTotalRecPoints();
+  //
 }
 
 //____________________________________________________________________________
@@ -350,8 +440,10 @@ void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
 {
   //fills QA histos for ESD
 
-  GetESDsData(0) -> Fill(esd->GetT0());
-  GetESDsData(1)-> Fill(esd->GetT0zVertex());
-
+  FillESDsData(0,esd->GetT0());
+  FillESDsData(1,esd->GetT0zVertex());
+  //
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
 }