]>
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" | |
52426eff | 22 | #include "TVector3.h" |
3cfb9c56 | 23 | |
a46c7ba5 | 24 | class AliHLTGlobalTrackMatcher : public AliHLTLogging{ |
b3e7198f | 25 | |
3cfb9c56 | 26 | public: |
27 | AliHLTGlobalTrackMatcher(); | |
b3e7198f | 28 | |
a46c7ba5 | 29 | /** destructor */ |
3cfb9c56 | 30 | virtual ~AliHLTGlobalTrackMatcher(); |
31 | ||
a46c7ba5 | 32 | //Main function, loops over tracks and calls appropriate functions to establish matches |
2a24cbbe | 33 | template <class T> |
ec54c698 | 34 | Int_t Match( TObjArray * trackArray, vector<T*> &phosClustersVector, vector<T*> &emcalClustersVector, Double_t bz ); |
a46c7ba5 | 35 | |
36 | private: | |
37 | ||
434146d0 | 38 | void DoInit(); |
bad7877b | 39 | |
2a24cbbe | 40 | //Loops over clusters and decides if track is a good match to any of these |
41 | template <class T> | |
42 | Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz); | |
bad7877b | 43 | |
2a24cbbe | 44 | //Add track Id to cluster's list of matching tracks |
45 | Int_t AddTrackToCluster(Int_t tId, Int_t* clustersArray, Bool_t bestMatch, Int_t nMatches); | |
46 | Int_t AddTrackToCluster(Int_t tId, TArrayI* clustersArray, Bool_t bestMatch, Int_t nMatches); | |
47 | ||
48 | //Projects track to detector volume and decides if it's anywhere near calorimeter volume | |
49 | Bool_t IsTrackCloseToDetector(AliExternalTrackParam * track, Double_t bz, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ, Double_t dRadius); | |
50 | ||
51 | // Geometrical cut off values used to decide whether track is anywhere near calorimeter volumes | |
a46c7ba5 | 52 | Float_t fPhosMaxZ; // max Z track (cm) |
53 | Float_t fPhosMaxX; // max X track (cm) | |
54 | Float_t fEmcalMaxZ; // max Z track (cm) | |
55 | Float_t fEmcalMaxX; // max X track (cm) | |
56 | ||
57 | Float_t fMatchDistance; // Square of maximum distance where track is considered a match to cluster (cm^2) | |
3cfb9c56 | 58 | |
a46c7ba5 | 59 | const Double_t fPhosRadius; // Radial position of PHOS |
60 | const Double_t fEmcalRadius; // Radial position of EMCAL | |
bad7877b | 61 | |
bc72e5b9 | 62 | AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & ); |
63 | AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &); | |
64 | ||
2a24cbbe | 65 | ClassDef(AliHLTGlobalTrackMatcher,1) |
3cfb9c56 | 66 | }; |
67 | ||
2a24cbbe | 68 | |
69 | template <class T> | |
01d100c8 | 70 | Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &phosClustersVector, |
71 | vector<T*> &emcalClustersVector, Double_t bz ) | |
72 | { | |
2a24cbbe | 73 | //See above for documentation |
74 | ||
75 | Int_t nTracks = trackArray->GetEntriesFast(); | |
ec54c698 | 76 | Int_t nPhosClusters = phosClustersVector.size(); |
77 | Int_t nEmcalClusters = emcalClustersVector.size(); | |
a46c7ba5 | 78 | |
ec54c698 | 79 | |
4502b5bb | 80 | //HLTError("tracks phos emcal %d %d %d", nTracks, nPhosClusters, nEmcalClusters); |
81 | ||
ec54c698 | 82 | //See if there are tracks and clusters to match |
2a24cbbe | 83 | if ( nTracks <= 0 ) { |
2a24cbbe | 84 | return 0; |
ec54c698 | 85 | } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) { |
2a24cbbe | 86 | return 0; |
87 | } | |
88 | ||
a46c7ba5 | 89 | Float_t bestMatchPhos[nPhosClusters]; |
90 | for(int ic = 0; ic < nPhosClusters; ic++) { | |
91 | bestMatchPhos[ic] = 999999; | |
2a24cbbe | 92 | } |
ec54c698 | 93 | |
94 | Float_t bestMatchEmcal[nEmcalClusters]; | |
95 | for(int ic = 0; ic < nEmcalClusters; ic++) { | |
96 | bestMatchEmcal[ic] = 999999; | |
97 | } | |
98 | ||
a46c7ba5 | 99 | //Loop over tracks |
2a24cbbe | 100 | for (int it = 0; it < nTracks; it++ ) { |
101 | AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it)); | |
a46c7ba5 | 102 | |
01d100c8 | 103 | if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) |
104 | { | |
105 | MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz); | |
106 | } | |
107 | else | |
108 | if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) | |
109 | { | |
110 | MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz); | |
111 | } | |
ec54c698 | 112 | } |
2a24cbbe | 113 | return 0; |
a46c7ba5 | 114 | } |
2a24cbbe | 115 | |
116 | ||
2a24cbbe | 117 | template <class T> |
118 | Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) { | |
a46c7ba5 | 119 | |
2a24cbbe | 120 | //See header file for documentation |
121 | Int_t iResult = 0; | |
2a24cbbe | 122 | Float_t clusterPosition[3]; |
123 | Double_t trackPosition[3]; | |
a46c7ba5 | 124 | |
01d100c8 | 125 | for(int ic = 0; ic < nClusters; ic++) |
126 | { | |
127 | T * cluster = clustersVector.at(ic); | |
128 | //Get cluster global coordinates | |
129 | cluster->GetPosition(clusterPosition); | |
130 | Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] | |
131 | + clusterPosition[1]*clusterPosition[1]); | |
132 | //Rotate tracking system to the angle of the cluster | |
133 | TVector3 cVec(clusterPosition); | |
134 | ||
135 | if (! (track->Rotate(cVec.Phi())) ) | |
136 | { | |
137 | continue; | |
138 | } | |
2a24cbbe | 139 | |
01d100c8 | 140 | if(! (track->GetXYZAt(rCluster, bz, trackPosition)) ) |
141 | { | |
142 | continue; | |
143 | } | |
52426eff | 144 | |
a46c7ba5 | 145 | //Get residual in z= 0 plane (squared) |
01d100c8 | 146 | Double_t dxy = 0; |
147 | for(int i = 0; i < 2; i++) | |
148 | { | |
149 | Double_t dd = trackPosition[i] - clusterPosition[i]; | |
150 | dxy += dd*dd; | |
151 | } | |
152 | ||
153 | //Get z residual (squared) | |
154 | Double_t dd = trackPosition[2] - clusterPosition[2]; | |
155 | Double_t dz = dd*dd; | |
156 | Double_t match = dz + dxy; | |
157 | ||
158 | if( match > fMatchDistance ) | |
159 | { | |
160 | continue; | |
161 | } | |
162 | if (match < bestMatch[ic]) | |
163 | { | |
164 | bestMatch[ic] = match; | |
165 | cluster->SetEmcCpvDistance(TMath::Sqrt(match)); | |
166 | cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz)); | |
167 | } | |
70cad768 | 168 | |
01d100c8 | 169 | //Add track to cluster's array of matching tracks |
170 | Int_t nTracksMatched = cluster->GetNTracksMatched(); | |
171 | iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), | |
172 | match < bestMatch[ic], nTracksMatched); | |
2a24cbbe | 173 | } |
2a24cbbe | 174 | |
175 | return iResult; | |
176 | } | |
177 | ||
01d100c8 | 178 | |
3cfb9c56 | 179 | #endif |
01d100c8 | 180 | |
181 |