]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCCalibCEComponent.cxx
converting to component registration by library agent - getting rid of global objects
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibCEComponent.cxx
CommitLineData
28355ac2 1// $Id$
2/**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTTPCCalibCEComponent.cxx
19 @author Jochen Thaeder
20 @date
21 @brief A pedestal calibration component for the TPC.
22*/
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
30#if __GNUC__>= 3
31using namespace std;
32#endif
33
34//#include "AliHLTTPCLogging.h"
35#include "AliHLTTPCDefinitions.h"
36//#include "AliHLTTPCTransform.h"
37
38#include "AliHLTTPCCalibCEComponent.h"
39
40//#include "AliRawDataHeader.h"
41#include "AliRawReaderMemory.h"
42#include "AliTPCRawStream.h"
43
44#include "AliTPCCalibCE.h"
45
46#include <cstdlib>
47#include <cerrno>
48#include "TString.h"
49
672f8b8c 50/** ROOT macro for the implementation of ROOT specific class methods */
28355ac2 51ClassImp(AliHLTTPCCalibCEComponent)
52
53AliHLTTPCCalibCEComponent::AliHLTTPCCalibCEComponent()
54 :
55 fRawReader(NULL),
56 fRawStream(NULL),
57 fCalibCE(NULL),
58 fRCUFormat(kFALSE),
59 fMinPatch(5),
60 fMaxPatch(0),
61 fSpecification(0) ,
62 fEnableAnalysis(kFALSE) {
63 // see header file for class documentation
64 // or
65 // refer to README to build package
66 // or
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
68}
69
70AliHLTTPCCalibCEComponent::~AliHLTTPCCalibCEComponent() {
71 // see header file for class documentation
72}
73
74// Public functions to implement AliHLTComponent's interface.
75// These functions are required for the registration process
76
77const char* AliHLTTPCCalibCEComponent::GetComponentID() {
78 // see header file for class documentation
79
80 return "TPCCalibCE";
81}
82
83void AliHLTTPCCalibCEComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
85
86 list.clear();
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
88}
89
90AliHLTComponentDataType AliHLTTPCCalibCEComponent::GetOutputDataType() {
91 // see header file for class documentation
92
93 return AliHLTTPCDefinitions::fgkCalibCEDataType;
94}
95
96void AliHLTTPCCalibCEComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
97 // see header file for class documentation
98
99 // XXX TODO: Find more realistic values.
100 constBase = 0;
101 inputMultiplier = (2.0);
102}
103
104AliHLTComponent* AliHLTTPCCalibCEComponent::Spawn() {
105 // see header file for class documentation
106
107 return new AliHLTTPCCalibCEComponent();
108}
109
110
111Int_t AliHLTTPCCalibCEComponent::ScanArgument( Int_t argc, const char** argv ) {
112 // see header file for class documentation
113
114 Int_t iResult = 0;
115 TString argument = "";
116 TString parameter = "";
117
118 if ( !argc )
119 return -EINVAL;
120
121 argument = argv[iResult];
122
123 if ( argument.IsNull() )
124 return -EINVAL;
125
126 // -rcuformat
127 if ( argument.CompareTo("-rcuformat") == 0 ) {
128
129 if ( ++iResult >= argc ) {
130 iResult = -EPROTO;
131 }
132 else {
133 parameter = argv[1];
134 if ( parameter.CompareTo("old") == 0 ) {
135 fRCUFormat = kTRUE;
136 HLTInfo( "RCU Format is set to old." );
137 }
138 else if ( parameter.CompareTo("new") == 0 ) {
139 fRCUFormat = kFALSE;
140 HLTInfo( "RCU Format is set to new." );
141 }
142 else {
143 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
144 iResult = -EPROTO;
145 }
146 }
147 }
148 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
149 HLTInfo( "Analysis before shipping data to FXS enabled." );
150 fEnableAnalysis = kTRUE;
151 }
152 else {
153 iResult = -EINVAL;
154 }
155
156 return iResult;
157}
158
159Int_t AliHLTTPCCalibCEComponent::InitCalibration() {
160 // see header file for class documentation
161
162 // ** Create pedestal calibration
163 if ( fCalibCE )
164 return EINPROGRESS;
165
166 fCalibCE = new AliTPCCalibCE();
167
168 // ** Create AliRoot Memory Reader
169 if (fRawReader)
170 return EINPROGRESS;
171
172 fRawReader = new AliRawReaderMemory();
173
174 return 0;
175}
176
177Int_t AliHLTTPCCalibCEComponent::DeinitCalibration() {
178 // see header file for class documentation
179
180 if ( fRawReader )
181 delete fRawReader;
182 fRawReader = NULL;
183
184 if ( fCalibCE )
185 delete fCalibCE;
186 fCalibCE = NULL;
187
188 return 0;
189}
190
191/*
192 * --- setter for rcuformat need in AliTPCCalibCE class
193 */
194Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
195 AliHLTComponentTriggerData& /*trigData*/ ) {
196 // see header file for class documentation
197
198 const AliHLTComponentBlockData* iter = NULL;
199
200 AliHLTUInt8_t slice=0, patch=0;
201 Int_t ddlId = 0;
202
203 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
204 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
205
206 while ( iter != NULL ) {
207
208 // ** Print Debug output which data format was received
209 // char tmp1[14], tmp2[14];
210 // DataType2Text( iter->fDataType, tmp1 );
211 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
212 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
213 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
214
215 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
216 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
217 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
218
219 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
220 else ddlId = 838 + (4*slice) + patch;
221
222 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
223
224 // ** Get min and max patch, used for output specification
225 if ( patch < fMinPatch ) fMinPatch = patch;
226 if ( patch > fMaxPatch ) fMaxPatch = patch;
227
228 // ** Init TPCRawStream
229 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
230 fRawReader->SetEquipmentID(ddlId);
231
232 fRawStream = new AliTPCRawStream( fRawReader );
233 fRawStream->SetOldRCUFormat( fRCUFormat );
234
235 // ** Process actual Pedestal Calibration - Fill histograms
236 fCalibCE->ProcessEvent( fRawStream );
237
238 // ** Delete TPCRawStream
239 if ( fRawStream )
240 delete fRawStream;
241 fRawStream = NULL;
242
243 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
244 iter = GetNextInputBlock();
245
246 } // while ( iter != NULL ) {
247
248 // ** Get output specification
249 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
250
251 // ** PushBack data to shared memory ...
252 PushBack( (TObject*) fCalibCE, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
253
254 return 0;
255} // Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
256
257
258Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
259 AliHLTComponentTriggerData& /*trigData*/ ) {
260 // see header file for class documentation
261
262 if ( fEnableAnalysis )
263 fCalibCE->Analyse();
264
265 // ** PushBack data to FXS ...
266 PushToFXS( (TObject*) fCalibCE, "TPC", "CE" ) ;
267
268 return 0;
269} // Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
270
271