]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCCalibPulserComponent.cxx
allow NULL pointer arguments in SetDataType
[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
9d9ffd37 66AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
67 // see header file for class documentation
68}
69
70// Public functions to implement AliHLTComponent's interface.
71// These functions are required for the registration process
72
73const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
74 // see header file for class documentation
75
76 return "TPCCalibPulser";
77}
78
79void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
80 // see header file for class documentation
81
82 list.clear();
83 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
84}
85
86AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
87 // see header file for class documentation
88
89 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
90}
91
92void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
93 // see header file for class documentation
94
95 // XXX TODO: Find more realistic values.
96 constBase = 0;
97 inputMultiplier = (2.0);
98}
99
100AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
101 // see header file for class documentation
102
103 return new AliHLTTPCCalibPulserComponent();
104}
105
106
107Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
108 // see header file for class documentation
109
110 Int_t iResult = 0;
111 TString argument = "";
112 TString parameter = "";
113
114 if ( !argc )
115 return -EINVAL;
116
117 argument = argv[iResult];
118
119 if ( argument.IsNull() )
120 return -EINVAL;
121
122 // -rcuformat
123 if ( argument.CompareTo("-rcuformat") == 0 ) {
124
125 if ( ++iResult >= argc ) {
126 iResult = -EPROTO;
127 }
128 else {
129 parameter = argv[1];
130 if ( parameter.CompareTo("old") == 0 ) {
131 fRCUFormat = kTRUE;
132 HLTInfo( "RCU Format is set to old." );
133 }
134 else if ( parameter.CompareTo("new") == 0 ) {
135 fRCUFormat = kFALSE;
136 HLTInfo( "RCU Format is set to new." );
137 }
138 else {
139 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
140 iResult = -EPROTO;
141 }
142 }
143 }
144 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
145 HLTInfo( "Analysis before shipping data to FXS enabled." );
146 fEnableAnalysis = kTRUE;
147 }
148 else {
149 iResult = -EINVAL;
150 }
151
152 return iResult;
153}
154
155Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
156 // see header file for class documentation
157
591fc7c3 158#ifndef HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 159 // ** Create pulser calibration
160 if ( fCalibPulser )
161 return EINPROGRESS;
162
163 fCalibPulser = new AliTPCCalibPulser();
164
165 // ** Create AliRoot Memory Reader
166 if (fRawReader)
167 return EINPROGRESS;
168
169#if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
170 fRawReader = new AliRawReaderMemory();
171#else
172 HLTFatal("AliRawReader not available - check your build");
173 return -ENODEV;
174#endif
175
176 return 0;
591fc7c3 177#else // HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 178#warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
179 HLTFatal("AliTPCCalibPulser not available - check your build");
180 return -ENODEV;
591fc7c3 181#endif //HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 182}
183
184Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
185 // see header file for class documentation
186
187 if ( fRawReader )
188 delete fRawReader;
189 fRawReader = NULL;
190
591fc7c3 191#ifndef HAVE_NOT_ALITPCCALIBPULSER
192 if ( fCalibPulser ) {
9d9ffd37 193 delete fCalibPulser;
591fc7c3 194 }
195#endif
9d9ffd37 196 fCalibPulser = NULL;
197
198 return 0;
199}
200
201/*
202 * --- setter for rcuformat need in AliTPCCalibPulser class
203 */
204Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
205 // see header file for class documentation
206
207 const AliHLTComponentBlockData* iter = NULL;
208
83fec083 209 AliHLTUInt8_t slice=0, patch=0;
9d9ffd37 210 Int_t DDLid = 0;
211
212 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
213 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
214
215 while ( iter != NULL ) {
216
217 // ** Print Debug output which data format was received
218 char tmp1[14], tmp2[14];
219 DataType2Text( iter->fDataType, tmp1 );
220 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
221
222 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
223 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
224
225 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
226 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
227 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
228
229 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
230 else DDLid = 838 + (4*slice) + patch;
231
232 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
233
234 // ** Get min and max patch, used for output specification
235 if ( patch < fMinPatch ) fMinPatch = patch;
236 if ( patch > fMaxPatch ) fMaxPatch = patch;
237
238 // ** Init TPCRawStream
239 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
240 fRawReader->SetEquipmentID(DDLid);
241
242 fRawStream = new AliTPCRawStream( fRawReader );
243 fRawStream->SetOldRCUFormat( fRCUFormat );
244
591fc7c3 245#ifndef HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 246 // ** Process actual Pulser Calibration - Fill histograms
247 fCalibPulser->ProcessEvent( fRawStream );
591fc7c3 248#else //!HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 249 HLTFatal("AliTPCCalibPulser not available - check your build");
250 return -ENODEV;
591fc7c3 251#endif //HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 252
253 // ** Delete TPCRawStream
254 if ( fRawStream )
255 delete fRawStream;
256 fRawStream = NULL;
257
258 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
259 iter = GetNextInputBlock();
260
261 } // while ( iter != NULL ) {
262
263 // ** Get output specification
264 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
265
266 // ** PushBack data to shared memory ...
267 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
268
269 return 0;
270} // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
271
272
62fd2539 273Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
9d9ffd37 274 // see header file for class documentation
275
591fc7c3 276#ifndef HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 277 if ( fEnableAnalysis )
278 fCalibPulser->Analyse();
591fc7c3 279#else //!HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 280 HLTFatal("AliTPCCalibPulser not available - check your build");
281 return -ENODEV;
591fc7c3 282#endif //HAVE_NOT_ALITPCCALIBPULSER
9d9ffd37 283
284 // ** PushBack data to FXS ...
285 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
286
287 return 0;
288} // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {