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> *
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 **************************************************************************/
19 * @file AliHLTCalibrationProcessor.cxx
20 * @author Jochen Thaeder, Sebastian Bablok
22 * @brief Base class of HLT calibration components. */
28 #include "AliHLTCalibrationProcessor.h"
29 #include "AliHLTMemoryFile.h"
34 #include <TObjString.h>
37 ClassImp(AliHLTCalibrationProcessor);
40 const AliHLTUInt32_t AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize = 204;
41 const AliHLTUInt32_t AliHLTCalibrationProcessor::fgkFXSProtocolHeaderVersion = 1;
44 * ################ Constructor / Destructor ####################
47 AliHLTCalibrationProcessor::AliHLTCalibrationProcessor() :
49 fUseCorruptEvents(kFALSE),
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 AliHLTCalibrationProcessor::~AliHLTCalibrationProcessor() {
62 // see header file for class documentation
66 * ######################## InitCalibration #####################
69 Int_t AliHLTCalibrationProcessor::DoInit( int argc, const char** argv ) {
70 // see header file for class documentation
73 TString argument = "";
74 TString parameter = "";
75 Int_t bMissingParam=0;
77 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
80 if ( argument.IsNull() ) continue;
83 if ( argument.CompareTo("-eventmodulo") == 0 ) {
84 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
86 parameter.Remove(TString::kLeading, ' '); // remove all blanks
87 if (parameter.IsDigit()) {
88 fEventModulo = parameter.Atoi();
89 HLTInfo("EventModulo is set to %d.", fEventModulo);
92 HLTError("Cannot convert EventModulo specifier '%s'.", argv[ii]);
98 else if ( argument.CompareTo( "-usecorruptevents" ) == 0 ) {
99 HLTInfo( "Passing through of corrupted events enabled." );
100 fUseCorruptEvents = kTRUE;
102 // not known by calibration processor
104 if ( ( iResult = ScanArgument( argc-ii, &argv[ii] ) ) == -EINVAL ) {
105 HLTError( "unknown argument %s", argument.Data() );
108 else if ( iResult == -EPROTO ) {
112 else if ( iResult >= 0 ) {
119 if ( bMissingParam ) {
120 HLTError( "missing parameter for argument %s", argument.Data() );
124 if ( iResult >= 0 ) {
125 iResult = InitCalibration();
131 Int_t AliHLTCalibrationProcessor::InitCalibration() {
132 // see header file for class documentation
134 // fDummy is just touched here to avoid coding convention violation RC11.
135 // The function can not be declared const since it is just the default implementation,
136 // overloaded virtual function might not be const.
143 Int_t AliHLTCalibrationProcessor::ScanArgument(int argc, const char** argv) {
144 // see header file for class documentation
146 // there are no other arguments than the standard ones
147 if ( argc == 0 && argv == NULL) {
148 // this is just to get rid of the warning "unused parameter"
151 // fDummy is just touched here to avoid coding convention violation RC11.
152 // The function can not be declared const since it is just the default implementation,
153 // overloaded virtual function might not be const.
160 * ######################## DeinitCalibration #####################
163 Int_t AliHLTCalibrationProcessor::DoDeinit() {
164 // see header file for class documentation
166 int iResult = DeinitCalibration();
171 Int_t AliHLTCalibrationProcessor::DeinitCalibration() {
172 // see header file for class documentation
174 // fDummy is just touched here to avoid coding convention violation RC11.
175 // The function can not be declared const since it is just the default implementation,
176 // overloaded virtual function might not be const.
183 * ######################## DoEvent #####################
186 Int_t AliHLTCalibrationProcessor::DoEvent( const AliHLTComponentEventData& evtData,
187 const AliHLTComponentBlockData* blocks,
188 AliHLTComponentTriggerData& trigData,
189 AliHLTUInt8_t* outputPtr,
190 AliHLTUInt32_t& size,
191 vector<AliHLTComponentBlockData>& outputBlocks )
193 // see header file for class documentation
196 const AliHLTComponentBlockData* iter = NULL;
198 const AliHLTComponentBlockData* blkSOR = NULL;
199 const AliHLTComponentBlockData* blkEOR = NULL;
200 const AliHLTComponentBlockData* blkDDL = NULL;
202 HLTInfo( "Event ID: %lu", evtData.fEventID );
204 // --------------- START OF RUN -----------------
205 blkSOR = GetFirstInputBlock( kAliHLTDataTypeSOR );
207 // ---------------- END OF RUN ------------------
208 blkEOR = GetFirstInputBlock( kAliHLTDataTypeEOR );
210 // -------------- GET DDLNumber -----------------
211 blkDDL = GetFirstInputBlock( kAliHLTDataTypeDDL );
214 HLTInfo("DDLLIST block received, size: %u", iter->fSize );
215 //AliHLTEventDDL ddlList = ( AliHLTEventDDL* ) iter->fPtr;
218 // ------------ decide which event type ----------
220 // - if event Type is not SOR or EOR -> process data
221 if ( ! blkEOR && !blkSOR ) {
222 iResult = ProcessCalibration( evtData, blocks, trigData, outputPtr, size, outputBlocks );
226 // - if event Type is EOR or event modulo is set -> ship data to FXS
227 // - use event modulo ship data also during the run
228 if ( ( fEventModulo > 0 && fEventCounter == fEventModulo ) || blkEOR ){
229 HLTDebug ( "Ship Data to FXS!" );
230 iResult = ShipDataToFXS( evtData, blocks, trigData, outputPtr, size, outputBlocks );
238 * ######################## ProcessCalibration #####################
241 Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& evtData,
242 const AliHLTComponentBlockData* blocks,
243 AliHLTComponentTriggerData& trigData,
244 AliHLTUInt8_t* outputPtr,
245 AliHLTUInt32_t& size,
246 vector<AliHLTComponentBlockData>& outputBlocks ) {
247 // see header file for class documentation
249 // we just forward to the high level method, all other parameters already
250 // have been stored internally
251 return ProcessCalibration( evtData, trigData );
254 Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& evtData,
255 AliHLTComponentTriggerData& trigData) {
256 // see header file for class documentation
258 HLTFatal( "no processing method implemented" );
263 * ######################## ShipDataToFXS #####################
266 Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& evtData,
267 const AliHLTComponentBlockData* blocks,
268 AliHLTComponentTriggerData& trigData,
269 AliHLTUInt8_t* outputPtr,
270 AliHLTUInt32_t& size,
271 vector<AliHLTComponentBlockData>& outputBlocks ) {
272 // see header file for class documentation
274 // we just forward to the high level method, all other parameters already
275 // have been stored internally
276 return ShipDataToFXS( evtData, trigData );
280 Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData) {
281 // see header file for class documentation
283 HLTFatal( "no processing method implemented" );
288 * ######################## CreateFXSHeader #####################
291 Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTFXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
292 // see header file for class documentation
296 AliHLTUInt32_t runNumber = GetRunNo(); // debug : 2176;
298 HLTDebug( "RunNumber = %d", runNumber );
300 /* STILL TO BE DONE .. but interface fixed */
302 // if ( pDDLNumber != "" ) {
303 char ddltmp[5] = "4444";
304 strncpy ( fDDLNumber, ddltmp, gkAliHLTFXSHeaderfDDLNumberSize );
307 //strncpy ( fDDLNumber, pDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize );
310 fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
314 // Fill header version
315 pHeader.fHeaderVersion = AliHLTCalibrationProcessor::fgkFXSProtocolHeaderVersion;
318 pHeader.fRunNumber = runNumber;
321 HLTDebug( "FXS Header Detector size max %i - actual %i .",gkAliHLTFXSHeaderfOriginSize, strlen( pDetector ) );
322 strncpy ( pHeader.fOrigin, pDetector, gkAliHLTFXSHeaderfOriginSize ) ;
324 // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfOriginSize, write one 0 is cheaper than an if.
325 pHeader.fOrigin[gkAliHLTFXSHeaderfOriginSize] = 0;
328 HLTInfo( "FXS Header FileID size max %i - actual %i .",gkAliHLTFXSHeaderfFileIDSize, strlen( pFileID ) );
329 strncpy ( pHeader.fFileID, pFileID, gkAliHLTFXSHeaderfFileIDSize ) ;
331 // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfFileIDSize, write one 0 is cheaper than an if.
332 pHeader.fFileID[gkAliHLTFXSHeaderfFileIDSize] = 0;
335 HLTInfo( "FXS Header DDLNumber size max %i - actual %i .", gkAliHLTFXSHeaderfDDLNumberSize, strlen( pDDLNumber ) );
336 strncpy ( pHeader.fDDLNumber, fDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize) ;
338 // To take care if DDLNumber which are longer than gkAliHLTFXSHeaderfDDLNumberSize, write one 0 is cheaper than an if.
339 pHeader.fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
342 } // Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
345 * ######################## PushToFXS #####################
348 Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
349 // see header file for class documentation
353 AliHLTFXSHeader pHeader;
355 CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
359 AliHLTMemoryFile* pMemFile = CreateMemoryFile( kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec );
362 iResult = pMemFile->WriteHeader( (const char*) &pHeader, AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
365 HLTError( "Buffer size to small - for header!" );
368 iResult = Write( pMemFile, pObject );
370 HLTError( "Buffer size to small - for data!" );
373 iResult = CloseMemoryFile( pMemFile );
387 } // Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* detector, const char* pFileID, const char* pDDLNumber ) {
389 Int_t AliHLTCalibrationProcessor::PushToFXS( void* pBuffer, int iSize, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
393 AliHLTFXSHeader pHeader;
395 CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
397 iResult = PushBack( pBuffer, iSize, kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec, (void*) (&pHeader), AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
401 } // Int_t AliHLTCalibrationProcessor::PushToFXS(void* pBuffer, int iSize, const char* pDdetector, const char* pFileID, const char* pDDLNumber = "") {