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