1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Ã
\98ystein 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"
30 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
32 kAliHLTVoidDataType,{0,"",""}
35 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
37 //AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSBase(), AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0),
38 // fRecPointStructArrayPtr(0), fRecPointListPtr(0)
39 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
40 fRecPointStructArrayPtr(0), fRecPointListPtr(0)
45 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
51 delete fClusterizerPtr;
57 delete fRecPointListPtr;
61 if (fRecPointStructArrayPtr)
63 for (int i = 0; i < 1000; i++)
65 // fRecPointStructArrayPtr[i].Del();
67 delete fRecPointStructArrayPtr;
68 fRecPointStructArrayPtr = 0;
75 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent::Deinit()
77 ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
81 // PTH AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
82 // fClusterizerPtr(0),
84 // fRecPointStructArrayPtr(0),
85 // fRecPointListPtr(0)
87 //Copy constructor, not implemented
91 AliHLTPHOSClusterizerComponent::Deinit()
97 delete fClusterizerPtr;
101 if (fRecPointListPtr)
103 delete fRecPointListPtr;
104 fRecPointListPtr = 0;
107 for (int i = 0; i < 1000; i++)
109 // fRecPointStructArrayPtr[i].Del();
112 if (fRecPointStructArrayPtr)
114 for (int i = 0; i < 1000; i++)
116 // fRecPointStructArrayPtr[i].Del();
118 delete fRecPointStructArrayPtr;
119 fRecPointStructArrayPtr = 0;
126 AliHLTPHOSClusterizerComponent::DoDeinit()
128 //Do deinitialization
129 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit");
136 AliHLTPHOSClusterizerComponent::GetComponentID()
139 return "AliHltPhosClusterizer";
143 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
145 //Get datatypes for input
146 const AliHLTComponentDataType* pType=fgkInputDataTypes;
147 while (pType->fID!=0)
149 list.push_back(*pType);
154 AliHLTComponentDataType
155 AliHLTPHOSClusterizerComponent::GetOutputDataType()
157 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
158 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
162 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
166 inputMultiplier = 0.2;
170 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
171 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
172 std::vector<AliHLTComponentBlockData>& outputBlocks)
179 Int_t nRecPoints = 0;
184 AliHLTUInt8_t* outBPtr;
186 const AliHLTComponentBlockData* iter = 0;
189 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
191 //AliHLTPHOSRecPointContainerStruct *recPointContainerPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
192 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
193 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
196 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
197 if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
199 // cout << "Warning: data type is not fgkAliHLTDigitDataType " << endl;
202 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
204 if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
207 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
208 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
209 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
210 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
211 // fAllDigitsPtr->fDigitDataStruct[i+nDigits].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
217 // nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
219 fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
220 nRecPoints = fClusterizerPtr->ClusterizeEvent();
221 //nRecPoints = fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
222 cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
227 // fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
228 // fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
230 mysize += sizeof(AliHLTPHOSClusterDataStruct);
232 AliHLTComponentBlockData bd;
236 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
237 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
238 bd.fSpecification = 0xFFFFFFFF;
239 outputBlocks.push_back( bd );
246 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
247 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
254 // fClusterizerPtr->ResetCellEnergyArray();
261 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
264 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
265 fClusterizerPtr = new AliHLTPHOSClusterizer();
266 //fClusterizerPtr->SetNoCrazyness(true);
268 for (int i = 0; i < argc; i++)
271 if(!strcmp("-threshold", argv[i]))
272 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
273 if(!strcmp("-clusterthreshold", argv[i]))
274 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
275 if(!strcmp("-highgain", argv[i]))
276 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
277 if(!strcmp("-lowgain", argv[i]))
278 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
279 if(!strcmp("-arraysize", argv[i]))
280 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
282 // fClusterizerPtr->ResetCellEnergyArray();
283 fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ZROWS_MOD*N_XCOLUMNS_MOD];
284 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
285 for (int i = 0; i < 1000; i++)
287 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
288 // fRecPointStructArrayPtr[i].New();
291 printf("Clusterizer component started with:\n");
292 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
293 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
294 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
295 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
296 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
302 AliHLTPHOSClusterizerComponent::Spawn()
304 //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
305 return new AliHLTPHOSClusterizerComponent();