Provide return value if the function is not void
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
CommitLineData
209a4703 1
2//insert copyright
3
4#include "AliHLTPHOSDigitMakerComponent.h"
5#include "AliHLTPHOSDigitMaker.h"
6#include "TTree.h"
7#include "AliHLTPHOSProcessor.h"
8#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
9#include "AliHLTPHOSDigitContainerDataStruct.h"
10#include "TClonesArray.h"
11#include "TFile.h"
12#include <sys/stat.h>
13#include <sys/types.h>
14
15const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
16
17AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
18
19AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
20 AliHLTPHOSProcessor(),
21 fDigitMakerPtr(0),
22 fEventCount(0)
23{
24
25}
26
27AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
28{
29}
30
31int
32AliHLTPHOSDigitMakerComponent::Deinit()
33{
34 if(fDigitMakerPtr)
35 {
36 delete fDigitMakerPtr;
37 fDigitMakerPtr = 0;
38 }
52be7fb0 39 return 0;
209a4703 40}
41
42const char*
43AliHLTPHOSDigitMakerComponent::GetComponentID()
44{
45 return "PhosDigitMaker";
46}
47
48void
49
50AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
51{
52 //Get datatypes for input
53 const AliHLTComponentDataType* pType=fgkInputDataTypes;
54 while (pType->fID!=0) {
55 list.push_back(*pType);
56 pType++;
57 }
58}
59
60AliHLTComponentDataType
61AliHLTPHOSDigitMakerComponent::GetOutputDataType()
62{
63 return AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
64}
65
66
67void
68AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
69{
70 constBase = 30;
71 inputMultiplier = 1;
72}
73
74int
75AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
76 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
77 std::vector<AliHLTComponentBlockData>& outputBlocks)
78{
79 //Do event
80
81 UInt_t tSize = 0;
82 UInt_t offset = 0;
83 UInt_t mysize = 0;
84 Int_t nRecPoints = 0;
85 Int_t index = 0;
86
87 Int_t fileCount = 0;
88 Int_t digitCount = 0;
89 char filename [50];
90
91
92 AliHLTUInt8_t* outBPtr;
93 outBPtr = outputPtr;
94 const AliHLTComponentBlockData* iter = 0;
95 unsigned long ndx;
96 fDigitContainerPtr = (AliHLTPHOSDigitContainerDataStruct*)outBPtr;
97 //fDigitMakerPtr->SetDigitContainerStruct(fDigitContainerPtr);
98 fDigitMakerPtr->SetDigitContainerStruct((AliHLTPHOSDigitContainerDataStruct*)outBPtr);
99
100 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
101 {
102 iter = blocks+ndx;
103
104 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
105 {
106 // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
107 continue;
108
109 }
110 digitCount = fDigitMakerPtr->MakeDigits(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
111 }
112 fEventCount++;
113
114 mysize = 0;
115 offset = tSize;
116
117 mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
118 ((AliHLTPHOSDigitContainerDataStruct*)outBPtr)->fNDigits = digitCount;
119 AliHLTComponentBlockData bd;
120 FillBlockData( bd );
121 bd.fOffset = offset;
122 bd.fSize = mysize;
123 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
124 bd.fSpecification = 0xFFFFFFFF;
125 outputBlocks.push_back( bd );
126
127 tSize += mysize;
128 outBPtr += mysize;
129
130 if( tSize > size )
131 {
132 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data",
133 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
134 , tSize, size );
135 return EMSGSIZE;
136 }
137
138 fDigitMakerPtr->Reset();
139
140 if(fEventCount % 10 == 0)
141 {
142 cout << "Event #: " << fEventCount << endl;
143 cout << " - Number of digits found: " << digitCount << endl;
144 }
145
146 return 0;
147}
148
149
150int
151AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
152{
153 //Do initialization
154
155 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
156
157 for(int i = 0; i < argc; i++)
158 {
159 if(!strcmp("-threshold", argv[i]))
160 fDigitMakerPtr->SetDigitThreshold(atoi(argv[i+1]));
161 if(!strcmp("-presamples", argv[i]))
162 fDigitMakerPtr->SetNrPresamples(atoi(argv[i+1]));
163 }
164
165 //fDigitMakerPtr->SetDigitThreshold(2);
166
167 return 0;
168}
169
170AliHLTComponent*
171AliHLTPHOSDigitMakerComponent::Spawn()
172{
173 return new AliHLTPHOSDigitMakerComponent();
174}