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