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
30 //#include "AliHLTTPCLogging.h"
31 #include "AliHLTTPCDefinitions.h"
32 //#include "AliHLTTPCTransform.h"
34 #include "AliHLTTPCCalibCEComponent.h"
36 #include "AliRawReaderMemory.h"
37 #include "AliTPCRawStream.h"
39 #include "AliTPCCalibCE.h"
47 /** ROOT macro for the implementation of ROOT specific class methods */
48 ClassImp(AliHLTTPCCalibCEComponent)
50 AliHLTTPCCalibCEComponent::AliHLTTPCCalibCEComponent()
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 226
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 AliHLTTPCCalibCEComponent::~AliHLTTPCCalibCEComponent() {
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* AliHLTTPCCalibCEComponent::GetComponentID() {
78 // see header file for class documentation
83 void AliHLTTPCCalibCEComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
87 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
90 AliHLTComponentDataType AliHLTTPCCalibCEComponent::GetOutputDataType() {
91 // see header file for class documentation
93 return AliHLTTPCDefinitions::fgkCalibCEDataType;
96 void AliHLTTPCCalibCEComponent::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* AliHLTTPCCalibCEComponent::Spawn() {
105 // see header file for class documentation
107 return new AliHLTTPCCalibCEComponent();
111 Int_t AliHLTTPCCalibCEComponent::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 AliHLTTPCCalibCEComponent::InitCalibration() {
158 // see header file for class documentation
160 // ** Create pedestal calibration
164 fCalibCE = new AliTPCCalibCE();
166 // ** Create AliRoot Memory Reader
170 fRawReader = new AliRawReaderMemory();
175 Int_t AliHLTTPCCalibCEComponent::DeinitCalibration() {
176 // see header file for class documentation
190 * --- setter for rcuformat need in AliTPCCalibCE class
192 Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
193 AliHLTComponentTriggerData& /*trigData*/ ) {
194 // see header file for class documentation
196 const AliHLTComponentBlockData* iter = NULL;
198 AliHLTUInt8_t slice=0, patch=0;
201 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
202 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
204 while ( iter != NULL ) {
206 // ** Print Debug output which data format was received
207 // char tmp1[14], tmp2[14];
208 // DataType2Text( iter->fDataType, tmp1 );
209 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
210 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
211 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
213 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
214 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
215 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
217 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
218 else ddlId = 838 + (4*slice) + patch;
220 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
222 // ** Get min and max patch, used for output specification
223 if ( patch < fMinPatch ) fMinPatch = patch;
224 if ( patch > fMaxPatch ) fMaxPatch = patch;
226 // ** Init TPCRawStream
227 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
228 fRawReader->SetEquipmentID(ddlId);
230 fRawStream = new AliTPCRawStream( fRawReader );
232 // ** Process actual Pedestal Calibration - Fill histograms
233 fCalibCE->ProcessEvent( fRawStream );
235 // ** Delete TPCRawStream
240 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
241 iter = GetNextInputBlock();
243 } // while ( iter != NULL ) {
245 // ** Get output specification
246 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
248 // ** PushBack data to shared memory ...
249 PushBack( (TObject*) fCalibCE, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
252 } // Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
255 Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
256 AliHLTComponentTriggerData& /*trigData*/ ) {
257 // see header file for class documentation
259 if ( fEnableAnalysis )
262 // ** PushBack data to FXS ...
263 PushToFXS( (TObject*) fCalibCE, "TPC", "CE" ) ;
266 } // Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {