LCOV - code coverage report
Current view: top level - TRD/TRDsim - AliTRDQADataMakerSim.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 108 150 72.0 %
Date: 2016-06-14 17:26:59 Functions: 15 21 71.4 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ////////////////////////////////////////////////////////////////////////////
      19             : //                                                                        //
      20             : //  Produces the data needed to calculate the quality assurance.          //
      21             : //  All data must be mergeable objects.                                   //
      22             : //                                                                        //
      23             : //  Author:                                                               //
      24             : //    Sylwester Radomski (radomski@physi.uni-heidelberg.de)               //
      25             : //                                                                        //
      26             : ////////////////////////////////////////////////////////////////////////////
      27             : 
      28             : // --- ROOT system ---
      29             : #include <TClonesArray.h>
      30             : #include <TFile.h> 
      31             : #include <TH1F.h> 
      32             : #include <TH2F.h>
      33             : #include <TH3F.h>
      34             : #include <TProfile.h>
      35             : #include <TF1.h>
      36             : #include <TCanvas.h>
      37             : #include <TTree.h>
      38             : 
      39             : // --- AliRoot header files ---
      40             : //#include "AliESDEvent.h"
      41             : #include "AliLog.h"
      42             : #include "AliTRDdigit.h"
      43             : #include "AliTRDhit.h"
      44             : //#include "AliTRDcluster.h"
      45             : #include "AliTRDQADataMakerSim.h"
      46             : #include "AliTRDdigitsManager.h"
      47             : #include "AliTRDgeometry.h"
      48             : #include "AliTRDarrayADC.h"
      49             : #include "AliTRDarraySignal.h"
      50             : //#include "AliTRDrawStream.h"
      51             : 
      52             : #include "AliQAChecker.h"
      53             : 
      54          12 : ClassImp(AliTRDQADataMakerSim)
      55             : 
      56             : //____________________________________________________________________________ 
      57             :   AliTRDQADataMakerSim::AliTRDQADataMakerSim() : 
      58           3 :   AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker"),
      59           1 :   fTmpHits(NULL) 
      60           5 : {
      61             :   //
      62             :   // Default constructor
      63           2 : }
      64             : 
      65             : //____________________________________________________________________________ 
      66             : AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
      67           0 :   AliQADataMakerSim(), 
      68           0 :   fTmpHits(NULL)
      69           0 : {
      70             :   //
      71             :   // Copy constructor 
      72             :   //
      73             : 
      74           0 :   SetName((const char*)qadm.GetName()) ; 
      75           0 :   SetTitle((const char*)qadm.GetTitle()); 
      76             : 
      77           0 : }
      78             : 
      79             : //__________________________________________________________________
      80             : AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
      81             : {
      82             :   //
      83             :   // Equal operator.
      84             :   //
      85             : 
      86           0 :   this->~AliTRDQADataMakerSim();
      87           0 :   new(this) AliTRDQADataMakerSim(qadm);
      88           0 :   return *this;
      89             : 
      90           0 : }
      91             : 
      92             : //____________________________________________________________________________ 
      93             : AliTRDQADataMakerSim::~AliTRDQADataMakerSim()
      94           6 : {
      95           1 :   if (fTmpHits) {
      96           0 :     fTmpHits->Clear() ; 
      97           0 :     delete fTmpHits ; 
      98             :   }
      99           3 : }
     100             : 
     101             : //____________________________________________________________________________ 
     102             : void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
     103             : {
     104             :   //
     105             :   // Detector specific actions at end of cycle
     106             :   //
     107          18 :   ResetEventTrigClasses();
     108             :   //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task));
     109             : 
     110             :   // call the checker
     111           9 :   AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;    
     112             : 
     113             : 
     114           9 : }
     115             : 
     116             : //____________________________________________________________________________ 
     117             : void AliTRDQADataMakerSim::InitHits()
     118             : {
     119             :   //
     120             :   // Create Hits histograms in Hits subdir
     121             :   //
     122             :   const Bool_t expert   = kTRUE ; 
     123             :   const Bool_t image    = kTRUE ; 
     124             :   
     125             :   const Int_t kNhist = 4;
     126           0 :   TH1F *hist[kNhist];
     127             : 
     128           0 :   hist[0] = new TH1F("qaTRD_hits_det", "TRD hits det;Detector Id of the hit;Counts", 540, -0.5, 539.5) ; 
     129             : 
     130           0 :   hist[1] = new TH1F("qaTRD_hist_Qdrift", "TRD hits Qdrift;Charge from tracks;Counts", 100, 0, 100);
     131           0 :   hist[2] = new TH1F("qaTRD_hist_Qamp", "TRD hits Qamp;Charge from TRD photon;Counts", 100, 0, 100);
     132           0 :   hist[3] = new TH1F("qaTRD_hist_Qphoton", "TRD hits Qphoton;Charge from TRD photon;Counts", 100, 0, 100);
     133             : 
     134           0 :   for(Int_t i=0; i<kNhist; i++) {
     135             :     //hist[i]->Sumw2();
     136           0 :     Add2HitsList(hist[i], i, !expert, image);
     137             :   }
     138             :   //
     139           0 :   ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
     140           0 : }
     141             : 
     142             : //____________________________________________________________________________ 
     143             : void AliTRDQADataMakerSim::InitDigits()
     144             : {
     145             :   //
     146             :   // Create Digits histograms in Digits subdir
     147             :   //
     148             :   const Bool_t expert   = kTRUE ; 
     149             :   const Bool_t image    = kTRUE ; 
     150             :   
     151             :   const Int_t kNhist = 3;
     152           2 :   TH1F *hist[kNhist];
     153             : 
     154           2 :   hist[0] = new TH1F("qaTRD_digits_det", "TRD digits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
     155           2 :   hist[1] = new TH1F("qaTRD_digits_time", "TRDdigits time;Time bin;Counts", 40, -0.5, 39.5);
     156           2 :   hist[2] = new TH1F("qaTRD_digits_amp", "TRD digits amp;Amplitude;Counts", 100, -5.5, 94.5);
     157             : 
     158           8 :   for(Int_t i=0; i<kNhist; i++) {
     159           3 :     hist[i]->Sumw2();
     160           3 :     Add2DigitsList(hist[i], i, !expert, image);
     161             :   }
     162             :   //
     163           1 :   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
     164           1 : }
     165             : 
     166             : //____________________________________________________________________________ 
     167             : void AliTRDQADataMakerSim::InitSDigits()
     168             : {
     169             :   //
     170             :   // Create SDigits histograms in SDigits subdir
     171             :   //
     172             :   const Bool_t expert   = kTRUE ; 
     173             :   const Bool_t image    = kTRUE ; 
     174             :   
     175             :   const Int_t kNhist = 3;
     176           2 :   TH1F *hist[kNhist];
     177             : 
     178           2 :   hist[0] = new TH1F("qaTRD_sdigits_det", "TRD sdigits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
     179           2 :   hist[1] = new TH1F("qaTRD_sdigits_time", "TRD sdigits time;Time bin;Counts", 40, -0.5, 39.5);
     180           2 :   hist[2] = new TH1F("qaTRD_sdigits_amp", "TRD sdigits amp;Amplitude;Counts", 100, 0, 1e7);
     181             : 
     182           8 :   for(Int_t i=0; i<kNhist; i++) {
     183           3 :     hist[i]->Sumw2();
     184           3 :     Add2SDigitsList(hist[i], i, !expert, image);
     185             :   }
     186             :   //
     187           1 :   ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
     188           1 : }
     189             : 
     190             : //____________________________________________________________________________
     191             : void AliTRDQADataMakerSim::MakeHits()
     192             : {
     193             :   //
     194             :   // Make QA data from Hits
     195             :   //
     196             :   
     197         224 :   TIter next(fHitsArray); 
     198             :   AliTRDhit * hit; 
     199             : 
     200         448 :   while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
     201           0 :     FillHitsData(0,hit->GetDetector());
     202           0 :     Double_t q = TMath::Abs(hit->GetCharge());
     203             : 
     204           0 :     if (hit->FromDrift()) FillHitsData(1,q);
     205           0 :     if (hit->FromAmplification()) FillHitsData(2,q);
     206           0 :     if (hit->FromTRphoton()) FillHitsData(3,q);
     207             :   }
     208         112 : }
     209             : 
     210             : //____________________________________________________________________________
     211             : void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
     212             : {
     213             :   //
     214             :   // Make QA data from Hits
     215             :   //
     216             : 
     217           8 :   if (!CheckPointer(hitTree, "TRD hits tree")) return;
     218             : 
     219           4 :   TBranch *branch = hitTree->GetBranch("TRD");
     220           4 :   if (!CheckPointer(branch, "TRD hits branch")) return;
     221             :   
     222           4 :   Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
     223           4 :   if (fHitsArray)
     224           3 :     fHitsArray->Clear() ; 
     225             :   else
     226           2 :    fHitsArray = new TClonesArray("AliTRDhit", nhits+1000);
     227             :   
     228             :   //Int_t index = 0;
     229           4 :   Int_t nEntries = (Int_t)branch->GetEntries();
     230         232 :   for(Int_t i = 0; i < nEntries; i++) {
     231         112 :     branch->GetEntry(i);
     232         112 :     MakeHits();
     233         112 :     fHitsArray->Clear() ; 
     234             :   }
     235             :   //
     236           4 :   IncEvCountCycleHits();
     237           4 :   IncEvCountTotalHits();
     238             :   //
     239           8 : }
     240             : 
     241             : //____________________________________________________________________________
     242             : void AliTRDQADataMakerSim::MakeDigits()
     243             : {
     244             :   //
     245             :   // Makes data from Digits
     246             :   //
     247             : 
     248           0 :   if (!fDigitsArray)
     249             :     return ; 
     250             :   
     251           0 :   TIter next(fDigitsArray) ; 
     252             :   AliTRDdigit * digit ; 
     253             :   
     254             :   // Info("Make digits", "From the arrya");
     255             :   
     256           0 :   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
     257           0 :     if (digit->GetAmp() < 1) continue;
     258           0 :     FillDigitsData(0,digit->GetDetector());
     259           0 :     FillDigitsData(1,digit->GetTime());
     260           0 :     FillDigitsData(2,digit->GetAmp());
     261             :   }
     262             : 
     263           0 : }
     264             : 
     265             : //____________________________________________________________________________
     266             : void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
     267             : {
     268             :   //
     269             :   // Makes data from digits tree
     270             :   //
     271             :   // Info("Make digits", "From a tree");
     272             : 
     273           8 :   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
     274           4 :   digitsManager->CreateArrays();
     275           4 :   digitsManager->ReadDigits(digits);
     276          21 :   static TObjArray histDet,histTime,histSignal;
     277             :   //
     278           4 :   GetMatchingDigitsData(0,&histDet);
     279           4 :   GetMatchingDigitsData(1,&histTime);
     280           4 :   GetMatchingDigitsData(2,&histSignal);
     281             : 
     282        4328 :   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
     283             :     {
     284        2160 :       AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
     285             : 
     286             :       // This is to take care of switched off super modules
     287        4132 :       if (digitsIn->GetNtime() == 0) continue;
     288             :       
     289         188 :       digitsIn->Expand();
     290             :       
     291             :       //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     292             :       //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
     293             :       
     294         188 :       Int_t nRows = digitsIn->GetNrow();
     295         188 :       Int_t nCols = digitsIn->GetNcol();
     296         188 :       Int_t nTbins = digitsIn->GetNtime();
     297             :       
     298        5576 :       for(Int_t row = 0; row < nRows; row++) 
     299      754000 :         for(Int_t col = 0; col < nCols; col++) 
     300    20966400 :           for(Int_t time = 0; time < nTbins; time++) 
     301             :             {   
     302    10108800 :               Float_t signal = digitsIn->GetData(row,col,time);
     303    20127393 :               if (signal < 1) continue;
     304      360828 :               for (int ih=histDet.GetEntriesFast();ih--;) ((TH1*)histDet.UncheckedAt(ih))->Fill(i);
     305      360828 :               for (int ih=histTime.GetEntriesFast();ih--;) ((TH1*)histTime.UncheckedAt(ih))->Fill(time);
     306      360828 :               for (int ih=histSignal.GetEntriesFast();ih--;) ((TH1*)histSignal.UncheckedAt(ih))->Fill(signal);
     307       90207 :             }
     308             :       
     309             :       //delete digitsIn;
     310         188 :     }
     311           8 :   delete digitsManager;
     312             :   //
     313           4 :   IncEvCountCycleDigits();
     314           4 :   IncEvCountTotalDigits();
     315             :   //
     316           4 : }
     317             : 
     318             : //____________________________________________________________________________
     319             : void AliTRDQADataMakerSim::MakeSDigits()
     320             : {
     321             :   //
     322             :   // Makes data from Digits
     323             :   //
     324             : 
     325           0 :   if (!fSDigitsArray)
     326             :     return ; 
     327             : 
     328           0 :   TIter next(fSDigitsArray) ; 
     329             :   AliTRDdigit * digit ; 
     330           0 :   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
     331           0 :     FillDigitsData(0,digit->GetDetector());
     332           0 :     FillDigitsData(1,digit->GetTime());
     333           0 :     FillDigitsData(2,digit->GetAmp());
     334             :   }
     335             : 
     336           0 : }
     337             : 
     338             : //____________________________________________________________________________
     339             : void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
     340             : {
     341             :   //
     342             :   // Makes data from SDigits
     343             :   //
     344             :   // Check id histograms already created for this Event Specie
     345           8 :   if ( ! GetSDigitsData(0) )
     346           0 :     InitSDigits() ;
     347             :   
     348           4 :   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
     349           4 :   digitsManager->SetSDigits(kTRUE);
     350           4 :   digitsManager->CreateArrays();
     351           4 :   digitsManager->ReadDigits(digits);
     352             : 
     353          21 :   static TObjArray histDet,histTime,histSignal;
     354             :   //
     355           4 :   GetMatchingSDigitsData(0,&histDet);
     356           4 :   GetMatchingSDigitsData(1,&histTime);
     357           4 :   GetMatchingSDigitsData(2,&histSignal);
     358             : 
     359        4328 :   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
     360             :     {
     361        2160 :       AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
     362             :   
     363             :     // This is to take care of switched off super modules
     364        4132 :       if (digitsIn->GetNtime() == 0) continue;
     365             :       
     366         188 :     digitsIn->Expand(); 
     367             :       
     368             :       //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     369             :       //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
     370         188 :       Int_t nRows = digitsIn->GetNrow();
     371         188 :       Int_t nCols = digitsIn->GetNcol();
     372         188 :       Int_t nTbins = digitsIn->GetNtime();
     373             : 
     374        5576 :       for(Int_t row = 0; row < nRows; row++) 
     375             :         {
     376      754000 :           for(Int_t col = 0; col < nCols; col++) 
     377             :             {
     378    20966400 :               for(Int_t time = 0; time < nTbins; time++) 
     379             :                 {           
     380    10108800 :                   Float_t signal = digitsIn->GetData(row,col,time);
     381    20157455 :                   if (signal < 1) continue;
     382      240580 :                   for (int ih=histDet.GetEntriesFast();ih--;) ((TH1*)histDet.UncheckedAt(ih))->Fill(i);
     383      240580 :                   for (int ih=histTime.GetEntriesFast();ih--;) ((TH1*)histTime.UncheckedAt(ih))->Fill(time);
     384      240580 :                   for (int ih=histSignal.GetEntriesFast();ih--;) ((TH1*)histSignal.UncheckedAt(ih))->Fill(signal);
     385       60145 :                 }
     386             :             }
     387             :         }
     388             :       // delete digitsIn;
     389         188 :     }
     390           8 :   delete digitsManager;
     391             :   //
     392           4 :   IncEvCountCycleSDigits();
     393           4 :   IncEvCountTotalSDigits();  
     394             :   //
     395           4 : }
     396             : 
     397             : //____________________________________________________________________________ 
     398             : void AliTRDQADataMakerSim::StartOfDetectorCycle()
     399             : {
     400             :   //
     401             :   // Detector specific actions at start of cycle
     402             :   //
     403             : 
     404          12 : }
     405             : 
     406             : //__________________________________________________________________________
     407             : Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name) 
     408             : {
     409             :   //
     410             :   // Checks initialization of pointers
     411             :   //
     412             : 
     413          16 :   if (!obj) AliWarning(Form("null pointer: %s", name));
     414           8 :   return !!obj;
     415             : 
     416             : }

Generated by: LCOV version 1.11