From 4d42193f82ed5646c5d27136a370ba7f0e2007aa Mon Sep 17 00:00:00 2001 From: odjuvsla Date: Wed, 3 Feb 2010 21:48:24 +0000 Subject: [PATCH] - adding clusterizer component to the CALO library --- HLT/CALO/AliHLTCaloClusterizerComponent.cxx | 260 ++++++++++++++++++++ HLT/CALO/AliHLTCaloClusterizerComponent.h | 180 ++++++++++++++ 2 files changed, 440 insertions(+) create mode 100644 HLT/CALO/AliHLTCaloClusterizerComponent.cxx create mode 100644 HLT/CALO/AliHLTCaloClusterizerComponent.h diff --git a/HLT/CALO/AliHLTCaloClusterizerComponent.cxx b/HLT/CALO/AliHLTCaloClusterizerComponent.cxx new file mode 100644 index 00000000000..3e521443bb4 --- /dev/null +++ b/HLT/CALO/AliHLTCaloClusterizerComponent.cxx @@ -0,0 +1,260 @@ +// $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Oystein Djuvsland * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +#include + +#include "AliHLTCaloClusterizerComponent.h" +#include "AliHLTCaloClusterizer.h" +#include "AliHLTCaloRecPointDataStruct.h" +#include "AliHLTCaloRecPointHeaderStruct.h" +#include "AliHLTCaloDigitDataStruct.h" +#include "AliHLTCaloDigitContainerDataStruct.h" +#include "AliHLTCaloDefinitions.h" + +/** @file AliHLTCaloClusterizerComponent.cxx + @author Oystein Djuvsland + @date + @brief A clusterizer component for PHOS HLT +*/ + +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +AliHLTCaloClusterizerComponent gAliHLTCaloClusterizerComponent; + +AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(): + AliHLTPHOSProcessor(), + fAllDigitsPtr(0), + fClusterizerPtr(0), + fDigitCount(0), + fNoCrazyness(0) +{ + //See headerfile for documentation +} + +AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() +{ + //See headerfile for documentation + + if(fClusterizerPtr) + { + delete fClusterizerPtr; + fClusterizerPtr = 0; + } + if(fAllDigitsPtr) + { + delete fAllDigitsPtr; + fAllDigitsPtr = 0; + } +} + + +int +AliHLTCaloClusterizerComponent::Deinit() +{ + //See headerfile for documentation + + if (fClusterizerPtr) + { + delete fClusterizerPtr; + fClusterizerPtr = 0; + } + + return 0; +} + +void +AliHLTCaloClusterizerComponent::GetInputDataTypes( vector& list) +{ + //See headerfile for documentation + list.clear(); + list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType); +} + +AliHLTComponentDataType +AliHLTCaloClusterizerComponent::GetOutputDataType() +{ + //See headerfile for documentation + return AliHLTPHOSDefinitions::fgkRecPointDataType; +} + +void +AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) + +{ + //See headerfile for documentation + constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTPHOSRecPointDataStruct) + (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, + std::vector& outputBlocks) +{ + //See headerfile for documentation + + if(blocks == 0) return 0; + + UInt_t offset = 0; + UInt_t mysize = 0; + Int_t nRecPoints = 0; + Int_t nDigits = 0; + + UInt_t availableSize = size; + AliHLTUInt8_t* outBPtr; + outBPtr = outputPtr; + const AliHLTComponentBlockData* iter = 0; + unsigned long ndx; + + UInt_t specification = 0; + + AliHLTCaloDigitDataStruct *digitDataPtr = 0; + + AliHLTCaloRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast(outBPtr); + + fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast(outBPtr+sizeof(AliHLTCaloRecPointHeaderStruct))); + + // Adding together all the digits, should be put in standalone method + for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) + { + iter = blocks+ndx; + if (iter->fDataType == AliHLTCaloDefinitions::fgkDigitDataType) + { + // Get the digit header + + // Update the number of digits + nDigits += iter->fSize/sizeof(AliHLTCaloDigitDataStruct);; + // Get the specification + specification = specification|iter->fSpecification; + + digitDataPtr = reinterpret_cast(iter->fPtr); + for (Int_t i = 0; i < nDigits; i++) + { + fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX; + fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ; + fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy; + // HLTDebug("Digit energy: %f", digitDataPtr->fEnergy); + fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime; + fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness; + j++; + digitDataPtr++; + } + + } + } + + fAllDigitsPtr->fNDigits = j; + nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize); + + if(nRecPoints == -1) + { + HLTError("Running out of buffer, exiting for safety."); + return -ENOBUFS; + } + + recPointHeaderPtr->fNRecPoints = nRecPoints; + mysize += sizeof(AliHLTCaloRecPointHeaderStruct); + + HLTDebug("Number of clusters: %d", nRecPoints); + + AliHLTComponentBlockData bd; + FillBlockData( bd ); + bd.fOffset = offset; + bd.fSize = mysize; + bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType; + bd.fSpecification = specification; + outputBlocks.push_back( bd ); + + size = mysize; + + return 0; +} + +int +AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) +{ + // see header file for class documentation + + const char* path="HLT/ConfigPHOS/ClusterizerComponent"; + + if (cdbEntry) path = cdbEntry; + + return ConfigureFromCDBTObjString(cdbEntry); +} + +int +AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) +{ + //See header file for documentation + + if(argc <= 0) return 0; + + int i=0; + + TString argument=argv[i]; + + if (argument.CompareTo("-digitthreshold") == 0) + { + if (++i >= argc) return -EPROTO; + argument = argv[i]; + fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); + return 1; + } + + if (argument.CompareTo("-recpointthreshold") == 0) + { + if (++i >= argc) return -EPROTO; + argument = argv[i]; + fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); + return 1; + } + return 0; +} + +int +AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) +{ + //See headerfile for documentation + + fAllDigitsPtr = new AliHLTCaloDigitContainerDataStruct(); + fClusterizerPtr = new AliHLTCaloClusterizer(); + fClusterizerPtr->SetDigitContainer(fAllDigitsPtr); + fNoCrazyness = false; + // + + // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; + + // ConfigureFromCDBTObjString(path); + + for (int i = 0; i < argc; i++) + { + ScanConfigurationArgument(i, argv); + } + + return 0; +} + +AliHLTComponent* +AliHLTCaloClusterizerComponent::Spawn() +{ + //See headerfile for documentation + + return new AliHLTCaloClusterizerComponent(); +} diff --git a/HLT/CALO/AliHLTCaloClusterizerComponent.h b/HLT/CALO/AliHLTCaloClusterizerComponent.h new file mode 100644 index 00000000000..5e67e61a39f --- /dev/null +++ b/HLT/CALO/AliHLTCaloClusterizerComponent.h @@ -0,0 +1,180 @@ +//-*- Mode: C++ -*- +// $Id: AliHLTCaloClusterizerComponent.h 36636 2009-11-11 02:16:41Z odjuvsla $ + + +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * All rights reserved. * + * * + * Primary Authors: Oystein Djuvsland * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +#ifndef ALIHLTPHOSCLUSTERIZERCOMPONENT_H +#define ALIHLTPHOSCLUSTERIZERCOMPONENT_H + + + +/** + * Clusterizer component for PHOS HLT + * + * @file AliHLTCaloClusterizerComponent.h + * @author Oystein Djuvsland + * @date + * @brief A clusterizer component for PHOS HLT +*/ + +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#include "AliHLTPHOSProcessor.h" + +class AliHLTCaloDigitDataStruct; +class AliHLTCaloDigitContainerStruct; +class AliHLTCaloClusterizer; +class AliHLTCaloRecPointDataStruct; + +/** + * @class AliHLTCaloClusterizerComponent + * + * Class for running clusterization for PHOS in HLT. It takes digits as input and + * gives reconstruction points as output. + * + * The component has the following component arguments: + * -clusterthreshold The energy threshold for starting a new rec point + * -energythreshold The energy threshold for including a digit in a + * rec point + * @ingroup alihlt_phos + */ + +/** + * @class AliHLTCaloClusterizerComponent + * + * Class for running clusterization for PHOS in HLT. + * + *

General properties:

+ * + * Component ID: \b PhosClusterizer
+ * Library: \b libAliHLTPHOS.so
+ * Input Data Types: @ref AliHLTPHOSDefinitions::fgkDigitDataType
+ * Output Data Types: @ref AliHLTPHOSDefinitions::fgkRecPointDataType
+ * + *

Mandatory arguments:

+ * + * \li No mandatory arguments for component
+ * + *

Optional arguments:

+ * + * \li -digitthreshold value
+ * threshold for a digit to be added to a rec point in GeV (default value: 0.03) + * \li -recpointthreshold value
+ * threshold for starting a new rec point (default value: 0.2) + * \li -partitionmode + * if we want to do clusterisation on the partition level (not available...) (defaul value: false) + * + *

Configuration:

+ * + * \li No configuration arguments + * + *

Default CDB entries:

+ * \li No CDB entry yet, will come. + * + *

Performance:

+ * Pretty good (~ 3 kHz), depends on amount of data... + * + *

Memory consumption:

+ * Depends on the amount of data, but pretty godd + * + *

Output size:

+ * Depends on the amount of data... + * + * More detailed description. (At some point...) + * + * @ingroup alihlt_phos + */ + +class AliHLTCaloClusterizerComponent: public AliHLTPHOSProcessor + { + public: + + /** Constructor */ + AliHLTCaloClusterizerComponent(); + + /** Destructor */ + virtual ~AliHLTCaloClusterizerComponent(); + + /** Copy constructor */ + AliHLTCaloClusterizerComponent ( const AliHLTCaloClusterizerComponent & ) : + AliHLTPHOSProcessor(), + fAllDigitsPtr ( 0 ), + fClusterizerPtr ( 0 ), + // fRecPointStructArrayPtr(0), + fDigitCount ( 0 ) + { + //Copy constructor not implemented + } + + /** Assignment */ + AliHLTCaloClusterizerComponent & operator = ( const AliHLTCaloClusterizerComponent ) + { + //Assignment + return *this; + } + + /** interface function, see @ref AliHLTComponent for description */ + void GetInputDataTypes ( std::vector& list ) = 0; + + /** interface function, see @ref AliHLTComponent for description */ + AliHLTComponentDataType GetOutputDataType(); + + /** interface function, see @ref AliHLTComponent for description */ + void GetOutputDataSize ( unsigned long& constBase, double& inputMultiplier ); + + /** interface function, see @ref AliHLTComponent for description */ + + using AliHLTPHOSProcessor::DoEvent; + int DoEvent ( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, + std::vector& outputBlocks ); + + protected: + + /** interface function, see @ref AliHLTComponent for description */ + int DoInit ( int argc, const char** argv ); + + /** interface function, see @ref AliHLTComponent for description */ + int Deinit(); + + /** interface function, see @ref AliHLTComponent for description */ + int Reconfigure ( const char* cdbEntry, const char* chainId ); + + /** interface function, see @ref AliHLTComponent for description */ + int ScanConfigurationArgument ( int argc, const char** argv ); + + /** The data type we want */ + AliHLTComponentDataType fDataType; //COMMENT + + private: + + /** Pointer to our digits */ + AliHLTCaloDigitContainerStruct *fAllDigitsPtr; //! transient + + /** Pointer to the clusterizer it self */ + AliHLTCaloClusterizer* fClusterizerPtr; //! transient + + /** Number of digits in event */ + Int_t fDigitCount; //COMMENT + + }; + +#endif -- 2.39.3