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