1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
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 **************************************************************************/
18 #include "AliHLTPHOSClusterizerComponent.h"
19 #include "AliHLTPHOSClusterizer.h"
20 //#include "AliHLTPHOSPhysicsDefinitions.h"
21 //#include "AliHLTPHOSDefinitions.h"
22 #include "AliHLTPHOSRecPointDataStruct.h"
23 //#include "AliHLTPHOSClusterDataStruct.h"
24 //#include "AliHLTPHOSRecPointListDataStruct.h"
25 #include "AliHLTPHOSDigitContainerDataStruct.h"
29 /** @file AliHLTPHOSClusterizerComponent.cxx
30 @author Oystein Djuvsland
32 @brief A clusterizer component for PHOS HLT
35 // see header file for class documentation
37 // refer to README to build package
39 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
47 kAliHLTVoidDataType,{0,"",""}
50 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
52 //AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSBase(), AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0),
53 // fRecPointStructArrayPtr(0), fRecPointListPtr(0)
54 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
55 fRecPointStructArrayPtr(0) //, fRecPointListPtr(0)
57 //See headerfile for documentation
60 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
62 //See headerfile for documentation
66 delete fClusterizerPtr;
72 delete fRecPointListPtr;
76 if (fRecPointStructArrayPtr)
78 for (int i = 0; i < 1000; i++)
80 // fRecPointStructArrayPtr[i].Del();
82 delete fRecPointStructArrayPtr;
83 fRecPointStructArrayPtr = 0;
90 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent::Deinit()
92 ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
96 // PTH AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
97 // fClusterizerPtr(0),
99 // fRecPointStructArrayPtr(0),
100 // fRecPointListPtr(0)
102 //Copy constructor, not implemented
106 AliHLTPHOSClusterizerComponent::Deinit()
108 //See headerfile for documentation
112 delete fClusterizerPtr;
116 if (fRecPointListPtr)
118 delete fRecPointListPtr;
119 fRecPointListPtr = 0;
122 for (int i = 0; i < 1000; i++)
124 // fRecPointStructArrayPtr[i].Del();
127 if (fRecPointStructArrayPtr)
129 for (int i = 0; i < 1000; i++)
131 // fRecPointStructArrayPtr[i].Del();
133 delete fRecPointStructArrayPtr;
134 fRecPointStructArrayPtr = 0;
141 AliHLTPHOSClusterizerComponent::GetComponentID()
143 //See headerfile for documentation
145 return "AliHltPhosClusterizer";
149 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
151 //See headerfile for documentation
153 const AliHLTComponentDataType* pType=fgkInputDataTypes;
154 while (pType->fID!=0)
156 list.push_back(*pType);
161 AliHLTComponentDataType
162 AliHLTPHOSClusterizerComponent::GetOutputDataType()
164 //See headerfile for documentation
166 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
170 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
173 //See headerfile for documentation
176 inputMultiplier = 0.2;
180 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
181 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
182 std::vector<AliHLTComponentBlockData>& outputBlocks)
184 //See headerfile for documentation
189 Int_t nRecPoints = 0;
194 AliHLTUInt8_t* outBPtr;
196 const AliHLTComponentBlockData* iter = 0;
199 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
201 //AliHLTPHOSRecPointContainerStruct *recPointContainerPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
202 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
203 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
206 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
207 if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
209 // cout << "Warning: data type is not fgkAliHLTDigitDataType " << endl;
212 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
214 if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
217 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
218 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
219 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
220 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
221 // fAllDigitsPtr->fDigitDataStruct[i+nDigits].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
227 fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
228 nRecPoints = fClusterizerPtr->ClusterizeEvent();
229 //nRecPoints = fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
230 cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
235 // fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
236 // fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
238 // mysize += sizeof(AliHLTPHOSClusterDataStruct);
239 mysize += sizeof(AliHLTPHOSRecPointDataStruct);
242 AliHLTComponentBlockData bd;
246 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
247 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
248 bd.fSpecification = 0xFFFFFFFF;
249 outputBlocks.push_back( bd );
256 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
257 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
264 // fClusterizerPtr->ResetCellEnergyArray();
271 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
273 //See headerfile for documentation
275 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
276 fClusterizerPtr = new AliHLTPHOSClusterizer();
277 //fClusterizerPtr->SetNoCrazyness(true);
279 for (int i = 0; i < argc; i++)
282 if(!strcmp("-energythreshold", argv[i]))
283 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
284 if(!strcmp("-clusterthreshold", argv[i]))
285 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
286 if(!strcmp("-highgain", argv[i]))
287 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
288 if(!strcmp("-lowgain", argv[i]))
289 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
290 if(!strcmp("-arraysize", argv[i]))
291 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
293 // fClusterizerPtr->ResetCellEnergyArray();
296 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
297 for (int i = 0; i < 1000; i++)
299 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
300 // fRecPointStructArrayPtr[i].New();
303 printf("Clusterizer component started with:\n");
304 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
305 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
306 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
307 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
308 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
314 AliHLTPHOSClusterizerComponent::Spawn()
316 //See headerfile for documentation
318 return new AliHLTPHOSClusterizerComponent();