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.
27 #include "AliHLTTPCLogging.h"
28 #include "AliHLTTPCTransform.h"
30 #include "AliHLTTPCCalibPedestalComponent.h"
32 #include "AliRawDataHeader.h"
33 #include "AliRawReaderMemory.h"
34 #include "AliTPCRawStream.h"
36 #include "AliTPCCalibPedestal.h"
42 // this is a global object used for automatic component registration, do not use this
43 AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
45 ClassImp(AliHLTTPCCalibPedestalComponent)
47 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
56 fEnableAnalysis(kFALSE) {
57 // see header file for class documentation
59 // refer to README to build package
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
64 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
65 // see header file for class documentation
68 // Public functions to implement AliHLTComponent's interface.
69 // These functions are required for the registration process
71 const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
72 // see header file for class documentation
74 return "TPCCalibPedestal";
77 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
78 // see header file for class documentation
81 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
84 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
85 // see header file for class documentation
87 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
90 void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
91 // see header file for class documentation
93 // XXX TODO: Find more realistic values.
95 inputMultiplier = (2.0);
98 AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
99 // see header file for class documentation
101 return new AliHLTTPCCalibPedestalComponent();
105 Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
106 // see header file for class documentation
109 TString argument = "";
110 TString parameter = "";
115 argument = argv[iResult];
117 if ( argument.IsNull() )
121 if ( argument.CompareTo("-rcuformat") == 0 ) {
123 if ( ++iResult >= argc ) {
128 if ( parameter.CompareTo("old") == 0 ) {
130 HLTInfo( "RCU Format is set to old." );
132 else if ( parameter.CompareTo("new") == 0 ) {
134 HLTInfo( "RCU Format is set to new." );
137 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
142 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
143 HLTInfo( "Analysis before shipping data to FXS enabled." );
144 fEnableAnalysis = kTRUE;
153 Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
154 // see header file for class documentation
156 // ** Create pedestal calibration
157 if ( fCalibPedestal )
160 fCalibPedestal = new AliTPCCalibPedestal();
162 // ** Create AliRoot Memory Reader
166 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
167 fRawReader = new AliRawReaderMemory();
169 HLTFatal("AliRawReader not available - check your build");
176 Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
177 // see header file for class documentation
183 if ( fCalibPedestal )
184 delete fCalibPedestal;
185 fCalibPedestal = NULL;
191 * --- setter for rcuformat need in AliTPCCalibPedestal class
193 Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
194 // see header file for class documentation
196 const AliHLTComponentBlockData* iter = NULL;
198 AliHLTUInt8_t slice=0, patch=0;
201 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
202 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
204 while ( iter != NULL ) {
206 // ** Print Debug output which data format was received
207 char tmp1[14], tmp2[14];
208 DataType2Text( iter->fDataType, tmp1 );
209 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
211 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
212 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
214 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
215 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
216 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
218 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
219 else DDLid = 838 + (4*slice) + patch;
221 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
223 // ** Get min and max patch, used for output specification
224 if ( patch < fMinPatch ) fMinPatch = patch;
225 if ( patch > fMaxPatch ) fMaxPatch = patch;
227 // ** Init TPCRawStream
228 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
229 fRawReader->SetEquipmentID(DDLid);
231 fRawStream = new AliTPCRawStream( fRawReader );
232 fRawStream->SetOldRCUFormat( fRCUFormat );
234 // ** Process actual Pedestal Calibration - Fill histograms
235 fCalibPedestal->ProcessEvent( fRawStream );
237 // ** Delete TPCRawStream
242 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
243 iter = GetNextInputBlock();
245 } // while ( iter != NULL ) {
247 // ** Get output specification
248 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
250 // ** PushBack data to shared memory ...
251 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
254 } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
257 Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
258 // see header file for class documentation
260 if ( fEnableAnalysis )
261 fCalibPedestal->Analyse();
263 // ** PushBack data to FXS ...
264 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
267 } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {