LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCCalibRaw.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 46 350 13.1 %
Date: 2016-06-14 17:26:59 Functions: 4 23 17.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             : /// \class AliTPCCalibRaw
      19             : /// \brief Implementation of the TPC Raw drift velocity and Altro L1 Phase  calibration
      20             : ///
      21             : /// \author Jens Wiechula, J.Wiechula@gsi.de
      22             : ///
      23             : /// Class Description
      24             : /// -----------------
      25             : ///
      26             : /// ~~~{.cpp}
      27             : /// TFile f("CalibAltro.root");
      28             : /// AliTPCCalibRaw *al=(AliTPCCalibRaw*)f.Get(f.GetListOfKeys()->At(0)->GetName())
      29             : /// {
      30             : /// TCanvas *c1=(TCanvas*)gROOT->FindObject("c1");
      31             : /// if (!c1) c1=new TCanvas("c1","c1");
      32             : /// c1->Clear();
      33             : ///
      34             : /// TH2F h2f("h2","h2;RCU;fail",216,0,216,al->GetNevents(),0,al->GetNevents());
      35             : /// Bool_t first=kTRUE;
      36             : /// Int_t i,iev;
      37             : /// for (i=0;i<216;++i) {
      38             : ///   TVectorF *v=al->GetALTROL1PhaseFailEventsRCU(i);
      39             : ///   if (!v) continue;
      40             : ///   for (iev=0;iev<al->GetNevents();++iev) {
      41             : ///     h2f->SetBinContent(i+1,iev+1,(*v)(iev));
      42             : ///   }
      43             : /// //   TH1F h(*v);
      44             : /// //   h.SetLineColor(i/216.*50+50);
      45             : /// //   ((TH1F*)h.Clone(Form("h%d",i)))->Draw(first?"":"same");
      46             : /// //   c1->Modified();
      47             : /// //   c1->Update();
      48             : ///   first=kFALSE;
      49             : /// }
      50             : /// h2f->Draw("col");
      51             : /// }
      52             : /// ~~~
      53             : 
      54             : //Root includes
      55             : #include <TROOT.h>
      56             : #include <TH2C.h>
      57             : #include <TH1F.h>
      58             : #include <TMap.h>
      59             : #include <TGraph.h>
      60             : #include <TObjString.h>
      61             : #include <TTimeStamp.h>
      62             : #include <TCanvas.h>
      63             : //AliRoot includes
      64             : #include "AliTPCCalROC.h"
      65             : #include "AliAltroRawStream.h"
      66             : #include "AliLog.h"
      67             : //class header
      68             : #include "AliTPCCalibRaw.h"
      69             : 
      70             : /// \cond CLASSIMP
      71          24 : ClassImp(AliTPCCalibRaw)
      72             : /// \endcond
      73             : 
      74             : AliTPCCalibRaw::AliTPCCalibRaw() :
      75           2 :   AliTPCCalibRawBase(),
      76           2 :   fPeakDetMinus(1),
      77           2 :   fPeakDetPlus(2),
      78           2 :   fNFailL1Phase(0),
      79           2 :   fNFailL1PhaseEvent(0),
      80           2 :   fNSecTime(600), //default 10 minutes
      81           2 :   fNBinsTime(60), //default 60*10 minutes = 10 hours
      82           2 :   fPadProcessed(kFALSE),
      83           2 :   fCurrentChannel(-1),
      84           2 :   fCurrentSector(-1),
      85           2 :   fLastSector(-2),
      86           2 :   fCurrentRow(-1),
      87           2 :   fCurrentPad(-1),
      88           2 :   fLastTimeBinProc(0),
      89           2 :   fPeakTimeBin(0),
      90           2 :   fLastSignal(0),
      91           2 :   fNOkPlus(0),
      92           2 :   fNOkMinus(0),
      93           2 :   fNanoSec(0),
      94           2 :   fArrCurrentPhaseDist(4),
      95           2 :   fArrCurrentPhase(kNRCU),
      96           2 :   fArrFailEventNumber(100),
      97           2 :   fArrALTROL1Phase(100000),
      98           2 :   fArrALTROL1PhaseEvent(kNRCU),
      99           2 :   fArrALTROL1PhaseFailEvent(kNRCU),
     100           2 :   fHnDrift(0x0),
     101           2 :   fVOccupancyEvent(100000),
     102           2 :   fVSignalSumEvent(100000),
     103           2 :   fVOccupancySenEvent(100000),
     104           2 :   fVSignalSumSenEvent(100000),
     105           2 :   fVNfiredPadsSenEvent(100000),
     106           2 :   fVTimeStampEvent(100000)
     107          10 : {
     108             :   //
     109             :   // Default ctor
     110             :   //
     111           2 :   SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
     112           2 :   CreateDVhist();
     113         868 :   for (Int_t ircu=0;ircu<kNRCU;++ircu) fArrCurrentPhase.GetMatrixArray()[ircu]=-1;
     114           2 :   fFirstTimeBin=850;
     115           2 :   fLastTimeBin=1020;
     116           4 : }
     117             : //_____________________________________________________________________
     118             : AliTPCCalibRaw::AliTPCCalibRaw(const TMap *config) :
     119           0 : AliTPCCalibRawBase(),
     120           0 : fPeakDetMinus(1),
     121           0 : fPeakDetPlus(2),
     122           0 : fNFailL1Phase(0),
     123           0 : fNFailL1PhaseEvent(0),
     124           0 : fNSecTime(600), //default 10 minutes
     125           0 : fNBinsTime(60), //default 60*10 minutes = 10 hours
     126           0 : fPadProcessed(kFALSE),
     127           0 : fCurrentChannel(-1),
     128           0 : fCurrentSector(-1),
     129           0 : fLastSector(-2),
     130           0 : fCurrentRow(-1),
     131           0 : fCurrentPad(-1),
     132           0 : fLastTimeBinProc(0),
     133           0 : fPeakTimeBin(0),
     134           0 : fLastSignal(0),
     135           0 : fNOkPlus(0),
     136           0 : fNOkMinus(0),
     137           0 : fNanoSec(0),
     138           0 : fArrCurrentPhaseDist(4),
     139           0 : fArrCurrentPhase(kNRCU),
     140           0 : fArrFailEventNumber(100),
     141           0 : fArrALTROL1Phase(100000),
     142           0 : fArrALTROL1PhaseEvent(kNRCU),
     143           0 : fArrALTROL1PhaseFailEvent(kNRCU),
     144           0 : fHnDrift(0x0),
     145           0 : fVOccupancyEvent(100000),
     146           0 : fVSignalSumEvent(100000),
     147           0 : fVOccupancySenEvent(100000),
     148           0 : fVSignalSumSenEvent(100000),
     149           0 : fVNfiredPadsSenEvent(100000),
     150           0 : fVTimeStampEvent(100000)
     151           0 : {
     152             :   /// Default ctor
     153             : 
     154           0 :   SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
     155           0 :   CreateDVhist();
     156           0 :   for (Int_t ircu=0;ircu<kNRCU;++ircu) fArrCurrentPhase.GetMatrixArray()[ircu]=-1;
     157           0 :   fFirstTimeBin=850;
     158           0 :   fLastTimeBin=1020;
     159           0 :   if (config->GetValue("FirstTimeBin")) fFirstTimeBin = ((TObjString*)config->GetValue("FirstTimeBin"))->GetString().Atoi();
     160           0 :   if (config->GetValue("LastTimeBin")) fLastTimeBin = ((TObjString*)config->GetValue("LastTimeBin"))->GetString().Atoi();
     161           0 :   if (config->GetValue("DebugLevel")) fDebugLevel = ((TObjString*)config->GetValue("DebugLevel"))->GetString().Atoi();
     162           0 : }
     163             : 
     164             : //_____________________________________________________________________
     165             : AliTPCCalibRaw::~AliTPCCalibRaw()
     166           0 : {
     167             :   /// dtor
     168             : 
     169           0 :   delete fHnDrift;
     170           0 : }
     171             : //_____________________________________________________________________
     172             : // AliTPCCalibRaw& AliTPCCalibRaw::operator = (const  AliTPCCalibRaw &source)
     173             : // {
     174             : //   //
     175             : //   // assignment operator
     176             : //   //
     177             : //   if (&source == this) return *this;
     178             : //   new (this) AliTPCCalibRaw(source);
     179             : //
     180             : //   return *this;
     181             : // }
     182             : 
     183             : //_____________________________________________________________________
     184             : Int_t AliTPCCalibRaw::Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
     185             :              const Int_t iTimeBin, const Float_t signal)
     186             : {
     187             :   /// Data filling method
     188             : 
     189           0 :   if (iRow<0) return 0;
     190           0 :   if (iPad<0) return 0;
     191           0 :   if (iTimeBin<0) return 0;
     192             :   //
     193           0 :   Int_t iChannel  = fROC->GetRowIndexes(isector)[iRow]+iPad; //  global pad position in sector
     194             :   //occupancy
     195           0 :   fVOccupancyEvent.GetMatrixArray()[GetNevents()]++;
     196           0 :   fVSignalSumEvent.GetMatrixArray()[GetNevents()]+=signal;
     197             :   //occupancy in sensitive regions
     198           0 :   Int_t npads=(Int_t)fROC->GetNPads(isector,iRow);
     199           0 :   Int_t cpad=iPad-npads/2;
     200           0 :   if (isector<(Int_t)fROC->GetNInnerSector()){
     201             :     //IROC case (spot)
     202           0 :     if ( iRow>19 && iRow<46 ){
     203           0 :       if ( TMath::Abs(cpad)<7 ){
     204           0 :         fVOccupancySenEvent.GetMatrixArray()[GetNevents()]++;
     205           0 :         fVSignalSumSenEvent.GetMatrixArray()[GetNevents()]+=signal;
     206           0 :         if (iChannel!=fCurrentChannel) fVNfiredPadsSenEvent.GetMatrixArray()[GetNevents()]++;
     207             :       }
     208             :     }
     209           0 :   } else if ( iRow>75 ){
     210             :     //OROC case (outer corners and last three rows are sensitive)
     211           0 :     Int_t padEdge=(Int_t)TMath::Min(iPad,npads-iPad);
     212           0 :     Int_t nrows=(Int_t)fROC->GetNRows(isector);
     213           0 :     if ((nrows-iRow-1)<3 || padEdge<((((Int_t)iRow-76)/4+1))*2){
     214           0 :       fVOccupancySenEvent.GetMatrixArray()[GetNevents()]++;
     215           0 :       fVSignalSumSenEvent.GetMatrixArray()[GetNevents()]+=signal;
     216           0 :       if (iChannel!=fCurrentChannel) fVNfiredPadsSenEvent.GetMatrixArray()[GetNevents()]++;
     217             :     }
     218           0 :   }
     219             :   //
     220           0 :   if ( (iTimeBin>fLastTimeBin) || (iTimeBin<fFirstTimeBin)   ) return 0;
     221             :   //don't process edge pads
     222           0 :   if (IsEdgePad(isector,iRow,iPad)) return 0;
     223             : //   Double_t x[kHnBinsDV]={1,isector,0};
     224             : //   fHnDrift->Fill(x);
     225           0 :   if (fCurrentChannel==iChannel){
     226           0 :     if (fPadProcessed) return 0;
     227             :   } else {
     228           0 :     fPadProcessed=kFALSE;
     229           0 :     fNOkPlus=0;
     230           0 :     fNOkMinus=0;
     231           0 :     fPeakTimeBin=0;
     232           0 :     fLastSignal=0;
     233             :   }
     234             : //   Double_t x2[kHnBinsDV]={2,isector,0};
     235             : //   fHnDrift->Fill(x2);
     236             : 
     237             : 
     238           0 :   if (signal>fLastSignal) ++fNOkPlus;
     239           0 :   else if(signal<fLastSignal && fNOkPlus>=fPeakDetPlus){
     240           0 :     ++fNOkMinus;
     241           0 :     if (!fPeakTimeBin) fPeakTimeBin=fLastTimeBinProc;
     242           0 :     if ( fNOkMinus>=fPeakDetMinus ) {
     243           0 :       Double_t x[kHnBinsDV]={static_cast<Double_t>(fPeakTimeBin),static_cast<Double_t>(isector),static_cast<Double_t>((fTimeStamp-fFirstTimeStamp)/fNSecTime)};
     244           0 :       fHnDrift->Fill(x);
     245           0 :     }
     246             :   } else {
     247           0 :     fNOkPlus=0;
     248           0 :     fNOkMinus=0;
     249           0 :     fPeakTimeBin=0;
     250           0 :     fLastSignal=0;
     251             :   }
     252             : 
     253           0 :   fLastTimeBinProc=iTimeBin;
     254           0 :   fLastSignal=TMath::Nint(signal);
     255           0 :   fCurrentChannel = iChannel;
     256           0 :   return 0;
     257           0 : }
     258             : //_____________________________________________________________________
     259             : void AliTPCCalibRaw::UpdateDDL(){
     260             :   /// fill ALTRO L1 information
     261             : 
     262             :   //set nanoseconds
     263           0 :   if (!fNanoSec) {
     264           0 :     TTimeStamp s;
     265           0 :     fNanoSec=s.GetNanoSec();
     266           0 :   }
     267             :   // current phase
     268           0 :   Int_t phase=(Int_t)(GetL1PhaseTB()*4.);
     269             :   //Fill pahse information of current rcu and event
     270           0 :   fArrCurrentPhase.GetMatrixArray()[fCurrDDLNum]=phase;
     271             :   //increase phase counter
     272           0 :   ++((fArrCurrentPhaseDist.GetMatrixArray())[phase]);
     273             : 
     274           0 : }
     275             : //_____________________________________________________________________
     276             : void AliTPCCalibRaw::ResetEvent()
     277             : {
     278             :   /// Reset event counters
     279             : 
     280           0 :   fCurrentChannel=-1;
     281           0 :   fCurrentRow=-1;
     282           0 :   fCurrentPad=-1;
     283           0 :   fArrCurrentPhaseDist.Zero();
     284           0 : }
     285             : //_____________________________________________________________________
     286             : void AliTPCCalibRaw::EndEvent()
     287             : {
     288             :   /// End event analysis
     289             : 
     290             : 
     291             :   //find phase of the current event
     292             :   Int_t phaseMaxEntries=-1;
     293             :   Int_t maxEntries=0;
     294           0 :   for (Int_t i=0;i<fArrCurrentPhaseDist.GetNrows();++i){
     295           0 :     Int_t entries=(Int_t)fArrCurrentPhaseDist[i];
     296           0 :     if (maxEntries<entries) {
     297             :       maxEntries=entries;
     298             :       phaseMaxEntries=i;
     299           0 :     }
     300             :   }
     301             :   // store phase of current event
     302           0 :   if (fArrALTROL1Phase.GetNrows()-1<=GetNevents())
     303           0 :     fArrALTROL1Phase.ResizeTo(GetNevents()+10000);
     304           0 :   (fArrALTROL1Phase.GetMatrixArray())[GetNevents()]=phaseMaxEntries;
     305             : 
     306             :   //loop over RCUs and test failures
     307             :   UInt_t fail=0;
     308           0 :   for (Int_t ircu=0;ircu<kNRCU;++ircu){
     309           0 :     Int_t phase=(Int_t)fArrCurrentPhase[ircu];
     310           0 :     if (phase<0) continue;
     311           0 :     if (phase!=phaseMaxEntries){
     312           0 :       TVectorF *arr=MakeArrL1PhaseRCU(fCurrDDLNum,kTRUE);
     313           0 :       if (arr->GetNrows()-1<=(Int_t)fNFailL1PhaseEvent) arr->ResizeTo(arr->GetNrows()+100);
     314           0 :       (arr->GetMatrixArray())[fNFailL1PhaseEvent]=phase;
     315           0 :       ++fNFailL1Phase;
     316             :       fail=1;
     317           0 :       }
     318             :     //reset current phase information
     319           0 :     fArrCurrentPhase[ircu]=-1;
     320           0 :   }
     321           0 :   if (fail){
     322           0 :     if (fArrFailEventNumber.GetNrows()-1<=(Int_t)fNFailL1PhaseEvent) fArrFailEventNumber.ResizeTo(fArrFailEventNumber.GetNrows()+100);
     323           0 :     fArrFailEventNumber.GetMatrixArray()[fNFailL1PhaseEvent]=GetNevents();
     324           0 :   }
     325           0 :   fNFailL1PhaseEvent+=fail;
     326             :   //time stamps
     327           0 :   fVTimeStampEvent.GetMatrixArray()[GetNevents()]=GetTimeStamp()-fFirstTimeStamp+fNanoSec*1e-9;
     328           0 :   fNanoSec=0;
     329             :   //occupance related
     330           0 :   if (fVOccupancyEvent.GetNrows()-1<=GetNevents()){
     331           0 :     fVOccupancyEvent.ResizeTo(GetNevents()+10000);
     332           0 :     fVSignalSumEvent.ResizeTo(GetNevents()+10000);
     333           0 :     fVOccupancySenEvent.ResizeTo(GetNevents()+10000);
     334           0 :     fVSignalSumSenEvent.ResizeTo(GetNevents()+10000);
     335           0 :     fVTimeStampEvent.ResizeTo(GetNevents()+10000);
     336           0 :     fVNfiredPadsSenEvent.ResizeTo(GetNevents()+10000);
     337           0 :   }
     338           0 :   IncrementNevents();
     339           0 : }
     340             : //_____________________________________________________________________
     341             : TH2C *AliTPCCalibRaw::MakeHistL1RCUEvents(Int_t type)
     342             : {
     343             :   /// Create a 2D histo RCU:Events indicating the there was a deviation
     344             :   /// from the mean L1 phase of the event
     345             :   ///
     346             :   /// type: 0=Failures, 1=Phases
     347             : 
     348             :   //number of relavant events, depending on version
     349           0 :   Int_t nevents=GetNevents();
     350             :   //check version
     351             :   Bool_t newVersion=kFALSE;
     352           0 :   for (Int_t ircu=0; ircu<kNRCU; ++ircu){
     353           0 :     const TVectorF *v=GetALTROL1PhaseEventsRCU(ircu);
     354           0 :     if (!v) continue;
     355           0 :     if ((UInt_t)(v->GetNrows())==fNFailL1PhaseEvent){
     356             :       newVersion=kTRUE;
     357             :       nevents=fNFailL1PhaseEvent;
     358           0 :     }
     359           0 :     break;
     360             :   }
     361           0 :   TH2C *h2 = new TH2C("hL1FailRCUEvents","L1 Failures;RCU;Event",kNRCU,0,kNRCU,nevents,0,nevents);
     362             :   Int_t add=0;
     363           0 :   for (Int_t ircu=0;ircu<kNRCU;++ircu) {
     364           0 :     const TVectorF *v=GetALTROL1PhaseEventsRCU(ircu);
     365           0 :     if (type==0){
     366             :       add=1;
     367           0 :       h2->SetMinimum(0);
     368           0 :       h2->SetMaximum(2);
     369           0 :     } else if (type==1) {
     370             :       add=0;
     371           0 :       h2->SetMinimum(0);
     372           0 :       h2->SetMaximum(4);
     373           0 :     }
     374           0 :     if (!v) continue;
     375           0 :     for (Int_t iev=0;iev<nevents;++iev) {
     376           0 :       Float_t val=(*v)(iev);
     377           0 :       Float_t phase=fArrALTROL1Phase.GetMatrixArray()[iev];
     378           0 :       if (newVersion) {
     379           0 :         Int_t event=(Int_t)fArrFailEventNumber.GetMatrixArray()[iev];
     380           0 :         phase=fArrALTROL1Phase.GetMatrixArray()[event];
     381           0 :       }
     382           0 :       if (type==0) val=(val!=phase);
     383           0 :       h2->SetBinContent(ircu+1,iev+1,val+add);
     384             :     }
     385           0 :   }
     386           0 :   return h2;
     387           0 : }
     388             : //_____________________________________________________________________
     389             : TH1F *AliTPCCalibRaw::MakeHistL1PhaseDist()
     390             : {
     391             :   /// L1 phase distribution. Should be flat in ideal case
     392             : 
     393           0 :   TH1F *h=new TH1F("L1phaseDist","Normalized L1 phase distribution;phase;fraction of events",4,0,4);
     394           0 :   h->Sumw2();
     395           0 :   for (Int_t iev=0;iev<GetNevents();++iev) h->Fill(fArrALTROL1Phase.GetMatrixArray()[iev]);
     396           0 :   if (GetNevents()>0) h->Scale(1./GetNevents());
     397           0 :   h->SetMinimum(0);
     398           0 :   h->SetMaximum(1);
     399           0 :   return h;
     400           0 : }
     401             : //_____________________________________________________________________
     402             : TVectorF *AliTPCCalibRaw::MakeVectL1PhaseDist()
     403             : {
     404             :   /// L1 phase distribution. Should be flat in ideal case
     405             : 
     406           0 :   TVectorF *v=new TVectorF(4);
     407           0 :   for (Int_t iev=0;iev<GetNevents();++iev) {
     408           0 :     Int_t phase=(Int_t)fArrALTROL1Phase.GetMatrixArray()[iev];
     409           0 :     ((v->GetMatrixArray())[phase])+=1./GetNevents();
     410             :   }
     411           0 :   return v;
     412           0 : }
     413             : //_____________________________________________________________________
     414             : TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsIROC(Int_t type)
     415             : {
     416             :   /// Create a 2D histo RCU:Events indicating the there was a deviation
     417             :   /// from the mean L1 phase of the event
     418             : 
     419           0 :   TH2C *h2 = new TH2C("hL1FailRCUEventsIROC","L1 Failures IROCs;RCU;Event",72,0,36,GetNevents(),0,GetNevents());
     420           0 :   for (Int_t ircu=0;ircu<72;++ircu) {
     421             :     const TVectorF *v=0;
     422           0 :     if (type==0)      v=GetALTROL1PhaseFailEventsRCU(ircu);
     423           0 :     else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
     424           0 :     if (!v) continue;
     425           0 :     for (Int_t iev=0;iev<GetNevents();++iev) {
     426           0 :       h2->SetBinContent(ircu+1,iev+1,(*v)(iev));
     427             :     }
     428           0 :   }
     429           0 :   return h2;
     430           0 : }
     431             : //_____________________________________________________________________
     432             : TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsOROC(Int_t type)
     433             : {
     434             :   /// Create a 2D histo RCU:Events indicating the there was a deviation
     435             :   /// from the mean L1 phase of the event
     436             : 
     437           0 :   TH2C *h2 = new TH2C("hL1FailRCUEventsOROC","L1 Failures OROCs;RCU;Event",144,0,36,GetNevents(),0,GetNevents());
     438           0 :   for (Int_t ircu=72;ircu<kNRCU;++ircu) {
     439             :     const TVectorF *v=0;
     440           0 :     if (type==0)      v=GetALTROL1PhaseFailEventsRCU(ircu);
     441           0 :     else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
     442           0 :     if (!v) continue;
     443           0 :     for (Int_t iev=0;iev<GetNevents();++iev) {
     444           0 :       h2->SetBinContent(ircu-72+1,iev+1,(*v)(iev));
     445             :     }
     446           0 :   }
     447           0 :   return h2;
     448           0 : }
     449             : //_____________________________________________________________________
     450             : void AliTPCCalibRaw::CreateDVhist()
     451             : {
     452             :   /// Setup the HnSparse for the drift velocity determination
     453             : 
     454           4 :   if (fHnDrift) return;
     455             :   //HnSparse bins
     456             :   //time bin, roc, time
     457           2 :   Int_t    bins[kHnBinsDV] = {static_cast<Int_t>(fLastTimeBin-fFirstTimeBin), 72, static_cast<Int_t>(fNBinsTime)};
     458           2 :   Double_t xmin[kHnBinsDV] = {static_cast<Double_t>(fFirstTimeBin),0,0};
     459           2 :   Double_t xmax[kHnBinsDV] = {static_cast<Double_t>(fLastTimeBin),72,static_cast<Double_t>(fNBinsTime)};
     460           6 :   fHnDrift=new THnSparseI("fHnDrift",Form("Drift velocity using last time bin;time bin[#times 100ns];ROC;Time bin [#times %us]",fNSecTime),kHnBinsDV, bins, xmin, xmax);
     461             : 
     462           4 : }
     463             : //_____________________________________________________________________
     464             : void AliTPCCalibRaw::Analyse()
     465             : {
     466             :   /// Analyse Data
     467             : 
     468             :   //resize arrays
     469           0 :   fArrALTROL1Phase.ResizeTo(GetNevents());
     470           0 :   for (Int_t ircu=0;ircu<kNRCU;++ircu){
     471           0 :     TVectorF *arr=MakeArrL1PhaseRCU(ircu);//MakeArrL1PhaseRCU(ircu);
     472           0 :     if (!arr) continue;
     473           0 :     arr->ResizeTo(fNFailL1PhaseEvent);
     474           0 :     fArrFailEventNumber.ResizeTo(fNFailL1PhaseEvent);
     475             : //    TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu);
     476             : //     arrF->ResizeTo(1);
     477           0 :   }
     478             :   //resize occupancy arrays only save event occupancy in sensitive regions by default
     479             :   //save the rest in debub mode
     480           0 :   fVOccupancySenEvent.ResizeTo(GetNevents());
     481           0 :   if (fDebugLevel>0){
     482           0 :     fVOccupancyEvent.ResizeTo(GetNevents());
     483           0 :     fVSignalSumEvent.ResizeTo(GetNevents());
     484           0 :     fVSignalSumSenEvent.ResizeTo(GetNevents());
     485           0 :     fVNfiredPadsSenEvent.ResizeTo(GetNevents());
     486           0 :     fVTimeStampEvent.ResizeTo(GetNevents());
     487           0 :   } else {
     488           0 :     fVOccupancyEvent.ResizeTo(0);
     489           0 :     fVSignalSumEvent.ResizeTo(0);
     490           0 :     fVSignalSumSenEvent.ResizeTo(0);
     491           0 :     fVNfiredPadsSenEvent.ResizeTo(0);
     492           0 :     fVTimeStampEvent.ResizeTo(0);
     493             :   }
     494             :   //Analyse drift velocity TODO
     495             : 
     496           0 : }
     497             : //_____________________________________________________________________
     498             : TGraph* AliTPCCalibRaw::MakeGraphOccupancy(const Int_t type, const Int_t xType)
     499             : {
     500             :   /// create occupancy graph (of samples abouve threshold)
     501             :   /// type=0:   number of samples
     502             :   /// type=1:   mean data volume (ADC counts/sample)
     503             :   /// type=2:   data volume (ADC counts)
     504             :   /// type=3:   samples per ADC count
     505             :   /// type=4:   sample occupancy
     506             :   ///
     507             :   /// type=5: number of sample sensitive / number of samples
     508             :   ///
     509             :   /// same in sensitive regions:
     510             :   /// type=10:  number of samples
     511             :   /// type=11:  mean data volume (ADC counts/sample)
     512             :   /// type=12:  data volume (ADC counts)
     513             :   /// type=13:  samples per ADC count
     514             :   /// type=14:  sample occupancy
     515             :   ///
     516             :   /// type=16: number of samples sensitive / number of pads sensitive
     517             :   /// type=17: pad occupancy in sensitive regions
     518             :   /// xType=0:  vs. time stamp
     519             :   /// xType=1:  vs. event counter
     520             : 
     521           0 :   TString title("Event occupancy");
     522           0 :   TString xTitle("Time");
     523           0 :   TString yTitle("number of samples");
     524           0 :   TGraph *gr=new TGraph(GetNevents());
     525           0 :   if (fVSignalSumEvent.GetNrows()==0&&!(type==10||type==14)) return 0;
     526           0 :   TVectorF *vOcc=&fVOccupancyEvent;
     527             :   TVectorF *vSum=&fVSignalSumEvent;
     528           0 :   TVectorF *vPads=&fVNfiredPadsSenEvent;
     529             :   Double_t norm=557568.;
     530           0 :   if (type!=14&&fVOccupancyEvent.GetNrows()==0){
     531           0 :     AliWarning("In non debug mode only occupancy in sensitive regions vs. event awailable!!!");
     532           0 :     return 0;
     533             :   }
     534           0 :   if (type>=10){
     535           0 :     vOcc=&fVOccupancySenEvent;
     536           0 :     vSum=&fVSignalSumSenEvent;
     537             :     vPads=&fVNfiredPadsSenEvent;
     538             :     norm=33012.;
     539           0 :   }
     540           0 :   for (Int_t i=0;i<GetNevents(); ++i){
     541           0 :     Double_t nAboveThreshold=vOcc->GetMatrixArray()[i];
     542             : 
     543             :     Double_t nSumADC        =1;
     544             :     Double_t timestamp      =1;
     545             :     Double_t nPads          =1;
     546             : 
     547           0 :     if (fVOccupancyEvent.GetNrows()>0){
     548           0 :       nSumADC        =vSum->GetMatrixArray()[i];
     549           0 :       timestamp      =fVTimeStampEvent.GetMatrixArray()[i]+fFirstTimeStamp;
     550           0 :       nPads          =vPads->GetMatrixArray()[i];
     551           0 :     }
     552             :     Double_t x=timestamp;
     553             :     Double_t y=0;
     554             :     //
     555           0 :     if (xType==1)     x=i;
     556             :     //
     557           0 :     if (type%10==0)            y=nAboveThreshold;
     558           0 :     if (type%10==1&&nAboveThreshold>0)      y=nSumADC/nAboveThreshold;
     559           0 :     if (type%10==2)            y=nSumADC;
     560           0 :     if (type%10==3&&nSumADC>0) y=nAboveThreshold/nSumADC;
     561           0 :     if (type%10==4)            y=nAboveThreshold/(norm*(fLastTimeBin-fFirstTimeBin));
     562           0 :     if (type==5)               y=fVOccupancySenEvent.GetMatrixArray()[i]/fVOccupancyEvent.GetMatrixArray()[i];
     563           0 :     if (type==16&&nPads>0)     y=nAboveThreshold/nPads;
     564           0 :     if (type==17)              y=nPads/norm;
     565             :     //
     566           0 :     gr->SetPoint(i,x,y);
     567             :   }
     568           0 :   if (xType==1) xTitle="Event";
     569           0 :   if (type%10==1)      yTitle="Mean ADC counts/sample";
     570           0 :   else if (type%10==2) yTitle="Data volume [ADC counts]";
     571           0 :   else if (type%10==3) yTitle="samples per ADC count";
     572           0 :   else if (type%10==4) yTitle="sample occupancy";
     573           0 :   if (type==5)         yTitle="N samples (sensitive) / N samples";
     574           0 :   if (type%10==6)      yTitle="N samples / N pads";
     575           0 :   if (type==17)        yTitle="Pad Occupancy";
     576           0 :   if (type>=10)        yTitle+=" (sensitive)";
     577           0 :   title=yTitle+":"+xTitle;
     578           0 :   title+=";"+xTitle+";"+yTitle;
     579           0 :   gr->SetTitle(title.Data());
     580           0 :   gr->SetEditable(kFALSE);
     581           0 :   return gr;
     582           0 : }
     583             : //_____________________________________________________________________
     584             : // TGraph* AliTPCCalibRaw::MakeGraphNoiseEvents()
     585             : // {
     586             :   //
     587             :   // Not implemented for the moment
     588             :   //
     589             : //   return 0;
     590             : // }
     591             : //_____________________________________________________________________
     592             : TCanvas* AliTPCCalibRaw::MakeCanvasOccupancy(const Int_t xType, Bool_t sen)
     593             : {
     594             :   /// Create a canvas with occupancy information of all 'type's (see MakeGraphOccupancy)
     595             :   /// xType=0: vs. timestamp
     596             :   /// xType=1: vs. event number
     597             :   ///
     598             :   /// sen=kTRUE: for sensitive regions
     599             : 
     600           0 :   TString name("RawOccupancy_");
     601           0 :   TString title("Raw Occupancy vs. ");
     602           0 :   if (xType==0){
     603           0 :     name+="Time";
     604           0 :     title+="time";
     605           0 :   } else if (xType==1){
     606           0 :     name+="Event";
     607           0 :     title+="event";
     608             :   }
     609           0 :   if (sen){
     610           0 :     name+="Sen";
     611           0 :     title+=" (sensitive)";
     612             :   }
     613           0 :   TCanvas *c=(TCanvas*)gROOT->GetListOfCanvases()->FindObject(name.Data());
     614           0 :   if (!c) c=new TCanvas(name.Data(),title.Data());
     615           0 :   c->Clear();
     616           0 :   c->Divide(2,2);
     617           0 :   for (Int_t i=0;i<4;++i){
     618           0 :     c->cd(i+1);
     619           0 :     TGraph *gr=MakeGraphOccupancy(i+10*(Int_t)sen,xType);
     620           0 :     gr->Draw("alp");
     621             :   }
     622             :   return c;
     623           0 : }
     624             : 
     625             : //_____________________________________________________________________
     626             : void AliTPCCalibRaw::Merge(AliTPCCalibRaw * const sig)
     627             : {
     628             :   /// Merge sig with this instance
     629             : 
     630           0 :   if (!sig) return;
     631           0 :   MergeBase(sig);
     632             :   //Add last time bin distribution histogram
     633           0 :   fHnDrift->Add(sig->fHnDrift);
     634             : 
     635             :   //Add occupancy data
     636             : 
     637           0 : }
     638             : 
     639             : //_____________________________________________________________________
     640             : Long64_t AliTPCCalibRaw::Merge(TCollection * const list)
     641             : {
     642             :   /// Merge all objects of this type in list
     643             : 
     644             :   Long64_t nmerged=1;
     645             : 
     646           0 :   TIter next(list);
     647             :   AliTPCCalibRaw *ce=0;
     648             :   TObject *o=0;
     649             : 
     650           0 :   while ( (o=next()) ){
     651           0 :     ce=dynamic_cast<AliTPCCalibRaw*>(o);
     652           0 :     if (ce){
     653           0 :       Merge(ce);
     654           0 :       ++nmerged;
     655           0 :     }
     656             :   }
     657             : 
     658             :   return nmerged;
     659           0 : }
     660             : 

Generated by: LCOV version 1.11