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 AliHLTTPCCalibPulserComponent.cxx
18 @author Jochen Thaeder
20 @brief A pulser 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 "AliHLTTPCCalibPulserComponent.h"
38 #include "AliRawDataHeader.h"
39 #include "AliRawReaderMemory.h"
40 #include "AliTPCRawStream.h"
42 #ifndef HAVE_NOT_ALITPCCALIBPULSER
43 #include "AliTPCCalibPulser.h"
44 #endif // HAVE_NOT_ALITPCCALIBPULSER
50 /** ROOT macro for the implementation of ROOT specific class methods */
51 ClassImp(AliHLTTPCCalibPulserComponent)
53 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
61 fEnableAnalysis(kFALSE) {
62 // see header file for class documentation
64 // refer to README to build package
66 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
70 // see header file for class documentation
73 // Public functions to implement AliHLTComponent's interface.
74 // These functions are required for the registration process
76 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
77 // see header file for class documentation
79 return "TPCCalibPulser";
82 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83 // see header file for class documentation
86 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
89 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
90 // see header file for class documentation
92 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
95 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
96 // see header file for class documentation
98 // XXX TODO: Find more realistic values.
100 inputMultiplier = (2.0);
103 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
104 // see header file for class documentation
106 return new AliHLTTPCCalibPulserComponent();
110 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
111 // see header file for class documentation
114 TString argument = "";
115 TString parameter = "";
120 argument = argv[iResult];
122 if ( argument.IsNull() )
126 if ( argument.CompareTo("-rcuformat") == 0 ) {
128 if ( ++iResult >= argc ) {
133 if ( parameter.CompareTo("old") == 0 ) {
134 HLTInfo( "RCU Format is set to old." );
136 else if ( parameter.CompareTo("new") == 0 ) {
137 HLTInfo( "RCU Format is set to new." );
140 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
145 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
146 HLTInfo( "Analysis before shipping data to FXS enabled." );
147 fEnableAnalysis = kTRUE;
156 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
157 // see header file for class documentation
159 #ifndef HAVE_NOT_ALITPCCALIBPULSER
160 // ** Create pulser calibration
164 fCalibPulser = new AliTPCCalibPulser();
166 // ** Create AliRoot Memory Reader
170 fRawReader = new AliRawReaderMemory();
173 #else // HAVE_NOT_ALITPCCALIBPULSER
174 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
175 HLTFatal("AliTPCCalibPulser not available - check your build");
177 #endif //HAVE_NOT_ALITPCCALIBPULSER
180 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
181 // see header file for class documentation
187 #ifndef HAVE_NOT_ALITPCCALIBPULSER
188 if ( fCalibPulser ) {
197 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
198 AliHLTComponentTriggerData& /*trigData*/ ) {
199 // see header file for class documentation
201 const AliHLTComponentBlockData* iter = NULL;
203 AliHLTUInt8_t slice=0, patch=0;
206 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
207 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
209 while ( iter != NULL ) {
211 // ** Print Debug output which data format was received
212 // char tmp1[14], tmp2[14];
213 // DataType2Text( iter->fDataType, tmp1 );
214 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
215 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
216 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
218 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
219 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
220 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
222 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
223 else ddlId = 838 + (4*slice) + patch;
225 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
227 // ** Get min and max patch, used for output specification
228 if ( patch < fMinPatch ) fMinPatch = patch;
229 if ( patch > fMaxPatch ) fMaxPatch = patch;
231 // ** Init TPCRawStream
232 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
233 fRawReader->SetEquipmentID(ddlId);
235 fRawStream = new AliTPCRawStream( fRawReader );
237 #ifndef HAVE_NOT_ALITPCCALIBPULSER
238 // ** Process actual Pulser Calibration - Fill histograms
239 fCalibPulser->ProcessEvent( fRawStream );
240 #else //!HAVE_NOT_ALITPCCALIBPULSER
241 HLTFatal("AliTPCCalibPulser not available - check your build");
243 #endif //HAVE_NOT_ALITPCCALIBPULSER
245 // ** Delete TPCRawStream
250 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
251 iter = GetNextInputBlock();
253 } // while ( iter != NULL ) {
255 // ** Get output specification
256 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
258 // ** PushBack data to shared memory ...
259 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
262 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
265 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
266 AliHLTComponentTriggerData& /*trigData*/ ) {
267 // see header file for class documentation
269 #ifndef HAVE_NOT_ALITPCCALIBPULSER
270 if ( fEnableAnalysis )
271 fCalibPulser->Analyse();
272 #else //!HAVE_NOT_ALITPCCALIBPULSER
273 HLTFatal("AliTPCCalibPulser not available - check your build");
275 #endif //HAVE_NOT_ALITPCCALIBPULSER
277 // ** PushBack data to FXS ...
278 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
281 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {