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