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. */
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 "AliHLTCalibrationProcessor.h"
35 #include "AliHLTMemoryFile.h"
40 #include <TObjString.h>
43 ClassImp(AliHLTCalibrationProcessor);
46 const AliHLTUInt32_t AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize = 204;
47 const AliHLTUInt32_t AliHLTCalibrationProcessor::fgkFXSProtocolHeaderVersion = 1;
50 * ################ Constructor / Destructor ####################
53 AliHLTCalibrationProcessor::AliHLTCalibrationProcessor() :
55 fUseCorruptEvents(kFALSE),
60 // see header file for class documentation
62 // refer to README to build package
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
67 AliHLTCalibrationProcessor::~AliHLTCalibrationProcessor() {
68 // see header file for class documentation
72 * ######################## InitCalibration #####################
75 Int_t AliHLTCalibrationProcessor::DoInit( int argc, const char** argv ) {
76 // see header file for class documentation
79 TString argument = "";
80 TString parameter = "";
81 Int_t bMissingParam=0;
83 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
86 if ( argument.IsNull() ) continue;
89 if ( argument.CompareTo("-eventmodulo") == 0 ) {
90 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
92 parameter.Remove(TString::kLeading, ' '); // remove all blanks
93 if (parameter.IsDigit()) {
94 fEventModulo = parameter.Atoi();
95 HLTInfo("EventModulo is set to %d.", fEventModulo);
98 HLTError("Cannot convert EventModulo specifier '%s'.", argv[ii]);
104 else if ( argument.CompareTo( "-usecorruptevents" ) == 0 ) {
105 HLTInfo( "Passing through of corrupted events enabled." );
106 fUseCorruptEvents = kTRUE;
108 // not known by calibration processor
110 if ( ( iResult = ScanArgument( argc-ii, &argv[ii] ) ) == -EINVAL ) {
111 HLTError( "unknown argument %s", argument.Data() );
114 else if ( iResult == -EPROTO ) {
118 else if ( iResult >= 0 ) {
125 if ( bMissingParam ) {
126 HLTError( "missing parameter for argument %s", argument.Data() );
130 if ( iResult >= 0 ) {
131 iResult = InitCalibration();
137 Int_t AliHLTCalibrationProcessor::InitCalibration() {
138 // see header file for class documentation
140 // fDummy is just touched here to avoid coding convention violation RC11.
141 // The function can not be declared const since it is just the default implementation,
142 // overloaded virtual function might not be const.
149 Int_t AliHLTCalibrationProcessor::ScanArgument(int argc, const char** argv) {
150 // see header file for class documentation
152 // there are no other arguments than the standard ones
153 if ( argc == 0 && argv == NULL) {
154 // this is just to get rid of the warning "unused parameter"
157 // fDummy is just touched here to avoid coding convention violation RC11.
158 // The function can not be declared const since it is just the default implementation,
159 // overloaded virtual function might not be const.
166 * ######################## DeinitCalibration #####################
169 Int_t AliHLTCalibrationProcessor::DoDeinit() {
170 // see header file for class documentation
172 int iResult = DeinitCalibration();
177 Int_t AliHLTCalibrationProcessor::DeinitCalibration() {
178 // see header file for class documentation
180 // fDummy is just touched here to avoid coding convention violation RC11.
181 // The function can not be declared const since it is just the default implementation,
182 // overloaded virtual function might not be const.
189 * ######################## DoEvent #####################
192 Int_t AliHLTCalibrationProcessor::DoEvent( const AliHLTComponentEventData& evtData,
193 const AliHLTComponentBlockData* blocks,
194 AliHLTComponentTriggerData& trigData,
195 AliHLTUInt8_t* outputPtr,
196 AliHLTUInt32_t& size,
197 vector<AliHLTComponentBlockData>& outputBlocks )
199 // see header file for class documentation
202 const AliHLTComponentBlockData* iter = NULL;
204 const AliHLTComponentBlockData* blkSOR = NULL;
205 const AliHLTComponentBlockData* blkEOR = NULL;
206 const AliHLTComponentBlockData* blkDDL = NULL;
208 HLTInfo( "Event ID: %lu", evtData.fEventID );
210 // --------------- START OF RUN -----------------
211 blkSOR = GetFirstInputBlock( kAliHLTDataTypeSOR );
213 // ---------------- END OF RUN ------------------
214 blkEOR = GetFirstInputBlock( kAliHLTDataTypeEOR );
216 // -------------- GET DDLNumber -----------------
217 blkDDL = GetFirstInputBlock( kAliHLTDataTypeDDL );
220 HLTInfo("DDLLIST block received, size: %u", iter->fSize );
221 //AliHLTEventDDL ddlList = ( AliHLTEventDDL* ) iter->fPtr;
224 // ------------ decide which event type ----------
226 // - if event Type is not SOR or EOR -> process data
227 if ( ! blkEOR && !blkSOR ) {
228 iResult = ProcessCalibration( evtData, blocks, trigData, outputPtr, size, outputBlocks );
232 // - if event Type is EOR or event modulo is set -> ship data to FXS
233 // - use event modulo ship data also during the run
234 if ( ( fEventModulo > 0 && fEventCounter == fEventModulo ) || blkEOR ){
235 HLTDebug ( "Ship Data to FXS!" );
236 iResult = ShipDataToFXS( evtData, blocks, trigData, outputPtr, size, outputBlocks );
244 * ######################## ProcessCalibration #####################
247 Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& evtData,
248 const AliHLTComponentBlockData* /*blocks*/,
249 AliHLTComponentTriggerData& trigData,
250 AliHLTUInt8_t* /*outputPtr*/,
251 AliHLTUInt32_t& /*size*/,
252 vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
253 // see header file for class documentation
255 // we just forward to the high level method, all other parameters already
256 // have been stored internally
257 return ProcessCalibration( evtData, trigData );
260 Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,
261 AliHLTComponentTriggerData& /*trigData*/) {
262 // see header file for class documentation
264 HLTFatal( "no processing method implemented" );
269 * ######################## ShipDataToFXS #####################
272 Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& evtData,
273 const AliHLTComponentBlockData* /*blocks*/,
274 AliHLTComponentTriggerData& trigData,
275 AliHLTUInt8_t* /*outputPtr*/,
276 AliHLTUInt32_t& /*size*/,
277 vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
278 // see header file for class documentation
280 // we just forward to the high level method, all other parameters already
281 // have been stored internally
282 return ShipDataToFXS( evtData, trigData );
286 Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
287 AliHLTComponentTriggerData& /*trigData*/) {
288 // see header file for class documentation
290 HLTFatal( "no processing method implemented" );
295 * ######################## CreateFXSHeader #####################
298 Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTFXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
299 // see header file for class documentation
303 AliHLTUInt32_t runNumber = GetRunNo(); // debug : 2176;
305 HLTDebug( "RunNumber = %d", runNumber );
307 /* STILL TO BE DONE .. but interface fixed */
309 // if ( pDDLNumber != "" ) {
310 char ddltmp[5] = "4444";
311 strncpy ( fDDLNumber, ddltmp, gkAliHLTFXSHeaderfDDLNumberSize );
314 //strncpy ( fDDLNumber, pDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize );
317 fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
321 // Fill header version
322 pHeader.fHeaderVersion = AliHLTCalibrationProcessor::fgkFXSProtocolHeaderVersion;
325 pHeader.fRunNumber = runNumber;
328 HLTDebug( "FXS Header Detector size max %i - actual %i .",gkAliHLTFXSHeaderfOriginSize, strlen( pDetector ) );
329 strncpy ( pHeader.fOrigin, pDetector, gkAliHLTFXSHeaderfOriginSize ) ;
331 // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfOriginSize, write one 0 is cheaper than an if.
332 pHeader.fOrigin[gkAliHLTFXSHeaderfOriginSize] = 0;
335 HLTInfo( "FXS Header FileID size max %i - actual %i .",gkAliHLTFXSHeaderfFileIDSize, strlen( pFileID ) );
336 strncpy ( pHeader.fFileID, pFileID, gkAliHLTFXSHeaderfFileIDSize ) ;
338 // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfFileIDSize, write one 0 is cheaper than an if.
339 pHeader.fFileID[gkAliHLTFXSHeaderfFileIDSize] = 0;
342 HLTInfo( "FXS Header DDLNumber size max %i - actual %i .", gkAliHLTFXSHeaderfDDLNumberSize, strlen( pDDLNumber ) );
343 strncpy ( pHeader.fDDLNumber, fDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize) ;
345 // To take care if DDLNumber which are longer than gkAliHLTFXSHeaderfDDLNumberSize, write one 0 is cheaper than an if.
346 pHeader.fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
349 } // Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
352 * ######################## PushToFXS #####################
355 Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
356 // see header file for class documentation
360 AliHLTFXSHeader pHeader;
362 CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
366 AliHLTMemoryFile* pMemFile = CreateMemoryFile( kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec );
369 iResult = pMemFile->WriteHeaderBuffer( (const char*) &pHeader, AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
372 HLTError( "Buffer size to small - for header!" );
375 iResult = Write( pMemFile, pObject );
377 HLTError( "Buffer size to small - for data!" );
380 iResult = CloseMemoryFile( pMemFile );
394 } // Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* detector, const char* pFileID, const char* pDDLNumber ) {
396 Int_t AliHLTCalibrationProcessor::PushToFXS( void* pBuffer, int iSize, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
397 // see header file for class documentation
401 AliHLTFXSHeader pHeader;
403 CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
405 iResult = PushBack( pBuffer, iSize, kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec, (void*) (&pHeader), AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
409 } // Int_t AliHLTCalibrationProcessor::PushToFXS(void* pBuffer, int iSize, const char* pDdetector, const char* pFileID, const char* pDDLNumber = "") {