]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTProcessor.cxx
removing error code translation targeted by coverity, the translation via strerr...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTProcessor.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
9  *                  for The ALICE HLT Project.                            *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /** @file   AliHLTProcessor.cxx
21     @author Matthias Richter, Timm Steinbeck
22     @date   
23     @brief  Base class implementation for HLT analysis components. */
24
25 #if __GNUC__>= 3
26 using namespace std;
27 #endif
28
29 #include "AliHLTProcessor.h"
30 #include <string.h>
31 #include "TDatime.h"
32 #include "TString.h"
33
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTProcessor)
36
37 AliHLTProcessor::AliHLTProcessor()
38   : AliHLTComponent()
39   , fpDebugCounters(NULL)
40
41   // see header file for class documentation
42   // or
43   // refer to README to build package
44   // or
45   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 }
47
48 AliHLTProcessor::~AliHLTProcessor()
49
50   // see header file for class documentation
51   if (fpDebugCounters) delete fpDebugCounters;
52   fpDebugCounters=NULL;
53 }
54
55 int AliHLTProcessor::DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
56                             AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
57                             AliHLTUInt32_t& size,
58                             vector<AliHLTComponentBlockData>& outputBlocks,
59                             AliHLTComponentEventDoneData*& edd )
60 {
61   // see header file for class documentation
62   int iResult=0;
63   ReleaseEventDoneData();
64
65   iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
66
67   edd = NULL;
68   AliHLTComponentEventDoneData* eddTmp = GetCurrentEventDoneData();
69   if (eddTmp) {
70     int ret = GetEventDoneData(eddTmp->fDataSize, &edd);
71     if (ret) {
72       HLTError( "Cannot get event done data of %u bytes for event %lu: error (%d)", 
73                 eddTmp->fDataSize, evtData.fEventID, ret );
74       return -ENOMEM;
75     }
76     edd->fStructSize = sizeof(AliHLTComponentEventDoneData);
77     edd->fDataSize = eddTmp->fDataSize;
78     edd->fData = reinterpret_cast<AliHLTUInt8_t*>(edd)+edd->fStructSize;
79     memcpy( edd->fData, eddTmp->fData, eddTmp->fDataSize );
80
81     // 2009-12-07 want to make this switchable, but this first needs some
82     // extension in the online framework to change the log level settings
83     // in the component while running
84     if (false/*CheckFilter(kHLTLogDebug)*/) {
85       if (!fpDebugCounters) {
86         fpDebugCounters=new AliHLTProcessorCounters;
87       }
88       if (fpDebugCounters) {
89         int wordCnt=edd->fDataSize/4;
90         AliHLTUInt32_t* buffer=reinterpret_cast<AliHLTUInt32_t*>(edd->fData);
91         int word=0;
92         while (word<wordCnt) {
93           switch (buffer[word]) {
94           case 3: 
95             fpDebugCounters->fReadoutFilter++; 
96             word+=1+buffer[word+1]*4;
97             break;
98           case 4:
99             fpDebugCounters->fMonitoringFilter++; 
100             word+=1+buffer[word+1]*4;
101             break;
102           case 5:
103             fpDebugCounters->fMonitoringEvent++; 
104             break;
105           default:
106             fpDebugCounters->fMismatch++;
107             break;
108           }
109           word++;
110         }
111
112         static UInt_t lastTime=0;
113         TDatime time;
114         if (time.Get()-lastTime>1) {
115           lastTime=time.Get();
116           HLTImportant("EventDoneData size %d: readout %d, monitoring filter %d, monitoring event %d, format error %d", 
117                        edd->fDataSize, fpDebugCounters->fReadoutFilter, fpDebugCounters->fMonitoringFilter, fpDebugCounters->fMonitoringEvent, fpDebugCounters->fMismatch);
118           for (int i=0; i< wordCnt; ) {
119             TString message;
120             for (int j=0; j<4 && i<wordCnt; j++) {
121               TString number; number.Form("0x%08x ", buffer[i++]);
122               message+=number;
123             }
124             HLTImportant("   %s", message.Data());
125           }
126         }
127       }
128     }
129   }
130   return iResult;
131 }
132
133 int AliHLTProcessor::DoEvent( const AliHLTComponentEventData& evtData,
134                               const AliHLTComponentBlockData* /*blocks*/, 
135                               AliHLTComponentTriggerData& trigData,
136                               AliHLTUInt8_t* /*outputPtr*/, 
137                               AliHLTUInt32_t& size,
138                               vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
139 {
140   // we just forward to the high level method, all other parameters already
141   // have been stored internally
142   size=0;
143   return DoEvent(evtData, trigData);
144 }
145
146 int AliHLTProcessor::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
147 {
148   HLTFatal("no processing method implemented");
149   return -ENOSYS;
150 }