]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCRunStatisticsProducerComponent.cxx
added 'backwards' mapping: row/pad to channel; code cleanup
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCRunStatisticsProducerComponent.cxx
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   AliHLTTPCRunStatisticsProducerComponent.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 "AliHLTTPCRunStatisticsProducerComponent.h"
36 #include "AliHLTTPCEventStatistics.h"
37 #include "TMath.h"
38
39 #include <cerrno>
40
41 /** ROOT macro for the implementation of ROOT specific class methods */
42 ClassImp(AliHLTTPCRunStatisticsProducerComponent)
43     
44 // ------------------------------------------------------------------------------------------
45 AliHLTTPCRunStatisticsProducerComponent::AliHLTTPCRunStatisticsProducerComponent() : 
46   fRunStat(NULL),
47   fIsHeader(kFALSE) {
48
49   // see header file for class documentation
50   // or
51   // refer to README to build package
52   // or
53   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 }
55
56 // ------------------------------------------------------------------------------------------
57 AliHLTTPCRunStatisticsProducerComponent::~AliHLTTPCRunStatisticsProducerComponent() {
58   // see header file for class documentation
59 }
60
61 // ------------------------------------------------------------------------------------------
62 const char* AliHLTTPCRunStatisticsProducerComponent::GetComponentID() {
63   // see header file for class documentation
64   return "TPCRunStatisticsProducer"; 
65 }
66
67 // ------------------------------------------------------------------------------------------
68 void AliHLTTPCRunStatisticsProducerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
69   // see header file for class documentation
70
71   list.clear(); 
72   list.push_back( kAliHLTDataTypeEventStatistics );
73 }
74
75 // ------------------------------------------------------------------------------------------
76 AliHLTComponentDataType AliHLTTPCRunStatisticsProducerComponent::GetOutputDataType() {
77   // see header file for class documentation
78
79   return kAliHLTDataTypeRunStatistics|kAliHLTDataOriginTPC;
80 }
81
82 // ------------------------------------------------------------------------------------------
83 void AliHLTTPCRunStatisticsProducerComponent::GetOutputDataSize( unsigned long& constBase, 
84                                                                  double& inputMultiplier ) {
85   // see header file for class documentation
86
87   constBase = sizeof( AliHLTTPCRunStatistics );
88   inputMultiplier = 0.0;
89 }
90
91 // ------------------------------------------------------------------------------------------
92 AliHLTComponent* AliHLTTPCRunStatisticsProducerComponent::Spawn() {
93   // Spawn function, return new instance of this class
94   // see header file for class documentation
95
96   return new AliHLTTPCRunStatisticsProducerComponent;
97 }
98  
99 // ------------------------------------------------------------------------------------------
100 Int_t AliHLTTPCRunStatisticsProducerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
101   // see header file for class documentation
102
103   Int_t iResult = 0;
104   
105   if ( fRunStat )
106     return EINPROGRESS;
107
108   fRunStat = new AliHLTTPCRunStatistics();
109
110   return iResult;
111 }
112
113 // ------------------------------------------------------------------------------------------
114 Int_t AliHLTTPCRunStatisticsProducerComponent::DoDeinit() {
115   // see header file for class documentation
116
117   if ( fRunStat )
118     delete fRunStat;
119   fRunStat = NULL;
120
121   return 0;
122 }
123
124 // ------------------------------------------------------------------------------------------
125 Int_t AliHLTTPCRunStatisticsProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
126                                                         AliHLTComponentTriggerData& /*trigData*/ ) {
127   // see header file for class documentation
128
129   // ** Process EventStatistics Block
130   AliHLTTPCEventStatistics* evStat = (AliHLTTPCEventStatistics*) GetFirstInputObject ( kAliHLTDataTypeEventStatistics|kAliHLTDataOriginTPC, 
131                                                                                        "AliHLTTPCEventStatistics" );
132   if ( evStat )
133     ProcessEventStatistics ( evStat );
134   
135   if ( ! fIsHeader ) {
136     fRunStat->SetDetectorName("TPC");
137     
138     if ( evStat )
139       fRunStat->SetClusterThreshold( evStat->GetClusterThreshold() );
140   }
141
142   // ** increase number of events
143   fRunStat->AddNEvents();
144
145
146   PushBack ( (TObject*) GetRunStatistics(), sizeof(AliHLTTPCRunStatistics), kAliHLTDataTypeRunStatistics|kAliHLTDataOriginTPC, (AliHLTUInt32_t) 0 );
147
148   return 0;
149 }
150
151 // -- **********************************************************************************************
152 // -- *******************************   Processing Functions  **************************************
153 // -- **********************************************************************************************
154
155 // -- **********************************************************************************************
156 void AliHLTTPCRunStatisticsProducerComponent::ProcessEventStatistics( AliHLTTPCEventStatistics* evStat ) {
157   // see header file for class documentation
158   
159   // ** add number of total tracks
160   fRunStat->AddNTotalTracks( evStat->GetNTotalTracks() );
161
162   // ** add number of long tracks  ( tracks above cluster threshold )
163   fRunStat->AddNTracksAboveClusterThreshold( evStat->GetNTracksAboveClusterThreshold() );
164
165   // ** add number of total clusters
166   fRunStat->AddNTotalCluster( evStat->GetNTotalCluster() );
167
168   // ** add number of cluster used in tracks
169   fRunStat->AddNUsedCluster( evStat->GetNUsedCluster() );
170
171   // ** add number of average clusters per track
172   fRunStat->AddAvgClusterPerTrack( evStat->GetAvgClusterPerTrack() );
173
174 }
175
176
177