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()
138 return "AliHltPhosClusterizer";
142 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
144 //Get datatypes for input
145 const AliHLTComponentDataType* pType=fgkInputDataTypes;
146 while (pType->fID!=0)
148 list.push_back(*pType);
153 AliHLTComponentDataType
154 AliHLTPHOSClusterizerComponent::GetOutputDataType()
156 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
157 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
161 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
165 inputMultiplier = 0.2;
169 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
170 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
171 std::vector<AliHLTComponentBlockData>& outputBlocks)
178 Int_t nRecPoints = 0;
183 AliHLTUInt8_t* outBPtr;
185 const AliHLTComponentBlockData* iter = 0;
188 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
190 //AliHLTPHOSRecPointContainerStruct *recPointContainerPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
191 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
192 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
195 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
196 if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
198 // cout << "Warning: data type is not fgkAliHLTDigitDataType " << endl;
201 for (Int_t i = 0; i < digitContainerPtr->fNDigits; i++)
203 if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
206 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
207 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
208 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
209 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
210 // fAllDigitsPtr->fDigitDataStruct[i+nDigits].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
216 // nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
218 fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
219 nRecPoints = fClusterizerPtr->ClusterizeEvent();
220 //nRecPoints = fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
221 cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
226 // fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
227 // fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
229 mysize += sizeof(AliHLTPHOSClusterDataStruct);
231 AliHLTComponentBlockData bd;
235 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
236 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
237 bd.fSpecification = 0xFFFFFFFF;
238 outputBlocks.push_back( bd );
245 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
246 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
253 // fClusterizerPtr->ResetCellEnergyArray();
260 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
263 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
264 fClusterizerPtr = new AliHLTPHOSClusterizer();
265 //fClusterizerPtr->SetNoCrazyness(true);
267 for (int i = 0; i < argc; i++)
270 if(!strcmp("-threshold", argv[i]))
271 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
272 if(!strcmp("-clusterthreshold", argv[i]))
273 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
274 if(!strcmp("-highgain", argv[i]))
275 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
276 if(!strcmp("-lowgain", argv[i]))
277 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
278 if(!strcmp("-arraysize", argv[i]))
279 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
281 // fClusterizerPtr->ResetCellEnergyArray();
282 fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ZROWS_MOD*N_XCOLUMNS_MOD];
283 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
284 for (int i = 0; i < 1000; i++)
286 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
287 // fRecPointStructArrayPtr[i].New();
290 printf("Clusterizer component started with:\n");
291 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
292 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
293 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
294 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
295 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
301 AliHLTPHOSClusterizerComponent::Spawn()
303 //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
304 return new AliHLTPHOSClusterizerComponent();