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.
27 #include "AliHLTTPCLogging.h"
28 #include "AliHLTTPCTransform.h"
30 #include "AliHLTTPCCalibPulserComponent.h"
32 #include "AliRawDataHeader.h"
33 #include "AliRawReaderMemory.h"
34 #include "AliTPCRawStream.h"
36 #ifndef HAVE_NOT_ALITPCCALIBPULSER
37 #include "AliTPCCalibPulser.h"
38 #endif // HAVE_NOT_ALITPCCALIBPULSER
44 // this is a global object used for automatic component registration, do not use this
45 AliHLTTPCCalibPulserComponent gAliHLTTPCCalibPulserComponent;
47 ClassImp(AliHLTTPCCalibPulserComponent)
49 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
58 fEnableAnalysis(kFALSE) {
59 // see header file for class documentation
61 // refer to README to build package
63 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent(const AliHLTTPCCalibPulserComponent&)
75 fEnableAnalysis(kFALSE) {
76 // see header file for class documentation
78 HLTFatal("copy constructor untested");
81 AliHLTTPCCalibPulserComponent& AliHLTTPCCalibPulserComponent::operator=(const AliHLTTPCCalibPulserComponent&) {
82 // see header file for class documentation
84 HLTFatal("assignment operator untested");
88 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
89 // see header file for class documentation
92 // Public functions to implement AliHLTComponent's interface.
93 // These functions are required for the registration process
95 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
96 // see header file for class documentation
98 return "TPCCalibPulser";
101 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
102 // see header file for class documentation
105 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
108 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
109 // see header file for class documentation
111 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
114 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
115 // see header file for class documentation
117 // XXX TODO: Find more realistic values.
119 inputMultiplier = (2.0);
122 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
123 // see header file for class documentation
125 return new AliHLTTPCCalibPulserComponent();
129 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
130 // see header file for class documentation
133 TString argument = "";
134 TString parameter = "";
139 argument = argv[iResult];
141 if ( argument.IsNull() )
145 if ( argument.CompareTo("-rcuformat") == 0 ) {
147 if ( ++iResult >= argc ) {
152 if ( parameter.CompareTo("old") == 0 ) {
154 HLTInfo( "RCU Format is set to old." );
156 else if ( parameter.CompareTo("new") == 0 ) {
158 HLTInfo( "RCU Format is set to new." );
161 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
166 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
167 HLTInfo( "Analysis before shipping data to FXS enabled." );
168 fEnableAnalysis = kTRUE;
177 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
178 // see header file for class documentation
180 #ifndef HAVE_NOT_ALITPCCALIBPULSER
181 // ** Create pulser calibration
185 fCalibPulser = new AliTPCCalibPulser();
187 // ** Create AliRoot Memory Reader
191 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
192 fRawReader = new AliRawReaderMemory();
194 HLTFatal("AliRawReader not available - check your build");
199 #else // HAVE_NOT_ALITPCCALIBPULSER
200 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
201 HLTFatal("AliTPCCalibPulser not available - check your build");
203 #endif //HAVE_NOT_ALITPCCALIBPULSER
206 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
207 // see header file for class documentation
213 #ifndef HAVE_NOT_ALITPCCALIBPULSER
214 if ( fCalibPulser ) {
224 * --- setter for rcuformat need in AliTPCCalibPulser class
226 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
227 // see header file for class documentation
229 const AliHLTComponentBlockData* iter = NULL;
231 AliHLTUInt8_t slice=0, patch=0;
234 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
235 iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
237 while ( iter != NULL ) {
239 // ** Print Debug output which data format was received
240 char tmp1[14], tmp2[14];
241 DataType2Text( iter->fDataType, tmp1 );
242 DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
244 HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
245 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
247 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
248 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
249 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
251 if (patch < 2) DDLid = 768 + (2 * slice) + patch;
252 else DDLid = 838 + (4*slice) + patch;
254 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
256 // ** Get min and max patch, used for output specification
257 if ( patch < fMinPatch ) fMinPatch = patch;
258 if ( patch > fMaxPatch ) fMaxPatch = patch;
260 // ** Init TPCRawStream
261 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
262 fRawReader->SetEquipmentID(DDLid);
264 fRawStream = new AliTPCRawStream( fRawReader );
265 fRawStream->SetOldRCUFormat( fRCUFormat );
267 #ifndef HAVE_NOT_ALITPCCALIBPULSER
268 // ** Process actual Pulser Calibration - Fill histograms
269 fCalibPulser->ProcessEvent( fRawStream );
270 #else //!HAVE_NOT_ALITPCCALIBPULSER
271 HLTFatal("AliTPCCalibPulser not available - check your build");
273 #endif //HAVE_NOT_ALITPCCALIBPULSER
275 // ** Delete TPCRawStream
280 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
281 iter = GetNextInputBlock();
283 } // while ( iter != NULL ) {
285 // ** Get output specification
286 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
288 // ** PushBack data to shared memory ...
289 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
292 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
295 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
296 // see header file for class documentation
298 #ifndef HAVE_NOT_ALITPCCALIBPULSER
299 if ( fEnableAnalysis )
300 fCalibPulser->Analyse();
301 #else //!HAVE_NOT_ALITPCCALIBPULSER
302 HLTFatal("AliTPCCalibPulser not available - check your build");
304 #endif //HAVE_NOT_ALITPCCALIBPULSER
306 // ** PushBack data to FXS ...
307 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
310 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {