]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCEventStatisticsProducerComponent.cxx
Conv. PID improved; Energy now calculated from KFParticle; PHOS PID
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCEventStatisticsProducerComponent.cxx
CommitLineData
2ff24e4c 1//-*- Mode: C++ -*-
2// $Id$
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: Jochen Thaeder <thaeder@kip.uni-heidelberg.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 AliHLTTPCEventStatisticsProducerComponent.cxx
20 @author Jochen Thaeder
21 @date
22 @brief Component for the @see AliHLTTPCEventStatisticsProducer class
23*/
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31#if __GNUC__ >= 3
32using namespace std;
33#endif
34
35#include "AliHLTTPCEventStatisticsProducerComponent.h"
36
37#include "AliHLTTPCDefinitions.h"
38#include "AliHLTTPCClusterDataFormat.h"
39#include "AliHLTTPCTrackSegmentData.h"
40#include "AliHLTTPCTrackletDataFormat.h"
41#include "AliHLTTPCTrack.h"
42
43#include "TMath.h"
44
45#include <cerrno>
46
672f8b8c 47/** ROOT macro for the implementation of ROOT specific class methods */
2ff24e4c 48ClassImp(AliHLTTPCEventStatisticsProducerComponent)
49
50// ------------------------------------------------------------------------------------------
51AliHLTTPCEventStatisticsProducerComponent::AliHLTTPCEventStatisticsProducerComponent() :
52 fClusterThreshold(0),
53 fEvStat(NULL),
54 fNTracksPerSlice(),
55 fTracks(NULL),
56 fGlobalTracks(kFALSE),
57 fNSlice(0) {
58 // see header file for class documentation
59 // or
60 // refer to README to build package
61 // or
62 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63}
64
65// ------------------------------------------------------------------------------------------
66AliHLTTPCEventStatisticsProducerComponent::~AliHLTTPCEventStatisticsProducerComponent() {
67 // see header file for class documentation
68}
69
70// ------------------------------------------------------------------------------------------
71const char* AliHLTTPCEventStatisticsProducerComponent::GetComponentID() {
72 // see header file for class documentation
73 return "TPCEventStatisticsProducer";
74}
75
76// ------------------------------------------------------------------------------------------
77void AliHLTTPCEventStatisticsProducerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
78 // see header file for class documentation
79
80 list.clear();
81 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
82 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
83 list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
84}
85
86// ------------------------------------------------------------------------------------------
87AliHLTComponentDataType AliHLTTPCEventStatisticsProducerComponent::GetOutputDataType() {
88 // see header file for class documentation
89
90 return kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC;
91}
92
93// ------------------------------------------------------------------------------------------
94void AliHLTTPCEventStatisticsProducerComponent::GetOutputDataSize( unsigned long& constBase,
95 double& inputMultiplier ) {
96 // see header file for class documentation
97
98 constBase = sizeof( AliHLTTPCEventStatistics );
99 inputMultiplier = 0.0;
100}
101
102// ------------------------------------------------------------------------------------------
103// Spawn function, return new instance of this class
104AliHLTComponent* AliHLTTPCEventStatisticsProducerComponent::Spawn() {
105 // see header file for class documentation
106
107 return new AliHLTTPCEventStatisticsProducerComponent;
108}
109
110
111// ------------------------------------------------------------------------------------------
112Int_t AliHLTTPCEventStatisticsProducerComponent::DoInit( int argc, const char** argv ) {
113 // see header file for class documentation
114
115 Int_t iResult = 0;
116
117 // ** Defaults
118
119 Int_t threshold = 0;
120
121 // ** Argument handling
122
123 TString argument = "";
124 TString parameter = "";
125 Int_t bMissingParam=0;
126
127 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
128
129 argument = argv[ii];
130
131 if ( argument.IsNull() ) continue;
132
133 // -detector
134 if ( ! argument.CompareTo("-clusterThreshold") ) {
135
136 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
137
138 parameter = argv[ii];
139 parameter.Remove( TString::kLeading, ' ' );
140
141 if (parameter.IsDigit() ) {
142 threshold = (Int_t) parameter.Atoi();
143 HLTInfo( "Threshold of clusters for long tracks is set to %d.", threshold );
144 }
145 else {
146 HLTError( "Cannot convert clusterThreshold specifier '%s'.", parameter.Data() );
147 iResult = -EINVAL;
148 break;
149 }
150
151 } // if ( ! argument.CompareTo("-clusterThreshold") ) {
152
153 // - unknow parameter
154 else {
155 iResult = -EINVAL;
156 HLTError("Unknown argument '%s'", argument.Data() );
157 }
158
159 } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
160
161 if ( bMissingParam ) {
162 HLTError( "Missing parameter for argument '%s'.", argument.Data() );
163 iResult = -EPROTO;
164 }
165
166 // set members
167
168 fClusterThreshold = threshold;
169
170 return iResult;
171}
172
173// ------------------------------------------------------------------------------------------
174Int_t AliHLTTPCEventStatisticsProducerComponent::DoDeinit() {
175 // see header file for class documentation
176
177 if ( fEvStat )
178 delete fEvStat;
179 fEvStat = NULL;
180
181 if ( fTracks )
182 delete fTracks;
183 fTracks = NULL;
184
185 return 0;
186}
187
188// ------------------------------------------------------------------------------------------
2b4385d9 189Int_t AliHLTTPCEventStatisticsProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
2ff24e4c 190 // see header file for class documentation
191
192 const AliHLTComponentBlockData* iter = NULL;
193
194 // ** No readout list for SOR and EOR event
195 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
196 return 0;
197
198 //
199 // ** Setup for new Event
200 //
201 InitializeEvent();
202
203 //
204 // ** Read in cluster from ClusterFinder
205 //
206
207 // ** Loop over all input blocks and specify which data format should be read
208 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
209
210 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
211 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
212
213 HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
214
5eefc803 215 AddClusters( iter->fPtr, (Int_t) slice, (Int_t) patch );
2ff24e4c 216 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
217
218
219 //
220 // ** Read in track segments from Tracker
221 //
222
223 iter = NULL;
224
225 // ** Loop over all input blocks and specify which data format should be read
226 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
227
228 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
229 HLTDebug ( "Input Data - TPC track segments - Slice: %d.", slice );
230
5eefc803 231 AddTracks( iter->fPtr, (Int_t) slice );
2ff24e4c 232 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
233
234 //
235 // ** Read in tracks from GlobalMerger
236 //
237
238 iter = NULL;
239
240 // ** Loop over all input blocks and specify which data format should be read
241 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
1d229444 242
2ff24e4c 243 HLTDebug ( "Input Data - TPC track segments." );
244
5eefc803 245 AddTracks( iter->fPtr );
2ff24e4c 246 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
247
248
1d229444 249 TObject* iterObject = NULL;
250
251 // ** GetESDs
252 iterObject = (TObject* )GetFirstInputObject(kAliHLTDataTypeESDTree|kAliHLTDataOriginTPC);
253
254 if ( iterObject ) {
255
256 HLTDebug ( "Input Data - TPC ESD." );
257
258 AddESD( (TTree*) iterObject );
259 }
260
2ff24e4c 261 //
262 // ** Produce event statistics
263 //
264
265 ProcessEvent();
266
267 PushBack ( (TObject*) GetEventStatistics(), sizeof(AliHLTTPCEventStatistics), kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC, (AliHLTUInt32_t) 0 );
268
269 return 0;
270}
271
272// -- **********************************************************************************************
273// -- ******************************* Processing Functions **************************************
274// -- **********************************************************************************************
275
276// -- **********************************************************************************************
277void AliHLTTPCEventStatisticsProducerComponent::InitializeEvent() {
278 // see header file for class documentation
279
280 if ( fEvStat )
281 delete fEvStat;
282
283 fEvStat = new AliHLTTPCEventStatistics();
284 fEvStat->SetClusterThreshold( fClusterThreshold );
285
286 // ** Initialize arrays to 0
287 memset( fNTracksPerSlice, -1, 36*sizeof(Int_t) );
288
289 // ** New AliHLTTPCTrackArray
290 if ( fTracks )
291 delete fTracks;
292 fTracks = new AliHLTTPCTrackArray;
293
294 fGlobalTracks = kFALSE;
295 fNSlice = 0;
296}
297
298// -- **********************************************************************************************
5eefc803 299void AliHLTTPCEventStatisticsProducerComponent::AddClusters( void* ptr, Int_t slice, Int_t patch ) {
2ff24e4c 300 // see header file for class documentation
301
302 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) ptr;
303
5eefc803 304 // these 2 variables have been introduced to avoid warning: unused variable in production compile
305 Int_t sliceAntiWarning = slice;
306 Int_t patchAntiWarning = patch;
307
2ff24e4c 308 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
5eefc803 309 HLTDebug( "%d Clusters found for slice %u - patch %u\n", nSpacepoint, sliceAntiWarning, patchAntiWarning );
310
311 sliceAntiWarning = 0;
312 patchAntiWarning = 0;
2ff24e4c 313
314 // ** Add to event statistics
315 fEvStat->AddNTotalCluster( nSpacepoint );
316
317}
318
319// -- **********************************************************************************************
5eefc803 320void AliHLTTPCEventStatisticsProducerComponent::AddTracks( void* ptr, Int_t slice ) {
2ff24e4c 321 // see header file for class documentation
322
323 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) ptr;
324
325 Int_t nTracks = (Int_t) trackData->fTrackletCnt;
326
327 AliHLTTPCTrackSegmentData* segmentData = (AliHLTTPCTrackSegmentData*) &( trackData->fTracklets[0] );
328
329 // ** Tracks which are not from GlobalMerger have to be transformed to global Coordinates ( bTransform=1, else 0 )
330 Int_t bTransform;
331
332
333 // ** Global tracks
334 if ( slice == -1 ) {
335 HLTDebug( "%d tracks found for event.", nTracks );
336
337 bTransform = 0;
338 fGlobalTracks = kTRUE;
339 }
340 else {
341 HLTDebug( "%d tracks found for slice %u.", nTracks, slice );
342
343 // ** Fill number if tracks per slice
344 fNTracksPerSlice[slice] = (Int_t) trackData->fTrackletCnt;
345 fNSlice++;
346
347 bTransform = 1;
348 }
349
febeb705 350 fTracks->FillTracksChecked( segmentData, nTracks, 0, slice, bTransform );
2ff24e4c 351
352}
353
1d229444 354// -- **********************************************************************************************
355void AliHLTTPCEventStatisticsProducerComponent::AddESD( TTree* esdTree ) {
356 // see header file for class documentation
357
358 AliESDEvent* esd = new AliESDEvent();
359 esd->ReadFromTree(esdTree);
360 esdTree->GetEntry(0);
361
362 HLTWarning("Number of tracks found : %d", esd->GetNumberOfTracks() );
363
364 if ( esd )
365 delete esd;
366
367}
368
2ff24e4c 369// -- **********************************************************************************************
370void AliHLTTPCEventStatisticsProducerComponent::ProcessEvent() {
371 // see header file for class documentation
372
373 // ** Total number of tracks -- Add to event statistics
374 fEvStat->SetNTotalTracks( fTracks->GetNTracks() ) ;
375
376 // ** Loop over all tracks
377 for( Int_t trackNdx=0; trackNdx < fTracks->GetNTracks(); trackNdx++ ) {
378
379 AliHLTTPCTrack *track = fTracks->GetCheckedTrack( trackNdx );
380 if( !track ) continue;
381
382 // ** Used cluster -- Add to event statistics
383 fEvStat->AddNUsedCluster( track->GetNHits() );
384
385 // ** If is long track -- Add to event statistics
386 if ( track->GetNHits() >= fClusterThreshold )
387 fEvStat->AddNTracksAboveClusterThreshold();
388 }
389
390 // ** Average of ( number of clusters per track ), floored -- Add to event statistics
391 // N used cluster / N tracks
392 if ( fEvStat->GetNTotalTracks() > 0 ) {
393 fEvStat->SetAvgClusterPerTrack( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNUsedCluster() / (Double_t) fEvStat->GetNTotalTracks() ) );
394 }
395 fEvStat->SetAvgClusterPerTrack( 0 );
396
397 if ( fGlobalTracks ) FillTracksPerSlice();
398
399 // ** Average of ( tracks per slice )
400 if ( fNSlice > 0 )
401 fEvStat->SetNAvgTracksPerSector( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNTotalTracks() / (Double_t) fNSlice ) );
402 else
403 fEvStat->SetNAvgTracksPerSector( 0 );
404
405 // ** Max and Min of Tracks per slice
406 for ( Int_t ii=0; ii < 36; ii++ ) {
407
408 if ( fNTracksPerSlice[ii] == -1 ) continue;
409
410 if ( fNTracksPerSlice[ii] > fEvStat->GetNMaxTracksPerSector() )
411 fEvStat->SetNMaxTracksPerSector( fNTracksPerSlice[ii] );
412
413 if ( fNTracksPerSlice[ii] < fEvStat->GetNMinTracksPerSector() )
414 fEvStat->SetNMinTracksPerSector( fNTracksPerSlice[ii] );
415 }
416
417 // ** Info prints
418
419 HLTInfo( "Total N Tracks : %d", fEvStat->GetNTotalTracks() );
420 HLTInfo( "Total N Tracks with more than %d cluster : %d", fEvStat->GetClusterThreshold(), fEvStat->GetNTracksAboveClusterThreshold() );
421 HLTInfo( "Min N Tracks per slice : %d", fEvStat->GetNMinTracksPerSector() );
422 HLTInfo( "Max N Tracks per slice : %d", fEvStat->GetNMaxTracksPerSector() );
423 HLTInfo( "Avg N Tracks per slice : %d", fEvStat->GetNAvgTracksPerSector() );
424
425 HLTInfo( "Total N Cluster : %d", fEvStat->GetNTotalCluster() );
426 HLTInfo( "Used N Cluster : %d", fEvStat->GetNUsedCluster() );
427 HLTInfo( "Average (Cluster per track) : %d", fEvStat->GetAvgClusterPerTrack() );
428}
429
430// -- **********************************************************************************************
431void AliHLTTPCEventStatisticsProducerComponent::FillTracksPerSlice() {
432 // see header file for class documentation
433
434 // fill fNTracksPerSlice[36];
435 // fill fNSlice
436}