]>
Commit | Line | Data |
---|---|---|
dadc7068 | 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: Gaute Ovrebekk <ovrebekk@ift.uib.no> * | |
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 AliHLTTPCTrackHistoComponent.cxx | |
20 | @author Gaute Ovrebekk, Matthias Richter | |
21 | @date | |
22 | @brief The TPC conformal mapping tracker component. | |
23 | */ | |
24 | ||
25 | ||
26 | #if __GNUC__>= 3 | |
27 | using namespace std; | |
28 | #endif | |
29 | ||
30 | #include "AliHLTTPCTrackHistoComponent.h" | |
31 | #include "AliHLTTPCTransform.h" | |
32 | #include "AliHLTTPCClusterDataFormat.h" | |
33 | #include "AliHLTTPCTrackletDataFormat.h" | |
34 | #include "AliHLTTPCMemHandler.h" | |
35 | #include "AliHLTTPCDefinitions.h" | |
e2a9091e | 36 | #include "AliHLTTPCTrackArray.h" |
37 | #include "AliHLTTPCTrack.h" | |
38 | //#include "AliHLTGlobalBarrelTrack.h" | |
39 | #include "AliHLTExternalTrackParam.h" | |
40 | #include "AliHLTDataTypes.h" | |
41 | ||
dadc7068 | 42 | #include <TFile.h> |
43 | #include <TString.h> | |
a267c68e | 44 | #include "TNtuple.h" |
dadc7068 | 45 | #include "TObjString.h" |
46 | #include "TObjArray.h" | |
47 | ||
dadc7068 | 48 | |
dadc7068 | 49 | AliHLTTPCTrackHistoComponent gAliHLTTPCTrackHistoComponent; |
50 | ||
51 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
52 | ClassImp(AliHLTTPCTrackHistoComponent) | |
53 | ||
54 | AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent() | |
e2a9091e | 55 | : |
56 | fMinSlice(35), | |
57 | fMaxSlice(0), | |
58 | fMinPartition(5), | |
59 | fMaxPartition(0), | |
60 | fClusters(NULL), | |
a267c68e | 61 | fTracks(NULL), |
62 | fTracksArray(NULL) | |
e2a9091e | 63 | //fClustersArray(NULL), |
64 | //fNSpacePoints(NULL) | |
dadc7068 | 65 | { |
dadc7068 | 66 | // see header file for class documentation |
67 | // or | |
68 | // refer to README to build package | |
69 | // or | |
70 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
dadc7068 | 71 | } |
72 | ||
e2a9091e | 73 | AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent(){ |
74 | // see header file for class documentation | |
dadc7068 | 75 | } |
76 | ||
77 | // Public functions to implement AliHLTComponent's interface. | |
78 | // These functions are required for the registration process | |
79 | ||
e2a9091e | 80 | const char* AliHLTTPCTrackHistoComponent::GetComponentID(){ |
81 | // see header file for class documentation | |
dadc7068 | 82 | |
83 | return "TPCTrackHisto"; | |
84 | } | |
85 | ||
e2a9091e | 86 | void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){ |
87 | // see header file for class documentation | |
dadc7068 | 88 | list.clear(); |
e2a9091e | 89 | list.push_back(AliHLTTPCDefinitions::fgkClustersDataType); |
90 | list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); | |
91 | //list.push_back(AliHLTTPCDefinitions::fgkTracksDataType); | |
92 | list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); | |
93 | list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); | |
dadc7068 | 94 | } |
95 | ||
e2a9091e | 96 | AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType(){ |
97 | // see header file for class documentation | |
a267c68e | 98 | return kAliHLTDataTypeTNtuple; |
dadc7068 | 99 | } |
100 | ||
e2a9091e | 101 | void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){ |
102 | // see header file for class documentation | |
103 | ||
dadc7068 | 104 | constBase = 0; |
e2a9091e | 105 | inputMultiplier = 1;// XXX TODO: Find more realistic value |
dadc7068 | 106 | } |
107 | ||
e2a9091e | 108 | AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn(){ |
109 | // see header file for class documentation | |
dadc7068 | 110 | return new AliHLTTPCTrackHistoComponent; |
111 | } | |
112 | ||
e2a9091e | 113 | int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv ){ |
114 | // see header file for class documentation | |
a267c68e | 115 | |
e2a9091e | 116 | fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ:event"); |
117 | fTracks = new TNtuple("fTracks", "fTracks", "pt:eta:psi:nclusters:event"); | |
118 | fTracksArray = new AliHLTTPCTrackArray(); | |
119 | ||
120 | int iResult = 0; | |
121 | TString configuration = ""; | |
122 | TString argument = ""; | |
123 | for(int i=0; i<argc && iResult>=0; i++){ | |
124 | argument = argv[i]; | |
125 | if(!configuration.IsNull()) configuration += " "; | |
126 | configuration += argument; | |
dadc7068 | 127 | } |
128 | ||
e2a9091e | 129 | if(!configuration.IsNull()){ |
130 | iResult = Configure(configuration.Data()); | |
dadc7068 | 131 | } |
132 | return iResult; | |
133 | } | |
134 | ||
e2a9091e | 135 | int AliHLTTPCTrackHistoComponent::DoDeinit(){ |
136 | // see header file for class documentation | |
dadc7068 | 137 | |
a267c68e | 138 | delete fClusters; |
139 | delete fTracks; | |
140 | delete fTracksArray; | |
141 | ||
dadc7068 | 142 | return 0; |
143 | } | |
144 | ||
e2a9091e | 145 | int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){ |
146 | // see header file for class documentation | |
dadc7068 | 147 | |
e2a9091e | 148 | if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0; |
149 | if(!fTracksArray) fTracksArray = new AliHLTTPCTrackArray(); | |
dadc7068 | 150 | |
e2a9091e | 151 | const AliHLTComponentBlockData *iter = NULL; |
dadc7068 | 152 | |
e2a9091e | 153 | // //----------------- loop over slice tracks ----------------------// |
154 | // | |
155 | // for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock()){ | |
156 | // if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType)continue; | |
157 | // ReadTracks(iter,totalTracks); | |
158 | // } | |
159 | ||
dadc7068 | 160 | |
e2a9091e | 161 | |
162 | //----------------- loop over cluster blocks ---------------------// | |
163 | ||
164 | Int_t totalSpacePoints = 0; | |
165 | ||
166 | for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){ | |
167 | ||
168 | if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue; | |
169 | ||
170 | AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); | |
171 | AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); | |
172 | //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition); | |
173 | ||
174 | const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr; | |
175 | Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt; | |
176 | totalSpacePoints += nSpacepoint; | |
177 | HLTDebug("TrackHisto component found %d spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition); | |
178 | ||
179 | AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints; | |
180 | ||
181 | if(fClustersArray[minSlice][minPartition] != NULL){ | |
182 | //delete(fClustersArray[minSlice][minPartition]); | |
183 | fClustersArray[minSlice][minPartition] = NULL; | |
184 | } | |
185 | ||
186 | // fill the array with AliHLTTPCSpacePointData pointers | |
187 | // it will be used in the track loop to access information | |
188 | // for the used clusters only | |
189 | fClustersArray[minSlice][minPartition] = clusters; | |
190 | fNSpacePoints[minSlice][minPartition] = nSpacepoint; | |
191 | ||
192 | if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL; | |
193 | ||
194 | } // end of loop over cluster data blocks | |
195 | ||
196 | HLTInfo("TrackHisto found %d spacepoints",totalSpacePoints); | |
197 | ||
198 | ||
199 | ||
200 | ||
201 | //----------------- loop over merged tracks -------------------// | |
dadc7068 | 202 | |
e2a9091e | 203 | Int_t totalTracks = 0; |
a9f47f83 | 204 | |
e2a9091e | 205 | for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){ |
206 | if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue; | |
207 | ReadTracks(iter,totalTracks); | |
208 | } | |
dadc7068 | 209 | |
e2a9091e | 210 | HLTInfo("TrackHisto found %d tracks", totalTracks); |
dadc7068 | 211 | PushHisto(); |
212 | ||
a267c68e | 213 | delete fTracksArray; |
e2a9091e | 214 | fTracksArray = NULL; |
dadc7068 | 215 | |
216 | return 0; | |
217 | } | |
218 | ||
e2a9091e | 219 | int AliHLTTPCTrackHistoComponent::Configure(const char* arguments){ |
220 | // see header file for class documentation | |
dadc7068 | 221 | |
222 | int iResult=0; | |
223 | if (!arguments) return iResult; | |
224 | ||
225 | TString allArgs=arguments; | |
226 | TString argument; | |
227 | ||
228 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
dadc7068 | 229 | if (pTokens) { |
230 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
231 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
232 | if (argument.IsNull()) continue; | |
233 | ||
a267c68e | 234 | HLTError("unknown argument %s", argument.Data()); |
235 | iResult=-EINVAL; | |
236 | break; | |
dadc7068 | 237 | } |
238 | delete pTokens; | |
e2a9091e | 239 | } |
dadc7068 | 240 | return iResult; |
241 | } | |
242 | ||
243 | void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){ | |
e2a9091e | 244 | // see header file for class documentation |
dadc7068 | 245 | |
e2a9091e | 246 | AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); |
247 | AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); | |
248 | ||
249 | if( slice < fMinSlice ) fMinSlice = slice; | |
250 | if( slice > fMaxSlice ) fMaxSlice = slice; | |
251 | if( partition < fMinPartition ) fMinPartition = partition; | |
252 | if( partition > fMaxPartition ) fMaxPartition = partition; | |
253 | ||
254 | AliHLTTracksData *trackData = (AliHLTTracksData*)(iter->fPtr); | |
255 | AliHLTUInt32_t nTracks = trackData->fCount; | |
256 | ||
257 | ||
258 | AliHLTExternalTrackParam *track = (AliHLTExternalTrackParam*)trackData->fTracklets; | |
259 | tt+= nTracks; | |
260 | ||
261 | fTracksArray->FillTracksChecked(trackData->fTracklets,trackData->fCount,iter->fSize,slice,true); | |
262 | ||
263 | Int_t usedSpacePoints = 0; | |
dadc7068 | 264 | |
e2a9091e | 265 | for(AliHLTUInt32_t i=0;i<nTracks;i++){ |
266 | ||
267 | UInt_t nHits = track->fNPoints; | |
268 | fTracks->Fill( track->fq1Pt, track->fSinPsi, track->fTgl, nHits, GetEventId() ); | |
269 | ||
270 | const UInt_t *hitnum = track->fPointIDs; | |
271 | for(UInt_t h=0; h<nHits; h++){ | |
272 | ||
273 | UInt_t idTrack = hitnum[h]; | |
274 | Int_t sliceTrack = (idTrack>>25) & 0x7f; | |
275 | Int_t patchTrack = (idTrack>>22) & 0x7; | |
276 | UInt_t pos = idTrack&0x3fffff; | |
277 | ||
278 | // use the fClustersArray that was filled in the cluster loop | |
279 | if( !fClustersArray[sliceTrack][patchTrack] ) continue; | |
280 | if( fNSpacePoints[sliceTrack][patchTrack]<pos ) HLTError("Space point array out of boundaries!"); | |
281 | ||
282 | Float_t resy = 0., resz = 0.; | |
283 | ||
284 | FillResidual(pos,sliceTrack,patchTrack,resy,resz); | |
285 | fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, resy, resz, GetEventId() ); | |
286 | ||
287 | usedSpacePoints++; | |
288 | } | |
289 | UChar_t *tmpP = (UChar_t*)track; | |
290 | tmpP += sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t); | |
291 | track = (AliHLTExternalTrackParam*)tmpP; | |
292 | } | |
293 | ||
294 | ||
295 | /* //HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, partition ); | |
a267c68e | 296 | AliHLTTPCTrackletData* trackData = (AliHLTTPCTrackletData*) iter->fPtr; |
dadc7068 | 297 | AliHLTUInt32_t nTracks = trackData->fTrackletCnt; |
a267c68e | 298 | fTracksArray->FillTracksChecked(trackData->fTracklets,trackData->fTrackletCnt,iter->fSize,slice,true); |
e2a9091e | 299 | |
300 | //HLTInfo("TrackHisto found %d Tracks in slice %d partition %d", nTracks, slice, partition); | |
dadc7068 | 301 | AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*) trackData->fTracklets; |
302 | ||
303 | for(AliHLTUInt32_t i=0;i<nTracks;i++){ | |
dadc7068 | 304 | UInt_t nHits = tracks->fNPoints; |
a267c68e | 305 | |
306 | fTracks->Fill(tracks->fPt,tracks->fPsi,tracks->fTgl,nHits,GetEventId()); | |
307 | ||
dadc7068 | 308 | const UInt_t *hitnum = tracks->fPointIDs; |
309 | for(UInt_t h=0; h<nHits; h++){ | |
310 | UInt_t idTrack = hitnum[h]; | |
311 | Int_t sliceTrack = (idTrack>>25) & 0x7f; | |
312 | Int_t patchTrack = (idTrack>>22) & 0x7; | |
313 | UInt_t pos = idTrack&0x3fffff; | |
314 | fTrackClusterID[sliceTrack][patchTrack].push_back(pos); | |
315 | } | |
316 | UChar_t *tmpP = (UChar_t*)tracks; | |
317 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+tracks->fNPoints*sizeof(UInt_t); | |
318 | tracks = (AliHLTTPCTrackSegmentData*)tmpP; | |
e2a9091e | 319 | } */ |
dadc7068 | 320 | } |
321 | ||
322 | void AliHLTTPCTrackHistoComponent::PushHisto(){ | |
e2a9091e | 323 | // see header file for class documentation |
dadc7068 | 324 | |
e2a9091e | 325 | AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(fMinSlice,fMaxSlice,fMinPartition,fMaxPartition); |
326 | PushBack( (TObject*)fTracks, kAliHLTDataTypeTNtuple, fSpecification); | |
327 | PushBack( (TObject*)fClusters,kAliHLTDataTypeTNtuple, fSpecification); | |
a267c68e | 328 | } |
a267c68e | 329 | |
e2a9091e | 330 | void AliHLTTPCTrackHistoComponent::FillResidual(UInt_t pos,AliHLTUInt8_t slice,AliHLTUInt8_t partition,Float_t& resy,Float_t& resz){ |
331 | // see header file for class documentation | |
332 | ||
333 | AliHLTTPCSpacePointData *cl = &fClustersArray[slice][partition][pos]; | |
334 | if(!cl) return; | |
a267c68e | 335 | |
336 | AliHLTTPCTrack *gtrack = NULL; | |
337 | ||
e2a9091e | 338 | for(int i=0;i<fTracksArray->GetNTracks();i++){ |
339 | ||
340 | AliHLTTPCTrack *tt = fTracksArray->GetCheckedTrack(i); | |
341 | UInt_t *hitnum =tt->GetHitNumbers(); | |
342 | Int_t nHits = tt->GetNHits(); | |
343 | ||
344 | for(Int_t h=0; h<nHits; h++){ | |
345 | UInt_t id=hitnum[h]; | |
346 | Int_t Tslice = (id>>25) & 0x7f; | |
347 | Int_t Tpatch = (id>>22) & 0x7; | |
348 | UInt_t Tpos = id&0x3fffff; | |
349 | if(Tslice==slice && Tpatch==partition && Tpos==pos){ | |
350 | gtrack = tt; | |
351 | break; | |
352 | } | |
353 | } | |
354 | } | |
355 | ||
356 | if(!gtrack) return; | |
a267c68e | 357 | |
358 | Int_t tslice = gtrack->GetSector(); | |
359 | Double_t radius = gtrack->GetRadius(); // radius | |
360 | Double_t kappa = gtrack->GetKappa(); // curvature = 1/R , signed | |
361 | Double_t lambda = atan( gtrack->GetTgl() ); // dipAngle lambda | |
362 | ||
363 | // ------------------------------------ | |
364 | // ++ Get first/last point of the track | |
365 | ||
366 | Double_t xyzL[3]; // lastpoint of track | |
367 | Double_t xyzF[3]; // firstpoint of track | |
368 | ||
369 | xyzF[0] = gtrack->GetFirstPointX(); | |
370 | xyzF[1] = gtrack->GetFirstPointY(); | |
371 | xyzF[2] = gtrack->GetFirstPointZ(); | |
372 | ||
373 | xyzL[0] = gtrack->GetLastPointX(); | |
374 | xyzL[1] = gtrack->GetLastPointY(); | |
375 | xyzL[2] = gtrack->GetLastPointZ(); | |
376 | ||
377 | // -------------------------- | |
378 | // ++ Calculate length of the track | |
379 | ||
380 | Double_t s = 0.; // length of the track | |
381 | if ( AliHLTTPCTransform::GetBFieldValue() == 0. || kappa == 0 ) | |
382 | s = sqrt ( (xyzL[0] - xyzF[0])*(xyzL[0] - xyzF[0]) + (xyzL[1] - xyzF[1])*(xyzL[1] - xyzF[1]) ); | |
383 | else { | |
384 | // Calculate the length of the track. If it is to flat in in s,z plane use sxy, otherwise use sz | |
385 | if (fabs(lambda) > 0.05){ | |
386 | // length of track calculated out of z | |
387 | s = fabs( (xyzL[2] - xyzF[2]) / sin(lambda) ); // length of track calculated out of z | |
388 | } | |
389 | else { | |
390 | Double_t d = (xyzL[0] - xyzF[0])*(xyzL[0] - xyzF[0]) + (xyzL[1] - xyzF[1])*(xyzL[1] - xyzF[1]); | |
391 | // length of track calculated out of xy | |
392 | s = fabs ( acos( 0.5 * (2 - (d / (radius*radius)))) / ( kappa * cos(lambda) ) ); | |
393 | } | |
a9f47f83 | 394 | } |
dadc7068 | 395 | |
a267c68e | 396 | gtrack->Rotate(tslice,kTRUE); |
397 | ||
af69d367 | 398 | //Double_t padrows = 0; |
a267c68e | 399 | |
400 | Float_t xyzC[3]; // cluster tmp | |
401 | Float_t xyzTtmp[3]; // track tmp | |
402 | ||
403 | xyzC[0] = cl->fX; | |
404 | xyzC[1] = cl->fY; | |
405 | xyzC[2] = cl->fZ; | |
406 | ||
407 | Int_t padrow = AliHLTTPCTransform::GetPadRow(cl->fX); | |
408 | ||
409 | xyzTtmp[0] = gtrack->GetFirstPointX(); | |
410 | ||
411 | if(gtrack->GetCrossingPoint(padrow,xyzTtmp)) { | |
412 | // ---------------------- | |
413 | // ++ Calculate Residuals | |
414 | ||
415 | Float_t deltaY = ( xyzC[1] - xyzTtmp[1] ); | |
416 | Float_t deltaZ = ( xyzC[2] - xyzTtmp[2] ); | |
417 | ||
418 | resy = deltaY; | |
419 | resz = deltaZ; | |
e2a9091e | 420 | } else { |
a267c68e | 421 | resy = -1000; |
422 | resz = -1000; | |
5a90a5a4 | 423 | } |
dadc7068 | 424 | } |