]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
coding conventions (Oystein/Per Thomas)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
CommitLineData
ab38011b 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: Oystein Djuvsland *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
209a4703 15
16#include "AliHLTPHOSDigitMakerComponent.h"
17#include "AliHLTPHOSDigitMaker.h"
18#include "TTree.h"
19#include "AliHLTPHOSProcessor.h"
20#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
21#include "AliHLTPHOSDigitContainerDataStruct.h"
22#include "TClonesArray.h"
23#include "TFile.h"
24#include <sys/stat.h>
25#include <sys/types.h>
26
27const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
28
29AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
30
31AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
32 AliHLTPHOSProcessor(),
33 fDigitMakerPtr(0),
ab38011b 34 fEvtCnt(0)
209a4703 35{
ab38011b 36 //comment
209a4703 37}
38
39AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
40{
ab38011b 41 //comment
209a4703 42}
43
44int
45AliHLTPHOSDigitMakerComponent::Deinit()
46{
ab38011b 47 //comment
209a4703 48 if(fDigitMakerPtr)
49 {
50 delete fDigitMakerPtr;
51 fDigitMakerPtr = 0;
52 }
52be7fb0 53 return 0;
209a4703 54}
55
56const char*
57AliHLTPHOSDigitMakerComponent::GetComponentID()
58{
ab38011b 59 //comment
209a4703 60 return "PhosDigitMaker";
61}
62
63void
64
65AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
66{
67 //Get datatypes for input
68 const AliHLTComponentDataType* pType=fgkInputDataTypes;
69 while (pType->fID!=0) {
70 list.push_back(*pType);
71 pType++;
72 }
73}
74
75AliHLTComponentDataType
76AliHLTPHOSDigitMakerComponent::GetOutputDataType()
77{
ab38011b 78 //comment
209a4703 79 return AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
80}
81
82
83void
84AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
85{
ab38011b 86 //comment
209a4703 87 constBase = 30;
88 inputMultiplier = 1;
89}
90
91int
92AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
93 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
94 std::vector<AliHLTComponentBlockData>& outputBlocks)
95{
96 //Do event
97
98 UInt_t tSize = 0;
99 UInt_t offset = 0;
100 UInt_t mysize = 0;
101 Int_t nRecPoints = 0;
102 Int_t index = 0;
103
104 Int_t fileCount = 0;
105 Int_t digitCount = 0;
106 char filename [50];
107
108
109 AliHLTUInt8_t* outBPtr;
110 outBPtr = outputPtr;
111 const AliHLTComponentBlockData* iter = 0;
112 unsigned long ndx;
113 fDigitContainerPtr = (AliHLTPHOSDigitContainerDataStruct*)outBPtr;
114 //fDigitMakerPtr->SetDigitContainerStruct(fDigitContainerPtr);
115 fDigitMakerPtr->SetDigitContainerStruct((AliHLTPHOSDigitContainerDataStruct*)outBPtr);
116
117 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
118 {
119 iter = blocks+ndx;
120
121 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
122 {
123 // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
124 continue;
125
126 }
127 digitCount = fDigitMakerPtr->MakeDigits(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
128 }
ab38011b 129 fEvtCnt++;
209a4703 130
131 mysize = 0;
132 offset = tSize;
133
134 mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
135 ((AliHLTPHOSDigitContainerDataStruct*)outBPtr)->fNDigits = digitCount;
136 AliHLTComponentBlockData bd;
137 FillBlockData( bd );
138 bd.fOffset = offset;
139 bd.fSize = mysize;
140 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
141 bd.fSpecification = 0xFFFFFFFF;
142 outputBlocks.push_back( bd );
143
144 tSize += mysize;
145 outBPtr += mysize;
146
147 if( tSize > size )
148 {
149 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data",
150 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
151 , tSize, size );
152 return EMSGSIZE;
153 }
154
155 fDigitMakerPtr->Reset();
156
ab38011b 157 if(fEvtCnt % 10 == 0)
209a4703 158 {
ab38011b 159 cout << "Event #: " << fEvtCnt << endl;
209a4703 160 cout << " - Number of digits found: " << digitCount << endl;
161 }
162
163 return 0;
164}
165
166
167int
168AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
169{
170 //Do initialization
171
172 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
173
174 for(int i = 0; i < argc; i++)
175 {
176 if(!strcmp("-threshold", argv[i]))
177 fDigitMakerPtr->SetDigitThreshold(atoi(argv[i+1]));
178 if(!strcmp("-presamples", argv[i]))
179 fDigitMakerPtr->SetNrPresamples(atoi(argv[i+1]));
180 }
181
182 //fDigitMakerPtr->SetDigitThreshold(2);
183
184 return 0;
185}
186
187AliHLTComponent*
188AliHLTPHOSDigitMakerComponent::Spawn()
189{
ab38011b 190 //comment
209a4703 191 return new AliHLTPHOSDigitMakerComponent();
192}