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 // this is a global object used for automatic component registration, do not use this
51 AliHLTTPCCalibPulserComponent gAliHLTTPCCalibPulserComponent;
53 ClassImp(AliHLTTPCCalibPulserComponent)
55 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
64 fEnableAnalysis(kFALSE) {
65 // see header file for class documentation
67 // refer to README to build package
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
72 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
73 // see header file for class documentation
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
80 // see header file for class documentation
82 return "TPCCalibPulser";
85 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
86 // see header file for class documentation
89 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
92 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
93 // see header file for class documentation
95 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
98 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
99 // see header file for class documentation
101 // XXX TODO: Find more realistic values.
103 inputMultiplier = (2.0);
106 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
107 // see header file for class documentation
109 return new AliHLTTPCCalibPulserComponent();
113 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
114 // see header file for class documentation
117 TString argument = "";
118 TString parameter = "";
123 argument = argv[iResult];
125 if ( argument.IsNull() )
129 if ( argument.CompareTo("-rcuformat") == 0 ) {
131 if ( ++iResult >= argc ) {
136 if ( parameter.CompareTo("old") == 0 ) {
138 HLTInfo( "RCU Format is set to old." );
140 else if ( parameter.CompareTo("new") == 0 ) {
142 HLTInfo( "RCU Format is set to new." );
145 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
150 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
151 HLTInfo( "Analysis before shipping data to FXS enabled." );
152 fEnableAnalysis = kTRUE;
161 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
162 // see header file for class documentation
164 #ifndef HAVE_NOT_ALITPCCALIBPULSER
165 // ** Create pulser calibration
169 fCalibPulser = new AliTPCCalibPulser();
171 // ** Create AliRoot Memory Reader
175 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
176 fRawReader = new AliRawReaderMemory();
178 HLTFatal("AliRawReader not available - check your build");
183 #else // HAVE_NOT_ALITPCCALIBPULSER
184 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
185 HLTFatal("AliTPCCalibPulser not available - check your build");
187 #endif //HAVE_NOT_ALITPCCALIBPULSER
190 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
191 // see header file for class documentation
197 #ifndef HAVE_NOT_ALITPCCALIBPULSER
198 if ( fCalibPulser ) {
208 * --- setter for rcuformat need in AliTPCCalibPulser class
210 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
211 // see header file for class documentation
213 const AliHLTComponentBlockData* iter = NULL;
215 AliHLTUInt8_t slice=0, patch=0;
218 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
219 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
221 while ( iter != NULL ) {
223 // ** Print Debug output which data format was received
224 char tmp1[14], tmp2[14];
225 DataType2Text( iter->fDataType, tmp1 );
226 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
228 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
229 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
231 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
232 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
233 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
235 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
236 else ddlId = 838 + (4*slice) + patch;
238 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
240 // ** Get min and max patch, used for output specification
241 if ( patch < fMinPatch ) fMinPatch = patch;
242 if ( patch > fMaxPatch ) fMaxPatch = patch;
244 // ** Init TPCRawStream
245 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
246 fRawReader->SetEquipmentID(ddlId);
248 fRawStream = new AliTPCRawStream( fRawReader );
249 fRawStream->SetOldRCUFormat( fRCUFormat );
251 #ifndef HAVE_NOT_ALITPCCALIBPULSER
252 // ** Process actual Pulser Calibration - Fill histograms
253 fCalibPulser->ProcessEvent( fRawStream );
254 #else //!HAVE_NOT_ALITPCCALIBPULSER
255 HLTFatal("AliTPCCalibPulser not available - check your build");
257 #endif //HAVE_NOT_ALITPCCALIBPULSER
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*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
276 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
279 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
280 // see header file for class documentation
282 #ifndef HAVE_NOT_ALITPCCALIBPULSER
283 if ( fEnableAnalysis )
284 fCalibPulser->Analyse();
285 #else //!HAVE_NOT_ALITPCCALIBPULSER
286 HLTFatal("AliTPCCalibPulser not available - check your build");
288 #endif //HAVE_NOT_ALITPCCALIBPULSER
290 // ** PushBack data to FXS ...
291 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
294 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {