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"
28 /** @file AliHLTCaloClusterizerComponent.cxx
29 @author Oystein Djuvsland
31 @brief A clusterizer component for PHOS HLT
34 // see header file for class documentation
36 // refer to README to build package
38 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40 AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
41 AliHLTCaloProcessor(),
42 AliHLTCaloConstantsHandler(det),
45 fDigitsPointerArray(0),
46 fOutputDigitsArray(0),
50 //See headerfile for documentation
52 fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()];
54 fClusterizerPtr = new AliHLTCaloClusterizer(det);
56 fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
58 fAnalyserPtr = new AliHLTCaloClusterAnalyser();
62 fAnalyserPtr->SetClusterType(kPHOSCluster);
64 else if(det == "EMCAL")
66 fAnalyserPtr->SetClusterType(kEMCALClusterv1);
70 fAnalyserPtr->SetClusterType(kUndef);
76 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
78 //See headerfile for documentation
82 delete fClusterizerPtr;
89 AliHLTCaloClusterizerComponent::Deinit()
91 //See headerfile for documentation
95 delete fClusterizerPtr;
103 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
104 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
105 std::vector<AliHLTComponentBlockData>& outputBlocks)
107 //See headerfile for documentation
109 if(blocks == 0) return 0;
113 Int_t nRecPoints = 0;
117 UInt_t availableSize = size;
118 AliHLTUInt8_t* outBPtr;
120 const AliHLTComponentBlockData* iter = 0;
123 UInt_t specification = 0;
125 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
127 // Adding together all the digits, should be put in standalone method
128 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
131 // HLTError("Got block");
132 if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
135 // Update the number of digits
136 nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);;
138 availableSize -= iter->fSize;
140 specification = specification|iter->fSpecification;
142 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
143 for (Int_t i = 0; i < nDigits; i++)
145 fDigitsPointerArray[digCount] = digitDataPtr;
155 AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
156 caloClusterHeaderPtr->fNDigits = digCount;
158 outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
159 mysize += sizeof(AliHLTCaloClusterHeaderStruct);
161 // Sort the digit pointers
162 qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
164 // Copy the digits to the output
165 fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
166 for(Int_t n = 0; n < digCount; n++)
168 memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
169 //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
170 outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
173 mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
175 //HLTDebug("Total number of digits: %d", digCount );
177 nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
179 //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);
189 caloClusterHeaderPtr->fNClusters = nClusters;
191 //HLTDebug("Number of clusters: %d", nRecPoints);
193 AliHLTComponentBlockData bd;
197 bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
198 bd.fSpecification = specification;
199 outputBlocks.push_back( bd );
208 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
210 // see header file for class documentation
212 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
214 if (cdbEntry) path = cdbEntry;
216 return ConfigureFromCDBTObjString(cdbEntry);
220 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
222 //See header file for documentation
224 if(argc <= 0) return 0;
228 TString argument=argv[i];
230 if (argument.CompareTo("-digitthreshold") == 0)
232 if (++i >= argc) return -EPROTO;
234 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
238 if (argument.CompareTo("-recpointthreshold") == 0)
240 if (++i >= argc) return -EPROTO;
242 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
249 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
251 //See headerfile for documentation
256 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
258 // ConfigureFromCDBTObjString(path);
260 for (int i = 0; i < argc; i++)
262 ScanConfigurationArgument(i, argv);
269 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
271 // See header file for documentation
272 return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
274 //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;