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)
35 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
36 fRecPointStructArrayPtr(0), fRecPointListPtr(0)
41 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
47 delete fClusterizerPtr;
53 delete fRecPointListPtr;
57 if(fRecPointStructArrayPtr)
59 for(int i = 0; i < 1000; i++)
61 fRecPointStructArrayPtr[i].Del();
63 delete fRecPointStructArrayPtr;
64 fRecPointStructArrayPtr = 0;
71 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent::Deinit()
73 ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
77 // PTH AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
78 // fClusterizerPtr(0),
80 // fRecPointStructArrayPtr(0),
81 // fRecPointListPtr(0)
83 //Copy constructor, not implemented
87 AliHLTPHOSClusterizerComponent::Deinit()
93 delete fClusterizerPtr;
99 delete fRecPointListPtr;
100 fRecPointListPtr = 0;
103 for(int i = 0; i < 1000; i++)
105 fRecPointStructArrayPtr[i].Del();
108 if(fRecPointStructArrayPtr)
110 for(int i = 0; i < 1000; i++)
112 fRecPointStructArrayPtr[i].Del();
114 delete fRecPointStructArrayPtr;
115 fRecPointStructArrayPtr = 0;
126 AliHLTPHOSClusterizerComponent::DoDeinit()
128 //Do deinitialization
129 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit");
136 AliHLTPHOSClusterizerComponent::GetComponentID()
138 return "AliHltPhosClusterizer";
142 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
144 //Get datatypes for input
145 const AliHLTComponentDataType* pType=fgkInputDataTypes;
146 while (pType->fID!=0) {
147 list.push_back(*pType);
152 AliHLTComponentDataType
153 AliHLTPHOSClusterizerComponent::GetOutputDataType()
155 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
156 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
160 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
164 inputMultiplier = 0.2;
168 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
169 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
170 std::vector<AliHLTComponentBlockData>& outputBlocks)
177 Int_t nRecPoints = 0;
180 AliHLTUInt8_t* outBPtr;
182 const AliHLTComponentBlockData* iter = 0;
185 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
189 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
191 cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
194 index = fClusterizerPtr->BuildCellEnergyArray( reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr),
199 nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
201 cout << "Number of clusters found: " << nRecPoints << endl;
203 for(Int_t i = 0; i < nRecPoints; i++)
208 fOutPtr = (AliHLTPHOSClusterDataStruct*)outBPtr;
209 fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
210 // fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
211 // fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
213 mysize += sizeof(AliHLTPHOSClusterDataStruct);
215 AliHLTComponentBlockData bd;
219 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
220 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
221 bd.fSpecification = 0xFFFFFFFF;
222 outputBlocks.push_back( bd );
229 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
230 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
237 fClusterizerPtr->ResetCellEnergyArray();
244 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
247 fClusterizerPtr = new AliHLTPHOSClusterizer();
248 for(int i = 0; i < argc; i++)
250 if(!strcmp("-threshold", argv[i]))
251 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
252 if(!strcmp("-clusterthreshold", argv[i]))
253 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
254 if(!strcmp("-highgain", argv[i]))
255 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
256 if(!strcmp("-lowgain", argv[i]))
257 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
258 if(!strcmp("-arraysize", argv[i]))
259 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));
261 fClusterizerPtr->ResetCellEnergyArray();
262 fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ZROWS_MOD*N_XCOLUMNS_MOD];
263 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
264 for(int i = 0; i < 1000; i++)
266 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
267 fRecPointStructArrayPtr[i].New();
269 printf("Clusterizer component started with:\n");
270 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
271 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
272 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
273 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
274 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
280 AliHLTPHOSClusterizerComponent::Spawn()
282 //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
283 return new AliHLTPHOSClusterizerComponent();