new class and related macro to monitor ITS alignment (C. Bombonati)
[u/mrichter/AliRoot.git] / ITS / AliITSResidualsAnalysis.h
1 #ifndef ALIITSRESIDUALSANALYSIS_H
2 #define ALIITSRESIDUALSANALYSIS_H
3
4 /* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7
8 //*************************************************************************
9 // AliITSResidualAnalysis: class which deals with the analysis of the     *
10 // tracks residuals in the ITS                                            *
11 // More comments will come with the development of the interfaces and     *
12 // functionalities of the class.                                          *
13 //*************************************************************************
14
15 #include "AliAlignmentTracks.h"
16
17 class TObject;
18 class TCanvas;
19 class TH1F;
20 class TH2F;
21 class TArrayI;
22
23 class AliTrackPointArray;
24 class AliTrackResiduals;
25 class AliAlignObj;
26
27 class AliITSResidualsAnalysis : public AliAlignmentTracks {
28   
29
30  public:
31     
32   AliITSResidualsAnalysis();  
33   AliITSResidualsAnalysis(const TString aliTrackPoints,const TString geom);
34   AliITSResidualsAnalysis(const TArrayI *volIDs);
35    AliITSResidualsAnalysis(TArrayI *volIDs,AliTrackPointArray **tracksClustArray,AliTrackPointArray **tracksFitPointsArray);
36   //AliITSResidualsAnalysis(const AliITSResidualsAnalysis &res);
37   ~AliITSResidualsAnalysis();
38
39
40   //virtual ~AliITSResidualsAnalysis(){}
41   // void AddArray(AliTrackPointArray *trackClust,AliTrackPoinArray *trackFitPoints);
42
43
44
45   void ListVolUsed(TTree *pointsTree,TArrayI ***arrayIndex,Int_t **lastIndex);
46   void ListVolUsed(){if(!fIsIndexBuilt)return;ListVolUsed(fPointsTree,fArrayIndex,fLastIndex);};
47
48   void  InitHistograms(const TArrayI *volIDs);
49   void FillResHists(AliTrackPointArray *trackClust,AliTrackPointArray *trackFitPoints) const;
50   void  DrawHists() const;
51   Bool_t AnalyzeHists(Int_t minNpoints) const;
52   void FillVolumeCorrelationHists(Int_t ivol,Int_t volIDalignable,Int_t volIDpoint,Bool_t used) const;
53   Bool_t SetBinning(const TArrayI *volids,Float_t *phiBin,Float_t *zBin);
54   Float_t** CheckSingleLayer(const TArrayI *volids);
55   TArrayI* GetSingleLayerVolids(Int_t layer) const;
56   Int_t GetBinPhiZ(const Int_t volID,Int_t *binz) const;
57   void GetTrackDirClusterCov(AliTrackPoint *point,Double_t &phi,Double_t &lambda,Double_t &lambda2,Double_t &alpha,Double_t &xovery,Double_t &zovery) const;
58   void CalculateResiduals(const TArrayI *volids,const TArrayI *volidsfit,AliGeomManager::ELayerID layerRangeMin,AliGeomManager::ELayerID layerRangeMax,Int_t iterations=1,Bool_t draw=kTRUE);
59   void ProcessPoints(TString minimizer="fast",Int_t fit=0,AliGeomManager::ELayerID iLayerToAlign=(AliGeomManager::ELayerID)1,AliGeomManager::ELayerID iLayerToExclude=(AliGeomManager::ELayerID)1,TString misalignmentFile="");
60   void ExtractResiduals(Int_t layer=1,Int_t minEnt=10,TString filename="ResidualsAnalysisTree.root") const;
61   Int_t PlotResiduals(Int_t layer=1,TString filename="resPlot_MA_layer") const;
62   TString GetFileNameTrackPoints() const { return fAliTrackPoints; };
63   TString GetFileNameGeometry() const { return fGeom; };
64   void SetFileNameTrackPoints(TString name) { fAliTrackPoints=name; };
65   void SetFileNameGeometry(TString name) { fGeom=name; };
66
67
68   enum ModulePhiZ{
69     fkPhiSPD1=20,
70     fkZSPD1=4,
71     fkPhiSPD2=40,
72     fkZSPD2=4,
73     fkPhiSDD1=14,
74     fkZSDD1=6,
75     fkPhiSDD2=22,
76     fkZSDD2=8,
77     fkPhiSSD1=34,
78     fkZSSD1=22,
79     fkPhiSSD2=38,
80     fkZSSD2=25
81   };
82
83
84  protected:
85     
86   Int_t fnHist;    // number of histogram = number of alignable volumes considered
87   Int_t fnPhi;     // coordinate of the volume (Phi)
88   Int_t fnZ;       // coordinate of the volume (Z)
89   Int_t **fvolidsToBin;         // array with volID and bin
90   Int_t *fLastVolVolid;         // Last Vol Volid
91   Double_t ***fCoordToBinTable; // array with coordinate and bin
92   TH1F **fVolResHistRPHI;       //  Histogram of Residuals along Global rphi 
93   TH1F **fResHistZ;             //  Histogram of Residuals along Global Z 
94   TH1F **fPullHistRPHI;         //  Misc Histogram ...
95   TH1F **fPullHistZ;            //  Misc Histogram ...
96   TH1F **fTrackDirPhi;          //  Misc Histogram ...
97   TH1F **fTrackDirLambda;       //  Misc Histogram ...
98   TH1F **fTrackDirLambda2;      //  Misc Histogram ...
99   TH1F **fTrackDirAlpha;        //  Misc Histogram ...
100   TH1F *fTrackDirPhiAll;        //  Misc Histogram ...
101   TH1F *fTrackDirLambdaAll;     //  Misc Histogram ...
102   TH1F *fTrackDirLambda2All;    //  Misc Histogram ...
103   TH1F *fTrackDirAlphaAll;      //  Misc Histogram ...
104   TH2F **fTrackDir;             //  Misc Histogram ...
105   TH2F *fTrackDirAll;           //  Misc Histogram ...
106   TH2F *fTrackDir2All;          //  Misc Histogram ...
107   TH2F *fTrackDirXZAll;         //  Misc Histogram ...
108   TH1F **fResHistGlob;          //  Histogram of Residuals
109   TH2F **fhistCorrVol;          //  Misc Histogram ...
110   TH2F *fVolNTracks;       // Histogram to see how many tracks pass through a given module 
111   TH2F *fhEmpty;           // Histogram to get/set the binning
112   TH2F *fhistVolNptsUsed;  // Histogram with the numer of points used per volume
113   TH2F *fhistVolUsed;      // Histogram with the numer of volumes udes
114   TH2F *fSigmaVolZ;        // Histogram with the sigma vs volume Z
115   Bool_t fsingleLayer;     // Tag for single layer
116   Bool_t fWriteHist;       // Tag for histograms
117   TArrayI *fpTrackVolIDs;  // array that gives the volID for the i^(th) entry 
118   TArrayI **fVolVolids;    // array with the volumes to analyze
119   TArrayI **fVolUsed;      // array with the volumes to use
120   Bool_t fRealignObjFileIsOpen; // indicator- if the file fRealignObjFilename is opened
121   TClonesArray *fClonesArray;   // pointer to the TClonesArray with the final AliAlignObjParams
122   TString fAliTrackPoints;      // Filename with the AliTrackPoints
123   TString fGeom;                // Filename with the Geometry
124
125   ClassDef(AliITSResidualsAnalysis,1) // Residuals analysis for the ITS
126     
127     };
128     
129 #endif
130