]>
Commit | Line | Data |
---|---|---|
91b95d47 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
2374af72 | 4 | * Authors: Oystein Djuvsland <oysteind@ift.uib.no> * |
91b95d47 | 5 | * * |
6 | * Permission to use, copy, modify and distribute this software and its * | |
7 | * documentation strictly for non-commercial purposes is hereby granted * | |
8 | * without fee, provided that the above copyright notice appears in all * | |
9 | * copies and that both the copyright notice and this permission notice * | |
10 | * appear in the supporting documentation. The authors make no claims * | |
11 | * about the suitability of this software for any purpose. It is * | |
12 | * provided "as is" without express or implied warranty. * | |
13 | **************************************************************************/ | |
aac22523 | 14 | |
d949e02e | 15 | #include <iostream> |
aac22523 | 16 | |
91b95d47 | 17 | #include "AliHLTPHOSClusterizerComponent.h" |
aac22523 | 18 | #include "AliHLTPHOSClusterizer.h" |
91b95d47 | 19 | #include "AliHLTPHOSRecPointDataStruct.h" |
9cc0deb1 | 20 | #include "AliHLTPHOSDigitContainerDataStruct.h" |
91b95d47 | 21 | |
aac22523 | 22 | |
23 | ||
2374af72 | 24 | /** @file AliHLTPHOSClusterizerComponent.cxx |
25 | @author Oystein Djuvsland | |
26 | @date | |
27 | @brief A clusterizer component for PHOS HLT | |
28 | */ | |
29 | ||
30 | // see header file for class documentation | |
31 | // or | |
32 | // refer to README to build package | |
33 | // or | |
34 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
35 | ||
36 | #if __GNUC__>= 3 | |
37 | using namespace std; | |
38 | #endif | |
39 | ||
9cc0deb1 | 40 | const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]= |
41 | { | |
42 | kAliHLTVoidDataType,{0,"",""} | |
43 | }; | |
aac22523 | 44 | |
45 | AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent; | |
46 | ||
dd9e7d9b | 47 | |
d949e02e | 48 | AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): |
49 | AliHLTPHOSProcessor(), | |
25b7f84c | 50 | fAllDigitsPtr(0), |
d949e02e | 51 | fClusterizerPtr(0), |
25b7f84c | 52 | fRecPointStructArrayPtr(0), |
53 | fDigitCount(0), | |
54 | fModuleClusterizationMode(false), | |
55 | fNoCrazyness(0) | |
aac22523 | 56 | { |
2374af72 | 57 | //See headerfile for documentation |
aac22523 | 58 | } |
59 | ||
60 | AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent() | |
61 | { | |
2374af72 | 62 | //See headerfile for documentation |
91b95d47 | 63 | |
25b7f84c | 64 | if(fClusterizerPtr) |
91b95d47 | 65 | { |
66 | delete fClusterizerPtr; | |
67 | fClusterizerPtr = 0; | |
68 | } | |
25b7f84c | 69 | if(fRecPointStructArrayPtr) |
91b95d47 | 70 | { |
9cc0deb1 | 71 | for (int i = 0; i < 1000; i++) |
72 | { | |
73 | // fRecPointStructArrayPtr[i].Del(); | |
74 | } | |
91b95d47 | 75 | delete fRecPointStructArrayPtr; |
76 | fRecPointStructArrayPtr = 0; | |
77 | } | |
25b7f84c | 78 | if(fAllDigitsPtr) |
79 | { | |
80 | delete fAllDigitsPtr; | |
81 | fAllDigitsPtr = 0; | |
82 | } | |
aac22523 | 83 | } |
84 | ||
aac22523 | 85 | |
6e709a0d | 86 | int |
aac22523 | 87 | AliHLTPHOSClusterizerComponent::Deinit() |
88 | { | |
2374af72 | 89 | //See headerfile for documentation |
91b95d47 | 90 | |
9cc0deb1 | 91 | if (fClusterizerPtr) |
91b95d47 | 92 | { |
93 | delete fClusterizerPtr; | |
94 | fClusterizerPtr = 0; | |
95 | } | |
9cc0deb1 | 96 | for (int i = 0; i < 1000; i++) |
6e709a0d | 97 | { |
9cc0deb1 | 98 | // fRecPointStructArrayPtr[i].Del(); |
6e709a0d | 99 | } |
9cc0deb1 | 100 | |
101 | if (fRecPointStructArrayPtr) | |
91b95d47 | 102 | { |
9cc0deb1 | 103 | for (int i = 0; i < 1000; i++) |
104 | { | |
105 | // fRecPointStructArrayPtr[i].Del(); | |
106 | } | |
91b95d47 | 107 | delete fRecPointStructArrayPtr; |
108 | fRecPointStructArrayPtr = 0; | |
109 | } | |
110 | ||
aac22523 | 111 | return 0; |
112 | } | |
113 | ||
9cc0deb1 | 114 | const Char_t* |
aac22523 | 115 | AliHLTPHOSClusterizerComponent::GetComponentID() |
116 | { | |
2374af72 | 117 | //See headerfile for documentation |
a20d23f9 | 118 | |
d949e02e | 119 | return "PhosClusterizer"; |
aac22523 | 120 | } |
121 | ||
122 | void | |
123 | AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
124 | { | |
25b7f84c | 125 | list.clear(); |
126 | list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType); | |
aac22523 | 127 | } |
128 | ||
9cc0deb1 | 129 | AliHLTComponentDataType |
aac22523 | 130 | AliHLTPHOSClusterizerComponent::GetOutputDataType() |
131 | { | |
2374af72 | 132 | //See headerfile for documentation |
25b7f84c | 133 | return AliHLTPHOSDefinitions::fgkClusterDataType; |
aac22523 | 134 | } |
135 | ||
136 | void | |
137 | AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
138 | ||
139 | { | |
2374af72 | 140 | //See headerfile for documentation |
aac22523 | 141 | constBase = 30; |
d949e02e | 142 | inputMultiplier = 1; |
aac22523 | 143 | } |
144 | ||
9cc0deb1 | 145 | int |
aac22523 | 146 | AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
25b7f84c | 147 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, |
9cc0deb1 | 148 | std::vector<AliHLTComponentBlockData>& outputBlocks) |
aac22523 | 149 | { |
2374af72 | 150 | //See headerfile for documentation |
b444d727 | 151 | AliHLTComponentTriggerData &trDta = trigData; |
152 | trDta.fDataSize++; | |
153 | trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future | |
154 | ||
aac22523 | 155 | UInt_t tSize = 0; |
9cc0deb1 | 156 | UInt_t offset = 0; |
aac22523 | 157 | UInt_t mysize = 0; |
158 | Int_t nRecPoints = 0; | |
9cc0deb1 | 159 | Int_t j =0; |
aac22523 | 160 | |
161 | AliHLTUInt8_t* outBPtr; | |
162 | outBPtr = outputPtr; | |
9cc0deb1 | 163 | const AliHLTComponentBlockData* iter = 0; |
164 | unsigned long ndx; | |
aac22523 | 165 | |
d949e02e | 166 | UInt_t specification = 0; |
167 | ||
9cc0deb1 | 168 | AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0; |
9cc0deb1 | 169 | fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr); |
25b7f84c | 170 | |
9cc0deb1 | 171 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
aac22523 | 172 | { |
173 | iter = blocks+ndx; | |
25b7f84c | 174 | if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType) |
9cc0deb1 | 175 | { |
25b7f84c | 176 | specification = specification|iter->fSpecification; |
177 | digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr); | |
178 | if(fModuleClusterizationMode) | |
179 | { | |
180 | for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++) | |
181 | { | |
182 | fAllDigitsPtr->fDigitDataStruct[j].fX = digitContainerPtr->fDigitDataStruct[i].fX; | |
183 | fAllDigitsPtr->fDigitDataStruct[j].fZ = digitContainerPtr->fDigitDataStruct[i].fZ; | |
184 | fAllDigitsPtr->fDigitDataStruct[j].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude; | |
185 | fAllDigitsPtr->fDigitDataStruct[j].fTime = digitContainerPtr->fDigitDataStruct[i].fTime; | |
186 | fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness; | |
187 | j++; | |
188 | } | |
189 | ||
190 | } | |
d949e02e | 191 | } |
aac22523 | 192 | } |
25b7f84c | 193 | if(fModuleClusterizationMode && fAllDigitsPtr != 0) |
194 | { | |
195 | fClusterizerPtr->SetDigitContainer(fAllDigitsPtr); | |
196 | } | |
197 | else if(digitContainerPtr != 0) | |
198 | { | |
199 | fClusterizerPtr->SetDigitContainer(digitContainerPtr); | |
200 | } | |
201 | if(digitContainerPtr != 0) | |
202 | { | |
203 | nRecPoints = fClusterizerPtr->ClusterizeEvent(); | |
204 | ||
205 | mysize = 0; | |
206 | offset = tSize; | |
9cc0deb1 | 207 | |
25b7f84c | 208 | mysize += sizeof(AliHLTPHOSRecPointContainerStruct); |
209 | ||
210 | AliHLTComponentBlockData bd; | |
211 | FillBlockData( bd ); | |
212 | bd.fOffset = offset; | |
213 | bd.fSize = mysize; | |
214 | bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType; | |
215 | bd.fSpecification = specification; | |
216 | outputBlocks.push_back( bd ); | |
217 | tSize += mysize; | |
218 | outBPtr += mysize; | |
219 | ||
220 | } | |
221 | ||
9cc0deb1 | 222 | if ( tSize > size ) |
aac22523 | 223 | { |
9cc0deb1 | 224 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data", |
225 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
226 | , tSize, size ); | |
227 | return EMSGSIZE; | |
aac22523 | 228 | } |
d949e02e | 229 | |
aac22523 | 230 | return 0; |
231 | ||
25b7f84c | 232 | |
aac22523 | 233 | } |
234 | ||
6e709a0d | 235 | int |
9be2600f | 236 | AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv ) |
aac22523 | 237 | { |
2374af72 | 238 | //See headerfile for documentation |
239 | ||
9cc0deb1 | 240 | fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct(); |
aac22523 | 241 | fClusterizerPtr = new AliHLTPHOSClusterizer(); |
d949e02e | 242 | fClusterizerPtr->SetDigitContainer(fAllDigitsPtr); |
243 | fNoCrazyness = false; | |
9cc0deb1 | 244 | // |
25b7f84c | 245 | |
246 | ScanArguments(argc, argv); | |
9cc0deb1 | 247 | for (int i = 0; i < argc; i++) |
6e709a0d | 248 | { |
d949e02e | 249 | if(!strcmp("-digitthreshold", argv[i])) |
250 | { | |
251 | fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1])); | |
d949e02e | 252 | } |
253 | if(!strcmp("-recpointthreshold", argv[i])) | |
254 | { | |
255 | fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1])); | |
25b7f84c | 256 | } |
257 | if(!strcmp("-modulemode", argv[i])) | |
258 | { | |
259 | fModuleClusterizationMode = true; | |
d949e02e | 260 | } |
6e709a0d | 261 | } |
2374af72 | 262 | |
aac22523 | 263 | return 0; |
264 | } | |
265 | ||
266 | AliHLTComponent* | |
267 | AliHLTPHOSClusterizerComponent::Spawn() | |
268 | { | |
2374af72 | 269 | //See headerfile for documentation |
270 | ||
aac22523 | 271 | return new AliHLTPHOSClusterizerComponent(); |
272 | } |