]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCTrackHistoComponent.cxx
added a method return the QAdata file name (MUON request)
[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
25
26#if __GNUC__>= 3
27using 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"
36#include <TFile.h>
37#include <TString.h>
38#include "TH1F.h"
39#include "TObjString.h"
40#include "TObjArray.h"
41
42//#include "AliHLTTPC.h"
43//#include <stdlib.h>
44//#include <cerrno>
45
46// this is a global object used for automatic component registration, do not use this
47AliHLTTPCTrackHistoComponent gAliHLTTPCTrackHistoComponent;
48
49/** ROOT macro for the implementation of ROOT specific class methods */
50ClassImp(AliHLTTPCTrackHistoComponent)
51
52AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent()
53:
54fHistoNClustersOnTracks(NULL),
55 fHistoAllClusters(NULL),
56 fHistoUsedClusters(NULL),
57 fHistoPT(NULL),
58 fHistoResidual(NULL),
59 fHistoTgl(NULL),
60 fPlotAll(kFALSE),
61 fPlotNClustersOnTracks(kFALSE),
62 fPlotChargeClusters(kFALSE),
63 fPlotChargeUsedClusters(kFALSE),
64 fPlotPT(kFALSE),
65 fPlotResidual(kFALSE),
66 fPlotTgl(kFALSE),
67 fClusters(),
68 fTracks()
69{
70
71 // see header file for class documentation
72 // or
73 // refer to README to build package
74 // or
75 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
76
77}
78
79AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent()
80{
81 // see header file for class documentation
82}
83
84// Public functions to implement AliHLTComponent's interface.
85// These functions are required for the registration process
86
87const char* AliHLTTPCTrackHistoComponent::GetComponentID()
88{
89 // see header file for class documentation
90
91 return "TPCTrackHisto";
92}
93
94void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
95{
96 // see header file for class documentation
97 list.clear();
98 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
99 list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
100 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
101}
102
103AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType()
104{
105 // see header file for class documentation
106 return kAliHLTDataTypeHistogram;
107
108}
109
110void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
111{
112 // see header file for class documentation
113 // XXX TODO: Find more realistic values.
114 constBase = 0;
115 inputMultiplier = 1;
116}
117
118AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn()
119{
120 // see header file for class documentation
121 return new AliHLTTPCTrackHistoComponent;
122}
123
124int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv )
125{
126 fHistoNClustersOnTracks = new TH1F("fHistoNClustersOnTracks","Number of Clusters on Tracks",160,0,160);
127 fHistoAllClusters = new TH1F("fHistoAllClusters","Charge of All Clusters",4000,0,4000);
128 fHistoUsedClusters = new TH1F("fHistoUsedClusters","Charge of Clusters used on Tracks",4000,0,4000);
129 fHistoPT = new TH1F("fHistoPT","pT of Tracks",100,0,10);
130 fHistoResidual = new TH1F("fHistoResidual","Resuduals",360,0,360); //change. Testing
131 fHistoTgl = new TH1F("fHistoTgl","Tgl of Tracks",900,0,90);
132
133 fPlotAll=kFALSE;
134 fPlotNClustersOnTracks=kFALSE;
135 fPlotChargeClusters=kFALSE;
136 fPlotChargeUsedClusters=kFALSE;
137 fPlotPT=kFALSE;
138 fPlotResidual=kFALSE;
139 fPlotTgl=kFALSE;
140
141 int iResult=0;
142 TString configuration="";
143 TString argument="";
144 for (int i=0; i<argc && iResult>=0; i++) {
145 argument=argv[i];
146 if (!configuration.IsNull()) configuration+=" ";
147 configuration+=argument;
148 }
149
150 if (!configuration.IsNull()) {
151 iResult=Configure(configuration.Data());
152 }
153 return iResult;
154}
155
156int AliHLTTPCTrackHistoComponent::DoDeinit()
157{
158 // see header file for class documentation
159
160 delete fHistoNClustersOnTracks;
161 delete fHistoAllClusters;
162 delete fHistoUsedClusters;
163 delete fHistoPT;
164 delete fHistoResidual;
165 delete fHistoTgl;
166
167 return 0;
168}
169
170int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
171{
172 const AliHLTComponentBlockData* iter = NULL;
173
174 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
175 return 0;
176
177 Int_t TotalTrack = 0;
178
179 //Reading Merged Tracks
180 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
181 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;}
182 ReadTracks(iter,TotalTrack);
183 }
184
185 //Reading Tracks form slice
186 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
187 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;}
188 ReadTracks(iter,TotalTrack);
189 }
190
191 int TotalSpacePoint = 0;
192 int nClustersUsed=0;
193
194 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
195
196 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
197
198 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
199 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
200
201 //HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
202 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) iter->fPtr;
203 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
204 TotalSpacePoint += nSpacepoint;
205 //HLTInfo("TrackHisto found %d Spacepoints in slice %d patch %d", nSpacepoint, slice, patch);
206 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) clusterData->fSpacePoints;
207
208 for(int i=0;i<nSpacepoint;i++){
209 UInt_t idCluster = clusters[i].fID;
210 Int_t sliceCl = (idCluster>>25) & 0x7f;
211 Int_t patchCl = (idCluster>>22) & 0x7;
212 UInt_t pos = idCluster&0x3fffff;
213 if(fPlotChargeClusters || fPlotAll){fHistoAllClusters->Fill(clusters[i].fCharge);}
214 for(UInt_t id=0;id<fTrackClusterID[sliceCl][patchCl].size();id++){
215 if(fTrackClusterID[sliceCl][patchCl][id]==pos){
216 clusters[i].fUsed=kTRUE;
217 nClustersUsed++;
218 if(fPlotChargeUsedClusters || fPlotAll){fHistoUsedClusters->Fill(clusters[i].fCharge);}
219 }
220 }
221 fClusters.push_back(clusters[i]);
222 }
223 }
224
225 HLTInfo("TrackHisto found %d Spacepoints",TotalSpacePoint);
226 HLTInfo("TrackHisto found %d Tracks",TotalTrack);
227
228 PushHisto();
229
230 fClusters.clear();
231 fTracks.clear();
232
233 return 0;
234}
235
236 int AliHLTTPCTrackHistoComponent::Configure(const char* arguments)
237 {
238
239 int iResult=0;
240 if (!arguments) return iResult;
241
242 TString allArgs=arguments;
243 TString argument;
244
245 TObjArray* pTokens=allArgs.Tokenize(" ");
246
247 if (pTokens) {
248 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
249 argument=((TObjString*)pTokens->At(i))->GetString();
250 if (argument.IsNull()) continue;
251
252 if (argument.CompareTo("-plot-All")==0) {
253 HLTInfo("Ploting All Histograms for Tracks");
254 fPlotAll = kTRUE;
255 fPlotNClustersOnTracks=kTRUE;
256 fPlotChargeClusters=kTRUE;
257 fPlotChargeUsedClusters=kTRUE;
258 fPlotPT=kTRUE;
259 fPlotResidual=kTRUE;
260 fPlotTgl=kTRUE;
261 continue;
262 }
263 else if (argument.CompareTo("-plot-nClusters")==0) {
264 HLTInfo("Ploting Number of clusters Used on Tracks");
265 fPlotNClustersOnTracks = kTRUE;
266 continue;
267 }
268 else if (argument.CompareTo("-plot-ChargeClusters")==0) {
269 HLTInfo("Ploting Charge of All Clusters");
270 fPlotChargeClusters = kTRUE;
271 continue;
272 }
273 else if (argument.CompareTo("-plot-ChargeUsedClusters")==0) {
274 HLTInfo("Ploting Charge of Clusters Used on Tracks");
275 fPlotChargeUsedClusters = kTRUE;
276 continue;
277 }
278 else if (argument.CompareTo("-plot-pT")==0) {
279 HLTInfo("Ploting pT of Tracks");
280 fPlotPT=kTRUE;
281 continue;
282 }
283 else if (argument.CompareTo("-plot-Residuals")==0) {
284 HLTInfo("Ploting Residuals");
285 fPlotResidual=kTRUE;
286 continue;
287 }
288 else if (argument.CompareTo("-plot-Tgl")==0) {
289 HLTInfo("Ploting Tgl of Tracks");
290 fPlotTgl=kTRUE;
291 continue;
292 }
293 else {
294 HLTError("unknown argument %s", argument.Data());
295 iResult=-EINVAL;
296 break;
297 }
298 }
299 delete pTokens;
300 }
301
302 return iResult;
303 }
304
305void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
306
307 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
308 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
309
310 //HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
311 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) iter->fPtr;
312 AliHLTUInt32_t nTracks = trackData->fTrackletCnt;
313 tt += nTracks;
314 //HLTInfo("TrackHisto found %d Tracks in slice %d patch %d", nTracks, slice, patch);
315 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*) trackData->fTracklets;
316
317 for(AliHLTUInt32_t i=0;i<nTracks;i++){
318 fTracks.push_back(tracks[i]);
319 UInt_t nHits = tracks->fNPoints;
320 if(fPlotNClustersOnTracks || fPlotAll){fHistoNClustersOnTracks->Fill(nHits);}
321 if(fPlotPT || fPlotAll){fHistoPT->Fill(tracks[i].fPt);}
322 if(fPlotTgl || fPlotAll){fHistoTgl->Fill(tracks[i].fTgl);}
323 const UInt_t *hitnum = tracks->fPointIDs;
324 for(UInt_t h=0; h<nHits; h++){
325 UInt_t idTrack = hitnum[h];
326 Int_t sliceTrack = (idTrack>>25) & 0x7f;
327 Int_t patchTrack = (idTrack>>22) & 0x7;
328 UInt_t pos = idTrack&0x3fffff;
329 fTrackClusterID[sliceTrack][patchTrack].push_back(pos);
330 }
331 UChar_t *tmpP = (UChar_t*)tracks;
332 tmpP += sizeof(AliHLTTPCTrackSegmentData)+tracks->fNPoints*sizeof(UInt_t);
333 tracks = (AliHLTTPCTrackSegmentData*)tmpP;
334 }
335}
336
337void AliHLTTPCTrackHistoComponent::PushHisto(){
338
339 if(fPlotNClustersOnTracks || fPlotAll){
340 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
341 PushBack( (TObject*) fHistoNClustersOnTracks,kAliHLTDataTypeHistogram, fSpecification);
342 }
343 if(fPlotChargeClusters || fPlotAll){
344 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
345 PushBack( (TObject*) fHistoAllClusters,kAliHLTDataTypeHistogram, fSpecification);
346 }
347 if(fPlotChargeUsedClusters || fPlotAll){
348 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
349 PushBack( (TObject*) fHistoUsedClusters,kAliHLTDataTypeHistogram, fSpecification);
350 }
351 if(fPlotPT || fPlotAll){
352 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
353 PushBack( (TObject*) fHistoPT,kAliHLTDataTypeHistogram, fSpecification);
354 }
355 if(fPlotResidual || fPlotAll){
356 for(unsigned int i=0;i<fTracks.size();i++){
357 fHistoResidual->Fill(fTracks[i].fPsi); //Not rigth. Change here and x in Histo. Just for test.
358 }
359 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
360 PushBack( (TObject*) fHistoResidual,kAliHLTDataTypeHistogram, fSpecification);
361 }
362 if(fPlotTgl || fPlotAll){
363 AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
364 PushBack( (TObject*) fHistoTgl,kAliHLTDataTypeHistogram, fSpecification);
365 }
366
367 fHistoNClustersOnTracks->Reset();
368 fHistoAllClusters->Reset();
369 fHistoUsedClusters->Reset();
370 fHistoPT->Reset();
371 fHistoResidual->Reset();
372 fHistoTgl->Reset();
373}