]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
Coding conventions and removal of obsolete files
[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
2374af72 27
28/**
29 * @file AliHLTPHOSDigitMakerComponent.cxx
30 * @author Oystein Djuvsland
31 * @date
32 * @brief A digit maker component for PHOS HLT
33*/
34
35// see below for class documentation
36// or
37// refer to README to build package
38// or
39// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40
41
209a4703 42const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
43
44AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
45
46AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
47 AliHLTPHOSProcessor(),
939c67e7 48 fDigitMakerPtr(0)
49 // fEvtCnt(0)
209a4703 50{
2374af72 51 //see header file for documentation
209a4703 52}
53
54AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
55{
2374af72 56 //see header file for documentation
209a4703 57}
58
59int
60AliHLTPHOSDigitMakerComponent::Deinit()
61{
2374af72 62 //see header file for documentation
209a4703 63 if(fDigitMakerPtr)
64 {
65 delete fDigitMakerPtr;
66 fDigitMakerPtr = 0;
67 }
52be7fb0 68 return 0;
209a4703 69}
70
71const char*
72AliHLTPHOSDigitMakerComponent::GetComponentID()
73{
2374af72 74 //see header file for documentation
209a4703 75 return "PhosDigitMaker";
76}
77
78void
79
80AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
81{
2374af72 82 //see header file for documentation
83
209a4703 84 const AliHLTComponentDataType* pType=fgkInputDataTypes;
85 while (pType->fID!=0) {
86 list.push_back(*pType);
87 pType++;
88 }
89}
90
91AliHLTComponentDataType
92AliHLTPHOSDigitMakerComponent::GetOutputDataType()
93{
2374af72 94 //see header file for documentation
209a4703 95 return AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
96}
97
98
99void
100AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
101{
2374af72 102 //see header file for documentation
209a4703 103 constBase = 30;
104 inputMultiplier = 1;
105}
106
107int
108AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
109 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
110 std::vector<AliHLTComponentBlockData>& outputBlocks)
111{
2374af72 112 //see header file for documentation
113
209a4703 114 UInt_t tSize = 0;
115 UInt_t offset = 0;
116 UInt_t mysize = 0;
209a4703 117 Int_t digitCount = 0;
939c67e7 118 // cout << " AliHLTPHOSDigitMakerComponent::DoEven fEvtCnt = " << fEvtCnt <<endl;
209a4703 119
120 AliHLTUInt8_t* outBPtr;
121 outBPtr = outputPtr;
122 const AliHLTComponentBlockData* iter = 0;
123 unsigned long ndx;
124 fDigitContainerPtr = (AliHLTPHOSDigitContainerDataStruct*)outBPtr;
125 //fDigitMakerPtr->SetDigitContainerStruct(fDigitContainerPtr);
126 fDigitMakerPtr->SetDigitContainerStruct((AliHLTPHOSDigitContainerDataStruct*)outBPtr);
127
128 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129 {
130 iter = blocks+ndx;
131
132 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
133 {
134 // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
135 continue;
136
137 }
138 digitCount = fDigitMakerPtr->MakeDigits(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
139 }
939c67e7 140
141 fPhosEventCount++;
209a4703 142
143 mysize = 0;
144 offset = tSize;
145
146 mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
147 ((AliHLTPHOSDigitContainerDataStruct*)outBPtr)->fNDigits = digitCount;
148 AliHLTComponentBlockData bd;
149 FillBlockData( bd );
150 bd.fOffset = offset;
151 bd.fSize = mysize;
152 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
153 bd.fSpecification = 0xFFFFFFFF;
154 outputBlocks.push_back( bd );
155
156 tSize += mysize;
157 outBPtr += mysize;
158
159 if( tSize > size )
160 {
161 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data",
162 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
163 , tSize, size );
164 return EMSGSIZE;
165 }
166
167 fDigitMakerPtr->Reset();
168
939c67e7 169 if(fPhosEventCount % 10 == 0)
209a4703 170 {
939c67e7 171 cout << "Event #: " << fPhosEventCount << endl;
209a4703 172 cout << " - Number of digits found: " << digitCount << endl;
173 }
174
175 return 0;
176}
177
178
179int
180AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
181{
2374af72 182 //see header file for documentation
209a4703 183
184 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
185
186 for(int i = 0; i < argc; i++)
187 {
188 if(!strcmp("-threshold", argv[i]))
189 fDigitMakerPtr->SetDigitThreshold(atoi(argv[i+1]));
190 if(!strcmp("-presamples", argv[i]))
191 fDigitMakerPtr->SetNrPresamples(atoi(argv[i+1]));
192 }
193
194 //fDigitMakerPtr->SetDigitThreshold(2);
195
196 return 0;
197}
198
199AliHLTComponent*
200AliHLTPHOSDigitMakerComponent::Spawn()
201{
2374af72 202 //see header file for documentation
209a4703 203 return new AliHLTPHOSDigitMakerComponent();
204}