]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCCalibPedestalComponent.cxx
added new helper components to libAliHLTUtil (EsdCollector and AliHLTOUTPublisher...
[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
672f8b8c 48/** ROOT macro for the implementation of ROOT specific class methods */
02d01bbf 49ClassImp(AliHLTTPCCalibPedestalComponent)
50
51AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
52 :
53 fRawReader(NULL),
54 fRawStream(NULL),
55 fCalibPedestal(NULL),
9d9ffd37 56 fMinPatch(5),
57 fMaxPatch(0),
58 fSpecification(0) ,
59 fEnableAnalysis(kFALSE) {
02d01bbf 60 // see header file for class documentation
61 // or
62 // refer to README to build package
63 // or
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65}
66
9d9ffd37 67AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
02d01bbf 68 // see header file for class documentation
69}
70
71// Public functions to implement AliHLTComponent's interface.
72// These functions are required for the registration process
73
9d9ffd37 74const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
02d01bbf 75 // see header file for class documentation
9d9ffd37 76
02d01bbf 77 return "TPCCalibPedestal";
78}
79
9d9ffd37 80void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
02d01bbf 81 // see header file for class documentation
9d9ffd37 82
02d01bbf 83 list.clear();
84 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
85}
86
9d9ffd37 87AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
02d01bbf 88 // see header file for class documentation
9d9ffd37 89
02d01bbf 90 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
91}
92
9d9ffd37 93void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
02d01bbf 94 // see header file for class documentation
9d9ffd37 95
02d01bbf 96 // XXX TODO: Find more realistic values.
97 constBase = 0;
98 inputMultiplier = (2.0);
99}
100
9d9ffd37 101AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
02d01bbf 102 // see header file for class documentation
9d9ffd37 103
02d01bbf 104 return new AliHLTTPCCalibPedestalComponent();
105}
106
9d9ffd37 107
108Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
02d01bbf 109 // see header file for class documentation
9d9ffd37 110
111 Int_t iResult = 0;
112 TString argument = "";
113 TString parameter = "";
114
115 if ( !argc )
116 return -EINVAL;
117
118 argument = argv[iResult];
02d01bbf 119
9d9ffd37 120 if ( argument.IsNull() )
121 return -EINVAL;
02d01bbf 122
9d9ffd37 123 // -rcuformat
124 if ( argument.CompareTo("-rcuformat") == 0 ) {
125
126 if ( ++iResult >= argc ) {
127 iResult = -EPROTO;
128 }
129 else {
130 parameter = argv[1];
131 if ( parameter.CompareTo("old") == 0 ) {
9d9ffd37 132 HLTInfo( "RCU Format is set to old." );
02d01bbf 133 }
9d9ffd37 134 else if ( parameter.CompareTo("new") == 0 ) {
9d9ffd37 135 HLTInfo( "RCU Format is set to new." );
02d01bbf 136 }
137 else {
9d9ffd37 138 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
139 iResult = -EPROTO;
02d01bbf 140 }
9d9ffd37 141 }
142 }
143 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
144 HLTInfo( "Analysis before shipping data to FXS enabled." );
145 fEnableAnalysis = kTRUE;
146 }
147 else {
148 iResult = -EINVAL;
149 }
02d01bbf 150
9d9ffd37 151 return iResult;
152}
02d01bbf 153
9d9ffd37 154Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
155 // see header file for class documentation
02d01bbf 156
02d01bbf 157 // ** Create pedestal calibration
158 if ( fCalibPedestal )
159 return EINPROGRESS;
160
161 fCalibPedestal = new AliTPCCalibPedestal();
162
163 // ** Create AliRoot Memory Reader
164 if (fRawReader)
165 return EINPROGRESS;
166
02d01bbf 167 fRawReader = new AliRawReaderMemory();
02d01bbf 168
169 return 0;
170}
171
9d9ffd37 172Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
02d01bbf 173 // see header file for class documentation
174
175 if ( fRawReader )
176 delete fRawReader;
177 fRawReader = NULL;
178
179 if ( fCalibPedestal )
180 delete fCalibPedestal;
181 fCalibPedestal = NULL;
182
183 return 0;
184}
185
ed504011 186Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
187 AliHLTComponentTriggerData& /*trigData*/ ) {
02d01bbf 188 // see header file for class documentation
189
190 const AliHLTComponentBlockData* iter = NULL;
02d01bbf 191
83fec083 192 AliHLTUInt8_t slice=0, patch=0;
6a8e0bb4 193 Int_t ddlId = 0;
02d01bbf 194
195 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
ed504011 196 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
02d01bbf 197
198 while ( iter != NULL ) {
199
200 // ** Print Debug output which data format was received
017efeea 201 // char tmp1[14], tmp2[14];
ed504011 202 // DataType2Text( iter->fDataType, tmp1 );
203 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
204 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
205 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
02d01bbf 206
207 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
208 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
209 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
210
6a8e0bb4 211 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
212 else ddlId = 838 + (4*slice) + patch;
02d01bbf 213
6a8e0bb4 214 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
02d01bbf 215
216 // ** Get min and max patch, used for output specification
9d9ffd37 217 if ( patch < fMinPatch ) fMinPatch = patch;
218 if ( patch > fMaxPatch ) fMaxPatch = patch;
02d01bbf 219
220 // ** Init TPCRawStream
221 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
6a8e0bb4 222 fRawReader->SetEquipmentID(ddlId);
02d01bbf 223
224 fRawStream = new AliTPCRawStream( fRawReader );
02d01bbf 225
226 // ** Process actual Pedestal Calibration - Fill histograms
227 fCalibPedestal->ProcessEvent( fRawStream );
228
229 // ** Delete TPCRawStream
230 if ( fRawStream )
231 delete fRawStream;
232 fRawStream = NULL;
233
234 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
235 iter = GetNextInputBlock();
236
237 } // while ( iter != NULL ) {
9d9ffd37 238
239 // ** Get output specification
240 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
241
242 // ** PushBack data to shared memory ...
243 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
02d01bbf 244
9d9ffd37 245 return 0;
246} // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
02d01bbf 247
9d9ffd37 248
ed504011 249Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
250 AliHLTComponentTriggerData& /*trigData*/ ) {
9d9ffd37 251 // see header file for class documentation
252
253 if ( fEnableAnalysis )
254 fCalibPedestal->Analyse();
02d01bbf 255
9d9ffd37 256 // ** PushBack data to FXS ...
257 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
02d01bbf 258
259 return 0;
9d9ffd37 260} // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
261
262