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 AliHLTTPCCalibPedestalComponent.cxx
18 @author Jochen Thaeder
20 @brief A pedestal 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 "AliHLTTPCCalibPedestalComponent.h"
34 #include "AliRawDataHeader.h"
35 #include "AliRawReaderMemory.h"
36 #include "AliTPCRawStream.h"
38 #include "AliTPCCalibPedestal.h"
46 /** ROOT macro for the implementation of ROOT specific class methods */
47 ClassImp(AliHLTTPCCalibPedestalComponent)
49 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
54 // Note: initialization of min and max seems to be in the wrong order but is on
55 // purpose in order to work correctly with the conditional in DoEvent line 221
56 // if ( patch < fMinPatch ) fMinPatch = patch;
57 // if ( patch > fMaxPatch ) fMaxPatch = patch;
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 AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
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* AliHLTTPCCalibPedestalComponent::GetComponentID() {
77 // see header file for class documentation
79 return "TPCCalibPedestal";
82 void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83 // see header file for class documentation
86 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
89 AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
90 // see header file for class documentation
92 return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
95 void AliHLTTPCCalibPedestalComponent::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* AliHLTTPCCalibPedestalComponent::Spawn() {
104 // see header file for class documentation
106 return new AliHLTTPCCalibPedestalComponent();
110 Int_t AliHLTTPCCalibPedestalComponent::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 AliHLTTPCCalibPedestalComponent::InitCalibration() {
157 // see header file for class documentation
159 // ** Create pedestal calibration
160 if ( fCalibPedestal )
163 fCalibPedestal = new AliTPCCalibPedestal();
165 // ** Create AliRoot Memory Reader
169 fRawReader = new AliRawReaderMemory();
174 Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
175 // see header file for class documentation
181 if ( fCalibPedestal )
182 delete fCalibPedestal;
183 fCalibPedestal = NULL;
188 Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
189 AliHLTComponentTriggerData& /*trigData*/ ) {
190 // see header file for class documentation
192 const AliHLTComponentBlockData* iter = NULL;
194 AliHLTUInt8_t slice=0, patch=0;
197 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
198 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
200 while ( iter != NULL ) {
202 // ** Print Debug output which data format was received
203 // char tmp1[14], tmp2[14];
204 // DataType2Text( iter->fDataType, tmp1 );
205 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
206 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
207 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
209 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
210 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
211 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
213 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
214 else ddlId = 838 + (4*slice) + patch;
216 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
218 // ** Get min and max patch, used for output specification
219 if ( patch < fMinPatch ) fMinPatch = patch;
220 if ( patch > fMaxPatch ) fMaxPatch = patch;
222 // ** Init TPCRawStream
223 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
224 fRawReader->SetEquipmentID(ddlId);
226 fRawStream = new AliTPCRawStream( fRawReader );
228 // ** Process actual Pedestal Calibration - Fill histograms
229 fCalibPedestal->ProcessEvent( fRawStream );
231 // ** Delete TPCRawStream
236 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
237 iter = GetNextInputBlock();
239 } // while ( iter != NULL ) {
241 // ** Get output specification
242 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
244 // ** PushBack data to shared memory ...
245 PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
248 } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
251 Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
252 AliHLTComponentTriggerData& /*trigData*/ ) {
253 // see header file for class documentation
255 if ( fEnableAnalysis )
256 fCalibPedestal->Analyse();
258 // ** PushBack data to FXS ...
259 PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
262 } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {