ROOT logo
#ifndef ALITPCCALROC_H
#define ALITPCCALROC_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id: AliTPCCalROC.h -1   */

//////////////////////////////////////////////////
//                                              //
//  TPC calibration base class for one ROC      //
//                                              //
//////////////////////////////////////////////////
#include <TObject.h>
#include <TMath.h>
#include <AliTPCROC.h>
#include "TLinearFitter.h"

class TH1F;
class TH2F;
class TArrayI;
class TF1;
//_____________________________________________________________________________
class AliTPCCalROC : public TNamed {

 public:
  
  AliTPCCalROC();
  AliTPCCalROC(UInt_t sector);
  AliTPCCalROC(const AliTPCCalROC &c);
 AliTPCCalROC &operator = (const AliTPCCalROC & param);
  virtual           ~AliTPCCalROC();  
  UInt_t        GetSector() const { return fSector;}
  UInt_t        GetNrows() const               { return fNRows;};
  UInt_t        GetNchannels()       const     { return fNChannels;};
  Bool_t        IsInRange(UInt_t row, UInt_t pad) { return (row<fNRows)? (fkIndexes[row]+pad)<fNChannels:kFALSE;}
  UInt_t        GetNPads(UInt_t row)  const     { return (row<fNRows)? AliTPCROC::Instance()->GetNPads(fSector,row):0;};
  Float_t      GetValue(UInt_t row, UInt_t pad) const { return ( (row<fNRows) && (fkIndexes[row]+pad)<fNChannels)? fData[fkIndexes[row]+pad]: 0; };
  Float_t      GetValue(UInt_t channel) const { return  fData[channel]; };
  void         SetValue(UInt_t row, UInt_t pad, Float_t vd) { if ( row<fNRows && (fkIndexes[row]+pad)<fNChannels)fData[fkIndexes[row]+pad]= vd; }
  void         SetValue(UInt_t channel, Float_t vd) {fData[channel]= vd; }
  void         Reset();
  virtual void Draw(Option_t* option = "");
  //
  Bool_t MedianFilter(Int_t deltaRow, Int_t deltaPad, AliTPCCalROC*outlierROC=0, Bool_t doEdge=kTRUE);
  Bool_t LTMFilter(Int_t deltaRow, Int_t deltaPad, Float_t fraction, Int_t type,  AliTPCCalROC*outlierROC=0, Bool_t doEdge=kTRUE);
  Bool_t Convolute(Double_t sigmaPad, Double_t sigmaRow,  AliTPCCalROC*outlierPad=0, TF1 *fpad=0, TF1 *frow=0 );
  //
  // algebra
  void Add(Float_t c1); // add c1 to each channel of the ROC
  void Multiply(Float_t c1); // multiply each channel of the ROC with c1
  void Add(const AliTPCCalROC * roc, Double_t c1 = 1);  // multiply AliTPCCalROC roc by c1 and add each channel to the coresponing channel in the ROC
  void Multiply(const AliTPCCalROC * roc);   // multiply each channel of the ROC with the coresponding channel of 'roc'
  void Divide(const AliTPCCalROC * roc);   // divide each channel of the ROC by the coresponding value of 'roc'
  // statistic
  //
  Double_t GetMean(AliTPCCalROC *const outlierROC = 0) const;
  Double_t GetRMS(AliTPCCalROC *const outlierROC = 0) const;
  Double_t GetMedian(AliTPCCalROC *const outlierROC = 0) const;
  Double_t GetLTM(Double_t *const sigma=0, Double_t fraction=0.9, AliTPCCalROC *const outlierROC = 0);
  TH1F * MakeHisto1D(Float_t min=4, Float_t max=-4, Int_t type=0);     
  TH2F * MakeHisto2D(Float_t min=4, Float_t max=-4, Int_t type=0);   
  TH2F * MakeHistoOutliers(Float_t delta=4, Float_t fraction=0.7, Int_t mode=0);

  AliTPCCalROC * LocalFit(Int_t rowRadius, Int_t padRadius, AliTPCCalROC* ROCoutliers = 0, Bool_t robust = kFALSE, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7);
  void GlobalFit(const AliTPCCalROC* ROCoutliers, Bool_t robust, TVectorD &fitParam, TMatrixD &covMatrix, Float_t & chi2, Int_t fitType = 1, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7, Double_t err=1);
  
  static AliTPCCalROC* CreateGlobalFitCalROC(TVectorD &fitParam, Int_t sector);
  
  static void Test();
 protected:
  
  Double_t GetNeighbourhoodValue(TLinearFitter* fitterQ, Int_t row, Int_t pad, Int_t rRadius, Int_t pRadius, AliTPCCalROC *const ROCoutliers, Bool_t robust, Double_t chi2Threshold, Double_t robustFraction);
  void GetNeighbourhood(TArrayI* &rowArray, TArrayI* &padArray, Int_t row, Int_t pad, Int_t rRadius, Int_t pRadius);
  
  UInt_t     fSector;          // sector number
  UInt_t     fNChannels;       // number of channels
  UInt_t     fNRows;           // number of rows
  const UInt_t* fkIndexes;      //!indexes
  Float_t  *fData;            //[fNChannels] Data
  ClassDef(AliTPCCalROC,2)    //  TPC ROC calibration class

};

#endif
 AliTPCCalROC.h:1
 AliTPCCalROC.h:2
 AliTPCCalROC.h:3
 AliTPCCalROC.h:4
 AliTPCCalROC.h:5
 AliTPCCalROC.h:6
 AliTPCCalROC.h:7
 AliTPCCalROC.h:8
 AliTPCCalROC.h:9
 AliTPCCalROC.h:10
 AliTPCCalROC.h:11
 AliTPCCalROC.h:12
 AliTPCCalROC.h:13
 AliTPCCalROC.h:14
 AliTPCCalROC.h:15
 AliTPCCalROC.h:16
 AliTPCCalROC.h:17
 AliTPCCalROC.h:18
 AliTPCCalROC.h:19
 AliTPCCalROC.h:20
 AliTPCCalROC.h:21
 AliTPCCalROC.h:22
 AliTPCCalROC.h:23
 AliTPCCalROC.h:24
 AliTPCCalROC.h:25
 AliTPCCalROC.h:26
 AliTPCCalROC.h:27
 AliTPCCalROC.h:28
 AliTPCCalROC.h:29
 AliTPCCalROC.h:30
 AliTPCCalROC.h:31
 AliTPCCalROC.h:32
 AliTPCCalROC.h:33
 AliTPCCalROC.h:34
 AliTPCCalROC.h:35
 AliTPCCalROC.h:36
 AliTPCCalROC.h:37
 AliTPCCalROC.h:38
 AliTPCCalROC.h:39
 AliTPCCalROC.h:40
 AliTPCCalROC.h:41
 AliTPCCalROC.h:42
 AliTPCCalROC.h:43
 AliTPCCalROC.h:44
 AliTPCCalROC.h:45
 AliTPCCalROC.h:46
 AliTPCCalROC.h:47
 AliTPCCalROC.h:48
 AliTPCCalROC.h:49
 AliTPCCalROC.h:50
 AliTPCCalROC.h:51
 AliTPCCalROC.h:52
 AliTPCCalROC.h:53
 AliTPCCalROC.h:54
 AliTPCCalROC.h:55
 AliTPCCalROC.h:56
 AliTPCCalROC.h:57
 AliTPCCalROC.h:58
 AliTPCCalROC.h:59
 AliTPCCalROC.h:60
 AliTPCCalROC.h:61
 AliTPCCalROC.h:62
 AliTPCCalROC.h:63
 AliTPCCalROC.h:64
 AliTPCCalROC.h:65
 AliTPCCalROC.h:66
 AliTPCCalROC.h:67
 AliTPCCalROC.h:68
 AliTPCCalROC.h:69
 AliTPCCalROC.h:70
 AliTPCCalROC.h:71
 AliTPCCalROC.h:72
 AliTPCCalROC.h:73
 AliTPCCalROC.h:74
 AliTPCCalROC.h:75
 AliTPCCalROC.h:76
 AliTPCCalROC.h:77
 AliTPCCalROC.h:78
 AliTPCCalROC.h:79
 AliTPCCalROC.h:80
 AliTPCCalROC.h:81
 AliTPCCalROC.h:82
 AliTPCCalROC.h:83
 AliTPCCalROC.h:84