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 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
64 //See headerfile for documentation
68 delete fClusterizerPtr;
75 AliHLTCaloClusterizerComponent::Deinit()
77 //See headerfile for documentation
81 delete fClusterizerPtr;
89 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
90 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
91 std::vector<AliHLTComponentBlockData>& outputBlocks)
93 //See headerfile for documentation
95 if(blocks == 0) return 0;
103 UInt_t availableSize = size;
104 AliHLTUInt8_t* outBPtr;
106 const AliHLTComponentBlockData* iter = 0;
109 UInt_t specification = 0;
111 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
113 // Adding together all the digits, should be put in standalone method
114 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
117 // HLTError("Got block");
118 if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
121 // Update the number of digits
122 nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);;
124 availableSize -= iter->fSize;
126 specification = specification|iter->fSpecification;
128 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
129 for (Int_t i = 0; i < nDigits; i++)
131 fDigitsPointerArray[digCount] = digitDataPtr;
141 AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
142 caloClusterHeaderPtr->fNDigits = digCount;
144 outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
145 mysize += sizeof(AliHLTCaloClusterHeaderStruct);
147 // Sort the digit pointers
148 qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
150 // Copy the digits to the output
151 fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
152 for(Int_t n = 0; n < digCount; n++)
154 memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
155 //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
156 outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
159 mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
161 //HLTDebug("Total number of digits: %d", digCount );
163 nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
165 //HLTDebug("Number of rec points found: %d", nRecPoints);
167 fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
169 fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
171 fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
173 Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
175 caloClusterHeaderPtr->fNClusters = nClusters;
177 //HLTDebug("Number of clusters: %d", nRecPoints);
179 AliHLTComponentBlockData bd;
183 bd.fDataType = kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS;
184 bd.fSpecification = specification;
185 outputBlocks.push_back( bd );
194 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
196 // see header file for class documentation
198 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
200 if (cdbEntry) path = cdbEntry;
202 return ConfigureFromCDBTObjString(cdbEntry);
206 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
208 //See header file for documentation
210 if(argc <= 0) return 0;
214 TString argument=argv[i];
216 if (argument.CompareTo("-digitthreshold") == 0)
218 if (++i >= argc) return -EPROTO;
220 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
224 if (argument.CompareTo("-recpointthreshold") == 0)
226 if (++i >= argc) return -EPROTO;
228 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
235 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
237 //See headerfile for documentation
242 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
244 // ConfigureFromCDBTObjString(path);
246 for (int i = 0; i < argc; i++)
248 ScanConfigurationArgument(i, argv);
255 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
257 // See header file for documentation
258 return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
260 //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;