]>
Commit | Line | Data |
---|---|---|
4d42193f | 1 | // $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Oystein Djuvsland <oysteind@ift.uib.no> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | #include <iostream> | |
18 | ||
19 | #include "AliHLTCaloClusterizerComponent.h" | |
20 | #include "AliHLTCaloClusterizer.h" | |
21 | #include "AliHLTCaloRecPointDataStruct.h" | |
22 | #include "AliHLTCaloRecPointHeaderStruct.h" | |
23 | #include "AliHLTCaloDigitDataStruct.h" | |
24 | #include "AliHLTCaloDigitContainerDataStruct.h" | |
25 | #include "AliHLTCaloDefinitions.h" | |
ad44d760 | 26 | #include "TString.h" |
4d42193f | 27 | |
28 | /** @file AliHLTCaloClusterizerComponent.cxx | |
29 | @author Oystein Djuvsland | |
30 | @date | |
31 | @brief A clusterizer component for PHOS HLT | |
32 | */ | |
33 | ||
34 | // see header file for class documentation | |
35 | // or | |
36 | // refer to README to build package | |
37 | // or | |
38 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
39 | ||
4d42193f | 40 | |
ad44d760 | 41 | AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): |
ad44d760 | 42 | AliHLTCaloProcessor(), |
f92dcf21 | 43 | AliHLTCaloConstantsHandler(det), |
44 | fDigitsPointerArray(0), | |
4d42193f | 45 | fClusterizerPtr(0), |
ad44d760 | 46 | fDigitCount(0) |
47 | ||
4d42193f | 48 | { |
49 | //See headerfile for documentation | |
ad44d760 | 50 | |
51 | fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()]; | |
52 | ||
53 | fClusterizerPtr = new AliHLTCaloClusterizer(det); | |
54 | ||
55 | fClusterizerPtr->SetDigitArray(fDigitsPointerArray); | |
56 | ||
4d42193f | 57 | } |
58 | ||
59 | AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() | |
60 | { | |
61 | //See headerfile for documentation | |
62 | ||
63 | if(fClusterizerPtr) | |
64 | { | |
65 | delete fClusterizerPtr; | |
66 | fClusterizerPtr = 0; | |
67 | } | |
4d42193f | 68 | } |
69 | ||
70 | ||
71 | int | |
72 | AliHLTCaloClusterizerComponent::Deinit() | |
73 | { | |
74 | //See headerfile for documentation | |
75 | ||
76 | if (fClusterizerPtr) | |
77 | { | |
78 | delete fClusterizerPtr; | |
79 | fClusterizerPtr = 0; | |
80 | } | |
81 | ||
82 | return 0; | |
83 | } | |
84 | ||
ad44d760 | 85 | // void |
86 | // AliHLTCaloClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
87 | // { | |
88 | // //See headerfile for documentation | |
89 | // list.clear(); | |
90 | // list.push_back(AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS); | |
91 | // } | |
92 | ||
93 | // AliHLTComponentDataType | |
94 | // AliHLTCaloClusterizerComponent::GetOutputDataType() | |
95 | // { | |
96 | // //See headerfile for documentation | |
97 | // return AliHLTCaloDefinitions::fgkRecPointDataType|kAliHLTDataOriginPHOS; | |
98 | // } | |
99 | ||
100 | // void | |
101 | // AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
102 | ||
103 | // { | |
104 | // //See headerfile for documentation | |
105 | // constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ; | |
106 | // inputMultiplier = 1.5; | |
107 | // } | |
4d42193f | 108 | |
109 | int | |
110 | AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
111 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
112 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
113 | { | |
114 | //See headerfile for documentation | |
115 | ||
116 | if(blocks == 0) return 0; | |
117 | ||
118 | UInt_t offset = 0; | |
119 | UInt_t mysize = 0; | |
120 | Int_t nRecPoints = 0; | |
121 | Int_t nDigits = 0; | |
ad44d760 | 122 | Int_t digCount = 0; |
4d42193f | 123 | |
f92dcf21 | 124 | //UInt_t availableSize = size; |
4d42193f | 125 | AliHLTUInt8_t* outBPtr; |
126 | outBPtr = outputPtr; | |
127 | const AliHLTComponentBlockData* iter = 0; | |
128 | unsigned long ndx; | |
129 | ||
130 | UInt_t specification = 0; | |
131 | ||
132 | AliHLTCaloDigitDataStruct *digitDataPtr = 0; | |
133 | ||
4d42193f | 134 | // Adding together all the digits, should be put in standalone method |
135 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
136 | { | |
137 | iter = blocks+ndx; | |
ad44d760 | 138 | // HLTError("Got block"); |
139 | if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS)) | |
4d42193f | 140 | { |
141 | // Get the digit header | |
142 | ||
143 | // Update the number of digits | |
ad44d760 | 144 | nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);; |
145 | // HLTError("Got %d digits", nDigits); | |
146 | ||
4d42193f | 147 | specification = specification|iter->fSpecification; |
148 | ||
149 | digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
150 | for (Int_t i = 0; i < nDigits; i++) | |
151 | { | |
ad44d760 | 152 | fDigitsPointerArray[digCount] = digitDataPtr; |
153 | digCount++; | |
4d42193f | 154 | digitDataPtr++; |
155 | } | |
156 | ||
157 | } | |
158 | } | |
4d42193f | 159 | |
ad44d760 | 160 | if(digCount > 0) |
4d42193f | 161 | { |
ad44d760 | 162 | |
163 | // Sort the digit pointers | |
164 | qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits); | |
4d42193f | 165 | |
ad44d760 | 166 | // Copy the digits to the output |
167 | for(Int_t n = 0; n < digCount; n++) | |
168 | { | |
169 | memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct)); | |
170 | outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct); | |
171 | } | |
172 | ||
173 | mysize += digCount*sizeof(AliHLTCaloDigitDataStruct); | |
174 | ||
175 | AliHLTComponentBlockData bdDigits; | |
176 | FillBlockData( bdDigits ); | |
177 | bdDigits.fOffset = offset; | |
178 | bdDigits.fSize = mysize; | |
179 | bdDigits.fDataType = iter->fDataType; | |
180 | bdDigits.fSpecification = specification; | |
181 | outputBlocks.push_back( bdDigits ); | |
4d42193f | 182 | |
ad44d760 | 183 | |
184 | AliHLTCaloRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTCaloRecPointHeaderStruct*>(outBPtr); | |
185 | ||
186 | fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTCaloRecPointDataStruct*>(outBPtr+sizeof(AliHLTCaloRecPointHeaderStruct))); | |
187 | ||
188 | // HLTError("Total number of digits: %d", digCount ); | |
189 | ||
190 | printf("Total number of digits: %d\n", digCount); | |
191 | ||
192 | nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount, size, mysize); | |
193 | ||
194 | if(nRecPoints == -1) | |
195 | { | |
196 | // HLTError("Running out of buffer, exiting for safety."); | |
197 | return -ENOBUFS; | |
198 | } | |
199 | ||
200 | recPointHeaderPtr->fNRecPoints = nRecPoints; | |
201 | mysize += sizeof(AliHLTCaloRecPointHeaderStruct); | |
202 | ||
203 | // HLTError("Number of clusters: %d", nRecPoints); | |
204 | ||
205 | AliHLTComponentBlockData bd; | |
206 | FillBlockData( bd ); | |
207 | bd.fOffset = offset; | |
208 | bd.fSize = mysize; | |
209 | bd.fDataType = AliHLTCaloDefinitions::fgkClusterDataType; | |
210 | bd.fSpecification = specification; | |
211 | outputBlocks.push_back( bd ); | |
212 | } | |
213 | ||
4d42193f | 214 | size = mysize; |
215 | ||
216 | return 0; | |
217 | } | |
218 | ||
219 | int | |
220 | AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) | |
221 | { | |
222 | // see header file for class documentation | |
223 | ||
224 | const char* path="HLT/ConfigPHOS/ClusterizerComponent"; | |
225 | ||
226 | if (cdbEntry) path = cdbEntry; | |
227 | ||
228 | return ConfigureFromCDBTObjString(cdbEntry); | |
229 | } | |
230 | ||
231 | int | |
232 | AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) | |
233 | { | |
234 | //See header file for documentation | |
235 | ||
236 | if(argc <= 0) return 0; | |
237 | ||
238 | int i=0; | |
239 | ||
240 | TString argument=argv[i]; | |
241 | ||
242 | if (argument.CompareTo("-digitthreshold") == 0) | |
243 | { | |
244 | if (++i >= argc) return -EPROTO; | |
245 | argument = argv[i]; | |
246 | fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); | |
247 | return 1; | |
248 | } | |
249 | ||
250 | if (argument.CompareTo("-recpointthreshold") == 0) | |
251 | { | |
252 | if (++i >= argc) return -EPROTO; | |
253 | argument = argv[i]; | |
254 | fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); | |
255 | return 1; | |
256 | } | |
257 | return 0; | |
258 | } | |
259 | ||
260 | int | |
261 | AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) | |
262 | { | |
263 | //See headerfile for documentation | |
264 | ||
ad44d760 | 265 | |
4d42193f | 266 | // |
267 | ||
268 | // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; | |
269 | ||
270 | // ConfigureFromCDBTObjString(path); | |
271 | ||
272 | for (int i = 0; i < argc; i++) | |
273 | { | |
274 | ScanConfigurationArgument(i, argv); | |
275 | } | |
276 | ||
277 | return 0; | |
278 | } | |
279 | ||
ad44d760 | 280 | Int_t |
281 | AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1) | |
4d42193f | 282 | { |
ad44d760 | 283 | // See header file for documentation |
284 | return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
4d42193f | 285 | } |