]>
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 | |
aac22523 | 15 | |
91b95d47 | 16 | #include "AliHLTPHOSClusterizerComponent.h" |
aac22523 | 17 | #include "AliHLTPHOSClusterizer.h" |
91b95d47 | 18 | #include "AliHLTPHOSRecPointDataStruct.h" |
9cc0deb1 | 19 | #include "AliHLTPHOSDigitContainerDataStruct.h" |
91b95d47 | 20 | |
aac22523 | 21 | |
22 | ||
2374af72 | 23 | /** @file AliHLTPHOSClusterizerComponent.cxx |
24 | @author Oystein Djuvsland | |
25 | @date | |
26 | @brief A clusterizer component for PHOS HLT | |
27 | */ | |
28 | ||
29 | // see header file for class documentation | |
30 | // or | |
31 | // refer to README to build package | |
32 | // or | |
33 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
34 | ||
35 | #if __GNUC__>= 3 | |
36 | using namespace std; | |
37 | #endif | |
38 | ||
9cc0deb1 | 39 | const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]= |
40 | { | |
41 | kAliHLTVoidDataType,{0,"",""} | |
42 | }; | |
aac22523 | 43 | |
44 | AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent; | |
45 | ||
dd9e7d9b | 46 | |
9cc0deb1 | 47 | AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0), |
2374af72 | 48 | fRecPointStructArrayPtr(0) //, fRecPointListPtr(0) |
aac22523 | 49 | { |
2374af72 | 50 | //See headerfile for documentation |
aac22523 | 51 | } |
52 | ||
53 | AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent() | |
54 | { | |
2374af72 | 55 | //See headerfile for documentation |
91b95d47 | 56 | |
9cc0deb1 | 57 | if (fClusterizerPtr) |
91b95d47 | 58 | { |
59 | delete fClusterizerPtr; | |
60 | fClusterizerPtr = 0; | |
61 | } | |
9cc0deb1 | 62 | if (fRecPointStructArrayPtr) |
91b95d47 | 63 | { |
9cc0deb1 | 64 | for (int i = 0; i < 1000; i++) |
65 | { | |
66 | // fRecPointStructArrayPtr[i].Del(); | |
67 | } | |
91b95d47 | 68 | delete fRecPointStructArrayPtr; |
69 | fRecPointStructArrayPtr = 0; | |
70 | } | |
9cc0deb1 | 71 | |
aac22523 | 72 | } |
73 | ||
aac22523 | 74 | |
6e709a0d | 75 | int |
aac22523 | 76 | AliHLTPHOSClusterizerComponent::Deinit() |
77 | { | |
2374af72 | 78 | //See headerfile for documentation |
91b95d47 | 79 | |
9cc0deb1 | 80 | if (fClusterizerPtr) |
91b95d47 | 81 | { |
82 | delete fClusterizerPtr; | |
83 | fClusterizerPtr = 0; | |
84 | } | |
9cc0deb1 | 85 | for (int i = 0; i < 1000; i++) |
6e709a0d | 86 | { |
9cc0deb1 | 87 | // fRecPointStructArrayPtr[i].Del(); |
6e709a0d | 88 | } |
9cc0deb1 | 89 | |
90 | if (fRecPointStructArrayPtr) | |
91b95d47 | 91 | { |
9cc0deb1 | 92 | for (int i = 0; i < 1000; i++) |
93 | { | |
94 | // fRecPointStructArrayPtr[i].Del(); | |
95 | } | |
91b95d47 | 96 | delete fRecPointStructArrayPtr; |
97 | fRecPointStructArrayPtr = 0; | |
98 | } | |
99 | ||
aac22523 | 100 | return 0; |
101 | } | |
102 | ||
9cc0deb1 | 103 | const Char_t* |
aac22523 | 104 | AliHLTPHOSClusterizerComponent::GetComponentID() |
105 | { | |
2374af72 | 106 | //See headerfile for documentation |
a20d23f9 | 107 | |
aac22523 | 108 | return "AliHltPhosClusterizer"; |
109 | } | |
110 | ||
111 | void | |
112 | AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
113 | { | |
2374af72 | 114 | //See headerfile for documentation |
115 | ||
91b95d47 | 116 | const AliHLTComponentDataType* pType=fgkInputDataTypes; |
9cc0deb1 | 117 | while (pType->fID!=0) |
118 | { | |
119 | list.push_back(*pType); | |
120 | pType++; | |
121 | } | |
aac22523 | 122 | } |
123 | ||
9cc0deb1 | 124 | AliHLTComponentDataType |
aac22523 | 125 | AliHLTPHOSClusterizerComponent::GetOutputDataType() |
126 | { | |
2374af72 | 127 | //See headerfile for documentation |
128 | ||
d2b84453 | 129 | return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType; |
aac22523 | 130 | } |
131 | ||
132 | void | |
133 | AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
134 | ||
135 | { | |
2374af72 | 136 | //See headerfile for documentation |
a20d23f9 | 137 | |
aac22523 | 138 | constBase = 30; |
6e709a0d | 139 | inputMultiplier = 0.2; |
aac22523 | 140 | } |
141 | ||
9cc0deb1 | 142 | int |
aac22523 | 143 | AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
9cc0deb1 | 144 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, |
145 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
aac22523 | 146 | { |
2374af72 | 147 | //See headerfile for documentation |
a20d23f9 | 148 | |
aac22523 | 149 | UInt_t tSize = 0; |
9cc0deb1 | 150 | UInt_t offset = 0; |
aac22523 | 151 | UInt_t mysize = 0; |
152 | Int_t nRecPoints = 0; | |
9cc0deb1 | 153 | Int_t nDigits = 0; |
9cc0deb1 | 154 | Int_t j =0; |
aac22523 | 155 | |
156 | AliHLTUInt8_t* outBPtr; | |
157 | outBPtr = outputPtr; | |
9cc0deb1 | 158 | const AliHLTComponentBlockData* iter = 0; |
159 | unsigned long ndx; | |
aac22523 | 160 | |
9cc0deb1 | 161 | AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0; |
9cc0deb1 | 162 | fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr); |
dd9e7d9b | 163 | |
9cc0deb1 | 164 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
aac22523 | 165 | { |
166 | iter = blocks+ndx; | |
9cc0deb1 | 167 | digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr); |
168 | if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType) | |
169 | { | |
9cc0deb1 | 170 | continue; |
171 | } | |
1804b020 | 172 | for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++) |
9cc0deb1 | 173 | { |
174 | if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness) | |
175 | continue; | |
176 | ||
177 | fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX; | |
178 | fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ; | |
179 | fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude; | |
180 | fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime; | |
9cc0deb1 | 181 | j++; |
182 | } | |
183 | nDigits++; | |
aac22523 | 184 | } |
9cc0deb1 | 185 | |
9cc0deb1 | 186 | fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr; |
187 | nRecPoints = fClusterizerPtr->ClusterizeEvent(); | |
9cc0deb1 | 188 | cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl; |
189 | ||
190 | mysize = 0; | |
191 | offset = tSize; | |
192 | ||
2374af72 | 193 | mysize += sizeof(AliHLTPHOSRecPointDataStruct); |
194 | ||
9cc0deb1 | 195 | AliHLTComponentBlockData bd; |
196 | FillBlockData( bd ); | |
197 | bd.fOffset = offset; | |
198 | bd.fSize = mysize; | |
199 | // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType; | |
200 | bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType; | |
201 | bd.fSpecification = 0xFFFFFFFF; | |
202 | outputBlocks.push_back( bd ); | |
203 | ||
204 | tSize += mysize; | |
205 | outBPtr += mysize; | |
206 | ||
207 | if ( tSize > size ) | |
aac22523 | 208 | { |
9cc0deb1 | 209 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data", |
210 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
211 | , tSize, size ); | |
212 | return EMSGSIZE; | |
aac22523 | 213 | } |
214 | ||
9cc0deb1 | 215 | |
aac22523 | 216 | size = tSize; |
9cc0deb1 | 217 | // fClusterizerPtr->ResetCellEnergyArray(); |
aac22523 | 218 | |
219 | return 0; | |
220 | ||
221 | } | |
222 | ||
6e709a0d | 223 | int |
9be2600f | 224 | AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv ) |
aac22523 | 225 | { |
2374af72 | 226 | //See headerfile for documentation |
227 | ||
9cc0deb1 | 228 | fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct(); |
aac22523 | 229 | fClusterizerPtr = new AliHLTPHOSClusterizer(); |
9cc0deb1 | 230 | //fClusterizerPtr->SetNoCrazyness(true); |
231 | // | |
232 | for (int i = 0; i < argc; i++) | |
6e709a0d | 233 | { |
9cc0deb1 | 234 | /* |
2374af72 | 235 | if(!strcmp("-energythreshold", argv[i])) |
9cc0deb1 | 236 | fClusterizerPtr->SetThreshold(atof(argv[i+1])); |
6e709a0d | 237 | if(!strcmp("-clusterthreshold", argv[i])) |
9cc0deb1 | 238 | fClusterizerPtr->SetClusterThreshold(atof(argv[i+1])); |
6e709a0d | 239 | if(!strcmp("-highgain", argv[i])) |
9cc0deb1 | 240 | fClusterizerPtr->SetHighGainFactor(atof(argv[i+1])); |
6e709a0d | 241 | if(!strcmp("-lowgain", argv[i])) |
9cc0deb1 | 242 | fClusterizerPtr->SetLowGainFactor(atof(argv[i+1])); |
6e709a0d | 243 | if(!strcmp("-arraysize", argv[i])) |
9cc0deb1 | 244 | fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/ |
6e709a0d | 245 | } |
9cc0deb1 | 246 | // fClusterizerPtr->ResetCellEnergyArray(); |
2374af72 | 247 | |
248 | ||
aac22523 | 249 | fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000]; |
9cc0deb1 | 250 | for (int i = 0; i < 1000; i++) |
6e709a0d | 251 | { |
252 | fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]); | |
9cc0deb1 | 253 | // fRecPointStructArrayPtr[i].New(); |
6e709a0d | 254 | } |
9cc0deb1 | 255 | /* |
6e709a0d | 256 | printf("Clusterizer component started with:\n"); |
257 | printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold()); | |
258 | printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold()); | |
259 | printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor()); | |
260 | printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor()); | |
261 | printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize()); | |
9cc0deb1 | 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 | } |