]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
- fixing compilation warnings
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
CommitLineData
87434909 1 // $Id$
1b41ab20 2
25b7f84c 3 /**************************************************************************
ab38011b 4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
6 * *
7 * Primary Authors: Oystein Djuvsland *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
209a4703 17
18#include "AliHLTPHOSDigitMakerComponent.h"
f137c3c5 19#include "AliHLTCaloDigitMaker.h"
20#include "AliHLTCaloDigitDataStruct.h"
21#include "AliHLTPHOSMapper.h"
94594220 22#include "AliHLTPHOSChannelDataHeaderStruct.h"
e304ea31 23#include "AliHLTPHOSChannelDataStruct.h"
209a4703 24#include "TFile.h"
25#include <sys/stat.h>
26#include <sys/types.h>
27
2374af72 28
29/**
ea54e1c8 30 * @file AliHLTPHOSDigitMakerComponent.cxx
2374af72 31 * @author Oystein Djuvsland
32 * @date
33 * @brief A digit maker component for PHOS HLT
34*/
35
36// see below for class documentation
37// or
38// refer to README to build package
39// or
40// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41
42
209a4703 43AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
44
45AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
46 AliHLTPHOSProcessor(),
25b7f84c 47 fDigitMakerPtr(0),
48 fDigitContainerPtr(0)
209a4703 49{
2374af72 50 //see header file for documentation
209a4703 51}
52
e304ea31 53
209a4703 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
209a4703 78
af6a2273 79void
209a4703 80AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
81{
2374af72 82 //see header file for documentation
94594220 83 list.clear();
84 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
209a4703 85}
86
87AliHLTComponentDataType
88AliHLTPHOSDigitMakerComponent::GetOutputDataType()
89{
2374af72 90 //see header file for documentation
25b7f84c 91 return AliHLTPHOSDefinitions::fgkDigitDataType;
209a4703 92}
93
94
95void
96AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
97{
2374af72 98 //see header file for documentation
e304ea31 99 constBase = 0;
f137c3c5 100 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
209a4703 101}
102
103int
104AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
105 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
106 std::vector<AliHLTComponentBlockData>& outputBlocks)
107{
2374af72 108 //see header file for documentation
209a4703 109 UInt_t offset = 0;
110 UInt_t mysize = 0;
e304ea31 111 Int_t digitCount = 0;
112 Int_t ret = 0;
209a4703 113
114 AliHLTUInt8_t* outBPtr;
115 outBPtr = outputPtr;
116 const AliHLTComponentBlockData* iter = 0;
117 unsigned long ndx;
d949e02e 118
119 UInt_t specification = 0;
f137c3c5 120 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
d949e02e 121
f137c3c5 122 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
123
124 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
5c6cac96 125
209a4703 126 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
127 {
128 iter = blocks+ndx;
129
94594220 130 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
209a4703 131 {
94594220 132 HLTDebug("Data block is not of type fgkChannelDataType");
209a4703 133 continue;
209a4703 134 }
e304ea31 135
136 specification |= iter->fSpecification;
f137c3c5 137 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
94594220 138
f137c3c5 139 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
e304ea31 140 if(ret == -1)
141 {
142 HLTError("Trying to write over buffer size");
143 return -ENOBUFS;
144 }
145 digitCount += ret;
209a4703 146 }
209a4703 147
f137c3c5 148 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
e304ea31 149
341aab10 150 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
87434909 151
87434909 152 if(mysize > 0)
209a4703 153 {
87434909 154 AliHLTComponentBlockData bd;
155 FillBlockData( bd );
156 bd.fOffset = offset;
157 bd.fSize = mysize;
158 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
159 bd.fSpecification = specification;
160 outputBlocks.push_back(bd);
209a4703 161 }
ab521ae4 162
94594220 163 fDigitMakerPtr->Reset();
9bf87c6f 164
165 size = mysize;
166
209a4703 167 return 0;
168}
169
170
171int
172AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
173{
2374af72 174 //see header file for documentation
209a4703 175
f137c3c5 176 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
177
178 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
179 fDigitMakerPtr->SetMapper(mapper);
209a4703 180
181 for(int i = 0; i < argc; i++)
182 {
d949e02e 183 if(!strcmp("-lowgainfactor", argv[i]))
184 {
185 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
d949e02e 186 }
187 if(!strcmp("-highgainfactor", argv[i]))
188 {
189 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
d949e02e 190 }
209a4703 191 }
192
193 //fDigitMakerPtr->SetDigitThreshold(2);
194
195 return 0;
196}
197
198AliHLTComponent*
199AliHLTPHOSDigitMakerComponent::Spawn()
200{
2374af72 201 //see header file for documentation
209a4703 202 return new AliHLTPHOSDigitMakerComponent();
203}