* provided "as is" without express or implied warranty. *
**************************************************************************/
-#include <iostream>
-
#include "AliHLTCaloClusterizerComponent.h"
#include "AliHLTCaloClusterizer.h"
+#include "AliHLTCaloClusterAnalyser.h"
#include "AliHLTCaloRecPointDataStruct.h"
#include "AliHLTCaloRecPointHeaderStruct.h"
#include "AliHLTCaloDigitDataStruct.h"
#include "AliHLTCaloDigitContainerDataStruct.h"
#include "AliHLTCaloDefinitions.h"
+#include "AliHLTCaloClusterDataStruct.h"
+#include "AliHLTCaloRecoParamHandler.h"
#include "TString.h"
/** @file AliHLTCaloClusterizerComponent.cxx
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
- AliHLTCaloConstantsHandler(det),
AliHLTCaloProcessor(),
- fDigitsPointerArray(0),
+ AliHLTCaloConstantsHandler(det),
+ fDataOrigin('\0'),
+ fAnalyserPtr(0),
+ fRecoParamsPtr(0),
+ fDigitsPointerArray(0),
+ fOutputDigitsArray(0),
fClusterizerPtr(0),
fDigitCount(0)
-
{
//See headerfile for documentation
-
- fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()];
-
- fClusterizerPtr = new AliHLTCaloClusterizer(det);
-
- fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
-
+
+
+
}
AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
{
//See headerfile for documentation
-
+delete fAnalyserPtr;
if(fClusterizerPtr)
{
delete fClusterizerPtr;
}
}
-
-int
-AliHLTCaloClusterizerComponent::Deinit()
-{
- //See headerfile for documentation
-
- if (fClusterizerPtr)
- {
- delete fClusterizerPtr;
- fClusterizerPtr = 0;
- }
-
- return 0;
-}
-
-// void
-// AliHLTCaloClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
-// {
-// //See headerfile for documentation
-// list.clear();
-// list.push_back(AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS);
-// }
-
-// AliHLTComponentDataType
-// AliHLTCaloClusterizerComponent::GetOutputDataType()
-// {
-// //See headerfile for documentation
-// return AliHLTCaloDefinitions::fgkRecPointDataType|kAliHLTDataOriginPHOS;
-// }
-
-// void
-// AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
-
-// {
-// //See headerfile for documentation
-// constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ;
-// inputMultiplier = 1.5;
-// }
-
int
AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
{
iter = blocks+ndx;
// HLTError("Got block");
- if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS))
+ if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
{
- // Get the digit header
-
- // Update the number of digits
- nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);;
- // HLTError("Got %d digits", nDigits);
+ // Update the number of digits
+ nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
+ availableSize -= iter->fSize;
+
specification = specification|iter->fSpecification;
- digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
- for (Int_t i = 0; i < nDigits; i++)
- {
- fDigitsPointerArray[digCount] = digitDataPtr;
- digCount++;
- digitDataPtr++;
- }
-
+ digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
+ for (Int_t i = 0; i < nDigits; i++)
+ {
+ fDigitsPointerArray[digCount] = digitDataPtr;
+ digCount++;
+ digitDataPtr++;
+ }
}
}
if(digCount > 0)
{
-
+
+ AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
+ caloClusterHeaderPtr->fNDigits = digCount;
+
+ outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
+ mysize += sizeof(AliHLTCaloClusterHeaderStruct);
+
// Sort the digit pointers
- qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
+// qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
// Copy the digits to the output
+ fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
for(Int_t n = 0; n < digCount; n++)
{
memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
+ //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
}
mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
+
+ //HLTDebug("Total number of digits: %d", digCount );
- AliHLTComponentBlockData bdDigits;
- FillBlockData( bdDigits );
- bdDigits.fOffset = offset;
- bdDigits.fSize = mysize;
- bdDigits.fDataType = iter->fDataType;
- bdDigits.fSpecification = specification;
- outputBlocks.push_back( bdDigits );
-
-
- AliHLTCaloRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTCaloRecPointHeaderStruct*>(outBPtr);
+ nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
- fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTCaloRecPointDataStruct*>(outBPtr+sizeof(AliHLTCaloRecPointHeaderStruct)));
-
- // HLTError("Total number of digits: %d", digCount );
+ //HLTDebug("Number of rec points found: %d", nRecPoints);
+ fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
+
+ fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
- printf("Total number of digits: %d\n", digCount);
-
- nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount, size, mysize);
-
- if(nRecPoints == -1)
+ fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
+
+ Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
+
+ if (nClusters < 0)
{
- // HLTError("Running out of buffer, exiting for safety.");
- return -ENOBUFS;
- }
-
- recPointHeaderPtr->fNRecPoints = nRecPoints;
- mysize += sizeof(AliHLTCaloRecPointHeaderStruct);
-
- // HLTError("Number of clusters: %d", nRecPoints);
-
+ caloClusterHeaderPtr->fNClusters = 0;
+ }
+ else
+ {
+ caloClusterHeaderPtr->fNClusters = nClusters;
+ }
+
+ //HLTDebug("Number of clusters: %d", nRecPoints);
+
AliHLTComponentBlockData bd;
FillBlockData( bd );
bd.fOffset = offset;
bd.fSize = mysize;
- bd.fDataType = AliHLTCaloDefinitions::fgkClusterDataType;
+ bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
bd.fSpecification = specification;
outputBlocks.push_back( bd );
}
fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
return 1;
}
+
+ if (argument.CompareTo("-cutonsinglecell") == 0)
+ {
+ if (++i >= argc) return -EPROTO;
+ argument = argv[i];
+ fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof());
+ return 1;
+ }
+ if (argument.CompareTo("-sortbyposition") == 0)
+ {
+ fClusterizerPtr->SetSortDigitsByPosition();
+ return 1;
+ }
+
return 0;
}
{
//See headerfile for documentation
+ fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
+
+ fClusterizerPtr = new AliHLTCaloClusterizer(fCaloConstants->GetDETNAME());
+
+ fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
+
+ fClusterizerPtr->SetSortDigitsByEnergy();
+
+ fAnalyserPtr = new AliHLTCaloClusterAnalyser();
+ if(fCaloConstants->GetDETNAME() == "PHOS")
+ {
+ fAnalyserPtr->SetClusterType(kPHOSCluster);
+ }
+ else if(fCaloConstants->GetDETNAME() == "EMCAL")
+ {
+ fAnalyserPtr->SetClusterType(kEMCALClusterv1);
+ }
+ else
+ {
+ fAnalyserPtr->SetClusterType(kUndef);
+ }
+ InitialiseGeometry();
+ if(fRecoParamsPtr)
+ {
+ if(!fRecoParamsPtr->GetParametersFromCDB())
+ {
+ fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
+ fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
+ fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
+ }
+ }
//
// const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
return 0;
}
+int AliHLTCaloClusterizerComponent::DoDeinit()
+{
+ // See header file for documentation
+ if(fDigitsPointerArray)
+ {
+ delete [] fDigitsPointerArray;
+ fDigitsPointerArray = 0;
+ }
+ if(fClusterizerPtr)
+ {
+ delete fClusterizerPtr;
+ fClusterizerPtr = 0;
+ }
+ if(fAnalyserPtr)
+ {
+ delete fAnalyserPtr;
+ fAnalyserPtr = 0;
+ }
+ return 0;
+}
Int_t
AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
{
// See header file for documentation
return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
+
+ //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
}