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{
26 AliHLTGlobalTrackMatcher();
29 virtual ~AliHLTGlobalTrackMatcher();
31 //Main function, loops over tracks and calls appropriate functions to establish matches
33 Int_t Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz );
39 //Loops over clusters and decides if track is a good match to any of these
41 Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz);
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);
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);
50 // Geometrical cut off values used to decide whether track is anywhere near calorimeter volumes
51 Float_t fPhosMaxZ; // max Z track (cm)
52 Float_t fPhosMaxX; // max X track (cm)
53 Float_t fEmcalMaxZ; // max Z track (cm)
54 Float_t fEmcalMaxX; // max X track (cm)
56 Float_t fMatchDistance; // Square of maximum distance where track is considered a match to cluster (cm^2)
58 const Double_t fPhosRadius; // Radial position of PHOS
59 const Double_t fEmcalRadius; // Radial position of EMCAL
61 AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & );
62 AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &);
64 ClassDef(AliHLTGlobalTrackMatcher,1)
69 Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz ) {
70 //See above for documentation
72 Int_t nTracks = trackArray->GetEntriesFast();
73 Int_t nPhosClusters = clustersVector.size();
75 //TODO emcal not yet implemented
76 Int_t nEmcalClusters = 0; //BALLE event->GetEMCALClusters(fEmcalClustersArray);
79 // HLTWarning("No tracks in event");
81 } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) {
82 //HLTWarning("No calorimeter clusters in Event");
86 Float_t bestMatchPhos[nPhosClusters];
87 for(int ic = 0; ic < nPhosClusters; ic++) {
88 bestMatchPhos[ic] = 999999;
91 //BALLE TODO EMCAL implement
92 // Float_t bestMatchEmcal[nEmcalClusters];
93 // for(int ic = 0; ic < nEmcalClusters; ic++) {
94 // bestMatchEmcal[ic] = 999999;
99 for (int it = 0; it < nTracks; it++ ) {
100 AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
102 if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
103 MatchTrackToClusters( track, clustersVector, nPhosClusters, bestMatchPhos, bz);
105 //BALLE TODO EMCAL !!!!
106 // } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
107 // MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz);
120 Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
122 //See header file for documentation
125 Float_t clusterPosition[3];
126 Double_t trackPosition[3];
129 for(int ic = 0; ic < nClusters; ic++) {
131 T * cluster = clustersVector.at(ic);
133 //Get cluster global coordinates
134 cluster->GetPosition(clusterPosition);
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)) ) {
139 HLTInfo("Track reached detector but not cluster!!!!!!");
144 // HLTInfo("Cluster global position %f %f %f", clusterPosition[0],clusterPosition[1],clusterPosition[2]);
147 //Calculate track - cluster residual
150 //Get residual in z= 0 plane (squared)
152 for(int i = 0; i < 2; i++) {
153 Double_t dd = trackPosition[i] - clusterPosition[i];
157 //Get z residual (squared)
158 Double_t dd = trackPosition[2] - clusterPosition[2];
161 Double_t match = dz + dxy;
163 // HLTInfo("Track cluster residual %f, maxmatch %f", match, fMatchDistance);
165 if( match > fMatchDistance ) {
170 if (match < bestMatch[ic]) {
171 bestMatch[ic] = match;
172 cluster->SetEmcCpvDistance(TMath::Sqrt(match));
173 cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz));
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);
179 //HLTInfo("Added track %d to cluster %d, it now has %d matching tracks", track->GetID(), cluster->GetID(), cluster->GetNTracksMatched());