LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCCalibCE.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 48 2.1 %
Date: 2016-06-14 17:26:59 Functions: 1 46 2.2 %

          Line data    Source code
       1             : #ifndef ALITPCCALIBCE_H
       2             : #define ALITPCCALIBCE_H
       3             : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       4             :  * See cxx source for full Copyright notice                               */
       5             : 
       6             : /// \class AliTPCCalibCE
       7             : /// \brief Implementation of the TPC Central Electrode calibration
       8             : 
       9             : #include <TVectorT.h>
      10             : #include <THnSparse.h>
      11             : 
      12             : #include "AliTPCCalibRawBase.h"
      13             : class TH1S;
      14             : #include "TObjArray.h"
      15             : class TH2S;
      16             : class TH1F;
      17             : class TTreeSRedirector;
      18             : class AliTPCCalPad;
      19             : class AliTPCROC;
      20             : class AliTPCCalROC;
      21             : class AliTPCParam;
      22             : class AliRawReader;
      23             : class TGraph;
      24             : class TMap;
      25             : class TCollection;
      26             : 
      27             : struct eventHeaderStruct;
      28             : 
      29             : class AliTPCCalibCE : public AliTPCCalibRawBase {
      30             : 
      31             : public:
      32             :   AliTPCCalibCE();
      33             :   AliTPCCalibCE(const AliTPCCalibCE &sig);
      34             :   AliTPCCalibCE(const TMap *config);
      35             :   virtual ~AliTPCCalibCE();
      36             : 
      37             :   AliTPCCalibCE& operator = (const  AliTPCCalibCE &source);
      38             : 
      39             :   virtual Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
      40             :                        const Int_t iTimeBin, const Float_t signal);
      41             :   virtual void ProcessBunch(const Int_t sector, const Int_t row, const Int_t pad,
      42             :                             const Int_t length, const UInt_t startTimeBin, const UShort_t* signal);
      43             : 
      44             :   virtual void Analyse();
      45             :   void AnalyseTrack();
      46             : 
      47             :     //
      48             :   AliTPCCalROC* GetCalRocT0  (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
      49             :   AliTPCCalROC* GetCalRocT0Err(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
      50             :   AliTPCCalROC* GetCalRocQ   (Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
      51             :   AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
      52             :   AliTPCCalROC* GetCalRocOutliers(Int_t sector, Bool_t force=kFALSE);  // get calibration object - sector
      53             : 
      54           0 :   const TObjArray* GetCalPadT0()    const { return &fCalRocArrayT0; }      // get calibration object
      55           0 :   const TObjArray* GetCalPadT0Err() const { return &fCalRocArrayT0Err; }      // get calibration object
      56           0 :   const TObjArray* GetCalPadQ()     const { return &fCalRocArrayQ;  }      // get calibration object
      57           0 :   const TObjArray* GetCalPadRMS()   const { return &fCalRocArrayRMS;}      // get calibration object
      58           0 :   const TObjArray* GetCalPadOutliers() const { return &fCalRocArrayOutliers;}      // get calibration object
      59             : 
      60             :   TH2S* GetHistoQ  (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
      61             :   TH2S* GetHistoT0 (Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
      62             :   TH2S* GetHistoRMS(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
      63             : 
      64           0 :   Float_t GetMeanT0rms() const {return fMeanT0rms;}
      65           0 :   Float_t GetMeanQrms() const {return fMeanQrms;}
      66           0 :   Float_t GetMeanRMSrms() const {return fMeanRMSrms;}
      67             : 
      68           0 :   Int_t   GetPeakDetectionMinus() const {return fPeakDetMinus;}
      69           0 :   Int_t   GetPeakDetectionPlus()  const {return fPeakDetPlus;}
      70           0 :   Int_t   GetPeakIntRangeMinus() const {return fPeakIntMinus;}
      71           0 :   Int_t   GetPeakIntRangePlus()  const {return fPeakIntPlus;}
      72           0 :   Float_t GetNnoiseThresholdMax() const {return fNoiseThresholdMax;}
      73           0 :   Float_t GetNnoiseThresholdSum() const {return fNoiseThresholdSum;}
      74             : 
      75             :   TH1S* GetHistoTmean(Int_t sector, Bool_t force=kFALSE);           // get refernce histogram
      76             : 
      77             :     //needed here to merge ClibCE objects
      78             :   TObjArray* GetParamArrayPol1(Int_t sector, Bool_t force=kFALSE);
      79             :   TObjArray* GetParamArrayPol2(Int_t sector, Bool_t force=kFALSE);
      80             : 
      81             : //    TObjArray*  GetTMeanArrayEvent(){ return &fTMeanArrayEvent; }
      82             : //    TObjArray*  GetQMeanArrayEvent(){ return &fQMeanArrayEvent; }
      83             :   TVectorF* GetTMeanEvents(Int_t sector, Bool_t force=kFALSE);
      84             :   TVectorF* GetQMeanEvents(Int_t sector, Bool_t force=kFALSE);
      85             : 
      86           0 :   const TVectorD*   GetEventTimes()  const   { return &fVEventTime;      }
      87           0 :   const TVectorD*   GetEventIds()    const   { return &fVEventNumber;    }
      88             : 
      89             :   //
      90           0 :   void  SetRangeRefQ  (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ   = nBins; fXminQ   = xMin; fXmaxQ   = xMax; }   //Set range for Q reference histograms
      91           0 :   void  SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0  = nBins; fXminT0  = xMin; fXmaxT0  = xMax; }   //Set range for T0 reference histograms
      92           0 :   void  SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; }   //Set range for T0 reference histograms
      93             :   //
      94           0 :   void  SetRangePeakDetection(Int_t minus, Int_t plus) { fPeakDetMinus=minus; fPeakDetPlus=plus;}
      95           0 :   void  SetRangePeakIntegral(Int_t minus, Int_t plus) { fPeakIntMinus=minus; fPeakIntPlus=plus;}
      96           0 :   void  SetNnoiseThresholdMax(Float_t n) {fNoiseThresholdMax=n;}
      97           0 :   void  SetNnoiseThresholdSum(Float_t n) {fNoiseThresholdSum=n;}
      98             :   //
      99           0 :   void  SetEventInfo(UInt_t runNumber,UInt_t timestamp, UInt_t eventId){ fRunNumber=runNumber; fTimeStamp=timestamp; fEventId=eventId;}
     100             :   //
     101           0 :   void  SetPedestalDatabase(AliTPCCalPad * const pedestalTPC, AliTPCCalPad * const padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;}
     102           0 :   void  SetIsZeroSuppressed(Bool_t zs=kTRUE) { fIsZeroSuppressed=zs; }
     103           0 :   void  SetSecRejectRatio(Float_t ratio) { fSecRejectRatio=ratio; }
     104             : 
     105           0 :   void SetProcessOld(Bool_t process=kTRUE) {fProcessOld=process;}
     106           0 :   void SetProcessNew(Bool_t process=kTRUE) {fProcessNew=process; if (process&&!fHnDrift) CreateDVhist(); }
     107           0 :   void SetROCblackData(Int_t rocblackDataDown=-1, Int_t rocblackDataUp=-1) {fROCblackDataDown=rocblackDataDown; fROCblackDataUp=rocblackDataUp;}
     108             :   //Getters
     109           0 :   Int_t GetNeventsProcessed() const { return fNevents; }
     110             : 
     111           0 :   Bool_t GetIsZeroSuppressed() const { return fIsZeroSuppressed; }
     112             : 
     113           0 :   Float_t  GetSecRejectRatio() const { return fSecRejectRatio; }
     114             : 
     115           0 :   const TVectorF *GetTime0Side(Int_t side=0) const {return (side==0)?&fVTime0SideA:&fVTime0SideC;}
     116           0 :   Float_t GetPeakIntegralMinus() const {return fPeakIntMinus;}
     117           0 :   Float_t GetPeakIntegralPlus() const {return fPeakIntPlus;}
     118             : 
     119             : 
     120             :   void Merge(AliTPCCalibCE * const ce);
     121             :   virtual Long64_t Merge(TCollection * const list);
     122             : 
     123             :   TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0);
     124             : 
     125             :   //
     126             :   // New functions using also the laser tracks
     127             :   //
     128             :   Bool_t IsEdgePad(Int_t sector, Int_t row, Int_t pad) const;
     129             : 
     130             :   void FindLocalMaxima(TObjArray * const arrObj, Double_t timestamp, Int_t burst);
     131             :   Int_t FindLaserTrackID(Int_t sector,Int_t row, const Double_t *peakpos,Double_t &mindist, const Double_t *peakposloc, Int_t &itrackMin2);
     132             : 
     133           0 :   const THnSparseI *GetHnDrift() const {return fHnDrift;}
     134           0 :   const TObjArray& GetArrHnDrift() const {return fArrHnDrift;}
     135           0 :   const TVectorD&  GetTimeBursts() const {return fTimeBursts;}
     136           0 :   const TObjArray  *GetArrFitGraphs() const {return fArrFitGraphs;}
     137             : 
     138             :   virtual void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
     139             : 
     140             :   static AliTPCCalibCE *ReadFromFile(const Char_t *filename);
     141             : 
     142             : protected:
     143             :   virtual void EndEvent();
     144             :   virtual void ResetEvent();
     145             : 
     146             : private:
     147             :     // reference histogram ranges
     148             :   Int_t   fNbinsT0;                 ///< Number of bins for T0 reference histogram
     149             :   Float_t fXminT0;                  ///< xmin   of T0 reference histogram
     150             :   Float_t fXmaxT0;                  ///< xmax   of T0 reference histogram
     151             :   Int_t   fNbinsQ;                  ///< Number of bins for T0 reference histogram
     152             :   Float_t fXminQ;                   ///< xmin   of T0 reference histogram
     153             :   Float_t fXmaxQ;                   ///< xmax   of T0 reference histogram
     154             :   Int_t   fNbinsRMS;                ///< Number of bins for T0 reference histogram
     155             :   Float_t fXminRMS;                 ///< xmin   of T0 reference histogram
     156             :   Float_t fXmaxRMS;                 ///< xmax   of T0 reference histogram
     157             :   Int_t   fPeakDetMinus;               ///< Consecutive timebins on rising edge to be regarded as a signal
     158             :   Int_t   fPeakDetPlus;                ///< Consecutive timebins on falling edge to be regarded as a signal
     159             :   Int_t   fPeakIntMinus;            ///< Peak integral range for COG determination. Bins used before max bin
     160             :   Int_t   fPeakIntPlus;             ///< Peak integral range for COG determination. Bins used after max bin
     161             :   Float_t fNoiseThresholdMax;       ///< Analysis Treshold for signal finding: Max>fNoiseThresholdMax*PadNoise
     162             :   Float_t fNoiseThresholdSum;       ///< Analysis Treshold for signal finding: Sum>fNoiseThresholdSum*PadNoise
     163             :   Int_t   fROCblackDataUp;          ///< Upper edge of ROC range to be processed in case of black event. if -1; online drif velocity algorithm
     164             :   Int_t   fROCblackDataDown;        ///< Lower edge of ROC rabge to be processed in case of black event. if -1; online drif velocity algorithm. 
     165             : 
     166             :   Bool_t  fIsZeroSuppressed;        ///< If data is Zero Suppressed -> Don't subtrakt pedestals!
     167             : 
     168             :   Int_t     fLastSector;            //!<! Last sector processed
     169             : 
     170             :   Float_t   fSecRejectRatio;        //!<! Needed percentage of signals in one chamber. Below it will be rejected
     171             :                                       //  This is neede if we do not process a laser event
     172             : 
     173             :   AliTPCParam *fParam;              //!<! TPC information
     174             : 
     175             :   AliTPCCalPad *fPedestalTPC;       //!<! Pedestal Information whole TPC
     176             :   AliTPCCalPad *fPadNoiseTPC;       //!<! Pad noise Information whole TPC
     177             :   AliTPCCalROC *fPedestalROC;       //!<! Pedestal Information for current ROC
     178             :   AliTPCCalROC *fPadNoiseROC;       //!<! Pad noise Information for current ROC
     179             : 
     180             :   TObjArray fCalRocArrayT0;         ///< Array of AliTPCCalROC class for Time0 calibration
     181             :   TObjArray fCalRocArrayT0Err;      ///< Array of AliTPCCalROC class for the error (rms) of Time0 calibration
     182             :   TObjArray fCalRocArrayQ;          ///< Array of AliTPCCalROC class for Charge calibration
     183             :   TObjArray fCalRocArrayRMS;        ///< Array of AliTPCCalROC class for signal width calibration
     184             :   TObjArray fCalRocArrayOutliers;   ///< Array of AliTPCCalROC class for signal outliers
     185             : 
     186             :   TObjArray fHistoQArray;           ///< Calibration histograms for Charge distribution
     187             :   TObjArray fHistoT0Array;          ///< Calibration histograms for Time0  distribution
     188             :   TObjArray fHistoRMSArray;         ///< Calibration histograms for signal width distribution
     189             : 
     190             :   Float_t   fMeanT0rms;             ///< mean of the rms of all pad T0  fits, used as error estimation of T0 results
     191             :   Float_t   fMeanQrms;              ///< mean of the rms of all pad Q   fits, used as error estimation of Q results
     192             :   Float_t   fMeanRMSrms;            ///< mean of the rms of all pad TMS fits, used as error estimation of RMS results
     193             : 
     194             :   TObjArray fHistoTmean;            //!<! Calibration histograms of the mean CE position for all sectors
     195             : 
     196             :   TObjArray fParamArrayEventPol1;   ///< Store mean arrival time parameters for each sector event by event from global plane fit
     197             :   TObjArray fParamArrayEventPol2;   ///< Store mean arrival time parameters for each sector event by event from global parabola fit
     198             :   TObjArray fTMeanArrayEvent;       ///< Store mean arrival time for each sector event by event
     199             :   TObjArray fQMeanArrayEvent;       ///< Store mean arrival Charge for each sector event by event
     200             :   TVectorD  fVEventTime;            ///< Timestamps of the events
     201             :   TVectorD  fVEventNumber;          ///< Eventnumbers of the events
     202             :   TVectorF  fVTime0SideA;           ///< Mean Time0 for side A for all events
     203             :   TVectorF  fVTime0SideC;           ///< Mean Time0 for side C for all events
     204             :   Double_t  fEventId;               //!<! Event Id of the current event
     205             :   UInt_t  fOldRunNumber;          //!<! Old Run Number
     206             : 
     207             :   TObjArray fPadTimesArrayEvent;    //!<! Pad Times for the event, before mean Time0 corrections
     208             :   TObjArray fPadQArrayEvent;        //!<! Charge for the event, only needed for debugging streamer
     209             :   TObjArray fPadRMSArrayEvent;      //!<! Signal width for the event, only needed for debugging streamer
     210             :   TObjArray fPadPedestalArrayEvent; //!<! Signal width for the event, only needed for debugging streamer
     211             : 
     212             :   Int_t     fCurrentChannel;        //!<! current channel processed
     213             :   Int_t     fCurrentSector;         //!<! current sector processed
     214             :   Int_t     fCurrentRow;            //!<! current row processed
     215             :   Float_t   fMaxPadSignal;          //!<! maximum bin of current pad
     216             :   Int_t     fMaxTimeBin;            //!<! time bin with maximum value
     217             :   Float_t   fPadSignal[1024];       //!<! signal of current Pad
     218             :   Float_t   fPadPedestal;           //!<! Pedestal Value of current pad
     219             :   Float_t   fPadNoise;              //!<! Noise Value of current pad
     220             : 
     221             :   TVectorD  fVTime0Offset;          //!<! Time0 Offset for each sector;
     222             :   TVectorD  fVTime0OffsetCounter;   //!<! Time0 Offset counter for each sector;
     223             :   TVectorD  fVMeanQ;                //!<! Mean Q for each sector;
     224             :   TVectorD  fVMeanQCounter;         //!<! Mean Q counter for each sector;
     225             : 
     226             :   Float_t   fCurrentCETimeRef;      //!<! Time refernce of the current sector
     227             : 
     228             :   // new part of the algorithm
     229             :   Bool_t      fProcessOld;             ///< Whether to use the old algorithm
     230             :   Bool_t      fProcessNew;             ///< Whether to use the new algorithm
     231             :   Bool_t      fAnalyseNew;             //!<! Whether to analyse the new part of the algorithm.
     232             :                                        //In the DA this needs to be switched off, in the Preprocessor on...
     233             :   enum {kHnBinsDV=5};
     234             :   THnSparseI *fHnDrift;                //!<! Histogram digits for each pad and timebin for several timestamps
     235             :   TObjArray   fArrHnDrift;             ///< array of sparse histograms for each burst
     236             :   TVectorD    fTimeBursts;             ///< time stamps of bursts
     237             :   UInt_t      fBinsLastAna[100];       ///< number of bin in the THnSparse during the last analysis
     238             :   UShort_t    fPeaks[14];               //!<! Peak position: 4 laser layers and CE
     239             :   UShort_t    fPeakWidths[14];          //!<! Peak window widths
     240             :   TObjArray  *fArrFitGraphs;           ///< Fit resut graphs for each parameter
     241             :   UInt_t      fEventInBunch;           //!<! event in current bunch
     242             : 
     243             : 
     244             :   //
     245             :   void   FindPedestal(Float_t part=.6);
     246             :   void   UpdateCETimeRef(); //Get the time reference of the last valid measurement in sector
     247             :   void   FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF maxima);
     248             :   void   FindLocalMaxima(TVectorF &maxima);
     249             :   Bool_t IsPeak(Int_t pos, Int_t tminus, Int_t tplus) const;
     250             : 
     251             :   TH2S* GetHisto(Int_t sector, TObjArray *arr,
     252             :                  Int_t nbinsY, Float_t ymin, Float_t ymax,
     253             :                  const Char_t *type, Bool_t force);
     254             :   TH1S* GetHisto(Int_t sector, TObjArray *arr,
     255             :                  const Char_t *type, Bool_t force);
     256             : 
     257             :   AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const;
     258             : 
     259             :   TVectorF* GetVectSector(Int_t sector, TObjArray *arr, UInt_t size, Bool_t force=kFALSE) const;
     260             :   TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE);
     261             : 
     262             :   TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE) const;
     263             : 
     264             :   void ResetPad();
     265             :   void ProcessPad();
     266             : 
     267             :   // new part of the algorithm
     268             :   void CreateDVhist();
     269             : 
     270             :   void   FindLaserLayers();
     271             :   Bool_t IsPeakInRange(UShort_t timebin, Int_t roc) const;
     272             : 
     273             :   TObjArray *SetupMeasured();
     274             :   void ResetMeasured(TObjArray * const arr);
     275             : 
     276             :   void AddCEtoIdeal(TObjArray *arr);
     277             : 
     278             :   void CalculateDV(TObjArray * const arrIdeal, TObjArray * const arrMeasured, Int_t burst);
     279             :   Double_t SetBurstHnDrift();
     280             :   //debug
     281             :   TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE);
     282             :   TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE);
     283             :   TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE);
     284             : 
     285             :   /// \cond CLASSIMP
     286          24 :   ClassDef(AliTPCCalibCE,11)  //Implementation of the TPC Central Electrode calibration
     287             :   /// \endcond
     288             : };
     289             : 
     290             : //Inline functions
     291             : //_____________________________________________________________________
     292             : inline Bool_t AliTPCCalibCE::IsPeakInRange(UShort_t timebin, Int_t roc) const
     293             : {
     294             :   /// Check whether timebin is in the range of a laser layer
     295             : 
     296           0 :   Int_t side=(roc/18)%2;
     297           0 :   Int_t add=7*side;
     298             : //   return kTRUE;
     299           0 :   if (fPeaks[13]<2) return kTRUE; //not determined yet
     300           0 :   for (Int_t i=add; i<add+7; ++i){
     301           0 :     if (TMath::Abs((Short_t)timebin-(Short_t)fPeaks[i])<(Short_t)fPeakWidths[i]) return kTRUE;
     302             :   }
     303           0 :   return kFALSE;
     304           0 : }
     305             : 
     306             : #endif

Generated by: LCOV version 1.11