3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Jacek Otwinowski (Jacek.Otwinowski@gsi.de) *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTGlobalTrackMatcher.cxx
20 @author Jacek Otwinowski
22 @brief The HLT global merger base class
25 //#include "AliTPCReconstructor.h"
27 #include "AliHLTGlobalTrackMatcher.h"
28 #include "AliExternalTrackParam.h"
29 #include "AliHLTCaloClusterDataStruct.h"
30 #include "AliPHOSGeoUtils.h"
36 ClassImp(AliHLTGlobalTrackMatcher)
38 AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() :
40 fMaxX(72. + 72.*TMath::Sin(20) + 72.*TMath::Sin(40) +10. ),
44 fMaxSqDistance(99999),
45 fMatchingDistanceSq(9999999)
49 fPHOSGeom = new AliPHOSGeoUtils("PHOS", "noCPV");
54 //_____________________________________________________________________________
55 AliHLTGlobalTrackMatcher::~AliHLTGlobalTrackMatcher()
64 //_____________________________________________________________________________
65 Bool_t AliHLTGlobalTrackMatcher::Match(AliHLTComponentBlockData* pBlock)
68 Float_t shortestDistance = fMatchingDistance;
70 //Should be moved to constructor, fPHOSAngles should be a
71 Float_t fPHOSAngles[5] = {40, 20 , 0, -20 , 40};
72 Double_t fNormVector[1][3] = {{0, 0, 0}};
74 //Helper variables, must be set dynamically;
76 AliExternalTrackParam * track = NULL;
77 AliHLTCaloClusterDataStruct * cluster = NULL;
80 Double_t trackPos[3] = {0,0,0};
82 for (int it = 0; it < nt; it++ ) {
87 //See it track is even close to detector volume
88 if (! (track->GetXYZAt(fDetRadius, bz, trackPos)) )
91 if (trackPos[3] > fMaxZ || trackPos[3] < -fMaxZ)
94 if (trackPos[0] > fMaxX || trackPos[0] < fMinX)
97 //Track is close to Detector volume
98 //loop over clusters and find clusters that are fairly near track
99 //for(int ic = 0; ic < nClusters; ic++) {
100 Double_t clusterPos[3] = {cluster->fGlobalPos[0], cluster->fGlobalPos[1], cluster->fGlobalPos[2]};
101 Double_t distanceSq = 0;
103 //Find approximate distance between track and cluster
104 for(int i = 0; i < 3; i++) {
105 Float_t distance = trackPos[i] - clusterPos[1];
106 distanceSq += distance*distance;
110 if (distanceSq > fMaxSqDistance )
113 //We have a track in relatively close proximity to a cluster, do more accurate matching
115 //Get the module where the cluster is located
116 //Need CellId of one of the cells of the cluster;
119 Int_t relNumbering[4];
120 //BALLE check formart of relnumbering!!!!
121 fPHOSGeom->AbsToRelNumbering(cellId, relNumbering);
123 //Project the track to the plane defined by the module geometry.
124 track->Intersect(clusterPos, fNormVector[(int) relNumbering[0]], bz);
126 //Is the track closer to the cluster than previous matches.
127 if ( (Float_t distanceSq = clusterPos[0]*clusterPos[0] + clusterPos[2]* clusterPos[2]) < fTrackDistance[clusterIndex]*fTrackDistance[clusterIndex] ) {
129 fBestMatches[clusterIndex] = trackIndex;
130 fTrackDistance[clusterIndex] = distanceSq;
134 }//done looping over clusters