]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFit.h
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.h
index 20c10778bc7e48e816c8a87446cbb17698079452..eb91f40acc79c63384177c5d39b0fd0bfbcf56b9 100644 (file)
@@ -18,6 +18,7 @@
 # include <TVectorD.h>
 #endif 
 
+class TString;
 class TTree;
 class TProfile2D;
 class TGraphErrors;
@@ -30,11 +31,13 @@ class TH2F;
 class TF1;
 class TTreeSRedirector;
 
+
 class AliLog;
 
 class AliTRDCalibraMode;
 class AliTRDCalibraVector;
 class AliTRDCalibraVdriftLinearFit;
+class AliTRDCalibraExbAltFit;
 class AliTRDCalDet;
 class AliTRDCalROC;
 class AliTRDgeometry;
@@ -52,90 +55,102 @@ class AliTRDCalibraFit : public TObject {
   AliTRDCalibraFit(const AliTRDCalibraFit &c);
   AliTRDCalibraFit &operator=(const AliTRDCalibraFit &) { return *this; }
 
-       // Function for integration range of the charge 
-       void     RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const;
+  // ExB calibration
+  void     SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;};
   
-       // Functions fit for CH
-       Bool_t   AnalyseCH(const TH2I *ch);
-       Bool_t   AnalyseCH(AliTRDCalibraVector *calvect);
-       
-       // Functions fit for PH       
-       Bool_t   AnalysePH(const TProfile2D *ph);
-       Bool_t   AnalysePH(AliTRDCalibraVector *calvect);
-       
-       // Functions fit for PRF
-       Bool_t   AnalysePRF(const TProfile2D *prf);
-       Bool_t   AnalysePRF(AliTRDCalibraVector *calvect);
-       
-       Bool_t   AnalysePRFMarianFit(const TProfile2D *prf);
-       Bool_t   AnalysePRFMarianFit(AliTRDCalibraVector *calvect);
-       
-       // Functions fit for vdrift/lorentzangle
-       Bool_t   AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli);
-       
-       // Pad Calibration
-       Bool_t   SetModeCalibration(const char *name, Int_t i);
-       
-       //Reset Function
-       void     ResetVectorFit();
-       
-       // Some functions
-       Double_t *CalculPolynomeLagrange2(const Double_t *x, const Double_t *y) const;
-       Double_t *CalculPolynomeLagrange3(const Double_t *x, const Double_t *y) const;
-       Double_t *CalculPolynomeLagrange4(const Double_t *x, const Double_t *y) const;
-       
-       // Fill the database
-       void         PutMeanValueOtherVectorFit(Int_t ofwhat = 1, Bool_t perdetector = kFALSE);
-       void         PutMeanValueOtherVectorFit2(Int_t ofwhat = 1, Bool_t perdetector = kFALSE);
-       AliTRDCalDet *CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector = kFALSE);
-       AliTRDCalDet *CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore=kTRUE, Double_t scaleFitFactor = 0.02431, Bool_t perdetector = kTRUE);
-       AliTRDCalDet *CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector = kFALSE);
-       AliTRDCalDet *CreateDetObjectLorentzAngle(const TObjArray *vectorFit);
-       
-       TObject      *CreatePadObjectGain(const TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, const AliTRDCalDet *detobject = 0);
-       TObject      *CreatePadObjectVdrift(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0);
-       TObject      *CreatePadObjectT0(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0);
-       TObject      *CreatePadObjectPRF(const TObjArray *vectorFit);
-       
-       // Outliers stats
-       AliTRDCalDet *MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean);
-       TObject      *MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean);
+  // Functions fit for CH
+  Bool_t   AnalyseCH(const TH2I *ch);
+  Bool_t   AnalyseCH(AliTRDCalibraVector *calvect);
+  Double_t AnalyseCHAllTogether(const TH2I *ch);
+  
+  // Functions fit for PH       
+  Bool_t   AnalysePH(const TProfile2D *ph);
+  Bool_t   AnalysePH(AliTRDCalibraVector *calvect);
+  Double_t AnalysePHAllTogether(const TProfile2D *ph);
+  
+  // Functions fit for PRF
+  Bool_t   AnalysePRF(const TProfile2D *prf);
+  Bool_t   AnalysePRF(AliTRDCalibraVector *calvect);
+  
+  Bool_t   AnalysePRFMarianFit(const TProfile2D *prf);
+  Bool_t   AnalysePRFMarianFit(AliTRDCalibraVector *calvect);
+  
+  // Functions fit for vdrift/lorentzangle
+  Bool_t   AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli);
+  void     AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall);
+  Bool_t   AnalyseExbAltFit(AliTRDCalibraExbAltFit *calivdli);
+  
+  // Pad Calibration
+  Bool_t   SetModeCalibration(TString name, Int_t i);
+  
+  //Reset Function
+  void     ResetVectorFit();
+  
+  // Some functions
+  void CalculPolynomeLagrange2(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const;
+  void CalculPolynomeLagrange3(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const;
+  void CalculPolynomeLagrange4(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const;
+  
+  // Fill the database
+  void         RemoveOutliers(Int_t type, Bool_t perdetector = kFALSE);
+  void         RemoveOutliers2(Bool_t perdetector = kFALSE);
+  void         PutMeanValueOtherVectorFit(Int_t ofwhat = 1, Bool_t perdetector = kFALSE);
+  void         PutMeanValueOtherVectorFit2(Int_t ofwhat = 1, Bool_t perdetector = kFALSE);
+  AliTRDCalDet *CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector = kFALSE);
+  AliTRDCalDet *CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore=kTRUE, Double_t scaleFitFactor = 0.02431, Bool_t perdetector = kTRUE);
+  AliTRDCalDet *CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector = kFALSE);
+  AliTRDCalDet *CreateDetObjectLorentzAngle(const TObjArray *vectorFit);
+  AliTRDCalDet *CreateDetObjectExbAlt(const TObjArray *vectorFit);
+  
+  TObject      *CreatePadObjectGain(const TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, const AliTRDCalDet *detobject = 0);
+  TObject      *CreatePadObjectVdrift(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0);
+  TObject      *CreatePadObjectT0(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0);
+  TObject      *CreatePadObjectPRF(const TObjArray *vectorFit);
+  
+  // Outliers stats
+  AliTRDCalDet *MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean);
+  TObject      *MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean);
        
-       //
-       // Set or Get the variables
-       //
+  //
+  // Set or Get the variables
+  //
+  
+  // Fit
+  void     ChooseMethod(Short_t method)                              { fMethod = method;               }
+  void     SetBeginFitCharge(Float_t beginFitCharge);   
+  void     SetFitOutliersChargeLow(Float_t fitOutliersChargeLow)     { fOutliersFitChargeLow = fitOutliersChargeLow; }
+  void     SetFitOutliersChargeHigh(Float_t fitOutliersChargeHigh)   { fOutliersFitChargeHigh = fitOutliersChargeHigh; }
+  void     SetPeriodeFitPH(Int_t periodeFitPH);   
+  void     SetTakeTheMaxPH()                                         { fTakeTheMaxPH   = kTRUE;        }
+  void     SetT0Shift0(Float_t t0Shift0); 
+  void     SetT0Shift1(Float_t t0Shift1); 
+  void     SetRangeFitPRF(Float_t rangeFitPRF);     
+  void     SetAccCDB()                                               { fAccCDB         = kTRUE;        }
+  void     SetMinEntries(Int_t minEntries);                    
+  void     SetRebin(Short_t rebin);
+  
+  Int_t    GetPeriodeFitPH() const                                   { return fFitPHPeriode;           }
+  Float_t  GetFitOutliersChargeLow() const                           { return fOutliersFitChargeLow;   }
+  Float_t  GetFitOutliersChargeHigh() const                          { return fOutliersFitChargeHigh;  }
+  Bool_t   GetTakeTheMaxPH() const                                   { return fTakeTheMaxPH;           }
+  Float_t  GetT0Shift0() const                                       { return fT0Shift0;               }
+  Float_t  GetT0Shift1() const                                       { return fT0Shift1;               }
+  Float_t  GetRangeFitPRF() const                                    { return fRangeFitPRF;            }
+  Bool_t   GetAccCDB() const                                         { return fAccCDB;                 }
+  Int_t    GetMinEntries() const                                     { return fMinEntries;             }
+  Short_t  GetRebin() const                                          { return fRebin;                  }
+  Float_t  GetScaleFactorGain() const                                { return fScaleGain;              }
+  
+  // Statistics
+  Int_t    GetNumberFit() const                                      { return fNumberFit;              }
+  Int_t    GetNumberFitSuccess() const                               { return fNumberFitSuccess;       }
+  Int_t    GetNumberEnt() const                                      { return fNumberEnt;              }
+  Double_t GetStatisticMean() const                                  { return fStatisticMean;          }
+  
        
-       // Fit
-       void     ChooseMethod(Short_t method)                              { fMethod = method;               }
-       void     SetBeginFitCharge(Float_t beginFitCharge);   
-       void     SetPeriodeFitPH(Int_t periodeFitPH);   
-       void     SetTakeTheMaxPH()                                         { fTakeTheMaxPH   = kTRUE;        }
-       void     SetT0Shift0(Float_t t0Shift0); 
-       void     SetT0Shift1(Float_t t0Shift1); 
-       void     SetRangeFitPRF(Float_t rangeFitPRF);     
-       void     SetAccCDB()                                               { fAccCDB         = kTRUE;        }
-       void     SetMinEntries(Int_t minEntries);                    
-       void     SetRebin(Short_t rebin);
-       
-       Int_t    GetPeriodeFitPH() const                                   { return fFitPHPeriode;           }
-       Bool_t   GetTakeTheMaxPH() const                                   { return fTakeTheMaxPH;           }
-       Float_t  GetT0Shift0() const                                       { return fT0Shift0;               }
-       Float_t  GetT0Shift1() const                                       { return fT0Shift1;               }
-       Float_t  GetRangeFitPRF() const                                    { return fRangeFitPRF;            }
-       Bool_t   GetAccCDB() const                                         { return fAccCDB;                 }
-       Int_t    GetMinEntries() const                                     { return fMinEntries;             }
-       Short_t  GetRebin() const                                          { return fRebin;                  }
-       
-       // Statistics
-       Int_t    GetNumberFit() const                                      { return fNumberFit;              }
-       Int_t    GetNumberFitSuccess() const                               { return fNumberFitSuccess;       }
-       Int_t    GetNumberEnt() const                                      { return fNumberEnt;              }
-       Double_t GetStatisticMean() const                                  { return fStatisticMean;          }
-       
-       
-       // Debug
-       void     SetDebugLevel(Short_t level)                              { fDebugLevel = level;            }
-       void     SetDet(Int_t iLayer, Int_t iStack, Int_t iSector)         { fDet[0]  = iLayer; 
+  // Debug
+  void     SetDebugLevel(Short_t level)                              { fDebugLevel = level;            }
+  void     SetDet(Int_t iLayer, Int_t iStack, Int_t iSector)         { fDet[0]  = iLayer; 
                                                                             fDet[1]  = iStack; 
                                                                             fDet[2]  = iSector;             }
        void     SetFitVoir(Int_t fitVoir)                                 { fFitVoir = fitVoir;             }
@@ -167,7 +182,7 @@ class AliTRDCalibraFit : public TObject {
         AliTRDFitInfo &operator=(const AliTRDFitInfo&)     { return *this;            }
         virtual ~AliTRDFitInfo()                           { if(fCoef) { delete [] fCoef;} }
         
-        void      SetCoef(Float_t *coef)             { fCoef = coef;            }
+        void      SetCoef(Float_t *coef)                   { fCoef = coef;            }
         void      SetDetector(Int_t detector)              { fDetector = detector;    }
         
         Float_t  *GetCoef() const                          { return fCoef;            }
@@ -180,6 +195,8 @@ class AliTRDCalibraFit : public TObject {
         
        };
 
+       // Fit function
+       void     FitLagrangePoly(TH1* projPH);
 
  protected:
        
@@ -192,6 +209,8 @@ class AliTRDCalibraFit : public TObject {
        // Fit
        Short_t      fMethod;                // Method
        Float_t      fBeginFitCharge;        // The fit begins at mean/fBeginFitCharge for the gain calibration
+       Float_t      fOutliersFitChargeLow;  // The fit ends at fOutliersFitCharge procent number of entries
+       Float_t      fOutliersFitChargeHigh; // The fit ends at fOutliersFitCharge procent number of entries
        Int_t        fFitPHPeriode;          // Periode of the fit PH
        Bool_t       fTakeTheMaxPH;          // Take the Max for the T0 determination
        Float_t      fT0Shift0;              // T0 Shift with the maximum positive slope
@@ -200,6 +219,7 @@ class AliTRDCalibraFit : public TObject {
        Bool_t       fAccCDB;                // If there is a calibration database to be compared with....
        Int_t        fMinEntries;            // Min Entries to fit the histo
        Short_t      fRebin;                 // If you want to rebin the histo for the gain calibration 
+       Float_t      fScaleGain;            // Scale Factor used to scale the gain
        
        // Statistics      
        Int_t        fNumberFit;             // To know how many pad groups have been fitted
@@ -240,6 +260,9 @@ class AliTRDCalibraFit : public TObject {
        AliTRDCalROC *fCalROC;            // Current calib object
        AliTRDCalDet *fCalDet2;           // Current calib object
        AliTRDCalROC *fCalROC2;           // Current calib object
+
+       AliTRDCalDet *fCalDetVdriftUsed;  // ExB calibration
+       AliTRDCalDet *fCalDetExBUsed;     // ExB calibration
        
        // Current values detector
        
@@ -259,23 +282,27 @@ class AliTRDCalibraFit : public TObject {
        Bool_t   InitFitPH();
        Bool_t   InitFitPRF();
        Bool_t   InitFitLinearFitter();
+       Bool_t   InitFitExbAlt();
        
        // Not enough Statistics
        Bool_t   NotEnoughStatisticCH(Int_t idect);
        Bool_t   NotEnoughStatisticPH(Int_t idect,Double_t nentries);
        Bool_t   NotEnoughStatisticPRF(Int_t idect);
        Bool_t   NotEnoughStatisticLinearFitter();
+       Bool_t   NotEnoughStatisticExbAlt();
        
        // Fill Infos Fit
        Bool_t   FillInfosFitCH(Int_t idect);
        Bool_t   FillInfosFitPH(Int_t idect,Double_t nentries);
        Bool_t   FillInfosFitPRF(Int_t idect);
        Bool_t   FillInfosFitLinearFitter();
+       Bool_t   FillInfosFitExbAlt();
        
        void     FillFillCH(Int_t idect);
        void     FillFillPH(Int_t idect,Double_t nentries);
        void     FillFillPRF(Int_t idect);
        void     FillFillLinearFitter();
+       void     FillFillExbAlt();
        
        Bool_t   FillVectorFit();
        Bool_t   FillVectorFit2();
@@ -288,9 +315,9 @@ class AliTRDCalibraFit : public TObject {
        void     ReconstructFitRowMinRowMax(Int_t idect, Int_t i);
        Bool_t   CheckFitVoir();
        void     NormierungCharge();
-       Bool_t   SetNrphiFromTObject(const char *name, Int_t i);
-       Bool_t   SetNzFromTObject(const char *name, Int_t i);
-       Int_t    GetNumberOfGroupsPRF(const char* nametitle);
+       Bool_t   SetNrphiFromTObject(TString name, Int_t i);
+       Bool_t   SetNzFromTObject(TString name, Int_t i);
+       Int_t    GetNumberOfGroupsPRF(TString nametitle);
        
        // Calculate the mean coefs from the database
        Bool_t   CalculVdriftCoefMean();
@@ -302,8 +329,10 @@ class AliTRDCalibraFit : public TObject {
        void     SetCalROC(Int_t i);
        
        // Fit methods
-       void     FitBisCH(TH1 *projch, Double_t mean);
-       void     FitCH(TH1 *projch, Double_t mean);
+       void     FitBisCHEx(TH1 *projch, Double_t mean, Double_t nentries);
+       void     FitBisCH(TH1 *projch, Double_t mean, Double_t nentries);
+       void     FitCH(TH1 *projch, Double_t mean, Double_t nentries);
+       void     FitLandau(TH1 *projch, Double_t mean, Double_t nentries);
        void     FitMeanW(TH1 *projch, Double_t nentries);
        void     FitMeanWSm(TH1 *projch, Float_t sumAll);
        void     FitMean(TH1 *projch, Double_t nentries, Double_t mean);
@@ -313,7 +342,6 @@ class AliTRDCalibraFit : public TObject {
        Bool_t   FitPRFGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins,Float_t xMin,Float_t xMax);
        Double_t FitGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins, Float_t xMin,Float_t xMax,TVectorD *param, Bool_t kError= kTRUE);
        void     FitPente(TH1 *projPH);
-       void     FitLagrangePoly(TH1* projPH);
        void     FitTnpRange(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nbg,Int_t nybins);
        TH1I    *ReBin(const TH1I *hist) const;
        TH1F    *ReBin(const TH1F *hist) const;
@@ -334,20 +362,26 @@ class AliTRDCalibraFit : public TObject {
        static  Double_t AsymmGauss(const Double_t *x, const Double_t *par);
        static  Double_t FuncLandauGaus(const Double_t *x, const Double_t *par);
        static  Double_t LanGauFun(const Double_t *x, const Double_t *par);
+       static  Double_t LanGauFunEx(const Double_t *x, const Double_t *par);
        TF1     *LanGauFit(TH1 *his, const Double_t *fitrange, const Double_t *startvalues
                          , const Double_t *parlimitslo, const Double_t *parlimitshi, Double_t *fitparams
                          , Double_t *fiterrors, Double_t *chiSqr, Int_t *ndf) const;
-       Int_t    LanGauPro(const Double_t *params, Double_t &maxx, Double_t &fwhm);
-       static  Double_t GausConstant(const Double_t *x, const Double_t *par); 
+       TF1     *LanGauFitEx(TH1 *his, const Double_t *fitrange, const Double_t *startvalues
+                           , const Double_t *parlimitslo, const Double_t *parlimitshi
+                           , Double_t *fitparams, Double_t *fiterrors
+                           , Double_t *chiSqr, Int_t *ndf) const;
+     
        
        // This is a singleton, contructor is private!
        AliTRDCalibraFit();
        virtual ~AliTRDCalibraFit();
        
        
-  ClassDef(AliTRDCalibraFit,2)                 // TRD Calibration class
+  ClassDef(AliTRDCalibraFit,3)                 // TRD Calibration class
         
 };
   
 #endif
 
+
+