3 #ifndef ALIHLTGLOBALTRACKMATCHER_H
4 #define ALIHLTGLOBALTRACKMATCHER_H
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 *
11 /** @file AliHLTGlobalTrackMatcher.h
12 @author Svein Lindal (svein.lindal@fys.uio.no)
14 @brief The HLT class matching TPC tracks to calorimeter clusters
18 #include "AliHLTLogging.h"
19 #include "AliESDtrack.h"
20 #include "TObjArray.h"
23 class AliHLTGlobalTrackMatcher : public AliHLTLogging {
28 AliHLTGlobalTrackMatcher();
31 virtual ~AliHLTGlobalTrackMatcher();
33 ///Main function, loops over tracks and calls appropriate functions to establish matches
35 Int_t Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz );
38 ///Set the maximum Z to be within distance of detector volume
39 void SetMaxZ(Float_t z) { fMaxZ = z; }
40 ///Set the maximum X to be within distance of detector volume
41 void SetMaxX(Float_t x) { fMaxX = x; }
42 ///Set whether the detector is in positive y direction
43 void SetYSign(Bool_t y) { fYSign = y; }
44 ///Set the max distance to be considered a match
45 void SetMatchDistance(Float_t d) { fMatchDistance = d*d; }
46 ///Set the radius of detector volume
47 void SetRadius(Float_t r) { fRadius = r; }
53 //Loops over clusters and decides if track is a good match to any of these
55 Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz);
57 //Add track Id to cluster's list of matching tracks
58 Int_t AddTrackToCluster(Int_t tId, Int_t* clustersArray, Bool_t bestMatch, Int_t nMatches);
59 Int_t AddTrackToCluster(Int_t tId, TArrayI* clustersArray, Bool_t bestMatch, Int_t nMatches);
61 //Projects track to detector volume and decides if it's anywhere near calorimeter volume
62 Bool_t IsTrackCloseToDetector(AliExternalTrackParam * track, Double_t bz, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ, Double_t dRadius);
64 // Geometrical cut off values used to decide whether track is anywhere near calorimeter volumes
65 Float_t fMaxZ; // max Z track (cm)
66 Float_t fMaxX; // max X track (cm)
68 Float_t fMatchDistance; // Square of maximum distance where track is considered a match to cluster (cm^2)
69 Double_t fRadius; // Radial position of detector volume
70 Bool_t fYSign; // Positive or negative y
72 AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & );
73 AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &);
75 ClassDef(AliHLTGlobalTrackMatcher,1)
81 Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz ) {
82 //See above for documentation
85 Int_t nTracks = trackArray->GetEntriesFast();
86 Int_t nClusters = clustersVector.size();
90 } else if ( nClusters <= 0 ) {
94 Float_t bestMatch[nClusters];
95 for(int ic = 0; ic < nClusters; ic++) {
96 bestMatch[ic] = 999999;
99 for (int it = 0; it < nTracks; it++ ) {
100 AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
101 if ( IsTrackCloseToDetector(track, bz, fMaxX, fYSign, fMaxZ, fRadius ) ) {
102 MatchTrackToClusters( track, clustersVector, nClusters, bestMatch, bz);
111 Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
112 //See header file for documentation
115 Float_t clusterPosition[3];
116 Double_t trackPosition[3];
118 for(int ic = 0; ic < nClusters; ic++) {
120 T * cluster = clustersVector.at(ic);
122 cluster->GetPosition(clusterPosition);
124 //Get track postion at radius of cluster
125 Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]);
126 if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
127 HLTInfo("Track reached detector but not cluster!!!!!!");
131 //Calculate track - cluster residual
133 for(int i = 0; i < 2; i++) {
134 Double_t dd = trackPosition[i] - clusterPosition[i];
138 Double_t dd = trackPosition[2] - clusterPosition[2];
141 Double_t match = dz + dxy;
143 if( match > fMatchDistance ) {
147 if (match < bestMatch[ic]) {
148 bestMatch[ic] = match;
149 cluster->SetEmcCpvDistance(TMath::Sqrt(match));
150 cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz));
153 Int_t nTracksMatched = cluster->GetNTracksMatched();
154 iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched);