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 // this is a global object used for automatic component registration, do not use this
51 AliHLTTPCCalibCEComponent gAliHLTTPCCalibCEComponent;
53 ClassImp(AliHLTTPCCalibCEComponent)
55 AliHLTTPCCalibCEComponent::AliHLTTPCCalibCEComponent()
64 fEnableAnalysis(kFALSE) {
65 // see header file for class documentation
67 // refer to README to build package
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
72 AliHLTTPCCalibCEComponent::~AliHLTTPCCalibCEComponent() {
73 // see header file for class documentation
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTTPCCalibCEComponent::GetComponentID() {
80 // see header file for class documentation
85 void AliHLTTPCCalibCEComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
86 // see header file for class documentation
89 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
92 AliHLTComponentDataType AliHLTTPCCalibCEComponent::GetOutputDataType() {
93 // see header file for class documentation
95 return AliHLTTPCDefinitions::fgkCalibCEDataType;
98 void AliHLTTPCCalibCEComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
99 // see header file for class documentation
101 // XXX TODO: Find more realistic values.
103 inputMultiplier = (2.0);
106 AliHLTComponent* AliHLTTPCCalibCEComponent::Spawn() {
107 // see header file for class documentation
109 return new AliHLTTPCCalibCEComponent();
113 Int_t AliHLTTPCCalibCEComponent::ScanArgument( Int_t argc, const char** argv ) {
114 // see header file for class documentation
117 TString argument = "";
118 TString parameter = "";
123 argument = argv[iResult];
125 if ( argument.IsNull() )
129 if ( argument.CompareTo("-rcuformat") == 0 ) {
131 if ( ++iResult >= argc ) {
136 if ( parameter.CompareTo("old") == 0 ) {
138 HLTInfo( "RCU Format is set to old." );
140 else if ( parameter.CompareTo("new") == 0 ) {
142 HLTInfo( "RCU Format is set to new." );
145 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
150 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
151 HLTInfo( "Analysis before shipping data to FXS enabled." );
152 fEnableAnalysis = kTRUE;
161 Int_t AliHLTTPCCalibCEComponent::InitCalibration() {
162 // see header file for class documentation
164 // ** Create pedestal calibration
168 fCalibCE = new AliTPCCalibCE();
170 // ** Create AliRoot Memory Reader
174 fRawReader = new AliRawReaderMemory();
179 Int_t AliHLTTPCCalibCEComponent::DeinitCalibration() {
180 // see header file for class documentation
194 * --- setter for rcuformat need in AliTPCCalibCE class
196 Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
197 AliHLTComponentTriggerData& /*trigData*/ ) {
198 // see header file for class documentation
200 const AliHLTComponentBlockData* iter = NULL;
202 AliHLTUInt8_t slice=0, patch=0;
205 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
206 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
208 while ( iter != NULL ) {
210 // ** Print Debug output which data format was received
211 // char tmp1[14], tmp2[14];
212 // DataType2Text( iter->fDataType, tmp1 );
213 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
214 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
215 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
217 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
218 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
219 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
221 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
222 else ddlId = 838 + (4*slice) + patch;
224 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
226 // ** Get min and max patch, used for output specification
227 if ( patch < fMinPatch ) fMinPatch = patch;
228 if ( patch > fMaxPatch ) fMaxPatch = patch;
230 // ** Init TPCRawStream
231 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
232 fRawReader->SetEquipmentID(ddlId);
234 fRawStream = new AliTPCRawStream( fRawReader );
235 fRawStream->SetOldRCUFormat( fRCUFormat );
237 // ** Process actual Pedestal Calibration - Fill histograms
238 fCalibCE->ProcessEvent( fRawStream );
240 // ** Delete TPCRawStream
245 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
246 iter = GetNextInputBlock();
248 } // while ( iter != NULL ) {
250 // ** Get output specification
251 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
253 // ** PushBack data to shared memory ...
254 PushBack( (TObject*) fCalibCE, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
257 } // Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
260 Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
261 AliHLTComponentTriggerData& /*trigData*/ ) {
262 // see header file for class documentation
264 if ( fEnableAnalysis )
267 // ** PushBack data to FXS ...
268 PushToFXS( (TObject*) fCalibCE, "TPC", "CE" ) ;
271 } // Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {