]>
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 | ||
672f8b8c | 47 | /** ROOT macro for the implementation of ROOT specific class methods */ |
2ff24e4c | 48 | ClassImp(AliHLTTPCEventStatisticsProducerComponent) |
49 | ||
50 | // ------------------------------------------------------------------------------------------ | |
51 | AliHLTTPCEventStatisticsProducerComponent::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 | // ------------------------------------------------------------------------------------------ | |
66 | AliHLTTPCEventStatisticsProducerComponent::~AliHLTTPCEventStatisticsProducerComponent() { | |
67 | // see header file for class documentation | |
68 | } | |
69 | ||
70 | // ------------------------------------------------------------------------------------------ | |
71 | const char* AliHLTTPCEventStatisticsProducerComponent::GetComponentID() { | |
72 | // see header file for class documentation | |
73 | return "TPCEventStatisticsProducer"; | |
74 | } | |
75 | ||
76 | // ------------------------------------------------------------------------------------------ | |
77 | void 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 | // ------------------------------------------------------------------------------------------ | |
87 | AliHLTComponentDataType AliHLTTPCEventStatisticsProducerComponent::GetOutputDataType() { | |
88 | // see header file for class documentation | |
89 | ||
90 | return kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC; | |
91 | } | |
92 | ||
93 | // ------------------------------------------------------------------------------------------ | |
94 | void 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 | |
104 | AliHLTComponent* AliHLTTPCEventStatisticsProducerComponent::Spawn() { | |
105 | // see header file for class documentation | |
106 | ||
107 | return new AliHLTTPCEventStatisticsProducerComponent; | |
108 | } | |
109 | ||
110 | ||
111 | // ------------------------------------------------------------------------------------------ | |
112 | Int_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 | // ------------------------------------------------------------------------------------------ | |
174 | Int_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 | 189 | Int_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 | // -- ********************************************************************************************** | |
277 | void 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 | // -- ********************************************************************************************** | |
c9602aeb | 299 | void AliHLTTPCEventStatisticsProducerComponent::AddClusters( |
300 | void* ptr, | |
301 | #ifdef __DEBUG | |
302 | Int_t slice, Int_t patch | |
303 | #else | |
304 | Int_t, Int_t | |
305 | #endif | |
306 | ) | |
307 | { | |
2ff24e4c | 308 | // see header file for class documentation |
309 | ||
310 | const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) ptr; | |
311 | ||
312 | Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt; | |
c9602aeb | 313 | HLTDebug( "%d Clusters found for slice %u - patch %u\n", nSpacepoint, slice, patch ); |
2ff24e4c | 314 | |
315 | // ** Add to event statistics | |
316 | fEvStat->AddNTotalCluster( nSpacepoint ); | |
317 | ||
318 | } | |
319 | ||
320 | // -- ********************************************************************************************** | |
5eefc803 | 321 | void AliHLTTPCEventStatisticsProducerComponent::AddTracks( void* ptr, Int_t slice ) { |
2ff24e4c | 322 | // see header file for class documentation |
323 | ||
324 | const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) ptr; | |
325 | ||
326 | Int_t nTracks = (Int_t) trackData->fTrackletCnt; | |
327 | ||
328 | AliHLTTPCTrackSegmentData* segmentData = (AliHLTTPCTrackSegmentData*) &( trackData->fTracklets[0] ); | |
329 | ||
330 | // ** Tracks which are not from GlobalMerger have to be transformed to global Coordinates ( bTransform=1, else 0 ) | |
331 | Int_t bTransform; | |
332 | ||
333 | ||
334 | // ** Global tracks | |
335 | if ( slice == -1 ) { | |
336 | HLTDebug( "%d tracks found for event.", nTracks ); | |
337 | ||
338 | bTransform = 0; | |
339 | fGlobalTracks = kTRUE; | |
340 | } | |
341 | else { | |
342 | HLTDebug( "%d tracks found for slice %u.", nTracks, slice ); | |
343 | ||
344 | // ** Fill number if tracks per slice | |
345 | fNTracksPerSlice[slice] = (Int_t) trackData->fTrackletCnt; | |
346 | fNSlice++; | |
347 | ||
348 | bTransform = 1; | |
349 | } | |
350 | ||
febeb705 | 351 | fTracks->FillTracksChecked( segmentData, nTracks, 0, slice, bTransform ); |
2ff24e4c | 352 | |
353 | } | |
354 | ||
1d229444 | 355 | // -- ********************************************************************************************** |
356 | void AliHLTTPCEventStatisticsProducerComponent::AddESD( TTree* esdTree ) { | |
357 | // see header file for class documentation | |
358 | ||
359 | AliESDEvent* esd = new AliESDEvent(); | |
360 | esd->ReadFromTree(esdTree); | |
361 | esdTree->GetEntry(0); | |
362 | ||
363 | HLTWarning("Number of tracks found : %d", esd->GetNumberOfTracks() ); | |
364 | ||
365 | if ( esd ) | |
366 | delete esd; | |
367 | ||
368 | } | |
369 | ||
2ff24e4c | 370 | // -- ********************************************************************************************** |
371 | void AliHLTTPCEventStatisticsProducerComponent::ProcessEvent() { | |
372 | // see header file for class documentation | |
373 | ||
374 | // ** Total number of tracks -- Add to event statistics | |
375 | fEvStat->SetNTotalTracks( fTracks->GetNTracks() ) ; | |
376 | ||
377 | // ** Loop over all tracks | |
378 | for( Int_t trackNdx=0; trackNdx < fTracks->GetNTracks(); trackNdx++ ) { | |
379 | ||
380 | AliHLTTPCTrack *track = fTracks->GetCheckedTrack( trackNdx ); | |
381 | if( !track ) continue; | |
382 | ||
383 | // ** Used cluster -- Add to event statistics | |
384 | fEvStat->AddNUsedCluster( track->GetNHits() ); | |
385 | ||
386 | // ** If is long track -- Add to event statistics | |
387 | if ( track->GetNHits() >= fClusterThreshold ) | |
388 | fEvStat->AddNTracksAboveClusterThreshold(); | |
389 | } | |
390 | ||
391 | // ** Average of ( number of clusters per track ), floored -- Add to event statistics | |
392 | // N used cluster / N tracks | |
393 | if ( fEvStat->GetNTotalTracks() > 0 ) { | |
394 | fEvStat->SetAvgClusterPerTrack( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNUsedCluster() / (Double_t) fEvStat->GetNTotalTracks() ) ); | |
395 | } | |
396 | fEvStat->SetAvgClusterPerTrack( 0 ); | |
397 | ||
398 | if ( fGlobalTracks ) FillTracksPerSlice(); | |
399 | ||
400 | // ** Average of ( tracks per slice ) | |
401 | if ( fNSlice > 0 ) | |
402 | fEvStat->SetNAvgTracksPerSector( (Int_t) TMath::FloorNint( (Double_t) fEvStat->GetNTotalTracks() / (Double_t) fNSlice ) ); | |
403 | else | |
404 | fEvStat->SetNAvgTracksPerSector( 0 ); | |
405 | ||
406 | // ** Max and Min of Tracks per slice | |
407 | for ( Int_t ii=0; ii < 36; ii++ ) { | |
408 | ||
409 | if ( fNTracksPerSlice[ii] == -1 ) continue; | |
410 | ||
411 | if ( fNTracksPerSlice[ii] > fEvStat->GetNMaxTracksPerSector() ) | |
412 | fEvStat->SetNMaxTracksPerSector( fNTracksPerSlice[ii] ); | |
413 | ||
414 | if ( fNTracksPerSlice[ii] < fEvStat->GetNMinTracksPerSector() ) | |
415 | fEvStat->SetNMinTracksPerSector( fNTracksPerSlice[ii] ); | |
416 | } | |
417 | ||
418 | // ** Info prints | |
419 | ||
420 | HLTInfo( "Total N Tracks : %d", fEvStat->GetNTotalTracks() ); | |
421 | HLTInfo( "Total N Tracks with more than %d cluster : %d", fEvStat->GetClusterThreshold(), fEvStat->GetNTracksAboveClusterThreshold() ); | |
422 | HLTInfo( "Min N Tracks per slice : %d", fEvStat->GetNMinTracksPerSector() ); | |
423 | HLTInfo( "Max N Tracks per slice : %d", fEvStat->GetNMaxTracksPerSector() ); | |
424 | HLTInfo( "Avg N Tracks per slice : %d", fEvStat->GetNAvgTracksPerSector() ); | |
425 | ||
426 | HLTInfo( "Total N Cluster : %d", fEvStat->GetNTotalCluster() ); | |
427 | HLTInfo( "Used N Cluster : %d", fEvStat->GetNUsedCluster() ); | |
428 | HLTInfo( "Average (Cluster per track) : %d", fEvStat->GetAvgClusterPerTrack() ); | |
429 | } | |
430 | ||
431 | // -- ********************************************************************************************** | |
432 | void AliHLTTPCEventStatisticsProducerComponent::FillTracksPerSlice() { | |
433 | // see header file for class documentation | |
434 | ||
435 | // fill fNTracksPerSlice[36]; | |
436 | // fill fNSlice | |
437 | } |