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