3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTTPCCalibPedestalComponent.cxx
20 @author Jochen Thaeder
22 @brief A pedestal calibration component for the TPC.
29 #include "AliHLTTPCLogging.h"
30 #include "AliHLTTPCTransform.h"
32 #include "AliHLTTPCCalibPedestalComponent.h"
34 #include "AliRawDataHeader.h"
35 #include "AliRawReaderMemory.h"
36 #include "AliTPCRawStream.h"
38 #include "AliTPCCalibPedestal.h"
44 // this is a global object used for automatic component registration, do not use this
45 AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
47 ClassImp(AliHLTTPCCalibPedestalComponent)
49 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent(const AliHLTTPCCalibPedestalComponent&)
70 // see header file for class documentation
71 HLTFatal("copy constructor untested");
74 AliHLTTPCCalibPedestalComponent& AliHLTTPCCalibPedestalComponent::operator=(const AliHLTTPCCalibPedestalComponent&)
76 // see header file for class documentation
77 HLTFatal("assignment operator untested");
81 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent()
83 // see header file for class documentation
86 // Public functions to implement AliHLTComponent's interface.
87 // These functions are required for the registration process
89 const char* AliHLTTPCCalibPedestalComponent::GetComponentID()
91 // see header file for class documentation
92 return "TPCCalibPedestal";
95 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
97 // see header file for class documentation
99 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
102 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType()
104 // see header file for class documentation
105 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
108 void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
110 // see header file for class documentation
111 // XXX TODO: Find more realistic values.
113 inputMultiplier = (2.0);
116 AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn()
118 // see header file for class documentation
119 return new AliHLTTPCCalibPedestalComponent();
122 Int_t AliHLTTPCCalibPedestalComponent::DoInit( int argc, const char** argv ) {
123 // see header file for class documentation
125 // ** Interprete commandline arguments
131 // -- rcu format option -- default in constructor: kFALSE => use new data format
132 if ( !strcmp( argv[i], "rcuformat" ) ) {
134 HLTError( "Missing RCU format - RCU format not specified" );
138 // Decodes the rcu format -- options: "old" or "new"
139 if ( !strcmp( argv[i+1], "old" ) ) {
142 else if ( !strcmp( argv[i+1], "new" ) ) {
146 HLTError( "Missing RCU format - Cannot convert rcu format specifier '%s'.", argv[i+1] );
154 HLTError( "Unknown Option - Unknown option '%s'", argv[i] );
159 // ** Create pedestal calibration
160 if ( fCalibPedestal )
163 fCalibPedestal = new AliTPCCalibPedestal();
165 // ** Create AliRoot Memory Reader
169 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
170 fRawReader = new AliRawReaderMemory();
172 HLTFatal("AliRawReader not available - check your build");
179 Int_t AliHLTTPCCalibPedestalComponent::DoDeinit()
181 // see header file for class documentation
187 if ( fCalibPedestal )
188 delete fCalibPedestal;
189 fCalibPedestal = NULL;
195 * --- will be changing with the Calibration Processor, -> Split DoEvent into 2 functions:
196 * --- > Process event
197 * --- > Ship Data to FXS
198 * --- setter for rcuformat need in AliTPCCalibPedestal class
200 Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
201 // see header file for class documentation
203 const AliHLTComponentBlockData* iter = NULL;
204 AliHLTUInt32_t spec = 0;
211 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
212 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
214 while ( iter != NULL ) {
216 // ** Print Debug output which data format was received
217 char tmp1[14], tmp2[14];
218 DataType2Text( iter->fDataType, tmp1 );
219 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
221 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
223 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
224 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
225 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
227 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
228 else DDLid = 838 + (4*slice) + patch;
230 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
232 // ** Get min and max patch, used for output specification
233 if ( patch < minPatch ) minPatch = patch;
234 if ( patch > maxPatch ) maxPatch = patch;
236 // ** Init TPCRawStream
237 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
238 fRawReader->SetEquipmentID(DDLid);
240 fRawStream = new AliTPCRawStream( fRawReader );
241 fRawStream->SetOldRCUFormat( fRCUFormat );
243 // ** Process actual Pedestal Calibration - Fill histograms
244 fCalibPedestal->ProcessEvent( fRawStream );
246 // ** Delete TPCRawStream
251 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
252 iter = GetNextInputBlock();
254 } // while ( iter != NULL ) {
256 // !!! HIGHLY DEBUG !!!
257 // fCalibPedestal->DumpToFile("Pedestal.root");
258 // !!! HIGHLY DEBUG !!!
260 // ** Call only at "END OF RUN" event
261 // fCalibPedestal->Analyse();
263 // ** PushBack data to shared memory ...
264 spec = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
265 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, spec);
268 } // Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {