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()
58 // Note: initialization of min and max seems to be in the wrong order but is on
59 // purpose in order to work correctly with the conditional in DoEvent line 233
60 // if ( patch < fMinPatch ) fMinPatch = patch;
61 // if ( patch > fMaxPatch ) fMaxPatch = patch;
65 fEnableAnalysis(kFALSE) {
66 // see header file for class documentation
68 // refer to README to build package
70 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
74 // see header file for class documentation
77 // Public functions to implement AliHLTComponent's interface.
78 // These functions are required for the registration process
80 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
81 // see header file for class documentation
83 return "TPCCalibPulser";
86 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
87 // see header file for class documentation
90 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
93 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
94 // see header file for class documentation
96 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
99 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
100 // see header file for class documentation
102 // XXX TODO: Find more realistic values.
104 inputMultiplier = (2.0);
107 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
108 // see header file for class documentation
110 return new AliHLTTPCCalibPulserComponent();
114 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
115 // see header file for class documentation
118 TString argument = "";
119 TString parameter = "";
124 argument = argv[iResult];
126 if ( argument.IsNull() )
130 if ( argument.CompareTo("-rcuformat") == 0 ) {
132 if ( ++iResult >= argc ) {
137 if ( parameter.CompareTo("old") == 0 ) {
138 HLTInfo( "RCU Format is set to old." );
140 else if ( parameter.CompareTo("new") == 0 ) {
141 HLTInfo( "RCU Format is set to new." );
144 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
149 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
150 HLTInfo( "Analysis before shipping data to FXS enabled." );
151 fEnableAnalysis = kTRUE;
160 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
161 // see header file for class documentation
163 #ifndef HAVE_NOT_ALITPCCALIBPULSER
164 // ** Create pulser calibration
168 fCalibPulser = new AliTPCCalibPulser();
170 // ** Create AliRoot Memory Reader
174 fRawReader = new AliRawReaderMemory();
177 #else // HAVE_NOT_ALITPCCALIBPULSER
178 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
179 HLTFatal("AliTPCCalibPulser not available - check your build");
181 #endif //HAVE_NOT_ALITPCCALIBPULSER
184 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
185 // see header file for class documentation
191 #ifndef HAVE_NOT_ALITPCCALIBPULSER
192 if ( fCalibPulser ) {
201 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
202 AliHLTComponentTriggerData& /*trigData*/ ) {
203 // see header file for class documentation
205 const AliHLTComponentBlockData* iter = NULL;
207 AliHLTUInt8_t slice=0, patch=0;
210 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
211 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
213 while ( iter != NULL ) {
215 // ** Print Debug output which data format was received
216 // char tmp1[14], tmp2[14];
217 // DataType2Text( iter->fDataType, tmp1 );
218 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
219 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
220 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
222 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
223 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
224 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
226 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
227 else ddlId = 838 + (4*slice) + patch;
229 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
231 // ** Get min and max patch, used for output specification
232 if ( patch < fMinPatch ) fMinPatch = patch;
233 if ( patch > fMaxPatch ) fMaxPatch = patch;
235 // ** Init TPCRawStream
236 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
237 fRawReader->SetEquipmentID(ddlId);
239 fRawStream = new AliTPCRawStream( fRawReader );
241 #ifndef HAVE_NOT_ALITPCCALIBPULSER
242 // ** Process actual Pulser Calibration - Fill histograms
243 fCalibPulser->ProcessEvent( fRawStream );
244 #else //!HAVE_NOT_ALITPCCALIBPULSER
245 HLTFatal("AliTPCCalibPulser not available - check your build");
247 #endif //HAVE_NOT_ALITPCCALIBPULSER
249 // ** Delete TPCRawStream
254 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
255 iter = GetNextInputBlock();
257 } // while ( iter != NULL ) {
259 // ** Get output specification
260 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
262 // ** PushBack data to shared memory ...
263 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
266 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
269 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
270 AliHLTComponentTriggerData& /*trigData*/ ) {
271 // see header file for class documentation
273 #ifndef HAVE_NOT_ALITPCCALIBPULSER
274 if ( fEnableAnalysis )
275 fCalibPulser->Analyse();
276 #else //!HAVE_NOT_ALITPCCALIBPULSER
277 HLTFatal("AliTPCCalibPulser not available - check your build");
279 #endif //HAVE_NOT_ALITPCCALIBPULSER
281 // ** PushBack data to FXS ...
282 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
285 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {