Line data Source code
1 : // $Id$
2 :
3 : ///**************************************************************************
4 : // * This file is property of and copyright by the *
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 :
26 : #include "AliHLTProcessor.h"
27 : #include <string.h>
28 : #include "TDatime.h"
29 : #include "TString.h"
30 :
31 : /** ROOT macro for the implementation of ROOT specific class methods */
32 126 : ClassImp(AliHLTProcessor)
33 :
34 : AliHLTProcessor::AliHLTProcessor()
35 282 : : AliHLTComponent()
36 282 : , fpDebugCounters(NULL)
37 846 : {
38 282 : }
39 :
40 : AliHLTProcessor::~AliHLTProcessor()
41 558 : {
42 : // destructor
43 279 : if (fpDebugCounters) delete fpDebugCounters;
44 279 : fpDebugCounters=NULL;
45 279 : }
46 :
47 : int AliHLTProcessor::DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
48 : AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
49 : AliHLTUInt32_t& size,
50 : AliHLTComponentBlockDataList& outputBlocks,
51 : AliHLTComponentEventDoneData*& edd )
52 : {
53 : // Processing method, calls child's DoEvent
54 : int iResult=0;
55 0 : ReleaseEventDoneData();
56 :
57 0 : iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
58 :
59 0 : edd = NULL;
60 0 : AliHLTComponentEventDoneData* eddTmp = GetCurrentEventDoneData();
61 0 : if (eddTmp) {
62 0 : int ret = GetEventDoneData(eddTmp->fDataSize, &edd);
63 0 : if (ret) {
64 0 : HLTError( "Cannot get event done data of %u bytes for event %lu: error (%d)",
65 : eddTmp->fDataSize, evtData.fEventID, ret );
66 0 : return -ENOMEM;
67 : }
68 0 : edd->fStructSize = sizeof(AliHLTComponentEventDoneData);
69 0 : edd->fDataSize = eddTmp->fDataSize;
70 0 : edd->fData = reinterpret_cast<AliHLTUInt8_t*>(edd)+edd->fStructSize;
71 0 : memcpy( edd->fData, eddTmp->fData, eddTmp->fDataSize );
72 :
73 : // 2009-12-07 want to make this switchable, but this first needs some
74 : // extension in the online framework to change the log level settings
75 : // in the component while running
76 : if (false/*CheckFilter(kHLTLogDebug)*/) {
77 : if (!fpDebugCounters) {
78 : fpDebugCounters=new AliHLTProcessorCounters;
79 : }
80 : if (fpDebugCounters) {
81 : int wordCnt=edd->fDataSize/4;
82 : AliHLTUInt32_t* buffer=reinterpret_cast<AliHLTUInt32_t*>(edd->fData);
83 : int word=0;
84 : while (word<wordCnt) {
85 : switch (buffer[word]) {
86 : case 3:
87 : fpDebugCounters->fReadoutFilter++;
88 : word+=1+buffer[word+1]*4;
89 : break;
90 : case 4:
91 : fpDebugCounters->fMonitoringFilter++;
92 : word+=1+buffer[word+1]*4;
93 : break;
94 : case 5:
95 : fpDebugCounters->fMonitoringEvent++;
96 : break;
97 : default:
98 : fpDebugCounters->fMismatch++;
99 : break;
100 : }
101 : word++;
102 : }
103 :
104 : static UInt_t lastTime=0;
105 : TDatime time;
106 : if (time.Get()-lastTime>1) {
107 : lastTime=time.Get();
108 : HLTImportant("EventDoneData size %d: readout %d, monitoring filter %d, monitoring event %d, format error %d",
109 : edd->fDataSize, fpDebugCounters->fReadoutFilter, fpDebugCounters->fMonitoringFilter, fpDebugCounters->fMonitoringEvent, fpDebugCounters->fMismatch);
110 : for (int i=0; i< wordCnt; ) {
111 : TString message;
112 : for (int j=0; j<4 && i<wordCnt; j++) {
113 : TString number; number.Form("0x%08x ", buffer[i++]);
114 : message+=number;
115 : }
116 : HLTImportant(" %s", message.Data());
117 : }
118 : }
119 : }
120 : }
121 0 : }
122 0 : return iResult;
123 0 : }
124 :
125 : int AliHLTProcessor::DoEvent( const AliHLTComponentEventData& evtData,
126 : const AliHLTComponentBlockData* /*blocks*/,
127 : AliHLTComponentTriggerData& trigData,
128 : AliHLTUInt8_t* /*outputPtr*/,
129 : AliHLTUInt32_t& size,
130 : AliHLTComponentBlockDataList& /*outputBlocks*/ )
131 : {
132 : // we just forward to the high level method, all other parameters already
133 : // have been stored internally
134 0 : size=0;
135 0 : return DoEvent(evtData, trigData);
136 : }
137 :
138 : int AliHLTProcessor::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
139 : {
140 : // default method: one of DoEvent methods must be implemented
141 0 : HLTFatal("no processing method implemented");
142 0 : return -ENOSYS;
143 : }
|