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 "AliRawReaderMemory.h"
35 #include "AliTPCRawStream.h"
37 #ifndef HAVE_NOT_ALITPCCALIBPULSER
38 #include "AliTPCCalibPulser.h"
39 #endif // HAVE_NOT_ALITPCCALIBPULSER
47 /** ROOT macro for the implementation of ROOT specific class methods */
48 ClassImp(AliHLTTPCCalibPulserComponent)
50 AliHLTTPCCalibPulserComponent::AliHLTTPCCalibPulserComponent()
55 // Note: initialization of min and max seems to be in the wrong order but is on
56 // purpose in order to work correctly with the conditional in DoEvent line 233
57 // if ( patch < fMinPatch ) fMinPatch = patch;
58 // if ( patch > fMaxPatch ) fMaxPatch = patch;
62 fEnableAnalysis(kFALSE) {
63 // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 AliHLTTPCCalibPulserComponent::~AliHLTTPCCalibPulserComponent() {
71 // see header file for class documentation
74 // Public functions to implement AliHLTComponent's interface.
75 // These functions are required for the registration process
77 const char* AliHLTTPCCalibPulserComponent::GetComponentID() {
78 // see header file for class documentation
80 return "TPCCalibPulser";
83 void AliHLTTPCCalibPulserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
90 AliHLTComponentDataType AliHLTTPCCalibPulserComponent::GetOutputDataType() {
91 // see header file for class documentation
93 return AliHLTTPCDefinitions::fgkCalibPulserDataType;
96 void AliHLTTPCCalibPulserComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
97 // see header file for class documentation
99 // XXX TODO: Find more realistic values.
101 inputMultiplier = (2.0);
104 AliHLTComponent* AliHLTTPCCalibPulserComponent::Spawn() {
105 // see header file for class documentation
107 return new AliHLTTPCCalibPulserComponent();
111 Int_t AliHLTTPCCalibPulserComponent::ScanArgument( Int_t argc, const char** argv ) {
112 // see header file for class documentation
115 TString argument = "";
116 TString parameter = "";
121 argument = argv[iResult];
123 if ( argument.IsNull() )
127 if ( argument.CompareTo("-rcuformat") == 0 ) {
129 if ( ++iResult >= argc ) {
134 if ( parameter.CompareTo("old") == 0 ) {
135 HLTInfo( "RCU Format is set to old." );
137 else if ( parameter.CompareTo("new") == 0 ) {
138 HLTInfo( "RCU Format is set to new." );
141 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
146 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
147 HLTInfo( "Analysis before shipping data to FXS enabled." );
148 fEnableAnalysis = kTRUE;
157 Int_t AliHLTTPCCalibPulserComponent::InitCalibration() {
158 // see header file for class documentation
160 #ifndef HAVE_NOT_ALITPCCALIBPULSER
161 // ** Create pulser calibration
165 fCalibPulser = new AliTPCCalibPulser();
167 // ** Create AliRoot Memory Reader
171 fRawReader = new AliRawReaderMemory();
174 #else // HAVE_NOT_ALITPCCALIBPULSER
175 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
176 HLTFatal("AliTPCCalibPulser not available - check your build");
178 #endif //HAVE_NOT_ALITPCCALIBPULSER
181 Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() {
182 // see header file for class documentation
188 #ifndef HAVE_NOT_ALITPCCALIBPULSER
189 if ( fCalibPulser ) {
198 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
199 AliHLTComponentTriggerData& /*trigData*/ ) {
200 // see header file for class documentation
202 const AliHLTComponentBlockData* iter = NULL;
204 AliHLTUInt8_t slice=0, patch=0;
207 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
208 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
210 while ( iter != NULL ) {
212 // ** Print Debug output which data format was received
213 // char tmp1[14], tmp2[14];
214 // DataType2Text( iter->fDataType, tmp1 );
215 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
216 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
217 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
219 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
220 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
221 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
223 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
224 else ddlId = 838 + (4*slice) + patch;
226 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
228 // ** Get min and max patch, used for output specification
229 if ( patch < fMinPatch ) fMinPatch = patch;
230 if ( patch > fMaxPatch ) fMaxPatch = patch;
232 // ** Init TPCRawStream
233 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
234 fRawReader->SetEquipmentID(ddlId);
236 fRawStream = new AliTPCRawStream( fRawReader );
238 #ifndef HAVE_NOT_ALITPCCALIBPULSER
239 // ** Process actual Pulser Calibration - Fill histograms
240 fCalibPulser->ProcessEvent( fRawStream );
241 #else //!HAVE_NOT_ALITPCCALIBPULSER
242 HLTFatal("AliTPCCalibPulser not available - check your build");
244 #endif //HAVE_NOT_ALITPCCALIBPULSER
246 // ** Delete TPCRawStream
251 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
252 iter = GetNextInputBlock();
254 } // while ( iter != NULL ) {
256 // ** Get output specification
257 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
259 // ** PushBack data to shared memory ...
260 PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification);
263 } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
266 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
267 AliHLTComponentTriggerData& /*trigData*/ ) {
268 // see header file for class documentation
270 #ifndef HAVE_NOT_ALITPCCALIBPULSER
271 if ( fEnableAnalysis )
272 fCalibPulser->Analyse();
273 #else //!HAVE_NOT_ALITPCCALIBPULSER
274 HLTFatal("AliTPCCalibPulser not available - check your build");
276 #endif //HAVE_NOT_ALITPCCALIBPULSER
278 // ** PushBack data to FXS ...
279 PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
282 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {