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