]>
Commit | Line | Data |
---|---|---|
3cfb9c56 | 1 | //$Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Jacek Otwinowski (Jacek.Otwinowski@gsi.de) * | |
8 | * for The ALICE HLT Project. * | |
9 | * * | |
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 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTGlobalTrackMatcher.cxx | |
bad7877b | 20 | @author Svein Lindal |
3cfb9c56 | 21 | @date |
bad7877b | 22 | @brief The HLT class Matching Calorimeter clusters to TPC tracks |
3cfb9c56 | 23 | */ |
24 | ||
25 | //#include "AliTPCReconstructor.h" | |
26 | ||
27 | #include "AliHLTGlobalTrackMatcher.h" | |
28 | #include "AliExternalTrackParam.h" | |
29 | #include "AliHLTCaloClusterDataStruct.h" | |
bad7877b | 30 | #include "AliHLTCaloClusterReader.h" |
3cfb9c56 | 31 | #include "AliPHOSGeoUtils.h" |
bad7877b | 32 | #include "AliESDEvent.h" |
33 | ||
34 | //struct AliHLTCaloClusterHeaderStruct; | |
3cfb9c56 | 35 | |
36 | #if __GNUC__>= 3 | |
37 | using namespace std; | |
38 | #endif | |
39 | ||
40 | ClassImp(AliHLTGlobalTrackMatcher) | |
41 | ||
42 | AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() : | |
bad7877b | 43 | fClusterReader(NULL), |
44 | fPHOSGeom(NULL), | |
3cfb9c56 | 45 | fMaxZ(64.+10.), |
46 | fMaxX(72. + 72.*TMath::Sin(20) + 72.*TMath::Sin(40) +10. ), | |
47 | fMinX(-72.-10.), | |
bad7877b | 48 | |
49 | fDetRadius(-99999), | |
50 | fMatchDistanceSq(400), | |
708ccd54 | 51 | fNModules(3), |
bad7877b | 52 | fBestMatchesArray(NULL), |
53 | fTrackDistanceArray(NULL) | |
3cfb9c56 | 54 | { |
bad7877b | 55 | fClusterReader= new AliHLTCaloClusterReader(); |
3cfb9c56 | 56 | fPHOSGeom = new AliPHOSGeoUtils("PHOS", "noCPV"); |
3cfb9c56 | 57 | } |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliHLTGlobalTrackMatcher::~AliHLTGlobalTrackMatcher() | |
61 | { | |
62 | //Destructor | |
bad7877b | 63 | if (fPHOSGeom) |
64 | delete fPHOSGeom; | |
65 | fPHOSGeom = NULL; | |
3cfb9c56 | 66 | |
de31859c | 67 | if (fClusterReader) |
68 | delete fClusterReader; | |
69 | fClusterReader = NULL; | |
bad7877b | 70 | } |
3cfb9c56 | 71 | |
72 | //_____________________________________________________________________________ | |
bad7877b | 73 | Bool_t AliHLTGlobalTrackMatcher::Match(AliESDEvent* esdEvent, AliHLTCaloClusterHeaderStruct * clusterHeader) |
3cfb9c56 | 74 | { |
3cfb9c56 | 75 | |
bad7877b | 76 | Double_t fNormVector[5][3] = { |
77 | {0, 0, 0}, | |
78 | {0, 0, 0}, | |
79 | {0, 10, 0}, | |
80 | {10*TMath::Cos(20), 10*TMath::Sin(20), 0}, | |
81 | {10*TMath::Cos(40), 10*TMath::Sin(40), 0}, | |
82 | }; | |
83 | ||
bad7877b | 84 | fClusterReader->SetMemory(clusterHeader); |
85 | ||
86 | int nClusters = clusterHeader->fNClusters; | |
bad7877b | 87 | if( !(nClusters> 0) ) |
de31859c | 88 | return 0; |
89 | ||
90 | ||
91 | Double_t tDistance[nClusters]; | |
3cfb9c56 | 92 | |
de31859c | 93 | for(int i = 0; i < nClusters; i++) { |
94 | tDistance[i] = 99999; | |
95 | } | |
bad7877b | 96 | |
97 | //Position of track intersection with cylindrical plane defined by PHOS radius | |
3cfb9c56 | 98 | Double_t trackPos[3] = {0,0,0}; |
99 | ||
bad7877b | 100 | Double_t bz = esdEvent->GetMagneticField(); |
101 | int nt = esdEvent->GetNumberOfTracks(); | |
3cfb9c56 | 102 | for (int it = 0; it < nt; it++ ) { |
bad7877b | 103 | |
104 | AliExternalTrackParam * track = static_cast<AliExternalTrackParam*> (esdEvent->GetTrack(it)) ; | |
3cfb9c56 | 105 | |
bad7877b | 106 | //See if track is even close to detector volume |
3cfb9c56 | 107 | if (! (track->GetXYZAt(fDetRadius, bz, trackPos)) ) |
108 | continue; | |
109 | ||
110 | if (trackPos[3] > fMaxZ || trackPos[3] < -fMaxZ) | |
111 | continue; | |
112 | ||
113 | if (trackPos[0] > fMaxX || trackPos[0] < fMinX) | |
114 | continue; | |
115 | ||
116 | //Track is close to Detector volume | |
bad7877b | 117 | //loop over clusters to find clusters that are fairly close to track |
3cfb9c56 | 118 | |
bad7877b | 119 | fClusterReader->SetMemory(clusterHeader); |
bad7877b | 120 | int clusterIndex = -1; |
121 | AliHLTCaloClusterDataStruct* cluster; | |
122 | while( (cluster = fClusterReader->NextCluster()) ) { | |
bad7877b | 123 | clusterIndex++; |
de31859c | 124 | |
bad7877b | 125 | //Get approximate distance between cluster and track |
126 | Double_t clusterPos[3] = {cluster->fGlobalPos[0], cluster->fGlobalPos[1], cluster->fGlobalPos[2]}; | |
127 | Double_t distanceSq = 0; | |
128 | for(int i = 0; i < 3; i++) { | |
129 | Float_t distance = trackPos[i] - clusterPos[1]; | |
130 | distanceSq += distance*distance; | |
131 | } | |
3cfb9c56 | 132 | |
bad7877b | 133 | if (distanceSq >( fMatchDistanceSq + 60) ) |
134 | continue; | |
135 | ||
136 | //We have a cluster in relatively close proximity to the track, do more accurate matching | |
3cfb9c56 | 137 | |
bad7877b | 138 | //Get the module where the cluster is located |
139 | //Need CellId of one of the cells of the cluster; | |
140 | UShort_t cellId = -1; | |
141 | Double_t cellAmp = -1; | |
3cfb9c56 | 142 | |
bad7877b | 143 | //Get a (any) cell in the cluster |
144 | fClusterReader->GetCell(cluster, cellId, cellAmp, (UInt_t) (0) ); | |
3cfb9c56 | 145 | |
bad7877b | 146 | //Use cellId to find module nr; |
147 | Int_t relNumbering[4]; | |
148 | fPHOSGeom->AbsToRelNumbering(cellId, relNumbering); | |
3cfb9c56 | 149 | |
bad7877b | 150 | //Project the track to the plane defined by the module geometry and find intersection point |
151 | track->Intersect(clusterPos, fNormVector[relNumbering[0]], bz); | |
3cfb9c56 | 152 | |
bad7877b | 153 | //Is the track closer to the cluster than previous matches? |
154 | distanceSq = clusterPos[0]*clusterPos[0] + clusterPos[2]* clusterPos[2]; | |
de31859c | 155 | |
156 | //Is track close enough to be considered a match? | |
157 | if( distanceSq < fMatchDistanceSq) { | |
158 | ||
159 | //Is this a better match than previous best match? | |
160 | if ( distanceSq < tDistance[clusterIndex] ) { | |
161 | ||
162 | //Yes, add track label at beginning of array of matching track | |
163 | if( !(cluster->fTracksMatched) ) { | |
164 | cluster->fTracksMatched = new TArrayI(1); | |
165 | cluster->fTracksMatched->AddAt(track->GetLabel(), 0); | |
166 | } else { | |
167 | //Increase Array size by one | |
168 | cluster->fTracksMatched->Set(cluster->fTracksMatched->GetSize() + 1); | |
169 | //Move previous best match to last spot | |
170 | cluster->fTracksMatched->AddAt(cluster->fTracksMatched->GetAt(0), cluster->fTracksMatched->GetSize() - 1); | |
171 | //Finally add the new best to first spot | |
172 | cluster->fTracksMatched->AddAt(track->GetLabel(), 0); | |
b3e7198f | 173 | } |
de31859c | 174 | |
175 | //This is the new standard for best match | |
176 | tDistance[clusterIndex] = distanceSq; | |
177 | ||
178 | } else { | |
179 | ||
180 | //It's a match, but not best match | |
de31859c | 181 | //Increase Array size by one |
182 | cluster->fTracksMatched->Set(cluster->fTracksMatched->GetSize() + 1); | |
183 | //Add new track at back of the array | |
184 | cluster->fTracksMatched->AddAt(track->GetLabel(), cluster->fTracksMatched->GetSize() - 1); | |
185 | ||
186 | } | |
187 | ||
188 | } // if (distanceSq < fMaxDistanceSq) | |
189 | ||
190 | } //cluster loopx | |
191 | } // track loop | |
3cfb9c56 | 192 | |
de31859c | 193 | return 0; |
3cfb9c56 | 194 | |
bad7877b | 195 | } |