]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/Upgrade/AliToyMCReconstruction.h
o Add Delta Analysis
[u/mrichter/AliRoot.git] / TPC / Upgrade / AliToyMCReconstruction.h
1 #ifndef AliToyMCReconstruction_H
2 #define AliToyMCReconstruction_H
3
4 #include <TString.h>
5 #include <TObject.h>
6 #include <TClonesArray.h>
7 #include <TExMap.h>
8 #include <TVectorFfwd.h>
9 #include <THn.h>
10
11 class TTree;
12
13 class TTreeSRedirector;
14 class AliExternalTrackParam;
15 class AliTPCtrackerSector;
16 class AliToyMCEvent;
17 class AliTPCCorrection;
18 class AliTPCseed;
19 class AliTPCtrackerRow;
20 class AliToyMCTrack;
21 class AliTPCclusterMI;
22 class AliRieman;
23 class AliTrackPoint;
24 class AliTPCParam;
25
26 class AliToyMCReconstruction : public TObject {
27 public:
28   AliToyMCReconstruction();
29   virtual ~AliToyMCReconstruction();
30   
31   enum ECorrType {
32     kNoCorrection = 0,
33     kTPCCenter,
34     kAverageEta,
35     kIdeal,
36     kPreliminaryEta // NOT TO USE (needs fixing!!! Not yet in full code!!!)
37   };
38
39   enum EDet {
40     kITS=0,
41     kTPC,
42     kTRD
43   };
44
45   enum ERecoFill {
46     kFillSeed = 0x01,
47     kFillOrig = 0x02,
48     kFillTrack= 0x04,
49     
50     kFillITS  = 0x08,
51     kFillITS1 = 0x10,
52     kFillITS2 = 0x20
53   };
54   
55   void RunReco(const char* file, Int_t nmaxEv=-1);
56   void RunRecoAllClusters(const char* file, Int_t nmaxEv=-1);
57   void RunRecoAllClustersStandardTracking(const char* file, Int_t nmaxEv=-1);
58
59   void RunFullTracking(const char* file, Int_t nmaxEv=-1);
60   
61   // reconstruction settings
62   void      SetRecoSettings(Bool_t idealTracking, Int_t clusterType, ECorrType correctionType, Int_t seedingRow=130, Int_t seedingDist=10)
63                            { fIdealTracking=idealTracking; fClusterType=clusterType; fSeedingRow=seedingRow, fSeedingDist=seedingDist, fCorrectionType=correctionType; }
64   
65   void      SetClusterType(Int_t type)  { fClusterType = type;    }
66   Int_t     GetClusterType()  const     { return fClusterType;    }
67   
68   void      SetSeedingRow(Int_t row)    { fSeedingRow = row;      }
69   Int_t     GetSeedingRow()  const      { return fSeedingRow;     }
70   
71   void      SetSeedingDist(Int_t dist)  { fSeedingDist = dist;    }
72   Int_t     GetSeedingDist()  const     { return fSeedingDist;    }
73   
74   void      SetCorrType(ECorrType type) { fCorrectionType = type; }
75   ECorrType GetCorrectionType() const   { return fCorrectionType; }
76
77   void   SetUseMaterialBudget(Bool_t mat) { fUseMaterial = mat;   }
78   Bool_t GetUseMaterialBudget() const   { return fUseMaterial;    }
79
80   void   SetIdealTracking(Bool_t tr)    { fIdealTracking = tr;    }
81   Bool_t GetIdealTracking()  const      { return fIdealTracking;  }
82
83   void   SetFillClusterRes(Bool_t res)  { fFillClusterRes=res;    }
84   Bool_t GetFillClusterRes()  const     { return fFillClusterRes; }
85
86   void   SetUseT0list(Bool_t use)       { fUseT0list=use;    }
87   Bool_t GetUseT0list()  const          { return fUseT0list; }
88   
89   void   SetUseZ0list(Bool_t use)       { fUseZ0list=use;    }
90   Bool_t GetUseZ0list()  const          { return fUseZ0list; }
91   
92   void   SetForceAlpha(Bool_t use)       { fForceAlpha=use;    }
93   Bool_t GetForceAlpha()  const          { return fForceAlpha; }
94
95   void SetRecoInfo(Long64_t val) { fRecoInfo = val; }
96   Long64_t GetRecoInfo() const { return fRecoInfo; }
97   
98   void   SetTree(TTree *tree) { fTree=tree; }
99   TTree* GetTree() const { return fTree; }
100
101   AliExternalTrackParam* GetSeedFromTrack(const AliToyMCTrack * const tr, Bool_t forceSeed=kFALSE);
102   AliExternalTrackParam* GetSeedFromTrackIdeal(const AliToyMCTrack * const tr, EDet det );
103   AliExternalTrackParam* GetFittedTrackFromSeed(const AliToyMCTrack *tr, const AliExternalTrackParam *seed, TClonesArray *arrClustRes=0x0);
104   AliExternalTrackParam* GetFittedTrackFromSeedAllClusters(const AliToyMCTrack *tr, const AliExternalTrackParam *seed, Int_t &nClus);
105   AliExternalTrackParam* GetTrackRefit(const AliToyMCTrack * const tr, EDet det);
106
107   AliToyMCTrack *ConvertTPCSeedToToyMCTrack(const AliTPCseed &seed);
108   AliExternalTrackParam* GetRefittedTrack(const AliTPCseed &seed);
109   
110   AliTPCclusterMI* FindMiddleCluster(const AliTPCclusterMI *clInner, const AliTPCclusterMI *clOuter,
111                                      Double_t roady, Double_t roadz,
112                                      AliRieman &seedFit);
113
114   void AddMiddleClusters(AliTPCseed *seed,
115                          const AliTPCclusterMI *clInner, const AliTPCclusterMI *clOuter,
116                          Double_t roady, Double_t roadz,
117                          Int_t &nTotalClusters, AliRieman &seedFit);
118   Int_t MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
119   void MakeSeeds(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
120
121   void SetRieman(const AliTPCseed &seed, AliRieman &rieman);
122   void CopyRieman(const AliRieman &from, AliRieman &to);
123   
124   AliExternalTrackParam* ClusterToTrackAssociation(const AliTPCseed *seed, Int_t trackID, Int_t &nClus);
125   void ClusterToTrackAssociation(AliTPCseed &seed);
126   void AssociateClusters(AliTPCseed &seed, Int_t firstRow, Int_t lastRow, Bool_t direction);
127   
128   void InitSpaceCharge();
129
130   void SetLongT0seed(Bool_t l) { fLongT0seed=l; }
131   Bool_t GetLongT0seed() const { return fLongT0seed; }
132   
133   static TTree* ConnectTrees(const char* files);
134   
135   Double_t GetVDrift() const;
136   Double_t GetZLength(Int_t roc) const;
137
138   void InitStreamer(TString addName, Int_t level=1);
139
140   void ConnectInputFile(const char* file, Int_t nmaxEv=-1);
141   void Cleanup();
142
143   void DumpTracksToTree(const char* file);
144   
145 // private:
146   AliToyMCReconstruction(const AliToyMCReconstruction &rec);
147   AliToyMCReconstruction& operator= (AliToyMCReconstruction& rec);
148
149   void SetTrackPointFromCluster(const AliTPCclusterMI *cl, AliTrackPoint &p);
150   void ClusterToSpacePoint(const AliTPCclusterMI *cl, Float_t xyz[3]);
151
152   Int_t LoadInnerSectors();
153   Int_t LoadOuterSectors();
154   
155   Int_t GetSector(AliExternalTrackParam *track);
156   void FillSectorStructure(Int_t maxev);
157   void FillSectorStructureAC();
158
159   void SetupTrackMaps();
160
161   void CookLabel(AliTPCseed *seed, Double_t fraction, Int_t info[5]=0);
162
163   void DumpSeedInfo(TObjArray *arr);
164   void DumpTrackInfo(TObjArray *arr);
165   void DumpSeedInfo(const AliToyMCTrack *toyTrack, AliTPCseed *seed);
166   
167
168   void MarkClustersUsed(AliTPCseed *seed);
169   void ResetClustersZtoTime(AliTPCseed *seed);
170
171   Float_t FindClosestT0(const TVectorF &t0list, const TVectorF &z0list, AliExternalTrackParam &t0seed);
172   
173   // reco settings
174   Int_t  fSeedingRow;            // first row used for seeding
175   Int_t  fSeedingDist;           // distance of seeds
176   Int_t  fClusterType;           // cluster type to use
177   ECorrType fCorrectionType;     // type of space point correction
178   Bool_t fDoTrackFit;            // do track fitting
179   Bool_t fUseMaterial;           // use material budget in tracking
180   Bool_t fIdealTracking;         // use ideal coordinates for tracking
181
182   Int_t  fNmaxEvents;            // maximum number of events
183
184   // current reconstruction info
185   Double_t fTime0;               // current time0 used for reconstruction
186   Bool_t   fCreateT0seed;        // if current seed is the T0 seed
187   Bool_t   fLongT0seed;          // if we should use a t0 seed including all clusters in the seed range
188   Bool_t   fFillClusterRes;      // fill cluster residuals?
189   Bool_t   fUseT0list;           // if the list of T0 information should be used to guess the T0
190   Bool_t   fUseZ0list;           // if the list of Z vertex information should be used to guess the T0
191   Bool_t   fForceAlpha;          // force the correct alpha for the t0 seed extrapolation
192   Long64_t fRecoInfo;            // what information to fill in the output trees
193   
194   TTreeSRedirector *fStreamer;   // debug streamer
195   TFile *fInputFile;             // input file
196   TTree *fTree;                  // input tree with ToyMC info
197   AliToyMCEvent *fEvent;         // input event
198
199   AliTPCParam *fTPCParam;            // tpc reco parameters
200   AliTPCCorrection *fTPCCorrection; // space charge
201
202   const Int_t fkNSectorInner;        //number of inner sectors
203   AliTPCtrackerSector *fInnerSectorArray;  //array of inner sectors
204   const Int_t fkNSectorOuter;        //number of outer sectors
205   AliTPCtrackerSector *fOuterSectorArray;  //array of outer sectors
206
207   TClonesArray fAllClusters;     //Array keeping all clusters for free seeding
208
209   TExMap fMapTrackEvent;          // map global track number -> event number
210   TExMap fMapTrackTrackInEvent;   // map global track number -> track in event
211
212   THn    *fHnDelta;               // histogram with residuals
213
214   Bool_t fIsAC;                     // if we are tracking with sector arrays running from 0-36 rather than 0-18
215    
216   ClassDef(AliToyMCReconstruction,0)
217 };
218
219
220 #endif