]>
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> | |
ec54c698 | 70 | Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &phosClustersVector, vector<T*> &emcalClustersVector, Double_t bz ) { |
2a24cbbe | 71 | //See above for documentation |
72 | ||
ec54c698 | 73 | |
2a24cbbe | 74 | Int_t nTracks = trackArray->GetEntriesFast(); |
ec54c698 | 75 | Int_t nPhosClusters = phosClustersVector.size(); |
76 | Int_t nEmcalClusters = emcalClustersVector.size(); | |
a46c7ba5 | 77 | |
ec54c698 | 78 | |
4502b5bb | 79 | //HLTError("tracks phos emcal %d %d %d", nTracks, nPhosClusters, nEmcalClusters); |
80 | ||
ec54c698 | 81 | //See if there are tracks and clusters to match |
2a24cbbe | 82 | if ( nTracks <= 0 ) { |
2a24cbbe | 83 | return 0; |
ec54c698 | 84 | } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) { |
2a24cbbe | 85 | return 0; |
86 | } | |
87 | ||
4502b5bb | 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 | |
103 | if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) { | |
ec54c698 | 104 | MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz); |
105 | ||
106 | } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) { | |
107 | MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz); | |
2a24cbbe | 108 | } |
a46c7ba5 | 109 | |
ec54c698 | 110 | } |
a46c7ba5 | 111 | |
2a24cbbe | 112 | return 0; |
a46c7ba5 | 113 | } |
2a24cbbe | 114 | |
115 | ||
116 | ||
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; | |
122 | ||
123 | Float_t clusterPosition[3]; | |
124 | Double_t trackPosition[3]; | |
125 | ||
a46c7ba5 | 126 | |
127 | for(int ic = 0; ic < nClusters; ic++) { | |
2a24cbbe | 128 | |
129 | T * cluster = clustersVector.at(ic); | |
130 | ||
a46c7ba5 | 131 | //Get cluster global coordinates |
2a24cbbe | 132 | cluster->GetPosition(clusterPosition); |
52426eff | 133 | |
3bf63dbb | 134 | Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]); |
52426eff | 135 | |
136 | //Rotate tracking system to the angle of the cluster | |
137 | TVector3 cVec(clusterPosition); | |
138 | if (! (track->Rotate(cVec.Phi())) ) { | |
2a24cbbe | 139 | continue; |
140 | } | |
52426eff | 141 | |
142 | if(! (track->GetXYZAt(rCluster, bz, trackPosition)) ) { | |
143 | continue; | |
144 | } | |
145 | ||
a46c7ba5 | 146 | //Get residual in z= 0 plane (squared) |
2a24cbbe | 147 | Double_t dxy = 0; |
148 | for(int i = 0; i < 2; i++) { | |
149 | Double_t dd = trackPosition[i] - clusterPosition[i]; | |
150 | dxy += dd*dd; | |
151 | } | |
152 | ||
a46c7ba5 | 153 | //Get z residual (squared) |
2a24cbbe | 154 | Double_t dd = trackPosition[2] - clusterPosition[2]; |
155 | Double_t dz = dd*dd; | |
156 | ||
157 | Double_t match = dz + dxy; | |
70cad768 | 158 | |
2a24cbbe | 159 | if( match > fMatchDistance ) { |
160 | continue; | |
161 | } | |
162 | ||
163 | if (match < bestMatch[ic]) { | |
164 | bestMatch[ic] = match; | |
165 | cluster->SetEmcCpvDistance(TMath::Sqrt(match)); | |
23af1553 | 166 | cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz)); |
2a24cbbe | 167 | } |
168 | ||
a46c7ba5 | 169 | //Add track to cluster's array of matching tracks |
2a24cbbe | 170 | Int_t nTracksMatched = cluster->GetNTracksMatched(); |
171 | iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched); | |
2a24cbbe | 172 | } |
173 | ||
174 | return iResult; | |
175 | } | |
176 | ||
3cfb9c56 | 177 | #endif |