]>
Commit | Line | Data |
---|---|---|
ca071d0a | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
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 | **************************************************************************/ | |
17 | ||
18 | #include "AliHLTEMCALDigitMakerComponent.h" | |
19 | #include "AliHLTCaloDigitMaker.h" | |
20 | #include "AliHLTCaloDigitDataStruct.h" | |
21 | #include "AliHLTCaloChannelDataHeaderStruct.h" | |
22 | #include "AliHLTCaloChannelDataStruct.h" | |
23 | #include "AliHLTEMCALMapper.h" | |
24 | #include "AliHLTEMCALDefinitions.h" | |
25 | #include "TFile.h" | |
26 | #include <sys/stat.h> | |
27 | #include <sys/types.h> | |
28 | ||
29 | ||
30 | /** | |
31 | * @file AliHLTEMCALDigitMakerComponent.cxx | |
32 | * @author Oystein Djuvsland | |
33 | * @date | |
34 | * @brief A digit maker component for EMCAL HLT | |
35 | */ | |
36 | ||
37 | // see below for class documentation | |
38 | // or | |
39 | // refer to README to build package | |
40 | // or | |
41 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
42 | ||
43 | ||
44 | AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent; | |
45 | ||
46 | AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() : | |
47 | AliHLTCaloProcessor(), | |
48 | fDigitMakerPtr(0), | |
49 | fDigitContainerPtr(0) | |
50 | { | |
51 | //see header file for documentation | |
52 | } | |
53 | ||
54 | ||
55 | AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent() | |
56 | { | |
57 | //see header file for documentation | |
58 | } | |
59 | ||
60 | int | |
61 | AliHLTEMCALDigitMakerComponent::Deinit() | |
62 | { | |
63 | //see header file for documentation | |
64 | if(fDigitMakerPtr) | |
65 | { | |
66 | delete fDigitMakerPtr; | |
67 | fDigitMakerPtr = 0; | |
68 | } | |
69 | return 0; | |
70 | } | |
71 | ||
72 | const char* | |
73 | AliHLTEMCALDigitMakerComponent::GetComponentID() | |
74 | { | |
75 | //see header file for documentation | |
76 | return "EmcalDigitMaker"; | |
77 | } | |
78 | ||
79 | ||
80 | void | |
81 | AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list) | |
82 | { | |
83 | //see header file for documentation | |
84 | list.clear(); | |
85 | list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType); | |
86 | } | |
87 | ||
88 | AliHLTComponentDataType | |
89 | AliHLTEMCALDigitMakerComponent::GetOutputDataType() | |
90 | { | |
91 | //see header file for documentation | |
92 | return AliHLTEMCALDefinitions::fgkDigitDataType; | |
93 | } | |
94 | ||
95 | ||
96 | void | |
97 | AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
98 | { | |
99 | //see header file for documentation | |
100 | constBase = 0; | |
101 | inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1; | |
102 | } | |
103 | ||
104 | int | |
105 | AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
106 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
107 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
108 | { | |
109 | //see header file for documentation | |
110 | UInt_t offset = 0; | |
111 | UInt_t mysize = 0; | |
112 | Int_t digitCount = 0; | |
113 | Int_t ret = 0; | |
114 | ||
115 | AliHLTUInt8_t* outBPtr; | |
116 | outBPtr = outputPtr; | |
117 | const AliHLTComponentBlockData* iter = 0; | |
118 | unsigned long ndx; | |
119 | ||
120 | UInt_t specification = 0; | |
121 | AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0; | |
122 | ||
123 | // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr)); | |
124 | ||
125 | fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr)); | |
126 | ||
127 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
128 | { | |
129 | iter = blocks+ndx; | |
130 | ||
131 | if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType) | |
132 | { | |
133 | HLTError("Data block is not of type fgkChannelDataType"); | |
134 | continue; | |
135 | } | |
136 | ||
137 | specification |= iter->fSpecification; | |
138 | tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr); | |
139 | ||
140 | ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct))); | |
141 | if(ret == -1) | |
142 | { | |
143 | HLTError("Trying to write over buffer size"); | |
144 | return -ENOBUFS; | |
145 | } | |
146 | digitCount += ret; | |
147 | } | |
148 | ||
149 | mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct); | |
150 | ||
151 | HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size); | |
152 | ||
153 | if(mysize > 0) | |
154 | { | |
155 | AliHLTComponentBlockData bd; | |
156 | FillBlockData( bd ); | |
157 | bd.fOffset = offset; | |
158 | bd.fSize = mysize; | |
159 | bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType; | |
160 | bd.fSpecification = specification; | |
161 | outputBlocks.push_back(bd); | |
162 | } | |
163 | ||
164 | fDigitMakerPtr->Reset(); | |
165 | ||
166 | size = mysize; | |
167 | ||
168 | return 0; | |
169 | } | |
170 | ||
171 | ||
172 | int | |
173 | AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv ) | |
174 | { | |
175 | //see header file for documentation | |
176 | ||
177 | fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL"); | |
178 | ||
179 | AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2); | |
180 | fDigitMakerPtr->SetMapper(mapper); | |
181 | ||
182 | for(int i = 0; i < argc; i++) | |
183 | { | |
184 | if(!strcmp("-lowgainfactor", argv[i])) | |
185 | { | |
186 | fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1])); | |
187 | } | |
188 | if(!strcmp("-highgainfactor", argv[i])) | |
189 | { | |
190 | fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1])); | |
191 | } | |
192 | } | |
193 | ||
194 | //fDigitMakerPtr->SetDigitThreshold(2); | |
195 | ||
196 | return 0; | |
197 | } | |
198 | ||
199 | AliHLTComponent* | |
200 | AliHLTEMCALDigitMakerComponent::Spawn() | |
201 | { | |
202 | //see header file for documentation | |
203 | return new AliHLTEMCALDigitMakerComponent(); | |
204 | } |