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()
58 // Note: initialization of min and max seems to be in the wrong order but is on
59 // purpose in order to work correctly with the conditional in DoEvent line 226
60 // if ( patch < fMinPatch ) fMinPatch = patch;
61 // if ( patch > fMaxPatch ) fMaxPatch = patch;
65 fEnableAnalysis(kFALSE) {
66 // see header file for class documentation
68 // refer to README to build package
70 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73 AliHLTTPCCalibCEComponent::~AliHLTTPCCalibCEComponent() {
74 // see header file for class documentation
77 // Public functions to implement AliHLTComponent's interface.
78 // These functions are required for the registration process
80 const char* AliHLTTPCCalibCEComponent::GetComponentID() {
81 // see header file for class documentation
86 void AliHLTTPCCalibCEComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
87 // see header file for class documentation
90 list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
93 AliHLTComponentDataType AliHLTTPCCalibCEComponent::GetOutputDataType() {
94 // see header file for class documentation
96 return AliHLTTPCDefinitions::fgkCalibCEDataType;
99 void AliHLTTPCCalibCEComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
100 // see header file for class documentation
102 // XXX TODO: Find more realistic values.
104 inputMultiplier = (2.0);
107 AliHLTComponent* AliHLTTPCCalibCEComponent::Spawn() {
108 // see header file for class documentation
110 return new AliHLTTPCCalibCEComponent();
114 Int_t AliHLTTPCCalibCEComponent::ScanArgument( Int_t argc, const char** argv ) {
115 // see header file for class documentation
118 TString argument = "";
119 TString parameter = "";
124 argument = argv[iResult];
126 if ( argument.IsNull() )
130 if ( argument.CompareTo("-rcuformat") == 0 ) {
132 if ( ++iResult >= argc ) {
137 if ( parameter.CompareTo("old") == 0 ) {
138 HLTInfo( "RCU Format is set to old." );
140 else if ( parameter.CompareTo("new") == 0 ) {
141 HLTInfo( "RCU Format is set to new." );
144 HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
149 else if ( argument.CompareTo("-enableanalysis") == 0 ) {
150 HLTInfo( "Analysis before shipping data to FXS enabled." );
151 fEnableAnalysis = kTRUE;
160 Int_t AliHLTTPCCalibCEComponent::InitCalibration() {
161 // see header file for class documentation
163 // ** Create pedestal calibration
167 fCalibCE = new AliTPCCalibCE();
169 // ** Create AliRoot Memory Reader
173 fRawReader = new AliRawReaderMemory();
178 Int_t AliHLTTPCCalibCEComponent::DeinitCalibration() {
179 // see header file for class documentation
193 * --- setter for rcuformat need in AliTPCCalibCE class
195 Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
196 AliHLTComponentTriggerData& /*trigData*/ ) {
197 // see header file for class documentation
199 const AliHLTComponentBlockData* iter = NULL;
201 AliHLTUInt8_t slice=0, patch=0;
204 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
205 iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
207 while ( iter != NULL ) {
209 // ** Print Debug output which data format was received
210 // char tmp1[14], tmp2[14];
211 // DataType2Text( iter->fDataType, tmp1 );
212 // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
213 // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
214 // evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
216 // ** Get DDL ID in order to tell the memory reader which slice/patch to use
217 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
218 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
220 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
221 else ddlId = 838 + (4*slice) + patch;
223 HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
225 // ** Get min and max patch, used for output specification
226 if ( patch < fMinPatch ) fMinPatch = patch;
227 if ( patch > fMaxPatch ) fMaxPatch = patch;
229 // ** Init TPCRawStream
230 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
231 fRawReader->SetEquipmentID(ddlId);
233 fRawStream = new AliTPCRawStream( fRawReader );
235 // ** Process actual Pedestal Calibration - Fill histograms
236 fCalibCE->ProcessEvent( fRawStream );
238 // ** Delete TPCRawStream
243 // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
244 iter = GetNextInputBlock();
246 } // while ( iter != NULL ) {
248 // ** Get output specification
249 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
251 // ** PushBack data to shared memory ...
252 PushBack( (TObject*) fCalibCE, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
255 } // Int_t AliHLTTPCCalibCEComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
258 Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
259 AliHLTComponentTriggerData& /*trigData*/ ) {
260 // see header file for class documentation
262 if ( fEnableAnalysis )
265 // ** PushBack data to FXS ...
266 PushToFXS( (TObject*) fCalibCE, "TPC", "CE" ) ;
269 } // Int_t AliHLTTPCCalibCEComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {