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: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
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 AliHLTTPCEventStatisticsProducerComponent.cxx
20 @author Jochen Thaeder
22 @brief Component for the @see AliHLTTPCEventStatisticsProducer class
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "AliHLTTPCEventStatisticsProducerComponent.h"
37 #include "AliHLTTPCDefinitions.h"
38 #include "AliHLTTPCClusterDataFormat.h"
39 #include "AliHLTTPCTrackSegmentData.h"
40 #include "AliHLTTPCTrackletDataFormat.h"
41 #include "AliHLTTPCTrack.h"
47 // ** This is a global object used for automatic component registration, do not use this
48 AliHLTTPCEventStatisticsProducerComponent gAliHLTTPCEventStatisticsProducerComponent;
50 ClassImp(AliHLTTPCEventStatisticsProducerComponent)
52 // ------------------------------------------------------------------------------------------
53 AliHLTTPCEventStatisticsProducerComponent::AliHLTTPCEventStatisticsProducerComponent() :
58 fGlobalTracks(kFALSE),
60 // see header file for class documentation
62 // refer to README to build package
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
67 // ------------------------------------------------------------------------------------------
68 AliHLTTPCEventStatisticsProducerComponent::~AliHLTTPCEventStatisticsProducerComponent() {
69 // see header file for class documentation
72 // ------------------------------------------------------------------------------------------
73 const char* AliHLTTPCEventStatisticsProducerComponent::GetComponentID() {
74 // see header file for class documentation
75 return "TPCEventStatisticsProducer";
78 // ------------------------------------------------------------------------------------------
79 void AliHLTTPCEventStatisticsProducerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
80 // see header file for class documentation
83 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
84 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
85 list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
88 // ------------------------------------------------------------------------------------------
89 AliHLTComponentDataType AliHLTTPCEventStatisticsProducerComponent::GetOutputDataType() {
90 // see header file for class documentation
92 return kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC;
95 // ------------------------------------------------------------------------------------------
96 void AliHLTTPCEventStatisticsProducerComponent::GetOutputDataSize( unsigned long& constBase,
97 double& inputMultiplier ) {
98 // see header file for class documentation
100 constBase = sizeof( AliHLTTPCEventStatistics );
101 inputMultiplier = 0.0;
104 // ------------------------------------------------------------------------------------------
105 // Spawn function, return new instance of this class
106 AliHLTComponent* AliHLTTPCEventStatisticsProducerComponent::Spawn() {
107 // see header file for class documentation
109 return new AliHLTTPCEventStatisticsProducerComponent;
113 // ------------------------------------------------------------------------------------------
114 Int_t AliHLTTPCEventStatisticsProducerComponent::DoInit( int argc, const char** argv ) {
115 // see header file for class documentation
123 // ** Argument handling
125 TString argument = "";
126 TString parameter = "";
127 Int_t bMissingParam=0;
129 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
133 if ( argument.IsNull() ) continue;
136 if ( ! argument.CompareTo("-clusterThreshold") ) {
138 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
140 parameter = argv[ii];
141 parameter.Remove( TString::kLeading, ' ' );
143 if (parameter.IsDigit() ) {
144 threshold = (Int_t) parameter.Atoi();
145 HLTInfo( "Threshold of clusters for long tracks is set to %d.", threshold );
148 HLTError( "Cannot convert clusterThreshold specifier '%s'.", parameter.Data() );
153 } // if ( ! argument.CompareTo("-clusterThreshold") ) {
155 // - unknow parameter
158 HLTError("Unknown argument '%s'", argument.Data() );
161 } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
163 if ( bMissingParam ) {
164 HLTError( "Missing parameter for argument '%s'.", argument.Data() );
170 fClusterThreshold = threshold;
175 // ------------------------------------------------------------------------------------------
176 Int_t AliHLTTPCEventStatisticsProducerComponent::DoDeinit() {
177 // see header file for class documentation
190 // ------------------------------------------------------------------------------------------
191 Int_t AliHLTTPCEventStatisticsProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
192 // see header file for class documentation
194 const AliHLTComponentBlockData* iter = NULL;
196 // ** No readout list for SOR and EOR event
197 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
201 // ** Setup for new Event
206 // ** Read in cluster from ClusterFinder
209 // ** Loop over all input blocks and specify which data format should be read
210 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
212 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
213 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
215 HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
217 AddClusters( iter->fPtr, (Int_t) slice, (Int_t) patch );
218 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
222 // ** Read in track segments from Tracker
227 // ** Loop over all input blocks and specify which data format should be read
228 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
230 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
231 HLTDebug ( "Input Data - TPC track segments - Slice: %d.", slice );
233 AddTracks( iter->fPtr, (Int_t) slice );
234 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
237 // ** Read in tracks from GlobalMerger
242 // ** Loop over all input blocks and specify which data format should be read
243 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
245 HLTDebug ( "Input Data - TPC track segments." );
247 AddTracks( iter->fPtr );
248 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
252 // ** Produce event statistics
257 PushBack ( (TObject*) GetEventStatistics(), sizeof(AliHLTTPCEventStatistics), kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC, (AliHLTUInt32_t) 0 );
262 // -- **********************************************************************************************
263 // -- ******************************* Processing Functions **************************************
264 // -- **********************************************************************************************
266 // -- **********************************************************************************************
267 void AliHLTTPCEventStatisticsProducerComponent::InitializeEvent() {
268 // see header file for class documentation
273 fEvStat = new AliHLTTPCEventStatistics();
274 fEvStat->SetClusterThreshold( fClusterThreshold );
276 // ** Initialize arrays to 0
277 memset( fNTracksPerSlice, -1, 36*sizeof(Int_t) );
279 // ** New AliHLTTPCTrackArray
282 fTracks = new AliHLTTPCTrackArray;
284 fGlobalTracks = kFALSE;
288 // -- **********************************************************************************************
289 void AliHLTTPCEventStatisticsProducerComponent::AddClusters( void* ptr, Int_t slice, Int_t patch ) {
290 // see header file for class documentation
292 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) ptr;
294 // these 2 variables have been introduced to avoid warning: unused variable in production compile
295 Int_t sliceAntiWarning = slice;
296 Int_t patchAntiWarning = patch;
298 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
299 HLTDebug( "%d Clusters found for slice %u - patch %u\n", nSpacepoint, sliceAntiWarning, patchAntiWarning );
301 sliceAntiWarning = 0;
302 patchAntiWarning = 0;
304 // ** Add to event statistics
305 fEvStat->AddNTotalCluster( nSpacepoint );
309 // -- **********************************************************************************************
310 void AliHLTTPCEventStatisticsProducerComponent::AddTracks( void* ptr, Int_t slice ) {
311 // see header file for class documentation
313 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) ptr;
315 Int_t nTracks = (Int_t) trackData->fTrackletCnt;
317 AliHLTTPCTrackSegmentData* segmentData = (AliHLTTPCTrackSegmentData*) &( trackData->fTracklets[0] );
319 // ** Tracks which are not from GlobalMerger have to be transformed to global Coordinates ( bTransform=1, else 0 )
325 HLTDebug( "%d tracks found for event.", nTracks );
328 fGlobalTracks = kTRUE;
331 HLTDebug( "%d tracks found for slice %u.", nTracks, slice );
333 // ** Fill number if tracks per slice
334 fNTracksPerSlice[slice] = (Int_t) trackData->fTrackletCnt;
340 fTracks->FillTracks( nTracks, segmentData, slice, bTransform );
344 // -- **********************************************************************************************
345 void AliHLTTPCEventStatisticsProducerComponent::ProcessEvent() {
346 // see header file for class documentation
348 // ** Total number of tracks -- Add to event statistics
349 fEvStat->SetNTotalTracks( fTracks->GetNTracks() ) ;
351 // ** Loop over all tracks
352 for( Int_t trackNdx=0; trackNdx < fTracks->GetNTracks(); trackNdx++ ) {
354 AliHLTTPCTrack *track = fTracks->GetCheckedTrack( trackNdx );
355 if( !track ) continue;
357 // ** Used cluster -- Add to event statistics
358 fEvStat->AddNUsedCluster( track->GetNHits() );
360 // ** If is long track -- Add to event statistics
361 if ( track->GetNHits() >= fClusterThreshold )
362 fEvStat->AddNTracksAboveClusterThreshold();
365 // ** Average of ( number of clusters per track ), floored -- Add to event statistics
366 // N used cluster / N tracks
367 if ( fEvStat->GetNTotalTracks() > 0 ) {
368 fEvStat->SetAvgClusterPerTrack( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNUsedCluster() / (Double_t) fEvStat->GetNTotalTracks() ) );
370 fEvStat->SetAvgClusterPerTrack( 0 );
372 if ( fGlobalTracks ) FillTracksPerSlice();
374 // ** Average of ( tracks per slice )
376 fEvStat->SetNAvgTracksPerSector( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNTotalTracks() / (Double_t) fNSlice ) );
378 fEvStat->SetNAvgTracksPerSector( 0 );
380 // ** Max and Min of Tracks per slice
381 for ( Int_t ii=0; ii < 36; ii++ ) {
383 if ( fNTracksPerSlice[ii] == -1 ) continue;
385 if ( fNTracksPerSlice[ii] > fEvStat->GetNMaxTracksPerSector() )
386 fEvStat->SetNMaxTracksPerSector( fNTracksPerSlice[ii] );
388 if ( fNTracksPerSlice[ii] < fEvStat->GetNMinTracksPerSector() )
389 fEvStat->SetNMinTracksPerSector( fNTracksPerSlice[ii] );
394 HLTInfo( "Total N Tracks : %d", fEvStat->GetNTotalTracks() );
395 HLTInfo( "Total N Tracks with more than %d cluster : %d", fEvStat->GetClusterThreshold(), fEvStat->GetNTracksAboveClusterThreshold() );
396 HLTInfo( "Min N Tracks per slice : %d", fEvStat->GetNMinTracksPerSector() );
397 HLTInfo( "Max N Tracks per slice : %d", fEvStat->GetNMaxTracksPerSector() );
398 HLTInfo( "Avg N Tracks per slice : %d", fEvStat->GetNAvgTracksPerSector() );
400 HLTInfo( "Total N Cluster : %d", fEvStat->GetNTotalCluster() );
401 HLTInfo( "Used N Cluster : %d", fEvStat->GetNUsedCluster() );
402 HLTInfo( "Average (Cluster per track) : %d", fEvStat->GetAvgClusterPerTrack() );
405 // -- **********************************************************************************************
406 void AliHLTTPCEventStatisticsProducerComponent::FillTracksPerSlice() {
407 // see header file for class documentation
409 // fill fNTracksPerSlice[36];