]>
Commit | Line | Data |
---|---|---|
434146d0 | 1 | //$Id$ |
2 | ||
3cfb9c56 | 3 | #ifndef ALIHLTGLOBALTRACKMATCHER_H |
4 | #define ALIHLTGLOBALTRACKMATCHER_H | |
434146d0 | 5 | |
6 | ||
3cfb9c56 | 7 | //* This file is property of and copyright by the ALICE HLT Project * |
8 | //* ALICE Experiment at CERN, All rights reserved. * | |
9 | //* See cxx source for full Copyright notice * | |
10 | ||
11 | /** @file AliHLTGlobalTrackMatcher.h | |
12 | @author Svein Lindal (svein.lindal@fys.uio.no) | |
13 | @date | |
b3e7198f | 14 | @brief The HLT class matching TPC tracks to calorimeter clusters |
3cfb9c56 | 15 | */ |
16 | ||
17 | ||
3cfb9c56 | 18 | #include "AliHLTLogging.h" |
19 | #include "AliESDtrack.h" | |
2a24cbbe | 20 | #include "TObjArray.h" |
21 | #include "TArrayI.h" | |
3cfb9c56 | 22 | |
2a24cbbe | 23 | class AliHLTGlobalTrackMatcher : public AliHLTLogging{ |
b3e7198f | 24 | |
3cfb9c56 | 25 | public: |
26 | AliHLTGlobalTrackMatcher(); | |
b3e7198f | 27 | |
3cfb9c56 | 28 | /** destructor */ |
29 | virtual ~AliHLTGlobalTrackMatcher(); | |
30 | ||
2a24cbbe | 31 | //Main function, loops over tracks and calls appropriate functions to establish matches |
32 | template <class T> | |
33 | Int_t Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz ); | |
34 | ||
3cfb9c56 | 35 | private: |
2a24cbbe | 36 | |
434146d0 | 37 | void DoInit(); |
bad7877b | 38 | |
2a24cbbe | 39 | //Loops over clusters and decides if track is a good match to any of these |
40 | template <class T> | |
41 | Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz); | |
bad7877b | 42 | |
2a24cbbe | 43 | //Add track Id to cluster's list of matching tracks |
44 | Int_t AddTrackToCluster(Int_t tId, Int_t* clustersArray, Bool_t bestMatch, Int_t nMatches); | |
45 | Int_t AddTrackToCluster(Int_t tId, TArrayI* clustersArray, Bool_t bestMatch, Int_t nMatches); | |
46 | ||
47 | //Projects track to detector volume and decides if it's anywhere near calorimeter volume | |
48 | Bool_t IsTrackCloseToDetector(AliExternalTrackParam * track, Double_t bz, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ, Double_t dRadius); | |
49 | ||
50 | // Geometrical cut off values used to decide whether track is anywhere near calorimeter volumes | |
434146d0 | 51 | Float_t fPhosMaxZ; // max Z track (cm) |
52 | Float_t fPhosMaxX; // max X track (cm) | |
2a24cbbe | 53 | Float_t fEmcalMaxZ; // max Z track (cm) |
54 | Float_t fEmcalMaxX; // max X track (cm) | |
3cfb9c56 | 55 | |
2a24cbbe | 56 | Float_t fMatchDistance; // Square of maximum distance where track is considered a match to cluster (cm^2) |
3cfb9c56 | 57 | |
2a24cbbe | 58 | const Double_t fPhosRadius; // Radial position of PHOS |
59 | const Double_t fEmcalRadius; // Radial position of EMCAL | |
bad7877b | 60 | |
bc72e5b9 | 61 | AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & ); |
62 | AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &); | |
63 | ||
2a24cbbe | 64 | ClassDef(AliHLTGlobalTrackMatcher,1) |
3cfb9c56 | 65 | }; |
66 | ||
2a24cbbe | 67 | |
68 | template <class T> | |
69 | Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz ) { | |
70 | //See above for documentation | |
71 | ||
72 | Int_t nTracks = trackArray->GetEntriesFast(); | |
73 | Int_t nPhosClusters = clustersVector.size(); | |
74 | ||
75 | //TODO emcal not yet implemented | |
76 | Int_t nEmcalClusters = 0; //BALLE event->GetEMCALClusters(fEmcalClustersArray); | |
77 | ||
78 | if ( nTracks <= 0 ) { | |
74085fad | 79 | // HLTWarning("No tracks in event"); |
2a24cbbe | 80 | return 0; |
81 | } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) { | |
74085fad | 82 | //HLTWarning("No calorimeter clusters in Event"); |
2a24cbbe | 83 | return 0; |
84 | } | |
85 | ||
86 | Float_t bestMatchPhos[nPhosClusters]; | |
87 | for(int ic = 0; ic < nPhosClusters; ic++) { | |
88 | bestMatchPhos[ic] = 999999; | |
89 | } | |
90 | ||
91 | //BALLE TODO EMCAL implement | |
92 | // Float_t bestMatchEmcal[nEmcalClusters]; | |
93 | // for(int ic = 0; ic < nEmcalClusters; ic++) { | |
94 | // bestMatchEmcal[ic] = 999999; | |
95 | // } | |
96 | ||
97 | ||
98 | //Loop over tracks | |
99 | for (int it = 0; it < nTracks; it++ ) { | |
100 | AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it)); | |
101 | ||
102 | if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) { | |
103 | MatchTrackToClusters( track, clustersVector, nPhosClusters, bestMatchPhos, bz); | |
104 | ||
105 | //BALLE TODO EMCAL !!!! | |
106 | // } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) { | |
107 | // MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz); | |
108 | } | |
109 | ||
110 | ||
111 | } // track loop | |
112 | ||
113 | ||
114 | return 0; | |
115 | } | |
116 | ||
117 | ||
118 | ||
119 | template <class T> | |
120 | Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) { | |
121 | ||
122 | //See header file for documentation | |
123 | Int_t iResult = 0; | |
124 | ||
125 | Float_t clusterPosition[3]; | |
126 | Double_t trackPosition[3]; | |
127 | ||
128 | ||
129 | for(int ic = 0; ic < nClusters; ic++) { | |
130 | ||
131 | T * cluster = clustersVector.at(ic); | |
132 | ||
133 | //Get cluster global coordinates | |
134 | cluster->GetPosition(clusterPosition); | |
135 | ||
136 | //Get track postion at radius of cluster | |
137 | Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]); | |
138 | if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) { | |
ff9f0a1f | 139 | HLTInfo("Track reached detector but not cluster!!!!!!"); |
2a24cbbe | 140 | continue; |
141 | } | |
70cad768 | 142 | |
143 | ||
74085fad | 144 | // HLTInfo("Cluster global position %f %f %f", clusterPosition[0],clusterPosition[1],clusterPosition[2]); |
70cad768 | 145 | |
2a24cbbe | 146 | |
147 | //Calculate track - cluster residual | |
148 | ||
149 | ||
150 | //Get residual in z= 0 plane (squared) | |
151 | Double_t dxy = 0; | |
152 | for(int i = 0; i < 2; i++) { | |
153 | Double_t dd = trackPosition[i] - clusterPosition[i]; | |
154 | dxy += dd*dd; | |
155 | } | |
156 | ||
157 | //Get z residual (squared) | |
158 | Double_t dd = trackPosition[2] - clusterPosition[2]; | |
159 | Double_t dz = dd*dd; | |
160 | ||
161 | Double_t match = dz + dxy; | |
70cad768 | 162 | |
74085fad | 163 | // HLTInfo("Track cluster residual %f, maxmatch %f", match, fMatchDistance); |
70cad768 | 164 | |
2a24cbbe | 165 | if( match > fMatchDistance ) { |
166 | continue; | |
167 | } | |
168 | ||
23af1553 | 169 | |
2a24cbbe | 170 | if (match < bestMatch[ic]) { |
171 | bestMatch[ic] = match; | |
172 | cluster->SetEmcCpvDistance(TMath::Sqrt(match)); | |
23af1553 | 173 | cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz)); |
2a24cbbe | 174 | } |
175 | ||
176 | //Add track to cluster's array of matching tracks | |
177 | Int_t nTracksMatched = cluster->GetNTracksMatched(); | |
178 | iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched); | |
74085fad | 179 | //HLTInfo("Added track %d to cluster %d, it now has %d matching tracks", track->GetID(), cluster->GetID(), cluster->GetNTracksMatched()); |
2a24cbbe | 180 | } |
181 | ||
182 | return iResult; | |
183 | } | |
184 | ||
3cfb9c56 | 185 | #endif |