2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /** @file AliHLTTPCCalibCEComponent.cxx
19 @author Jochen Thaeder
21 @brief A pedestal calibration component for the TPC.
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
34 //#include "AliHLTTPCLogging.h"
35 #include "AliHLTTPCDefinitions.h"
36 //#include "AliHLTTPCTransform.h"
38 #include "AliHLTTPCCalibCEComponent.h"
40 //#include "AliRawDataHeader.h"
41 #include "AliRawReaderMemory.h"
42 #include "AliTPCRawStream.h"
44 #include "AliTPCCalibCE.h"
50 /** ROOT macro for the implementation of ROOT specific class methods */
51 ClassImp(AliHLTTPCCalibCEComponent)
53 AliHLTTPCCalibCEComponent::AliHLTTPCCalibCEComponent()
61 fEnableAnalysis(kFALSE) {
62 // see header file for class documentation
64 // refer to README to build package
66 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69 AliHLTTPCCalibCEComponent::~AliHLTTPCCalibCEComponent() {
70 // see header file for class documentation
73 // Public functions to implement AliHLTComponent's interface.
74 // These functions are required for the registration process
76 const char* AliHLTTPCCalibCEComponent::GetComponentID() {
77 // see header file for class documentation
82 void AliHLTTPCCalibCEComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83 // see header file for class documentation
86 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
89 AliHLTComponentDataType AliHLTTPCCalibCEComponent::GetOutputDataType() {
90 // see header file for class documentation
92 return AliHLTTPCDefinitions::fgkCalibCEDataType;
95 void AliHLTTPCCalibCEComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
96 // see header file for class documentation
98 // XXX TODO: Find more realistic values.
100 inputMultiplier = (2.0);
103 AliHLTComponent* AliHLTTPCCalibCEComponent::Spawn() {
104 // see header file for class documentation
106 return new AliHLTTPCCalibCEComponent();
110 Int_t AliHLTTPCCalibCEComponent::ScanArgument( Int_t argc, const char** argv ) {
111 // see header file for class documentation
114 TString argument = "";
115 TString parameter = "";
120 argument = argv[iResult];
122 if ( argument.IsNull() )
126 if ( argument.CompareTo("-rcuformat") == 0 ) {
128 if ( ++iResult >= argc ) {
133 if ( parameter.CompareTo("old") == 0 ) {
134 HLTInfo( "RCU Format is set to old." );
136 else if ( parameter.CompareTo("new") == 0 ) {
137 HLTInfo( "RCU Format is set to new." );
140 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
145 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
146 HLTInfo( "Analysis before shipping data to FXS enabled." );
147 fEnableAnalysis = kTRUE;
156 Int_t AliHLTTPCCalibCEComponent::InitCalibration() {
157 // see header file for class documentation
159 // ** Create pedestal calibration
163 fCalibCE = new AliTPCCalibCE();
165 // ** Create AliRoot Memory Reader
169 fRawReader = new AliRawReaderMemory();
174 Int_t AliHLTTPCCalibCEComponent::DeinitCalibration() {
175 // see header file for class documentation
189 * --- setter for rcuformat need in AliTPCCalibCE class
191 Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
192 AliHLTComponentTriggerData& /*trigData*/ ) {
193 // see header file for class documentation
195 const AliHLTComponentBlockData* iter = NULL;
197 AliHLTUInt8_t slice=0, patch=0;
200 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
201 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
203 while ( iter != NULL ) {
205 // ** Print Debug output which data format was received
206 // char tmp1[14], tmp2[14];
207 // DataType2Text( iter->fDataType, tmp1 );
208 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
209 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
210 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
212 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
213 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
214 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
216 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
217 else ddlId = 838 + (4*slice) + patch;
219 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
221 // ** Get min and max patch, used for output specification
222 if ( patch < fMinPatch ) fMinPatch = patch;
223 if ( patch > fMaxPatch ) fMaxPatch = patch;
225 // ** Init TPCRawStream
226 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
227 fRawReader->SetEquipmentID(ddlId);
229 fRawStream = new AliTPCRawStream( fRawReader );
231 // ** Process actual Pedestal Calibration - Fill histograms
232 fCalibCE->ProcessEvent( fRawStream );
234 // ** Delete TPCRawStream
239 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
240 iter = GetNextInputBlock();
242 } // while ( iter != NULL ) {
244 // ** Get output specification
245 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
247 // ** PushBack data to shared memory ...
248 PushBack( (TObject*) fCalibCE, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
251 } // Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
254 Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
255 AliHLTComponentTriggerData& /*trigData*/ ) {
256 // see header file for class documentation
258 if ( fEnableAnalysis )
261 // ** PushBack data to FXS ...
262 PushToFXS( (TObject*) fCalibCE, "TPC", "CE" ) ;
265 } // Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {