]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibTracksGain.h
Adding new classes for numerical debugging
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibTracksGain.h
1 #ifndef AliTPCCALIBTRACKSGAIN_H
2 #define AliTPCCALIBTRACKSGAIN_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6  
7 #include <TChain.h>
8 #include <TNamed.h>
9
10
11 #include <TObjArray.h>
12 #include <TH2D.h>
13 #include <TVectorD.h>
14 #include <TMatrixD.h>
15
16 #include <iostream>
17 #include <TH1F.h>
18
19 #include <AliTPCcalibBase.h>
20
21 using namespace std;
22
23 class TTreeSRedirector;
24 class TObjString;
25 class TLinearFitter;
26 class TProfile; 
27 class TProfile2D; 
28 class TH1F; 
29
30 class AliTPCClusterParam; 
31 class AliTPCParamSR; 
32 class AliTPCCalROC;
33 class AliTPCCalPad;
34 class AliTPCseed; 
35 class AliTPCclusterMI; 
36 class AliTrackPointArray;
37 class TTreeStream;
38 class AliTPCcalibTracksCuts;
39 class AliTPCFitPad;
40 class TGraph;
41 class AliTPCCClusterParam;
42
43 class AliTPCcalibTracksGain : public AliTPCcalibBase {
44 public:
45    enum {
46       kShortPads = 0,
47       kMediumPads = 1,
48       kLongPads = 2
49    };
50    enum {
51       kSimpleFitter = 0,
52       kSqrtFitter = 1,
53       kLogFitter = 2
54    };
55    
56   AliTPCcalibTracksGain();
57   AliTPCcalibTracksGain(const AliTPCcalibTracksGain& obj);
58   AliTPCcalibTracksGain(const char* name, const char* title, AliTPCcalibTracksCuts* cuts, TNamed* debugStreamPrefix = 0, AliTPCcalibTracksGain* prevIter = 0);
59   virtual ~AliTPCcalibTracksGain();
60   AliTPCcalibTracksGain& operator=(const AliTPCcalibTracksGain& rhs);
61   virtual Long64_t        Merge(TCollection *list);
62   virtual void            Process(AliTPCseed* seed);
63   virtual void            Terminate();
64   virtual void            Analyze();
65   //
66   // Tracks manipulation
67   //
68   void            AddTrack(AliTPCseed* seed);
69   void            DumpTrack(AliTPCseed* track);
70   Bool_t          GetDedx(AliTPCseed* track, Int_t padType,  Int_t*rows,
71                           Int_t &sector, Int_t& npoints, 
72                           TVectorD &dedxM, TVectorD &dedxQ, 
73                           TVectorD &parY, TVectorD &parZ, TVectorD & meanPos);
74   void            AddCluster(AliTPCclusterMI* cluster, Float_t momenta, Float_t mdedx, Int_t padType, Float_t xcenter, TVectorD &dedxQ, TVectorD & dedxM, Float_t fraction, Float_t fraction2, Float_t dedge, TVectorD& parY, TVectorD& parZ, TVectorD& meanPos);
75   void            AddTracklet(UInt_t sector, UInt_t padType,TVectorD &dedxQ, TVectorD &dedxM,TVectorD& parY, TVectorD& parZ, TVectorD& meanPos);
76
77   void            AddCluster(AliTPCclusterMI* cluster);
78   void            Add(AliTPCcalibTracksGain* cal);
79   //
80   // Histogram part
81   //
82   TH1F  * GetQM(Int_t sector=-1){return (TH1F*)(sector<0 ?  fArrayQM->At(72): fArrayQM->At(sector));}
83   TH1F  * GetQT(Int_t sector=-1){return (TH1F*)(sector<0 ?  fArrayQT->At(72): fArrayQT->At(sector));}
84   TProfile* GetProfileQM(Int_t sector){return (TProfile*)(sector<0 ? fProfileArrayQM->At(36): fProfileArrayQM->At(sector));}
85   TProfile* GetProfileQT(Int_t sector){return (TProfile*)(sector<0 ? fProfileArrayQT->At(36): fProfileArrayQT->At(sector));}
86   TProfile2D* GetProfileQM2D(Int_t sector){return (TProfile2D*)(sector<0 ? fProfileArrayQM2D->At(36): fProfileArrayQM2D->At(sector));}
87   TProfile2D* GetProfileQT2D(Int_t sector){return (TProfile2D*)(sector<0 ? fProfileArrayQT2D->At(36): fProfileArrayQT2D->At(sector));}
88   //
89   // Get Derived results - gain maps
90   //
91   AliTPCCalPad*   CreateFitCalPad(UInt_t fitType, Bool_t undoTransformation = kFALSE, Bool_t normalizeToPadSize = kFALSE);
92   AliTPCCalROC*   CreateFitCalROC(UInt_t sector, UInt_t fitType, Bool_t undoTransformation = kFALSE, Bool_t normalizeToPadSize = kFALSE);
93   AliTPCCalROC*   CreateFitCalROC(UInt_t sector, UInt_t padType, TVectorD &fitParam, UInt_t fitType, Bool_t undoTransformation = kFALSE, Bool_t normalizeToPadSize = kFALSE);
94   AliTPCCalROC*   CreateCombinedCalROC(const AliTPCCalROC* roc1, const AliTPCCalROC* roc2);
95   //
96   void            Evaluate(Bool_t robust = kFALSE, Double_t frac = -1.);
97   void            GetParameters(UInt_t segment, UInt_t padType, UInt_t fitType, TVectorD &fitParam);
98   void            GetErrors(UInt_t segment, UInt_t padType, UInt_t fitType, TVectorD &fitError);
99   Double_t        GetRedChi2(UInt_t segment, UInt_t padType, UInt_t fitType);
100   void            GetCovarianceMatrix(UInt_t segment, UInt_t padType, UInt_t fitType, TMatrixD& covMatrix);
101   //
102   //
103   void            UpdateClusterParam(AliTPCClusterParam *param);
104   TGraph *        CreateAmpGraph(Int_t ipad, Bool_t qmax);
105
106
107   TLinearFitter*  GetFitter(UInt_t segment, UInt_t padType, UInt_t fitType);
108   
109   
110 public:
111   //
112   // Helper function
113   //
114   static Double_t GetPadLength(Double_t lx);
115   static Int_t    GetPadType(Double_t lx);  
116   static Bool_t   GetRowPad(Double_t lx, Double_t ly, Int_t& row, Int_t& pad); // just for debugging
117   //
118   //
119   AliTPCcalibTracksCuts* fCuts;            // cuts that are used for sieving the tracks used for calibration
120   //
121   // Simple Profiles and histograms - per chambers + 1 total
122   //
123   TObjArray*        fArrayQM;                // Qmax normalized
124   TObjArray*        fArrayQT;                // Qtot normalized 
125   TObjArray*        fProfileArrayQM;         // Qmax normalized  versus local X
126   TObjArray*        fProfileArrayQT;         // Qtot normalized  versus local X 
127   TObjArray*        fProfileArrayQM2D;       // Qmax normalized  versus local X and phi
128   TObjArray*        fProfileArrayQT2D;       // Qtot normalized  versus local X and phi
129   //
130   // Fitters
131   //
132   AliTPCFitPad*     fSimpleFitter;         // simple fitter for short pads
133   AliTPCFitPad*     fSqrtFitter;           // sqrt fitter for medium pads
134   AliTPCFitPad*     fLogFitter;            // log fitter for long pads
135   TLinearFitter*    fFitter0M;          // fitting of the atenuation, angular correction, and mean chamber gain
136   TLinearFitter*    fFitter1M;          // fitting of the atenuation, angular correction, and mean chamber gain
137   TLinearFitter*    fFitter2M;          // fitting of the atenuation, angular correction, and mean chamber gain
138   TLinearFitter*    fFitter0T;          // fitting of the atenuation, angular correction, and mean chamber gain
139   TLinearFitter*    fFitter1T;          // fitting of the atenuation, angular correction, and mean chamber gain
140   TLinearFitter*    fFitter2T;          // fitting of the atenuation, angular correction, and mean chamber gain
141   AliTPCFitPad*     fSingleSectorFitter;   // just for debugging
142   //
143   // Conters
144   //
145   UInt_t          fTotalTracks;         // just for debugging
146   UInt_t          fAcceptedTracks;      // just for debugging
147   AliTPCCalPad*   fDebugCalPadRaw;      // just for debugging
148   AliTPCCalPad*   fDebugCalPadCorr;     // just for debugging
149   UInt_t          fNShortClusters[36];   // number of clusters registered on short pads
150   UInt_t          fNMediumClusters[36];  // number of clusters registered on medium pads
151   UInt_t          fNLongClusters[36];    // number of clusters registered on long pads
152   //
153   //
154   AliTPCcalibTracksGain* fPrevIter;        // the calibration object in its previous iteration (will not be owned by the new object, don't forget to delete it!)    
155   //
156   // Setup
157   //
158    static       AliTPCParamSR* fgTPCparam;              //! helper object for geometry related operations
159    static const Double_t       fgkM;                    // value used in the transformation of the charge values for the logarithmic fitter
160    static const char*          fgkDebugStreamFileName;  // filename of the debug stream file
161    static const Bool_t         fgkUseTotalCharge;       // whether to use the cluster's total or maximum charge
162
163    ClassDef(AliTPCcalibTracksGain, 1);
164 };
165
166 #endif