1 // $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $
3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 #include "AliHLTCaloClusterizerComponent.h"
18 #include "AliHLTCaloClusterizer.h"
19 #include "AliHLTCaloClusterAnalyser.h"
20 #include "AliHLTCaloRecPointDataStruct.h"
21 #include "AliHLTCaloRecPointHeaderStruct.h"
22 #include "AliHLTCaloDigitDataStruct.h"
23 #include "AliHLTCaloDigitContainerDataStruct.h"
24 #include "AliHLTCaloDefinitions.h"
25 #include "AliHLTCaloClusterDataStruct.h"
26 #include "AliHLTCaloRecoParamHandler.h"
29 /** @file AliHLTCaloClusterizerComponent.cxx
30 @author Oystein Djuvsland
32 @brief A clusterizer component for PHOS HLT
35 // see header file for class documentation
37 // refer to README to build package
39 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41 AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
42 AliHLTCaloProcessor(),
43 AliHLTCaloConstantsHandler(det),
47 fDigitsPointerArray(0),
48 fOutputDigitsArray(0),
52 //See headerfile for documentation
54 fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
56 fClusterizerPtr = new AliHLTCaloClusterizer(det);
58 fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
60 fAnalyserPtr = new AliHLTCaloClusterAnalyser();
64 fAnalyserPtr->SetClusterType(kPHOSCluster);
66 else if(det == "EMCAL")
68 fAnalyserPtr->SetClusterType(kEMCALClusterv1);
72 fAnalyserPtr->SetClusterType(kUndef);
78 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
80 //See headerfile for documentation
84 delete fClusterizerPtr;
91 AliHLTCaloClusterizerComponent::Deinit()
93 //See headerfile for documentation
97 delete fClusterizerPtr;
105 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
106 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
107 std::vector<AliHLTComponentBlockData>& outputBlocks)
109 //See headerfile for documentation
111 if(blocks == 0) return 0;
115 Int_t nRecPoints = 0;
119 UInt_t availableSize = size;
120 AliHLTUInt8_t* outBPtr;
122 const AliHLTComponentBlockData* iter = 0;
125 UInt_t specification = 0;
127 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
129 // Adding together all the digits, should be put in standalone method
130 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
133 // HLTError("Got block");
134 if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
137 // Update the number of digits
138 nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
139 availableSize -= iter->fSize;
141 specification = specification|iter->fSpecification;
143 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
144 for (Int_t i = 0; i < nDigits; i++)
146 fDigitsPointerArray[digCount] = digitDataPtr;
156 AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
157 caloClusterHeaderPtr->fNDigits = digCount;
159 outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
160 mysize += sizeof(AliHLTCaloClusterHeaderStruct);
162 // Sort the digit pointers
163 qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
165 // Copy the digits to the output
166 fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
167 for(Int_t n = 0; n < digCount; n++)
169 memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
170 //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
171 outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
174 mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
176 //HLTDebug("Total number of digits: %d", digCount );
178 nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
180 //HLTDebug("Number of rec points found: %d", nRecPoints);
181 fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
183 fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
185 fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
187 Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
191 caloClusterHeaderPtr->fNClusters = 0;
195 caloClusterHeaderPtr->fNClusters = nClusters;
198 //HLTDebug("Number of clusters: %d", nRecPoints);
200 AliHLTComponentBlockData bd;
204 bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
205 bd.fSpecification = specification;
206 outputBlocks.push_back( bd );
215 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
217 // see header file for class documentation
219 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
221 if (cdbEntry) path = cdbEntry;
223 return ConfigureFromCDBTObjString(cdbEntry);
227 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
229 //See header file for documentation
231 if(argc <= 0) return 0;
235 TString argument=argv[i];
237 if (argument.CompareTo("-digitthreshold") == 0)
239 if (++i >= argc) return -EPROTO;
241 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
245 if (argument.CompareTo("-recpointthreshold") == 0)
247 if (++i >= argc) return -EPROTO;
249 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
256 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
258 //See headerfile for documentation
262 if(!fRecoParamsPtr->GetParametersFromCDB())
264 fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
265 fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
266 fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
271 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
273 // ConfigureFromCDBTObjString(path);
275 for (int i = 0; i < argc; i++)
277 ScanConfigurationArgument(i, argv);
284 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
286 // See header file for documentation
287 return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
289 //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;