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(const AliHLTTPCCalibPedestalComponent&)
73 fEnableAnalysis(kFALSE) {
74 // see header file for class documentation
76 HLTFatal("copy constructor untested");
79 AliHLTTPCCalibPedestalComponent& AliHLTTPCCalibPedestalComponent::operator=(const AliHLTTPCCalibPedestalComponent&) {
80 // see header file for class documentation
82 HLTFatal("assignment operator untested");
86 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
87 // see header file for class documentation
90 // Public functions to implement AliHLTComponent's interface.
91 // These functions are required for the registration process
93 const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
94 // see header file for class documentation
96 return "TPCCalibPedestal";
99 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
100 // see header file for class documentation
103 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
106 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
107 // see header file for class documentation
109 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
112 void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
113 // see header file for class documentation
115 // XXX TODO: Find more realistic values.
117 inputMultiplier = (2.0);
120 AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
121 // see header file for class documentation
123 return new AliHLTTPCCalibPedestalComponent();
127 Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
128 // see header file for class documentation
131 TString argument = "";
132 TString parameter = "";
137 argument = argv[iResult];
139 if ( argument.IsNull() )
143 if ( argument.CompareTo("-rcuformat") == 0 ) {
145 if ( ++iResult >= argc ) {
150 if ( parameter.CompareTo("old") == 0 ) {
152 HLTInfo( "RCU Format is set to old." );
154 else if ( parameter.CompareTo("new") == 0 ) {
156 HLTInfo( "RCU Format is set to new." );
159 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
164 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
165 HLTInfo( "Analysis before shipping data to FXS enabled." );
166 fEnableAnalysis = kTRUE;
175 Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
176 // see header file for class documentation
178 // ** Create pedestal calibration
179 if ( fCalibPedestal )
182 fCalibPedestal = new AliTPCCalibPedestal();
184 // ** Create AliRoot Memory Reader
188 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
189 fRawReader = new AliRawReaderMemory();
191 HLTFatal("AliRawReader not available - check your build");
198 Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
199 // see header file for class documentation
205 if ( fCalibPedestal )
206 delete fCalibPedestal;
207 fCalibPedestal = NULL;
213 * --- setter for rcuformat need in AliTPCCalibPedestal class
215 Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
216 // see header file for class documentation
218 const AliHLTComponentBlockData* iter = NULL;
220 AliHLTUInt8_t slice=0, patch=0;
223 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
224 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
226 while ( iter != NULL ) {
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 );
233 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
234 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
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 );
240 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
241 else DDLid = 838 + (4*slice) + patch;
243 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
245 // ** Get min and max patch, used for output specification
246 if ( patch < fMinPatch ) fMinPatch = patch;
247 if ( patch > fMaxPatch ) fMaxPatch = patch;
249 // ** Init TPCRawStream
250 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
251 fRawReader->SetEquipmentID(DDLid);
253 fRawStream = new AliTPCRawStream( fRawReader );
254 fRawStream->SetOldRCUFormat( fRCUFormat );
256 // ** Process actual Pedestal Calibration - Fill histograms
257 fCalibPedestal->ProcessEvent( fRawStream );
259 // ** Delete TPCRawStream
264 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
265 iter = GetNextInputBlock();
267 } // while ( iter != NULL ) {
269 // ** Get output specification
270 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
272 // ** PushBack data to shared memory ...
273 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
276 } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
279 Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
280 // see header file for class documentation
282 if ( fEnableAnalysis )
283 fCalibPedestal->Analyse();
285 // ** PushBack data to FXS ...
286 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
289 } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {