*/
+
#include "AliHLTLogging.h"
#include "AliESDtrack.h"
#include "TObjArray.h"
#include "TArrayI.h"
+#include "TVector3.h"
class AliHLTGlobalTrackMatcher : public AliHLTLogging{
//Main function, loops over tracks and calls appropriate functions to establish matches
template <class T>
- Int_t Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz );
+ Int_t Match( TObjArray * trackArray, vector<T*> &phosClustersVector, vector<T*> &emcalClustersVector, Double_t bz );
private:
template <class T>
-Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &clustersVector, Double_t bz ) {
+Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*> &phosClustersVector, vector<T*> &emcalClustersVector, Double_t bz ) {
//See above for documentation
+
Int_t nTracks = trackArray->GetEntriesFast();
- Int_t nPhosClusters = clustersVector.size();
-
- //TODO emcal not yet implemented
- Int_t nEmcalClusters = 0; //BALLE event->GetEMCALClusters(fEmcalClustersArray);
+ Int_t nPhosClusters = phosClustersVector.size();
+ Int_t nEmcalClusters = emcalClustersVector.size();
+
+ //HLTError("tracks phos emcal %d %d %d", nTracks, nPhosClusters, nEmcalClusters);
+
+ //See if there are tracks and clusters to match
if ( nTracks <= 0 ) {
- HLTWarning("No tracks in event");
return 0;
- } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) {
- HLTWarning("No calorimeter clusters in Event");
+ } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) {
return 0;
}
+
Float_t bestMatchPhos[nPhosClusters];
for(int ic = 0; ic < nPhosClusters; ic++) {
bestMatchPhos[ic] = 999999;
}
-
- //BALLE TODO EMCAL implement
- // Float_t bestMatchEmcal[nEmcalClusters];
- // for(int ic = 0; ic < nEmcalClusters; ic++) {
- // bestMatchEmcal[ic] = 999999;
- // }
-
-
+
+ Float_t bestMatchEmcal[nEmcalClusters];
+ for(int ic = 0; ic < nEmcalClusters; ic++) {
+ bestMatchEmcal[ic] = 999999;
+ }
+
//Loop over tracks
for (int it = 0; it < nTracks; it++ ) {
AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
- MatchTrackToClusters( track, clustersVector, nPhosClusters, bestMatchPhos, bz);
-
- //BALLE TODO EMCAL !!!!
- // } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
- // MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz);
+ MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz);
+
+ } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
+ MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz);
}
-
- } // track loop
-
+ }
return 0;
}
//Get cluster global coordinates
cluster->GetPosition(clusterPosition);
-
- //Get track postion at radius of cluster
+
Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]);
- if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
- HLTWarning("Track reached detector but not cluster!!!!!!");
+
+ //Rotate tracking system to the angle of the cluster
+ TVector3 cVec(clusterPosition);
+ if (! (track->Rotate(cVec.Phi())) ) {
+ continue;
+ }
+
+ if(! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
continue;
}
-
- //Calculate track - cluster residual
-
- //Get residual in z= 0 plane (squared)
- Double_t dxy = 0;
- for(int i = 0; i < 2; i++) {
+ //Calculate track - cluster residuals
+ Double_t match = 0;
+ for(int i = 0; i < 3; i++) {
Double_t dd = trackPosition[i] - clusterPosition[i];
- dxy += dd*dd;
+ match += dd*dd;
}
- //Get z residual (squared)
- Double_t dd = trackPosition[2] - clusterPosition[2];
- Double_t dz = dd*dd;
-
- Double_t match = dz + dxy;
-
if( match > fMatchDistance ) {
continue;
}
if (match < bestMatch[ic]) {
+
bestMatch[ic] = match;
cluster->SetEmcCpvDistance(TMath::Sqrt(match));
- //cluster->SEt
+
+ Double_t dx = trackPosition[0] - clusterPosition[0];
+ Double_t dy = trackPosition[1] - clusterPosition[1];
+ Double_t dz = trackPosition[2] - clusterPosition[2];
+ cluster->SetTrackDistance( ((dx > 0) ? 1 : -1 )*TMath::Sqrt(dx*dx + dy*dy), dz);
}
//Add track to cluster's array of matching tracks
Int_t nTracksMatched = cluster->GetNTracksMatched();
iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched);
- HLTInfo("Added track %d to cluster %d, it now has %d matching tracks", track->GetID(), cluster->GetID(), cluster->GetNTracksMatched());
}
return iResult;