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