1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Øystein 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 **************************************************************************/
16 #include "AliHLTPHOSClusterizerComponent.h"
17 #include "AliHLTPHOSClusterizer.h"
18 #include "AliHLTPHOSPhysicsDefinitions.h"
19 #include "AliHLTPHOSDefinitions.h"
20 #include "AliHLTPHOSRecPointDataStruct.h"
21 #include "AliHLTPHOSClusterDataStruct.h"
22 #include "AliHLTPHOSRecPointListDataStruct.h"
27 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
29 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
31 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0),
32 fRecPointStructArrayPtr(0), fRecPointListPtr(0)
38 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
44 delete fClusterizerPtr;
50 delete fRecPointListPtr;
54 if(fRecPointStructArrayPtr)
56 delete fRecPointStructArrayPtr;
57 fRecPointStructArrayPtr = 0;
62 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
65 fRecPointStructArrayPtr(0),
68 //Copy constructor, not implemented
72 AliHLTPHOSClusterizerComponent::Deinit()
78 delete fClusterizerPtr;
84 delete fRecPointListPtr;
88 if(fRecPointStructArrayPtr)
90 delete fRecPointStructArrayPtr;
91 fRecPointStructArrayPtr = 0;
98 AliHLTPHOSClusterizerComponent::DoDeinit()
100 //Do deinitialization
101 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit");
108 AliHLTPHOSClusterizerComponent::GetComponentID()
110 return "AliHltPhosClusterizer";
114 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
116 //Get datatypes for input
117 const AliHLTComponentDataType* pType=fgkInputDataTypes;
118 while (pType->fID!=0) {
119 list.push_back(*pType);
124 AliHLTComponentDataType
125 AliHLTPHOSClusterizerComponent::GetOutputDataType()
127 return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
131 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
139 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
140 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
141 std::vector<AliHLTComponentBlockData>& outputBlocks)
148 Int_t nRecPoints = 0;
151 AliHLTUInt8_t* outBPtr;
153 const AliHLTComponentBlockData* iter = 0;
156 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
160 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
162 cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
165 index = fClusterizerPtr->BuildCellEnergyArray( reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr),
170 nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
172 for(Int_t i = 0; i < nRecPoints; i++)
177 fOutPtr = (AliHLTPHOSClusterDataStruct*)outBPtr;
178 fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
179 fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
181 mysize += sizeof(AliHLTPHOSClusterDataStruct);
183 AliHLTComponentBlockData bd;
187 bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
188 bd.fSpecification = 0xFFFFFFFF;
189 outputBlocks.push_back( bd );
196 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
197 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
204 fClusterizerPtr->ResetCellEnergyArray();
211 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
215 fClusterizerPtr = new AliHLTPHOSClusterizer();
216 fClusterizerPtr->SetThreshold(atof(argv[0]));
217 fClusterizerPtr->SetClusterThreshold(atof(argv[1]));
218 fClusterizerPtr->SetHighGainFactor(atof(argv[2]));
219 fClusterizerPtr->SetLowGainFactor(atof(argv[3]));
220 fClusterizerPtr->SetArraySize(atoi(argv[4]));
221 fClusterizerPtr->ResetCellEnergyArray();
222 fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ROWS_MOD*N_COLUMNS_MOD];
223 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
225 if (argc==0 && argv==NULL) {
226 // this is currently just to get rid of the warning "unused parameter"
233 AliHLTPHOSClusterizerComponent::Spawn()
235 //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
236 return new AliHLTPHOSClusterizerComponent();