]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/TPCLib/calibration/AliHLTTPCCalibPulserComponent.cxx
ALIROOT-5433 Transition to CDHv3 in HLT
[u/mrichter/AliRoot.git] / HLT / TPCLib / calibration / AliHLTTPCCalibPulserComponent.cxx
... / ...
CommitLineData
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// see header file for class documentation
24// or
25// refer to README to build package
26// or
27// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
28
29#include "AliHLTTPCLogging.h"
30#include "AliHLTTPCTransform.h"
31
32#include "AliHLTTPCCalibPulserComponent.h"
33
34#include "AliRawReaderMemory.h"
35#include "AliTPCRawStream.h"
36
37#ifndef HAVE_NOT_ALITPCCALIBPULSER
38#include "AliTPCCalibPulser.h"
39#endif // HAVE_NOT_ALITPCCALIBPULSER
40
41#include <stdlib.h>
42#include <errno.h>
43#include "TString.h"
44
45using namespace std;
46
47/** ROOT macro for the implementation of ROOT specific class methods */
48ClassImp(AliHLTTPCCalibPulserComponent)
49
50AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
51 :
52 fRawReader(NULL),
53 fRawStream(NULL),
54 fCalibPulser(NULL),
55 // Note: initialization of min and max seems to be in the wrong order but is on
56 // purpose in order to work correctly with the conditional in DoEvent line 233
57 // if ( patch < fMinPatch ) fMinPatch = patch;
58 // if ( patch > fMaxPatch ) fMaxPatch = patch;
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
70AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
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* AliHLTTPCCalibPulserComponent::GetComponentID() {
78 // see header file for class documentation
79
80 return "TPCCalibPulser";
81}
82
83void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
85
86 list.clear();
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
88}
89
90AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
91 // see header file for class documentation
92
93 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
94}
95
96void AliHLTTPCCalibPulserComponent::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* AliHLTTPCCalibPulserComponent::Spawn() {
105 // see header file for class documentation
106
107 return new AliHLTTPCCalibPulserComponent();
108}
109
110
111Int_t AliHLTTPCCalibPulserComponent::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 HLTInfo( "RCU Format is set to old." );
136 }
137 else if ( parameter.CompareTo("new") == 0 ) {
138 HLTInfo( "RCU Format is set to new." );
139 }
140 else {
141 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
142 iResult = -EPROTO;
143 }
144 }
145 }
146 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
147 HLTInfo( "Analysis before shipping data to FXS enabled." );
148 fEnableAnalysis = kTRUE;
149 }
150 else {
151 iResult = -EINVAL;
152 }
153
154 return iResult;
155}
156
157Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
158 // see header file for class documentation
159
160#ifndef HAVE_NOT_ALITPCCALIBPULSER
161 // ** Create pulser calibration
162 if ( fCalibPulser )
163 return EINPROGRESS;
164
165 fCalibPulser = new AliTPCCalibPulser();
166
167 // ** Create AliRoot Memory Reader
168 if (fRawReader)
169 return EINPROGRESS;
170
171 fRawReader = new AliRawReaderMemory();
172
173 return 0;
174#else // HAVE_NOT_ALITPCCALIBPULSER
175#warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
176 HLTFatal("AliTPCCalibPulser not available - check your build");
177 return -ENODEV;
178#endif //HAVE_NOT_ALITPCCALIBPULSER
179}
180
181Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
182 // see header file for class documentation
183
184 if ( fRawReader )
185 delete fRawReader;
186 fRawReader = NULL;
187
188#ifndef HAVE_NOT_ALITPCCALIBPULSER
189 if ( fCalibPulser ) {
190 delete fCalibPulser;
191 }
192#endif
193 fCalibPulser = NULL;
194
195 return 0;
196}
197
198Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
199 AliHLTComponentTriggerData& /*trigData*/ ) {
200 // see header file for class documentation
201
202 const AliHLTComponentBlockData* iter = NULL;
203
204 AliHLTUInt8_t slice=0, patch=0;
205 Int_t ddlId = 0;
206
207 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
208 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
209
210 while ( iter != NULL ) {
211
212 // ** Print Debug output which data format was received
213 // char tmp1[14], tmp2[14];
214 // DataType2Text( iter->fDataType, tmp1 );
215 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
216 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
217 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
218
219 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
220 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
221 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
222
223 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
224 else ddlId = 838 + (4*slice) + patch;
225
226 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
227
228 // ** Get min and max patch, used for output specification
229 if ( patch < fMinPatch ) fMinPatch = patch;
230 if ( patch > fMaxPatch ) fMaxPatch = patch;
231
232 // ** Init TPCRawStream
233 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
234 fRawReader->SetEquipmentID(ddlId);
235
236 fRawStream = new AliTPCRawStream( fRawReader );
237
238#ifndef HAVE_NOT_ALITPCCALIBPULSER
239 // ** Process actual Pulser Calibration - Fill histograms
240 fCalibPulser->ProcessEvent( fRawStream );
241#else //!HAVE_NOT_ALITPCCALIBPULSER
242 HLTFatal("AliTPCCalibPulser not available - check your build");
243 return -ENODEV;
244#endif //HAVE_NOT_ALITPCCALIBPULSER
245
246 // ** Delete TPCRawStream
247 if ( fRawStream )
248 delete fRawStream;
249 fRawStream = NULL;
250
251 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
252 iter = GetNextInputBlock();
253
254 } // while ( iter != NULL ) {
255
256 // ** Get output specification
257 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
258
259 // ** PushBack data to shared memory ...
260 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
261
262 return 0;
263} // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
264
265
266Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
267 AliHLTComponentTriggerData& /*trigData*/ ) {
268 // see header file for class documentation
269
270#ifndef HAVE_NOT_ALITPCCALIBPULSER
271 if ( fEnableAnalysis )
272 fCalibPulser->Analyse();
273#else //!HAVE_NOT_ALITPCCALIBPULSER
274 HLTFatal("AliTPCCalibPulser not available - check your build");
275 return -ENODEV;
276#endif //HAVE_NOT_ALITPCCALIBPULSER
277
278 // ** PushBack data to FXS ...
279 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
280
281 return 0;
282} // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {