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: Gaute Ovrebekk <ovrebekk@ift.uib.no> *
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 AliHLTTPCTrackHistoComponent.cxx
20 @author Gaute Ovrebekk, Matthias Richter
22 @brief The TPC conformal mapping tracker component.
30 #include "AliHLTTPCTrackHistoComponent.h"
31 #include "AliHLTTPCTransform.h"
32 #include "AliHLTTPCClusterDataFormat.h"
33 #include "AliHLTTPCTrackletDataFormat.h"
34 #include "AliHLTTPCMemHandler.h"
35 #include "AliHLTTPCDefinitions.h"
39 #include "TObjString.h"
40 #include "TObjArray.h"
42 //#include "AliHLTTPC.h"
46 AliHLTTPCTrackHistoComponent gAliHLTTPCTrackHistoComponent;
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTTPCTrackHistoComponent)
51 AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent()
53 fHistoNClustersOnTracks(NULL),
54 fHistoChargeAllClusters(NULL),
55 fHistoChargeUsedClusters(NULL),
59 fHistoNClusters(NULL),
60 fHistoNUsedClusters(NULL),
62 fHistoQMaxAllClusters(NULL),
63 fHistoQMaxUsedClusters(NULL),
65 fPlotNClustersOnTracks(kFALSE),
66 fPlotChargeClusters(kFALSE),
67 fPlotChargeUsedClusters(kFALSE),
69 fPlotResidual(kFALSE),
71 fPlotNClusters(kFALSE),
72 fPlotNUsedClusters(kFALSE),
74 fPlotQMaxClusters(kFALSE),
75 fPlotQMaxUsedClusters(kFALSE),
81 // see header file for class documentation
83 // refer to README to build package
85 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
89 AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent()
91 // see header file for class documentation
94 // Public functions to implement AliHLTComponent's interface.
95 // These functions are required for the registration process
97 const char* AliHLTTPCTrackHistoComponent::GetComponentID()
99 // see header file for class documentation
101 return "TPCTrackHisto";
104 void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
106 // see header file for class documentation
108 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
109 list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
110 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
113 AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType()
115 // see header file for class documentation
116 return kAliHLTDataTypeHistogram;
120 void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
122 // see header file for class documentation
123 // XXX TODO: Find more realistic values.
128 AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn()
130 // see header file for class documentation
131 return new AliHLTTPCTrackHistoComponent;
134 int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv )
136 fHistoNClustersOnTracks = new TH1F("fHistoNClustersOnTracks","Number of Clusters on Tracks",160,0,160);
137 fHistoChargeAllClusters = new TH1F("fHistoChargeAllClusters","Charge of All Clusters",4000,0,4000);
138 fHistoChargeUsedClusters = new TH1F("fHistoChargeUsedClusters","Charge of Clusters used on Tracks",4000,0,4000);
139 fHistoPT = new TH1F("fHistoPT","pT of Tracks",100,0,10);
140 fHistoResidual = new TH1F("fHistoResidual","Residuals",360,0,360); //change. Testing
141 fHistoTgl = new TH1F("fHistoTgl","Tgl of Tracks",900,0,90);
142 fHistoNClusters = new TH1F("fHistoNClusters","Total number of Clusters in Event",3000,0,3000);
143 fHistoNUsedClusters = new TH1F("fHistoNUsedClusters","Number of Used Cluster in event",3000,0,3000);
144 fHistoNTracks = new TH1F("fHistoNTracks","Number of Tracks in Event",10,0,10);
145 fHistoQMaxAllClusters = new TH1F("fHistoQMaxAllClusters","Charge of All Clusters",4000,0,4000);
146 fHistoQMaxUsedClusters = new TH1F("fHistoQMaxUsedClusters","Charge of Clusters used on Tracks",4000,0,4000);
148 fPlotNClustersOnTracks=kFALSE;
149 fPlotChargeClusters=kFALSE;
150 fPlotChargeUsedClusters=kFALSE;
152 fPlotResidual=kFALSE;
154 fPlotNClusters=kFALSE;
155 fPlotNUsedClusters=kFALSE;
157 fPlotQMaxClusters=kFALSE;
158 fPlotQMaxUsedClusters=kFALSE;
162 TString configuration="";
164 for (int i=0; i<argc && iResult>=0; i++) {
166 if (!configuration.IsNull()) configuration+=" ";
167 configuration+=argument;
170 if (!configuration.IsNull()) {
171 iResult=Configure(configuration.Data());
176 int AliHLTTPCTrackHistoComponent::DoDeinit()
178 // see header file for class documentation
180 delete fHistoNClustersOnTracks;
181 delete fHistoChargeAllClusters;
182 delete fHistoChargeUsedClusters;
184 delete fHistoResidual;
186 delete fHistoNClusters;
187 delete fHistoNUsedClusters;
188 delete fHistoNTracks;
189 delete fHistoQMaxAllClusters;
190 delete fHistoQMaxUsedClusters;
195 int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
197 const AliHLTComponentBlockData* iter = NULL;
199 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
202 Int_t TotalTrack = 0;
204 //Reading Merged Tracks
205 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
206 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;}
207 ReadTracks(iter,TotalTrack);
210 //Reading Tracks form slice
211 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
212 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;}
213 ReadTracks(iter,TotalTrack);
216 int TotalSpacePoint = 0;
219 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
221 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
223 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
224 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
226 //HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
227 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) iter->fPtr;
228 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
229 TotalSpacePoint += nSpacepoint;
230 //HLTInfo("TrackHisto found %d Spacepoints in slice %d patch %d", nSpacepoint, slice, patch);
231 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) clusterData->fSpacePoints;
233 for(int i=0;i<nSpacepoint;i++){
234 UInt_t idCluster = clusters[i].fID;
235 Int_t sliceCl = (idCluster>>25) & 0x7f;
236 Int_t patchCl = (idCluster>>22) & 0x7;
237 UInt_t pos = idCluster&0x3fffff;
238 if(fPlotChargeClusters || fPlotAll){fHistoChargeAllClusters->Fill(clusters[i].fCharge);}
239 if(fPlotQMaxClusters || fPlotAll){fHistoQMaxAllClusters->Fill(clusters[i].fMaxQ);}
240 for(UInt_t id=0;id<fTrackClusterID[sliceCl][patchCl].size();id++){
241 if(fTrackClusterID[sliceCl][patchCl][id]==pos){
242 clusters[i].fUsed=kTRUE;
244 if(fPlotChargeUsedClusters || fPlotAll){fHistoChargeUsedClusters->Fill(clusters[i].fCharge);}
245 if(fPlotQMaxUsedClusters || fPlotAll){fHistoQMaxUsedClusters->Fill(clusters[i].fMaxQ);}
248 fClusters.push_back(clusters[i]);
252 fHistoNClusters->Fill(TotalSpacePoint);
253 if(TotalTrack>0){fHistoNUsedClusters->Fill(nClustersUsed);}
254 fHistoNTracks->Fill(TotalTrack);
256 HLTInfo("TrackHisto found %d Spacepoints",TotalSpacePoint);
257 HLTInfo("TrackHisto found %d Tracks",TotalTrack);
263 for(UInt_t i=0;i<36;i++){
264 for(UInt_t j=0;j<6;j++){
265 fTrackClusterID[i][j].clear();
272 int AliHLTTPCTrackHistoComponent::Configure(const char* arguments)
276 if (!arguments) return iResult;
278 TString allArgs=arguments;
281 TObjArray* pTokens=allArgs.Tokenize(" ");
283 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
284 argument=((TObjString*)pTokens->At(i))->GetString();
285 if (argument.IsNull()) continue;
287 if (argument.CompareTo("-plot-All")==0) {
288 HLTInfo("Ploting All Histograms for Tracks");
290 fPlotNClustersOnTracks=kTRUE;
291 fPlotChargeClusters=kTRUE;
292 fPlotChargeUsedClusters=kTRUE;
296 fPlotNClusters=kTRUE;
297 fPlotNUsedClusters=kTRUE;
299 fPlotQMaxClusters=kTRUE;
300 fPlotQMaxUsedClusters=kTRUE;
304 else if (argument.CompareTo("-plot-nClusters")==0) {
305 HLTInfo("Ploting Number of clusters Used on Tracks");
306 fPlotNClustersOnTracks = kTRUE;
309 else if (argument.CompareTo("-plot-ChargeClusters")==0) {
310 HLTInfo("Ploting Charge of All Clusters");
311 fPlotChargeClusters = kTRUE;
314 else if (argument.CompareTo("-plot-ChargeUsedClusters")==0) {
315 HLTInfo("Ploting Charge of Clusters Used on Tracks");
316 fPlotChargeUsedClusters = kTRUE;
319 else if (argument.CompareTo("-plot-pT")==0) {
320 HLTInfo("Ploting pT of Tracks");
324 else if (argument.CompareTo("-plot-Residuals")==0) {
325 HLTInfo("Ploting Residuals");
329 else if (argument.CompareTo("-plot-Tgl")==0) {
330 HLTInfo("Ploting Tgl of Tracks");
334 else if (argument.CompareTo("-plot-NClusters")==0) {
335 HLTInfo("Ploting Number of Clusters");
336 fPlotNClusters=kTRUE;
339 else if (argument.CompareTo("-plot-NUsedClusters")==0) {
340 HLTInfo("Ploting Number Of Used Clusters");
341 fPlotNUsedClusters=kTRUE;
344 else if (argument.CompareTo("-plot-NTracks")==0) {
345 HLTInfo("Ploting Number Of Tracks");
349 else if (argument.CompareTo("-plot-QMaxAll")==0) {
350 HLTInfo("Ploting QMax for All Clusters");
351 fPlotQMaxClusters=kTRUE;
354 else if (argument.CompareTo("-plot-QMaxUsed")==0) {
355 HLTInfo("Ploting QMax for Used Clusters");
356 fPlotQMaxUsedClusters=kTRUE;
359 else if (argument.CompareTo("-reset-plots")==0) {
360 HLTInfo("Reseting plots");
365 HLTError("unknown argument %s", argument.Data());
376 void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
378 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
379 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
381 //HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
382 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) iter->fPtr;
383 AliHLTUInt32_t nTracks = trackData->fTrackletCnt;
385 //HLTInfo("TrackHisto found %d Tracks in slice %d patch %d", nTracks, slice, patch);
386 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*) trackData->fTracklets;
388 for(AliHLTUInt32_t i=0;i<nTracks;i++){
389 fTracks.push_back(tracks[i]);
390 UInt_t nHits = tracks->fNPoints;
391 if(fPlotNClustersOnTracks || fPlotAll){fHistoNClustersOnTracks->Fill(nHits);}
392 if(fPlotPT || fPlotAll){fHistoPT->Fill(tracks[i].fPt);}
393 if(fPlotTgl || fPlotAll){fHistoTgl->Fill(tracks[i].fTgl);}
394 const UInt_t *hitnum = tracks->fPointIDs;
395 for(UInt_t h=0; h<nHits; h++){
396 UInt_t idTrack = hitnum[h];
397 Int_t sliceTrack = (idTrack>>25) & 0x7f;
398 Int_t patchTrack = (idTrack>>22) & 0x7;
399 UInt_t pos = idTrack&0x3fffff;
400 fTrackClusterID[sliceTrack][patchTrack].push_back(pos);
402 UChar_t *tmpP = (UChar_t*)tracks;
403 tmpP += sizeof(AliHLTTPCTrackSegmentData)+tracks->fNPoints*sizeof(UInt_t);
404 tracks = (AliHLTTPCTrackSegmentData*)tmpP;
408 void AliHLTTPCTrackHistoComponent::PushHisto(){
410 if(fPlotNClustersOnTracks || fPlotAll){
411 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
412 PushBack( (TObject*) fHistoNClustersOnTracks,kAliHLTDataTypeHistogram, fSpecification);
414 if(fPlotChargeClusters || fPlotAll){
415 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
416 PushBack( (TObject*) fHistoChargeAllClusters,kAliHLTDataTypeHistogram, fSpecification);
418 if(fPlotChargeUsedClusters || fPlotAll){
419 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
420 PushBack( (TObject*) fHistoChargeUsedClusters,kAliHLTDataTypeHistogram, fSpecification);
422 if(fPlotPT || fPlotAll){
423 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
424 PushBack( (TObject*) fHistoPT,kAliHLTDataTypeHistogram, fSpecification);
426 if(fPlotResidual || fPlotAll){
427 for(unsigned int i=0;i<fTracks.size();i++){
428 fHistoResidual->Fill(fTracks[i].fPsi); //Not rigth. Change here and x in Histo. Just for test.
430 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
431 PushBack( (TObject*) fHistoResidual,kAliHLTDataTypeHistogram, fSpecification);
433 if(fPlotTgl || fPlotAll){
434 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
435 PushBack( (TObject*) fHistoTgl,kAliHLTDataTypeHistogram, fSpecification);
437 if(fPlotNClusters || fPlotAll){
438 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
439 PushBack( (TObject*) fHistoNClusters,kAliHLTDataTypeHistogram, fSpecification);
441 if(fPlotNUsedClusters || fPlotAll){
442 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
443 PushBack( (TObject*) fHistoNUsedClusters,kAliHLTDataTypeHistogram, fSpecification);
445 if(fPlotNTracks || fPlotAll){
446 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
447 PushBack( (TObject*) fHistoNTracks,kAliHLTDataTypeHistogram, fSpecification);
449 if(fPlotQMaxUsedClusters || fPlotAll){
450 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
451 PushBack( (TObject*) fHistoQMaxAllClusters,kAliHLTDataTypeHistogram, fSpecification);
453 if(fPlotQMaxUsedClusters || fPlotAll){
454 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
455 PushBack( (TObject*) fHistoQMaxUsedClusters,kAliHLTDataTypeHistogram, fSpecification);
459 fHistoNClustersOnTracks->Reset();
460 fHistoChargeAllClusters->Reset();
461 fHistoChargeUsedClusters->Reset();
463 fHistoResidual->Reset();
465 fHistoNClusters->Reset();
466 fHistoNUsedClusters->Reset();
467 fHistoNTracks->Reset();
468 fHistoQMaxAllClusters->Reset();
469 fHistoQMaxUsedClusters->Reset();