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