]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCCalibPedestalComponent.cxx
Applying transformation AliTPCTransform
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibPedestalComponent.cxx
CommitLineData
02d01bbf 1/**************************************************************************
9be2600f 2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
02d01bbf 4 * *
9be2600f 5 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
6 * for The ALICE HLT Project. *
02d01bbf 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 AliHLTTPCCalibPedestalComponent.cxx
18 @author Jochen Thaeder
19 @date
20 @brief A pedestal calibration component for the TPC.
21*/
22
6a8e0bb4 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
02d01bbf 29#if __GNUC__>= 3
30using namespace std;
31#endif
32
33#include "AliHLTTPCLogging.h"
34#include "AliHLTTPCTransform.h"
35
36#include "AliHLTTPCCalibPedestalComponent.h"
37
38#include "AliRawDataHeader.h"
39#include "AliRawReaderMemory.h"
40#include "AliTPCRawStream.h"
41
42#include "AliTPCCalibPedestal.h"
43
44#include <stdlib.h>
45#include <errno.h>
46#include "TString.h"
47
48// this is a global object used for automatic component registration, do not use this
49AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
50
51ClassImp(AliHLTTPCCalibPedestalComponent)
52
53AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
54 :
55 fRawReader(NULL),
56 fRawStream(NULL),
57 fCalibPedestal(NULL),
9d9ffd37 58 fRCUFormat(kFALSE),
59 fMinPatch(5),
60 fMaxPatch(0),
61 fSpecification(0) ,
62 fEnableAnalysis(kFALSE) {
02d01bbf 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
9d9ffd37 70AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
02d01bbf 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
9d9ffd37 77const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
02d01bbf 78 // see header file for class documentation
9d9ffd37 79
02d01bbf 80 return "TPCCalibPedestal";
81}
82
9d9ffd37 83void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
02d01bbf 84 // see header file for class documentation
9d9ffd37 85
02d01bbf 86 list.clear();
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
88}
89
9d9ffd37 90AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
02d01bbf 91 // see header file for class documentation
9d9ffd37 92
02d01bbf 93 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
94}
95
9d9ffd37 96void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
02d01bbf 97 // see header file for class documentation
9d9ffd37 98
02d01bbf 99 // XXX TODO: Find more realistic values.
100 constBase = 0;
101 inputMultiplier = (2.0);
102}
103
9d9ffd37 104AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
02d01bbf 105 // see header file for class documentation
9d9ffd37 106
02d01bbf 107 return new AliHLTTPCCalibPedestalComponent();
108}
109
9d9ffd37 110
111Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
02d01bbf 112 // see header file for class documentation
9d9ffd37 113
114 Int_t iResult = 0;
115 TString argument = "";
116 TString parameter = "";
117
118 if ( !argc )
119 return -EINVAL;
120
121 argument = argv[iResult];
02d01bbf 122
9d9ffd37 123 if ( argument.IsNull() )
124 return -EINVAL;
02d01bbf 125
9d9ffd37 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 ) {
02d01bbf 135 fRCUFormat = kTRUE;
9d9ffd37 136 HLTInfo( "RCU Format is set to old." );
02d01bbf 137 }
9d9ffd37 138 else if ( parameter.CompareTo("new") == 0 ) {
02d01bbf 139 fRCUFormat = kFALSE;
9d9ffd37 140 HLTInfo( "RCU Format is set to new." );
02d01bbf 141 }
142 else {
9d9ffd37 143 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
144 iResult = -EPROTO;
02d01bbf 145 }
9d9ffd37 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 }
02d01bbf 155
9d9ffd37 156 return iResult;
157}
02d01bbf 158
9d9ffd37 159Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
160 // see header file for class documentation
02d01bbf 161
02d01bbf 162 // ** Create pedestal calibration
163 if ( fCalibPedestal )
164 return EINPROGRESS;
165
166 fCalibPedestal = new AliTPCCalibPedestal();
167
168 // ** Create AliRoot Memory Reader
169 if (fRawReader)
170 return EINPROGRESS;
171
172#if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
173 fRawReader = new AliRawReaderMemory();
174#else
175 HLTFatal("AliRawReader not available - check your build");
176 return -ENODEV;
177#endif
178
179 return 0;
180}
181
9d9ffd37 182Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
02d01bbf 183 // see header file for class documentation
184
185 if ( fRawReader )
186 delete fRawReader;
187 fRawReader = NULL;
188
189 if ( fCalibPedestal )
190 delete fCalibPedestal;
191 fCalibPedestal = NULL;
192
193 return 0;
194}
195
196/*
02d01bbf 197 * --- setter for rcuformat need in AliTPCCalibPedestal class
198 */
5d2abf3b 199Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
02d01bbf 200 // see header file for class documentation
201
202 const AliHLTComponentBlockData* iter = NULL;
02d01bbf 203
83fec083 204 AliHLTUInt8_t slice=0, patch=0;
6a8e0bb4 205 Int_t ddlId = 0;
02d01bbf 206
207 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
208 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
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
22244bc6 217// HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
218// evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
02d01bbf 219
220 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
221 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
222 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
223
6a8e0bb4 224 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
225 else ddlId = 838 + (4*slice) + patch;
02d01bbf 226
6a8e0bb4 227 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
02d01bbf 228
229 // ** Get min and max patch, used for output specification
9d9ffd37 230 if ( patch < fMinPatch ) fMinPatch = patch;
231 if ( patch > fMaxPatch ) fMaxPatch = patch;
02d01bbf 232
233 // ** Init TPCRawStream
234 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
6a8e0bb4 235 fRawReader->SetEquipmentID(ddlId);
02d01bbf 236
237 fRawStream = new AliTPCRawStream( fRawReader );
238 fRawStream->SetOldRCUFormat( fRCUFormat );
239
240 // ** Process actual Pedestal Calibration - Fill histograms
241 fCalibPedestal->ProcessEvent( fRawStream );
242
243 // ** Delete TPCRawStream
244 if ( fRawStream )
245 delete fRawStream;
246 fRawStream = NULL;
247
248 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
249 iter = GetNextInputBlock();
250
251 } // while ( iter != NULL ) {
9d9ffd37 252
253 // ** Get output specification
254 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
255
256 // ** PushBack data to shared memory ...
257 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
02d01bbf 258
9d9ffd37 259 return 0;
260} // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
02d01bbf 261
9d9ffd37 262
62fd2539 263Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
9d9ffd37 264 // see header file for class documentation
265
266 if ( fEnableAnalysis )
267 fCalibPedestal->Analyse();
02d01bbf 268
9d9ffd37 269 // ** PushBack data to FXS ...
270 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
02d01bbf 271
272 return 0;
9d9ffd37 273} // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
274
275