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 /** ROOT macro for the implementation of ROOT specific class methods */
48 ClassImp(AliHLTTPCEventStatisticsProducerComponent)
50 // ------------------------------------------------------------------------------------------
51 AliHLTTPCEventStatisticsProducerComponent::AliHLTTPCEventStatisticsProducerComponent() :
56 fGlobalTracks(kFALSE),
58 // see header file for class documentation
60 // refer to README to build package
62 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65 // ------------------------------------------------------------------------------------------
66 AliHLTTPCEventStatisticsProducerComponent::~AliHLTTPCEventStatisticsProducerComponent() {
67 // see header file for class documentation
70 // ------------------------------------------------------------------------------------------
71 const char* AliHLTTPCEventStatisticsProducerComponent::GetComponentID() {
72 // see header file for class documentation
73 return "TPCEventStatisticsProducer";
76 // ------------------------------------------------------------------------------------------
77 void AliHLTTPCEventStatisticsProducerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
78 // see header file for class documentation
81 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
82 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
83 list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
86 // ------------------------------------------------------------------------------------------
87 AliHLTComponentDataType AliHLTTPCEventStatisticsProducerComponent::GetOutputDataType() {
88 // see header file for class documentation
90 return kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC;
93 // ------------------------------------------------------------------------------------------
94 void AliHLTTPCEventStatisticsProducerComponent::GetOutputDataSize( unsigned long& constBase,
95 double& inputMultiplier ) {
96 // see header file for class documentation
98 constBase = sizeof( AliHLTTPCEventStatistics );
99 inputMultiplier = 0.0;
102 // ------------------------------------------------------------------------------------------
103 // Spawn function, return new instance of this class
104 AliHLTComponent* AliHLTTPCEventStatisticsProducerComponent::Spawn() {
105 // see header file for class documentation
107 return new AliHLTTPCEventStatisticsProducerComponent;
111 // ------------------------------------------------------------------------------------------
112 Int_t AliHLTTPCEventStatisticsProducerComponent::DoInit( int argc, const char** argv ) {
113 // see header file for class documentation
121 // ** Argument handling
123 TString argument = "";
124 TString parameter = "";
125 Int_t bMissingParam=0;
127 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
131 if ( argument.IsNull() ) continue;
134 if ( ! argument.CompareTo("-clusterThreshold") ) {
136 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
138 parameter = argv[ii];
139 parameter.Remove( TString::kLeading, ' ' );
141 if (parameter.IsDigit() ) {
142 threshold = (Int_t) parameter.Atoi();
143 HLTInfo( "Threshold of clusters for long tracks is set to %d.", threshold );
146 HLTError( "Cannot convert clusterThreshold specifier '%s'.", parameter.Data() );
151 } // if ( ! argument.CompareTo("-clusterThreshold") ) {
153 // - unknow parameter
156 HLTError("Unknown argument '%s'", argument.Data() );
159 } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
161 if ( bMissingParam ) {
162 HLTError( "Missing parameter for argument '%s'.", argument.Data() );
168 fClusterThreshold = threshold;
173 // ------------------------------------------------------------------------------------------
174 Int_t AliHLTTPCEventStatisticsProducerComponent::DoDeinit() {
175 // see header file for class documentation
188 // ------------------------------------------------------------------------------------------
189 Int_t AliHLTTPCEventStatisticsProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
190 // see header file for class documentation
192 const AliHLTComponentBlockData* iter = NULL;
194 // ** No readout list for SOR and EOR event
195 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
199 // ** Setup for new Event
204 // ** Read in cluster from ClusterFinder
207 // ** Loop over all input blocks and specify which data format should be read
208 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
210 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
211 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
213 HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
215 AddClusters( iter->fPtr, (Int_t) slice, (Int_t) patch );
216 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
220 // ** Read in track segments from Tracker
225 // ** Loop over all input blocks and specify which data format should be read
226 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
228 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
229 HLTDebug ( "Input Data - TPC track segments - Slice: %d.", slice );
231 AddTracks( iter->fPtr, (Int_t) slice );
232 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock() ) {
235 // ** Read in tracks from GlobalMerger
240 // ** Loop over all input blocks and specify which data format should be read
241 for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
243 HLTDebug ( "Input Data - TPC track segments." );
245 AddTracks( iter->fPtr );
246 } // for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock() ) {
249 TObject* iterObject = NULL;
252 iterObject = (TObject* )GetFirstInputObject(kAliHLTDataTypeESDTree|kAliHLTDataOriginTPC);
256 HLTDebug ( "Input Data - TPC ESD." );
258 AddESD( (TTree*) iterObject );
262 // ** Produce event statistics
267 PushBack ( (TObject*) GetEventStatistics(), sizeof(AliHLTTPCEventStatistics), kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC, (AliHLTUInt32_t) 0 );
272 // -- **********************************************************************************************
273 // -- ******************************* Processing Functions **************************************
274 // -- **********************************************************************************************
276 // -- **********************************************************************************************
277 void AliHLTTPCEventStatisticsProducerComponent::InitializeEvent() {
278 // see header file for class documentation
283 fEvStat = new AliHLTTPCEventStatistics();
284 fEvStat->SetClusterThreshold( fClusterThreshold );
286 // ** Initialize arrays to 0
287 memset( fNTracksPerSlice, -1, 36*sizeof(Int_t) );
289 // ** New AliHLTTPCTrackArray
292 fTracks = new AliHLTTPCTrackArray;
294 fGlobalTracks = kFALSE;
298 // -- **********************************************************************************************
299 void AliHLTTPCEventStatisticsProducerComponent::AddClusters( void* ptr, Int_t slice, Int_t patch ) {
300 // see header file for class documentation
302 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) ptr;
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;
308 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
309 HLTDebug( "%d Clusters found for slice %u - patch %u\n", nSpacepoint, sliceAntiWarning, patchAntiWarning );
311 sliceAntiWarning = 0;
312 patchAntiWarning = 0;
314 // ** Add to event statistics
315 fEvStat->AddNTotalCluster( nSpacepoint );
319 // -- **********************************************************************************************
320 void AliHLTTPCEventStatisticsProducerComponent::AddTracks( void* ptr, Int_t slice ) {
321 // see header file for class documentation
323 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) ptr;
325 Int_t nTracks = (Int_t) trackData->fTrackletCnt;
327 AliHLTTPCTrackSegmentData* segmentData = (AliHLTTPCTrackSegmentData*) &( trackData->fTracklets[0] );
329 // ** Tracks which are not from GlobalMerger have to be transformed to global Coordinates ( bTransform=1, else 0 )
335 HLTDebug( "%d tracks found for event.", nTracks );
338 fGlobalTracks = kTRUE;
341 HLTDebug( "%d tracks found for slice %u.", nTracks, slice );
343 // ** Fill number if tracks per slice
344 fNTracksPerSlice[slice] = (Int_t) trackData->fTrackletCnt;
350 fTracks->FillTracksChecked( segmentData, nTracks, 0, slice, bTransform );
354 // -- **********************************************************************************************
355 void AliHLTTPCEventStatisticsProducerComponent::AddESD( TTree* esdTree ) {
356 // see header file for class documentation
358 AliESDEvent* esd = new AliESDEvent();
359 esd->ReadFromTree(esdTree);
360 esdTree->GetEntry(0);
362 HLTWarning("Number of tracks found : %d", esd->GetNumberOfTracks() );
369 // -- **********************************************************************************************
370 void AliHLTTPCEventStatisticsProducerComponent::ProcessEvent() {
371 // see header file for class documentation
373 // ** Total number of tracks -- Add to event statistics
374 fEvStat->SetNTotalTracks( fTracks->GetNTracks() ) ;
376 // ** Loop over all tracks
377 for( Int_t trackNdx=0; trackNdx < fTracks->GetNTracks(); trackNdx++ ) {
379 AliHLTTPCTrack *track = fTracks->GetCheckedTrack( trackNdx );
380 if( !track ) continue;
382 // ** Used cluster -- Add to event statistics
383 fEvStat->AddNUsedCluster( track->GetNHits() );
385 // ** If is long track -- Add to event statistics
386 if ( track->GetNHits() >= fClusterThreshold )
387 fEvStat->AddNTracksAboveClusterThreshold();
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() ) );
395 fEvStat->SetAvgClusterPerTrack( 0 );
397 if ( fGlobalTracks ) FillTracksPerSlice();
399 // ** Average of ( tracks per slice )
401 fEvStat->SetNAvgTracksPerSector( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNTotalTracks() / (Double_t) fNSlice ) );
403 fEvStat->SetNAvgTracksPerSector( 0 );
405 // ** Max and Min of Tracks per slice
406 for ( Int_t ii=0; ii < 36; ii++ ) {
408 if ( fNTracksPerSlice[ii] == -1 ) continue;
410 if ( fNTracksPerSlice[ii] > fEvStat->GetNMaxTracksPerSector() )
411 fEvStat->SetNMaxTracksPerSector( fNTracksPerSlice[ii] );
413 if ( fNTracksPerSlice[ii] < fEvStat->GetNMinTracksPerSector() )
414 fEvStat->SetNMinTracksPerSector( fNTracksPerSlice[ii] );
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() );
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() );
430 // -- **********************************************************************************************
431 void AliHLTTPCEventStatisticsProducerComponent::FillTracksPerSlice() {
432 // see header file for class documentation
434 // fill fNTracksPerSlice[36];