3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
7 * for The ALICE Off-line Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /** @file AliHLTTPCCalibPedestalComponent.cxx
19 @author Jochen Thaeder
21 @brief A pedestal calibration component for the TPC.
28 #include "AliHLTTPCLogging.h"
29 #include "AliHLTTPCTransform.h"
31 #include "AliHLTTPCCalibPedestalComponent.h"
33 #include "AliRawDataHeader.h"
34 #include "AliRawReaderMemory.h"
35 #include "AliTPCRawStream.h"
37 #include "AliTPCCalibPedestal.h"
43 // this is a global object used for automatic component registration, do not use this
44 AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
46 ClassImp(AliHLTTPCCalibPedestalComponent)
48 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
55 // see header file for class documentation
57 // refer to README to build package
59 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent(const AliHLTTPCCalibPedestalComponent&)
69 // see header file for class documentation
70 HLTFatal("copy constructor untested");
73 AliHLTTPCCalibPedestalComponent& AliHLTTPCCalibPedestalComponent::operator=(const AliHLTTPCCalibPedestalComponent&)
75 // see header file for class documentation
76 HLTFatal("assignment operator untested");
80 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent()
82 // see header file for class documentation
85 // Public functions to implement AliHLTComponent's interface.
86 // These functions are required for the registration process
88 const char* AliHLTTPCCalibPedestalComponent::GetComponentID()
90 // see header file for class documentation
91 return "TPCCalibPedestal";
94 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
96 // see header file for class documentation
98 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
101 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType()
103 // see header file for class documentation
104 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
107 void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
109 // see header file for class documentation
110 // XXX TODO: Find more realistic values.
112 inputMultiplier = (2.0);
115 AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn()
117 // see header file for class documentation
118 return new AliHLTTPCCalibPedestalComponent();
121 Int_t AliHLTTPCCalibPedestalComponent::DoInit( int argc, const char** argv ) {
122 // see header file for class documentation
124 // ** Interprete commandline arguments
130 // -- rcu format option -- default in constructor: kFALSE => use new data format
131 if ( !strcmp( argv[i], "rcuformat" ) ) {
133 HLTError( "Missing RCU format - RCU format not specified" );
137 // Decodes the rcu format -- options: "old" or "new"
138 if ( !strcmp( argv[i+1], "old" ) ) {
141 else if ( !strcmp( argv[i+1], "new" ) ) {
145 HLTError( "Missing RCU format - Cannot convert rcu format specifier '%s'.", argv[i+1] );
153 HLTError( "Unknown Option - Unknown option '%s'", argv[i] );
158 // ** Create pedestal calibration
159 if ( fCalibPedestal )
162 fCalibPedestal = new AliTPCCalibPedestal();
164 // ** Create AliRoot Memory Reader
168 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
169 fRawReader = new AliRawReaderMemory();
171 HLTFatal("AliRawReader not available - check your build");
178 Int_t AliHLTTPCCalibPedestalComponent::DoDeinit()
180 // see header file for class documentation
186 if ( fCalibPedestal )
187 delete fCalibPedestal;
188 fCalibPedestal = NULL;
194 * --- will be changing with the Calibration Processor, -> Split DoEvent into 2 functions:
195 * --- > Process event
196 * --- > Ship Data to FXS
197 * --- setter for rcuformat need in AliTPCCalibPedestal class
199 Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
200 // see header file for class documentation
202 const AliHLTComponentBlockData* iter = NULL;
203 AliHLTUInt32_t spec = 0;
210 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
211 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
213 while ( iter != NULL ) {
215 // ** Print Debug output which data format was received
216 char tmp1[14], tmp2[14];
217 DataType2Text( iter->fDataType, tmp1 );
218 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
220 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
222 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
223 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
224 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
226 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
227 else DDLid = 838 + (4*slice) + patch;
229 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
231 // ** Get min and max patch, used for output specification
232 if ( patch < minPatch ) minPatch = patch;
233 if ( patch > maxPatch ) maxPatch = patch;
235 // ** Init TPCRawStream
236 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
237 fRawReader->SetEquipmentID(DDLid);
239 fRawStream = new AliTPCRawStream( fRawReader );
240 fRawStream->SetOldRCUFormat( fRCUFormat );
242 // ** Process actual Pedestal Calibration - Fill histograms
243 fCalibPedestal->ProcessEvent( fRawStream );
245 // ** Delete TPCRawStream
250 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
251 iter = GetNextInputBlock();
253 } // while ( iter != NULL ) {
255 // !!! HIGHLY DEBUG !!!
256 // fCalibPedestal->DumpToFile("Pedestal.root");
257 // !!! HIGHLY DEBUG !!!
259 // ** Call only at "END OF RUN" event
260 // fCalibPedestal->Analyse();
262 // ** PushBack data to shared memory ...
263 spec = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
264 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, spec);
267 } // Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {