1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Oystein 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 "AliHLTPHOSRecPointDataStruct.h"
19 #include "AliHLTPHOSDigitContainerDataStruct.h"
23 /** @file AliHLTPHOSClusterizerComponent.cxx
24 @author Oystein Djuvsland
26 @brief A clusterizer component for PHOS HLT
29 // see header file for class documentation
31 // refer to README to build package
33 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
39 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
41 kAliHLTVoidDataType,{0,"",""}
44 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
47 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
48 fRecPointStructArrayPtr(0) //, fRecPointListPtr(0)
50 //See headerfile for documentation
53 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
55 //See headerfile for documentation
59 delete fClusterizerPtr;
62 if (fRecPointStructArrayPtr)
64 for (int i = 0; i < 1000; i++)
66 // fRecPointStructArrayPtr[i].Del();
68 delete fRecPointStructArrayPtr;
69 fRecPointStructArrayPtr = 0;
76 AliHLTPHOSClusterizerComponent::Deinit()
78 //See headerfile for documentation
82 delete fClusterizerPtr;
85 for (int i = 0; i < 1000; i++)
87 // fRecPointStructArrayPtr[i].Del();
90 if (fRecPointStructArrayPtr)
92 for (int i = 0; i < 1000; i++)
94 // fRecPointStructArrayPtr[i].Del();
96 delete fRecPointStructArrayPtr;
97 fRecPointStructArrayPtr = 0;
104 AliHLTPHOSClusterizerComponent::GetComponentID()
106 //See headerfile for documentation
108 return "AliHltPhosClusterizer";
112 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
114 //See headerfile for documentation
116 const AliHLTComponentDataType* pType=fgkInputDataTypes;
117 while (pType->fID!=0)
119 list.push_back(*pType);
124 AliHLTComponentDataType
125 AliHLTPHOSClusterizerComponent::GetOutputDataType()
127 //See headerfile for documentation
129 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
133 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
136 //See headerfile for documentation
139 inputMultiplier = 0.2;
143 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
144 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
145 std::vector<AliHLTComponentBlockData>& outputBlocks)
147 //See headerfile for documentation
152 Int_t nRecPoints = 0;
156 AliHLTUInt8_t* outBPtr;
158 const AliHLTComponentBlockData* iter = 0;
161 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
162 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
164 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
167 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
168 if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
172 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
174 if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
177 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
178 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
179 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
180 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
186 fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
187 nRecPoints = fClusterizerPtr->ClusterizeEvent();
188 cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
193 mysize += sizeof(AliHLTPHOSRecPointDataStruct);
195 AliHLTComponentBlockData bd;
199 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
200 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
201 bd.fSpecification = 0xFFFFFFFF;
202 outputBlocks.push_back( bd );
209 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
210 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
217 // fClusterizerPtr->ResetCellEnergyArray();
224 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
226 //See headerfile for documentation
228 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
229 fClusterizerPtr = new AliHLTPHOSClusterizer();
230 //fClusterizerPtr->SetNoCrazyness(true);
232 for (int i = 0; i < argc; i++)
235 if(!strcmp("-energythreshold", argv[i]))
236 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
237 if(!strcmp("-clusterthreshold", argv[i]))
238 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
239 if(!strcmp("-highgain", argv[i]))
240 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
241 if(!strcmp("-lowgain", argv[i]))
242 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
243 if(!strcmp("-arraysize", argv[i]))
244 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
246 // fClusterizerPtr->ResetCellEnergyArray();
249 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
250 for (int i = 0; i < 1000; i++)
252 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
253 // fRecPointStructArrayPtr[i].New();
256 printf("Clusterizer component started with:\n");
257 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
258 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
259 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
260 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
261 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
267 AliHLTPHOSClusterizerComponent::Spawn()
269 //See headerfile for documentation
271 return new AliHLTPHOSClusterizerComponent();