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
58 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
60 //See headerfile for documentation
64 delete fClusterizerPtr;
70 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
71 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
72 std::vector<AliHLTComponentBlockData>& outputBlocks)
74 //See headerfile for documentation
76 if(blocks == 0) return 0;
84 UInt_t availableSize = size;
85 AliHLTUInt8_t* outBPtr;
87 const AliHLTComponentBlockData* iter = 0;
90 UInt_t specification = 0;
92 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
94 // Adding together all the digits, should be put in standalone method
95 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
98 // HLTError("Got block");
99 if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
102 // Update the number of digits
103 nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
104 availableSize -= iter->fSize;
106 specification = specification|iter->fSpecification;
108 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
109 for (Int_t i = 0; i < nDigits; i++)
111 fDigitsPointerArray[digCount] = digitDataPtr;
121 AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
122 caloClusterHeaderPtr->fNDigits = digCount;
124 outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
125 mysize += sizeof(AliHLTCaloClusterHeaderStruct);
127 // Sort the digit pointers
128 qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
130 // Copy the digits to the output
131 fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
132 for(Int_t n = 0; n < digCount; n++)
134 memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
135 //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
136 outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
139 mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
141 //HLTDebug("Total number of digits: %d", digCount );
143 nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
145 //HLTDebug("Number of rec points found: %d", nRecPoints);
146 fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
148 fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
150 fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
152 Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
156 caloClusterHeaderPtr->fNClusters = 0;
160 caloClusterHeaderPtr->fNClusters = nClusters;
163 //HLTDebug("Number of clusters: %d", nRecPoints);
165 AliHLTComponentBlockData bd;
169 bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
170 bd.fSpecification = specification;
171 outputBlocks.push_back( bd );
180 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
182 // see header file for class documentation
184 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
186 if (cdbEntry) path = cdbEntry;
188 return ConfigureFromCDBTObjString(cdbEntry);
192 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
194 //See header file for documentation
196 if(argc <= 0) return 0;
200 TString argument=argv[i];
202 if (argument.CompareTo("-digitthreshold") == 0)
204 if (++i >= argc) return -EPROTO;
206 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
210 if (argument.CompareTo("-recpointthreshold") == 0)
212 if (++i >= argc) return -EPROTO;
214 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
218 if (argument.CompareTo("-cutonsinglecell") == 0)
220 if (++i >= argc) return -EPROTO;
222 fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof());
230 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
232 //See headerfile for documentation
234 fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
236 fClusterizerPtr = new AliHLTCaloClusterizer(fCaloConstants->GetDETNAME());
238 fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
240 fAnalyserPtr = new AliHLTCaloClusterAnalyser();
242 if(fCaloConstants->GetDETNAME() == "PHOS")
244 fAnalyserPtr->SetClusterType(kPHOSCluster);
246 else if(fCaloConstants->GetDETNAME() == "EMCAL")
248 fAnalyserPtr->SetClusterType(kEMCALClusterv1);
252 fAnalyserPtr->SetClusterType(kUndef);
254 InitialiseGeometry();
257 if(!fRecoParamsPtr->GetParametersFromCDB())
259 fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
260 fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
261 fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
266 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
268 // ConfigureFromCDBTObjString(path);
270 for (int i = 0; i < argc; i++)
272 ScanConfigurationArgument(i, argv);
277 int AliHLTCaloClusterizerComponent::DoDeinit()
279 // See header file for documentation
280 if(fDigitsPointerArray)
282 delete [] fDigitsPointerArray;
283 fDigitsPointerArray = 0;
287 delete fClusterizerPtr;
299 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
301 // See header file for documentation
302 return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
304 //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;