]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCTrackHistoComponent.cxx
cmake update (Oystein)
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCTrackHistoComponent.cxx
CommitLineData
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
dadc7068 25#if __GNUC__>= 3
26using namespace std;
27#endif
28
29#include "AliHLTTPCTrackHistoComponent.h"
30#include "AliHLTTPCTransform.h"
31#include "AliHLTTPCClusterDataFormat.h"
32#include "AliHLTTPCTrackletDataFormat.h"
33#include "AliHLTTPCMemHandler.h"
34#include "AliHLTTPCDefinitions.h"
97fdadce 35#include "AliHLTGlobalBarrelTrack.h"
e2a9091e 36#include "AliHLTExternalTrackParam.h"
37#include "AliHLTDataTypes.h"
38
dadc7068 39#include <TFile.h>
40#include <TString.h>
a267c68e 41#include "TNtuple.h"
2c95fda7 42#include "TH1F.h"
43#include "TProfile.h"
dadc7068 44#include "TObjString.h"
45#include "TObjArray.h"
46
dadc7068 47
dadc7068 48/** ROOT macro for the implementation of ROOT specific class methods */
49ClassImp(AliHLTTPCTrackHistoComponent)
50
51AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent()
97fdadce 52 :
53 fMinSlice(35)
54 , fMaxSlice(0)
55 , fMinPartition(5)
56 , fMaxPartition(0)
57 //, fReset(0)
58 , fNEvents(0)
59 , fNtotTracks(0)
60 , fEvtMod(20)
61 , fBufferSize(5000)
f53b49dd 62 , fdEdx(kFALSE)
97fdadce 63 , fMeanMultiplicity(NULL)
64 , fMultiplicity(NULL)
f53b49dd 65 , fDeDxVsP(NULL)
97fdadce 66 , fClusters(NULL)
67 , fTracks(NULL)
68 //, fNClusterVsXY(NULL)
69 //, fChargeVsXY(NULL)
97fdadce 70 //, fClustersArray(NULL)
71 //, fNSpacePoints(NULL)
dadc7068 72{
dadc7068 73 // see header file for class documentation
74 // or
75 // refer to README to build package
76 // or
77 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
dadc7068 78}
79
97fdadce 80const char* AliHLTTPCTrackHistoComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCTrackHisto";
81
e2a9091e 82AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent(){
83// see header file for class documentation
dadc7068 84}
85
86// Public functions to implement AliHLTComponent's interface.
87// These functions are required for the registration process
88
e2a9091e 89const char* AliHLTTPCTrackHistoComponent::GetComponentID(){
90// see header file for class documentation
dadc7068 91
92 return "TPCTrackHisto";
93}
94
e2a9091e 95void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
96// see header file for class documentation
97fdadce 97
dadc7068 98 list.clear();
2c95fda7 99 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC);
e2a9091e 100 list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
97fdadce 101 //list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
dadc7068 102}
103
e2a9091e 104AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType(){
105// see header file for class documentation
2c95fda7 106 return kAliHLTMultipleDataType;
107}
108
109int AliHLTTPCTrackHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
110// see header file for class documentation
111 tgtList.clear();
112 tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC);
113 tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
114 return tgtList.size();
dadc7068 115}
116
e2a9091e 117void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
118// see header file for class documentation
119
dadc7068 120 constBase = 0;
e2a9091e 121 inputMultiplier = 1;// XXX TODO: Find more realistic value
dadc7068 122}
123
e2a9091e 124AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn(){
125// see header file for class documentation
dadc7068 126 return new AliHLTTPCTrackHistoComponent;
127}
128
e2a9091e 129int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv ){
130// see header file for class documentation
a267c68e 131
482875f5 132 fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ");
482875f5 133 fTracks = new TNtuple("fTracks", "fTracks", "pt:eta:psi:nclusters");
97fdadce 134
135 fClusters->SetCircular(5000);
482875f5 136 fTracks->SetCircular(5000);
97fdadce 137
138 //fTracksArray = new AliHLTTPCTrackArray();
e2a9091e 139
2c95fda7 140 fMultiplicity = new TH1F("fMultiplicity", "Track multiplicity per event", 1000, 0, 1000);
97fdadce 141 fMeanMultiplicity = new TH1F("fMeanMultiplicity", "Mean track multiplicity vs. #evt", 10000/fEvtMod, 0, 10000);
f53b49dd 142 fDeDxVsP = new TProfile("fDeDxVsP", "E deposition per unit length vs. p",100, 0, 100);
143 fDeDxVsP->SetXTitle("p (GeV/c)");
97fdadce 144
145 // first configure the default
146 int iResult=0;
147 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
148
149 // configure from the command line parameters if specified
150 if (iResult>=0 && argc>0)
151 iResult=ConfigureFromArgumentString(argc, argv);
152
153 return iResult;
dadc7068 154}
155
e2a9091e 156int AliHLTTPCTrackHistoComponent::DoDeinit(){
157// see header file for class documentation
dadc7068 158
a267c68e 159 delete fClusters;
160 delete fTracks;
97fdadce 161 //delete fTracksArray;
a267c68e 162
2c95fda7 163 delete fMultiplicity;
164 delete fMeanMultiplicity;
f53b49dd 165 delete fDeDxVsP;
2c95fda7 166
dadc7068 167 return 0;
168}
169
97fdadce 170int AliHLTTPCTrackHistoComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
171// see header file for class documentation
172
173 // configure from the specified antry or the default one
174 const char* entry=cdbEntry;
175 if (!entry || entry[0]==0) {
176 entry=fgkOCDBEntry;
177 }
178
179 return ConfigureFromCDBTObjString(entry);
180}
181
182
e2a9091e 183int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
184// see header file for class documentation
dadc7068 185
e2a9091e 186 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
2c95fda7 187
188 fNEvents++;
189
97fdadce 190 //if(!fTracksArray) fTracksArray = new AliHLTTPCTrackArray();
dadc7068 191
e2a9091e 192 const AliHLTComponentBlockData *iter = NULL;
dadc7068 193
e2a9091e 194
195 //----------------- loop over cluster blocks ---------------------//
196
197 Int_t totalSpacePoints = 0;
198
199 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
200
201 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
202
203 AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
204 AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
205 //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
206
207 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
208 Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;
209 totalSpacePoints += nSpacepoint;
210 HLTDebug("TrackHisto component found %d spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
211
212 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
213
214 if(fClustersArray[minSlice][minPartition] != NULL){
215 //delete(fClustersArray[minSlice][minPartition]);
216 fClustersArray[minSlice][minPartition] = NULL;
217 }
218
219 // fill the array with AliHLTTPCSpacePointData pointers
220 // it will be used in the track loop to access information
221 // for the used clusters only
222 fClustersArray[minSlice][minPartition] = clusters;
223 fNSpacePoints[minSlice][minPartition] = nSpacepoint;
224
225 if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL;
226
227 } // end of loop over cluster data blocks
228
97fdadce 229 HLTDebug("TrackHisto found %d spacepoints",totalSpacePoints);
e2a9091e 230
231
232
233
234 //----------------- loop over merged tracks -------------------//
dadc7068 235
e2a9091e 236 Int_t totalTracks = 0;
a9f47f83 237
e2a9091e 238 for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
239 if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue;
240 ReadTracks(iter,totalTracks);
241 }
dadc7068 242
97fdadce 243 HLTDebug("TrackHisto found %d tracks", totalTracks);
dadc7068 244
2c95fda7 245 fMultiplicity->Fill(totalTracks);
246
247 fNtotTracks += totalTracks;
97fdadce 248
249 if(fNEvents%fEvtMod==0){
250 fMeanMultiplicity->Fill(fNEvents, Float_t(fNtotTracks)/(fEvtMod));
251 //HLTInfo("-------------- Event number: %d, total tracks accummulated %d", fNEvents, fNtotTracks);
2c95fda7 252 fNtotTracks = 0;
253 }
dadc7068 254
2c95fda7 255 PushHisto();
256
dadc7068 257 return 0;
258}
259
dadc7068 260void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
e2a9091e 261// see header file for class documentation
dadc7068 262
e2a9091e 263 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
264 AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
265
266 if( slice < fMinSlice ) fMinSlice = slice;
267 if( slice > fMaxSlice ) fMaxSlice = slice;
268 if( partition < fMinPartition ) fMinPartition = partition;
269 if( partition > fMaxPartition ) fMaxPartition = partition;
e2a9091e 270
271 Int_t usedSpacePoints = 0;
dadc7068 272
97fdadce 273 vector<AliHLTGlobalBarrelTrack> tracksVector;
274 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
2c95fda7 275
97fdadce 276 tt = tracksVector.size();
277
278 for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin(); element!=tracksVector.end(); element++){
f53b49dd 279
280 Double_t trackLength = 0.;
281 if(fdEdx==kTRUE) trackLength = element->GetPathLengthTo( element->GetLastPointX(), 5.0);
282
283 UInt_t nHits = element->GetNumberOfPoints();
284 fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits );
97fdadce 285
286 Double_t totCharge = 0;
287 const UInt_t *hitnum = element->GetPoints();
288 for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
289
290 UInt_t idTrack = hitnum[i];
291 Int_t sliceTrack = (idTrack>>25) & 0x7f;
292 Int_t patchTrack = (idTrack>>22) & 0x7;
293 UInt_t pos = idTrack&0x3fffff;
294
295 if( !fClustersArray[sliceTrack][patchTrack] ) continue;
296 if( fNSpacePoints[sliceTrack][patchTrack]<pos ) HLTError("Space point array out of boundaries!");
297
298 totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge;
299
300 Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.;
301
302 xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX;
303 xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY;
304 xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ;
305
306 AliHLTTPCTransform::Local2Global(xyz,slice);
307
308 Double_t p[2] = { xyz[1], xyz[2]};
309 Double_t cov[3] = { (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaY2, 0., (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaZ2};
310 Double_t *res = element->GetResiduals(p,cov,kFALSE);
311
312 //HLTInfo("resy: %f, resz: %f", res[0], res[1]);
313
314 if(!res) res[0] = res[1] = -1000.;
315 else fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, res[0], res[1]);
316
317 usedSpacePoints++;
318 }
f53b49dd 319 if(fdEdx==kTRUE && trackLength > 0) fDeDxVsP->Fill(element->OneOverPt()*TMath::Sqrt(1.+element->GetTgl()*element->GetTgl()), totCharge/trackLength);
97fdadce 320 }
dadc7068 321}
322
323void AliHLTTPCTrackHistoComponent::PushHisto(){
e2a9091e 324// see header file for class documentation
dadc7068 325
e2a9091e 326 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(fMinSlice,fMaxSlice,fMinPartition,fMaxPartition);
2c95fda7 327
328 PushBack( (TObject*)fTracks, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, fSpecification);
329 PushBack( (TObject*)fClusters, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, fSpecification);
330 PushBack( (TObject*)fMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
331 PushBack( (TObject*)fMeanMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
f53b49dd 332 PushBack( (TObject*)fDeDxVsP, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
a267c68e 333}
a267c68e 334
97fdadce 335int AliHLTTPCTrackHistoComponent::ScanConfigurationArgument(int argc, const char** argv){
e2a9091e 336// see header file for class documentation
2c95fda7 337
97fdadce 338 if (argc<=0) return 0;
339 int i=0;
340 TString argument=argv[i];
341
342 // -event-modulo
343 if (argument.CompareTo("-event-modulo")==0) {
344 if (++i>=argc) return -EPROTO;
345 argument=argv[i];
346 fEvtMod=argument.Atof();
347 return 2;
348 }
349
350 // -buffer-size
351 if (argument.CompareTo("-buffer-size")==0) {
352 if (++i>=argc) return -EPROTO;
353 argument=argv[i];
354 fBufferSize=argument.Atof();
355 return 2;
356 }
f53b49dd 357
358 // -dEdx
359 if (argument.CompareTo("-dEdx")==0) {
360 fdEdx=kTRUE;
361 return 1;
362 }
97fdadce 363 return -EINVAL;
dadc7068 364}