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
29 #include "AliHLTTPCLogging.h"
30 #include "AliHLTTPCTransform.h"
32 #include "AliHLTTPCCalibPulserComponent.h"
34 #include "AliRawDataHeader.h"
35 #include "AliRawReaderMemory.h"
36 #include "AliTPCRawStream.h"
38 #ifndef HAVE_NOT_ALITPCCALIBPULSER
39 #include "AliTPCCalibPulser.h"
40 #endif // HAVE_NOT_ALITPCCALIBPULSER
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTTPCCalibPulserComponent)
51 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
56 // Note: initialization of min and max seems to be in the wrong order but is on
57 // purpose in order to work correctly with the conditional in DoEvent line 233
58 // if ( patch < fMinPatch ) fMinPatch = patch;
59 // if ( patch > fMaxPatch ) fMaxPatch = patch;
63 fEnableAnalysis(kFALSE) {
64 // see header file for class documentation
66 // refer to README to build package
68 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
71 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
72 // see header file for class documentation
75 // Public functions to implement AliHLTComponent's interface.
76 // These functions are required for the registration process
78 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
79 // see header file for class documentation
81 return "TPCCalibPulser";
84 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
85 // see header file for class documentation
88 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
91 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
92 // see header file for class documentation
94 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
97 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
98 // see header file for class documentation
100 // XXX TODO: Find more realistic values.
102 inputMultiplier = (2.0);
105 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
106 // see header file for class documentation
108 return new AliHLTTPCCalibPulserComponent();
112 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
113 // see header file for class documentation
116 TString argument = "";
117 TString parameter = "";
122 argument = argv[iResult];
124 if ( argument.IsNull() )
128 if ( argument.CompareTo("-rcuformat") == 0 ) {
130 if ( ++iResult >= argc ) {
135 if ( parameter.CompareTo("old") == 0 ) {
136 HLTInfo( "RCU Format is set to old." );
138 else if ( parameter.CompareTo("new") == 0 ) {
139 HLTInfo( "RCU Format is set to new." );
142 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
147 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
148 HLTInfo( "Analysis before shipping data to FXS enabled." );
149 fEnableAnalysis = kTRUE;
158 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
159 // see header file for class documentation
161 #ifndef HAVE_NOT_ALITPCCALIBPULSER
162 // ** Create pulser calibration
166 fCalibPulser = new AliTPCCalibPulser();
168 // ** Create AliRoot Memory Reader
172 fRawReader = new AliRawReaderMemory();
175 #else // HAVE_NOT_ALITPCCALIBPULSER
176 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
177 HLTFatal("AliTPCCalibPulser not available - check your build");
179 #endif //HAVE_NOT_ALITPCCALIBPULSER
182 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
183 // see header file for class documentation
189 #ifndef HAVE_NOT_ALITPCCALIBPULSER
190 if ( fCalibPulser ) {
199 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
200 AliHLTComponentTriggerData& /*trigData*/ ) {
201 // see header file for class documentation
203 const AliHLTComponentBlockData* iter = NULL;
205 AliHLTUInt8_t slice=0, patch=0;
208 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
209 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
211 while ( iter != NULL ) {
213 // ** Print Debug output which data format was received
214 // char tmp1[14], tmp2[14];
215 // DataType2Text( iter->fDataType, tmp1 );
216 // 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 );
239 #ifndef HAVE_NOT_ALITPCCALIBPULSER
240 // ** Process actual Pulser Calibration - Fill histograms
241 fCalibPulser->ProcessEvent( fRawStream );
242 #else //!HAVE_NOT_ALITPCCALIBPULSER
243 HLTFatal("AliTPCCalibPulser not available - check your build");
245 #endif //HAVE_NOT_ALITPCCALIBPULSER
247 // ** Delete TPCRawStream
252 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
253 iter = GetNextInputBlock();
255 } // while ( iter != NULL ) {
257 // ** Get output specification
258 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
260 // ** PushBack data to shared memory ...
261 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
264 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
267 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
268 AliHLTComponentTriggerData& /*trigData*/ ) {
269 // see header file for class documentation
271 #ifndef HAVE_NOT_ALITPCCALIBPULSER
272 if ( fEnableAnalysis )
273 fCalibPulser->Analyse();
274 #else //!HAVE_NOT_ALITPCCALIBPULSER
275 HLTFatal("AliTPCCalibPulser not available - check your build");
277 #endif //HAVE_NOT_ALITPCCALIBPULSER
279 // ** PushBack data to FXS ...
280 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
283 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {