]>
Commit | Line | Data |
---|---|---|
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 "AliHLTCaloClusterizerComponent.h" | |
18 | #include "AliHLTCaloClusterizer.h" | |
19 | #include "AliHLTCaloClusterAnalyser.h" | |
20 | #include "AliHLTCaloRecPointDataStruct.h" | |
21 | #include "AliHLTCaloRecPointHeaderStruct.h" | |
22 | #include "AliHLTCaloDigitDataStruct.h" | |
23 | #include "AliHLTCaloDigitContainerDataStruct.h" | |
24 | #include "AliHLTCaloDefinitions.h" | |
25 | #include "AliHLTCaloClusterDataStruct.h" | |
26 | #include "TString.h" | |
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 | ||
40 | AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): | |
41 | AliHLTCaloProcessor(), | |
42 | AliHLTCaloConstantsHandler(det), | |
43 | fDataOrigin('\0'), | |
44 | fAnalyserPtr(0), | |
45 | fDigitsPointerArray(0), | |
46 | fOutputDigitsArray(0), | |
47 | fClusterizerPtr(0), | |
48 | fDigitCount(0) | |
49 | { | |
50 | //See headerfile for documentation | |
51 | ||
52 | fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()]; | |
53 | ||
54 | fClusterizerPtr = new AliHLTCaloClusterizer(det); | |
55 | ||
56 | fClusterizerPtr->SetDigitArray(fDigitsPointerArray); | |
57 | ||
58 | fAnalyserPtr = new AliHLTCaloClusterAnalyser(); | |
59 | ||
60 | if(det == "PHOS") | |
61 | { | |
62 | fAnalyserPtr->SetClusterType(kPHOSCluster); | |
63 | } | |
64 | else if(det == "EMCAL") | |
65 | { | |
66 | fAnalyserPtr->SetClusterType(kEMCALClusterv1); | |
67 | } | |
68 | else | |
69 | { | |
70 | fAnalyserPtr->SetClusterType(kUndef); | |
71 | } | |
72 | ||
73 | ||
74 | } | |
75 | ||
76 | AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() | |
77 | { | |
78 | //See headerfile for documentation | |
79 | delete fAnalyserPtr; | |
80 | if(fClusterizerPtr) | |
81 | { | |
82 | delete fClusterizerPtr; | |
83 | fClusterizerPtr = 0; | |
84 | } | |
85 | } | |
86 | ||
87 | ||
88 | int | |
89 | AliHLTCaloClusterizerComponent::Deinit() | |
90 | { | |
91 | //See headerfile for documentation | |
92 | ||
93 | if (fClusterizerPtr) | |
94 | { | |
95 | delete fClusterizerPtr; | |
96 | fClusterizerPtr = 0; | |
97 | } | |
98 | ||
99 | return 0; | |
100 | } | |
101 | ||
102 | int | |
103 | AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
104 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
105 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
106 | { | |
107 | //See headerfile for documentation | |
108 | ||
109 | if(blocks == 0) return 0; | |
110 | ||
111 | UInt_t offset = 0; | |
112 | UInt_t mysize = 0; | |
113 | Int_t nRecPoints = 0; | |
114 | Int_t nDigits = 0; | |
115 | Int_t digCount = 0; | |
116 | ||
117 | UInt_t availableSize = size; | |
118 | AliHLTUInt8_t* outBPtr; | |
119 | outBPtr = outputPtr; | |
120 | const AliHLTComponentBlockData* iter = 0; | |
121 | unsigned long ndx; | |
122 | ||
123 | UInt_t specification = 0; | |
124 | ||
125 | AliHLTCaloDigitDataStruct *digitDataPtr = 0; | |
126 | ||
127 | // Adding together all the digits, should be put in standalone method | |
128 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
129 | { | |
130 | iter = blocks+ndx; | |
131 | // HLTError("Got block"); | |
132 | if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin)) | |
133 | { | |
134 | ||
135 | // Update the number of digits | |
136 | nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);; | |
137 | ||
138 | availableSize -= iter->fSize; | |
139 | ||
140 | specification = specification|iter->fSpecification; | |
141 | ||
142 | digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
143 | for (Int_t i = 0; i < nDigits; i++) | |
144 | { | |
145 | fDigitsPointerArray[digCount] = digitDataPtr; | |
146 | digCount++; | |
147 | digitDataPtr++; | |
148 | } | |
149 | } | |
150 | } | |
151 | ||
152 | if(digCount > 0) | |
153 | { | |
154 | ||
155 | AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr); | |
156 | caloClusterHeaderPtr->fNDigits = digCount; | |
157 | ||
158 | outBPtr += sizeof(AliHLTCaloClusterHeaderStruct); | |
159 | mysize += sizeof(AliHLTCaloClusterHeaderStruct); | |
160 | ||
161 | // Sort the digit pointers | |
162 | qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits); | |
163 | ||
164 | // Copy the digits to the output | |
165 | fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
166 | for(Int_t n = 0; n < digCount; n++) | |
167 | { | |
168 | memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct)); | |
169 | //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
170 | outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct); | |
171 | } | |
172 | ||
173 | mysize += digCount*sizeof(AliHLTCaloDigitDataStruct); | |
174 | ||
175 | //HLTDebug("Total number of digits: %d", digCount ); | |
176 | ||
177 | nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount); | |
178 | ||
179 | //HLTDebug("Number of rec points found: %d", nRecPoints); | |
180 | ||
181 | fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr)); | |
182 | ||
183 | fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints); | |
184 | ||
185 | fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray); | |
186 | ||
187 | Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize); | |
188 | ||
189 | caloClusterHeaderPtr->fNClusters = nClusters; | |
190 | ||
191 | //HLTDebug("Number of clusters: %d", nRecPoints); | |
192 | ||
193 | AliHLTComponentBlockData bd; | |
194 | FillBlockData( bd ); | |
195 | bd.fOffset = offset; | |
196 | bd.fSize = mysize; | |
197 | bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin; | |
198 | bd.fSpecification = specification; | |
199 | outputBlocks.push_back( bd ); | |
200 | } | |
201 | ||
202 | size = mysize; | |
203 | ||
204 | return 0; | |
205 | } | |
206 | ||
207 | int | |
208 | AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) | |
209 | { | |
210 | // see header file for class documentation | |
211 | ||
212 | const char* path="HLT/ConfigPHOS/ClusterizerComponent"; | |
213 | ||
214 | if (cdbEntry) path = cdbEntry; | |
215 | ||
216 | return ConfigureFromCDBTObjString(cdbEntry); | |
217 | } | |
218 | ||
219 | int | |
220 | AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) | |
221 | { | |
222 | //See header file for documentation | |
223 | ||
224 | if(argc <= 0) return 0; | |
225 | ||
226 | int i=0; | |
227 | ||
228 | TString argument=argv[i]; | |
229 | ||
230 | if (argument.CompareTo("-digitthreshold") == 0) | |
231 | { | |
232 | if (++i >= argc) return -EPROTO; | |
233 | argument = argv[i]; | |
234 | fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); | |
235 | return 1; | |
236 | } | |
237 | ||
238 | if (argument.CompareTo("-recpointthreshold") == 0) | |
239 | { | |
240 | if (++i >= argc) return -EPROTO; | |
241 | argument = argv[i]; | |
242 | fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); | |
243 | return 1; | |
244 | } | |
245 | return 0; | |
246 | } | |
247 | ||
248 | int | |
249 | AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) | |
250 | { | |
251 | //See headerfile for documentation | |
252 | ||
253 | ||
254 | // | |
255 | ||
256 | // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; | |
257 | ||
258 | // ConfigureFromCDBTObjString(path); | |
259 | ||
260 | for (int i = 0; i < argc; i++) | |
261 | { | |
262 | ScanConfigurationArgument(i, argv); | |
263 | } | |
264 | ||
265 | return 0; | |
266 | } | |
267 | ||
268 | Int_t | |
269 | AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1) | |
270 | { | |
271 | // See header file for documentation | |
272 | return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
273 | ||
274 | //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
275 | } |