1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
17 /** @file AliHLTTPCCalibPedestalComponent.cxx
18 @author Jochen Thaeder
20 @brief A pedestal calibration component for the TPC.
23 // see header file for class documentation
25 // refer to README to build package
27 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
33 #include "AliHLTTPCLogging.h"
34 #include "AliHLTTPCTransform.h"
36 #include "AliHLTTPCCalibPedestalComponent.h"
38 #include "AliRawDataHeader.h"
39 #include "AliRawReaderMemory.h"
40 #include "AliTPCRawStream.h"
42 #include "AliTPCCalibPedestal.h"
48 // this is a global object used for automatic component registration, do not use this
49 AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
51 ClassImp(AliHLTTPCCalibPedestalComponent)
53 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
62 fEnableAnalysis(kFALSE) {
63 // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
71 // see header file for class documentation
74 // Public functions to implement AliHLTComponent's interface.
75 // These functions are required for the registration process
77 const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
78 // see header file for class documentation
80 return "TPCCalibPedestal";
83 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
90 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
91 // see header file for class documentation
93 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
96 void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
97 // see header file for class documentation
99 // XXX TODO: Find more realistic values.
101 inputMultiplier = (2.0);
104 AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
105 // see header file for class documentation
107 return new AliHLTTPCCalibPedestalComponent();
111 Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
112 // see header file for class documentation
115 TString argument = "";
116 TString parameter = "";
121 argument = argv[iResult];
123 if ( argument.IsNull() )
127 if ( argument.CompareTo("-rcuformat") == 0 ) {
129 if ( ++iResult >= argc ) {
134 if ( parameter.CompareTo("old") == 0 ) {
136 HLTInfo( "RCU Format is set to old." );
138 else if ( parameter.CompareTo("new") == 0 ) {
140 HLTInfo( "RCU Format is set to new." );
143 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
148 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
149 HLTInfo( "Analysis before shipping data to FXS enabled." );
150 fEnableAnalysis = kTRUE;
159 Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
160 // see header file for class documentation
162 // ** Create pedestal calibration
163 if ( fCalibPedestal )
166 fCalibPedestal = new AliTPCCalibPedestal();
168 // ** Create AliRoot Memory Reader
172 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
173 fRawReader = new AliRawReaderMemory();
175 HLTFatal("AliRawReader not available - check your build");
182 Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
183 // see header file for class documentation
189 if ( fCalibPedestal )
190 delete fCalibPedestal;
191 fCalibPedestal = NULL;
197 * --- setter for rcuformat need in AliTPCCalibPedestal class
199 Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
200 // see header file for class documentation
202 const AliHLTComponentBlockData* iter = NULL;
204 AliHLTUInt8_t slice=0, patch=0;
207 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
208 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
210 while ( iter != NULL ) {
212 // ** Print Debug output which data format was received
213 // char tmp1[14], tmp2[14];
214 //DataType2Text( iter->fDataType, tmp1 );
215 //DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
217 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
218 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
220 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
221 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
222 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
224 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
225 else ddlId = 838 + (4*slice) + patch;
227 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
229 // ** Get min and max patch, used for output specification
230 if ( patch < fMinPatch ) fMinPatch = patch;
231 if ( patch > fMaxPatch ) fMaxPatch = patch;
233 // ** Init TPCRawStream
234 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
235 fRawReader->SetEquipmentID(ddlId);
237 fRawStream = new AliTPCRawStream( fRawReader );
238 fRawStream->SetOldRCUFormat( fRCUFormat );
240 // ** Process actual Pedestal Calibration - Fill histograms
241 fCalibPedestal->ProcessEvent( fRawStream );
243 // ** Delete TPCRawStream
248 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
249 iter = GetNextInputBlock();
251 } // while ( iter != NULL ) {
253 // ** Get output specification
254 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
256 // ** PushBack data to shared memory ...
257 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
260 } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
263 Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
264 // see header file for class documentation
266 if ( fEnableAnalysis )
267 fCalibPedestal->Analyse();
269 // ** PushBack data to FXS ...
270 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
273 } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {