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"
29 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
31 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
33 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSBase(), AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0),
34 fRecPointStructArrayPtr(0), fRecPointListPtr(0)
39 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
45 delete fClusterizerPtr;
51 delete fRecPointListPtr;
55 if(fRecPointStructArrayPtr)
57 for(int i = 0; i < 1000; i++)
59 fRecPointStructArrayPtr[i].Del();
61 delete fRecPointStructArrayPtr;
62 fRecPointStructArrayPtr = 0;
67 // PTH AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
68 // fClusterizerPtr(0),
70 // fRecPointStructArrayPtr(0),
71 // fRecPointListPtr(0)
73 //Copy constructor, not implemented
77 AliHLTPHOSClusterizerComponent::Deinit()
83 delete fClusterizerPtr;
89 delete fRecPointListPtr;
93 for(int i = 0; i < 1000; i++)
95 fRecPointStructArrayPtr[i].Del();
98 if(fRecPointStructArrayPtr)
100 for(int i = 0; i < 1000; i++)
102 fRecPointStructArrayPtr[i].Del();
104 delete fRecPointStructArrayPtr;
105 fRecPointStructArrayPtr = 0;
116 AliHLTPHOSClusterizerComponent::DoDeinit()
118 //Do deinitialization
119 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit");
126 AliHLTPHOSClusterizerComponent::GetComponentID()
128 return "AliHltPhosClusterizer";
132 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
134 //Get datatypes for input
135 const AliHLTComponentDataType* pType=fgkInputDataTypes;
136 while (pType->fID!=0) {
137 list.push_back(*pType);
142 AliHLTComponentDataType
143 AliHLTPHOSClusterizerComponent::GetOutputDataType()
145 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
146 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
150 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
154 inputMultiplier = 0.2;
158 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
159 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
160 std::vector<AliHLTComponentBlockData>& outputBlocks)
167 Int_t nRecPoints = 0;
170 AliHLTUInt8_t* outBPtr;
172 const AliHLTComponentBlockData* iter = 0;
175 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
179 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
181 cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
184 index = fClusterizerPtr->BuildCellEnergyArray( reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr),
189 nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
191 cout << "Number of clusters found: " << nRecPoints << endl;
193 for(Int_t i = 0; i < nRecPoints; i++)
198 fOutPtr = (AliHLTPHOSClusterDataStruct*)outBPtr;
199 fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
200 // fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
201 // fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
203 mysize += sizeof(AliHLTPHOSClusterDataStruct);
205 AliHLTComponentBlockData bd;
209 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
210 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
211 bd.fSpecification = 0xFFFFFFFF;
212 outputBlocks.push_back( bd );
219 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
220 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
227 fClusterizerPtr->ResetCellEnergyArray();
234 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
237 fClusterizerPtr = new AliHLTPHOSClusterizer();
238 for(int i = 0; i < argc; i++)
240 if(!strcmp("-threshold", argv[i]))
241 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
242 if(!strcmp("-clusterthreshold", argv[i]))
243 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
244 if(!strcmp("-highgain", argv[i]))
245 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
246 if(!strcmp("-lowgain", argv[i]))
247 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
248 if(!strcmp("-arraysize", argv[i]))
249 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));
251 fClusterizerPtr->ResetCellEnergyArray();
252 fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ZROWS_MOD*N_XCOLUMNS_MOD];
253 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
254 for(int i = 0; i < 1000; i++)
256 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
257 fRecPointStructArrayPtr[i].New();
259 printf("Clusterizer component started with:\n");
260 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
261 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
262 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
263 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
264 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
270 AliHLTPHOSClusterizerComponent::Spawn()
272 //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
273 return new AliHLTPHOSClusterizerComponent();