]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/CALO/AliHLTCaloClusterizer.h
- added different sorting algorithms for the digits
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloClusterizer.h
index 5ba717e7f9c01f1c61629d0b1385b87df0b59277..f2d2bbbcd6ab4175c1276237959ff60a304afaaa 100644 (file)
 #include "AliHLTCaloRecPointDataStruct.h"\r
 #include "AliHLTCaloDigitContainerDataStruct.h"\r
 #include "AliHLTCaloDigitDataStruct.h"\r
-#include "AliHLTCaloConstantsHandler.h"\r
 #include "TString.h"\r
+#include "AliHLTCaloConstantsHandler.h"\r
 \r
 //#include "AliPHOSGeometry.h"\r
+#include "AliHLTLogging.h"\r
 \r
 class TClonesArray;\r
+class TString;\r
 //class AliPHOSDigit;\r
 //class AliPHOSRecoParamEmc;\r
 //class AliPHOSRecoParam;\r
@@ -60,48 +62,27 @@ class TClonesArray;
  *\r
  * @ingroup alihlt_calo\r
  */\r
-//class AliHLTCaloClusterizer : public AliHLTCaloBase\r
-\r
 \r
 \r
-class AliHLTCaloClusterizer : public AliHLTCaloConstantsHandler\r
+class AliHLTCaloClusterizer : public AliHLTCaloConstantsHandler, public AliHLTLogging\r
 {\r
   \r
 public:\r
   \r
   /** Constructor */\r
   AliHLTCaloClusterizer(TString det);    \r
-  \r
+\r
   /** Destructor */\r
   virtual ~AliHLTCaloClusterizer();\r
-\r
-//   /** Copy constructor */  \r
-//   AliHLTCaloClusterizer(const AliHLTCaloClusterizer &) : \r
-//     //    AliHLTCaloBase(),\r
-//     AliHLTCaloConstantsHandler(new TString("BALLE")),\r
-//     fRecPointDataPtr(0),\r
-//     fDigitDataPtr(0),\r
-//     fEmcClusteringThreshold(0),\r
-//     fEmcMinEnergyThreshold(0),\r
-//     fEmcTimeGate(0),\r
-//     fDigitsInCluster(0),\r
-//     fDigitContainerPtr(0),\r
-//     fMaxDigitIndexDiff(2*NZROWSMOD)\r
-//   {\r
-//     //Copy constructor not implemented\r
-//   }\r
-  \r
-  /** Assignment */\r
-  AliHLTCaloClusterizer & operator = (const AliHLTCaloClusterizer)\r
-  {\r
-    //Assignment\r
-    return *this; \r
-  }\r
   \r
   /** Set digit container */\r
   void SetDigitContainer(AliHLTCaloDigitContainerDataStruct* digitContainerPtr)\r
   { fDigitContainerPtr = digitContainerPtr; }\r
 \r
+  /** Set array with digits */\r
+  void SetDigitArray(AliHLTCaloDigitDataStruct **digitPointerArr)\r
+  { fDigitsPointerArray = digitPointerArr; } \r
+\r
   /** Set rec point data buffer */\r
   void SetRecPointDataPtr(AliHLTCaloRecPointDataStruct* recPointDataPtr);\r
 \r
@@ -118,7 +99,7 @@ public:
   void SetEmcTimeGate(Float_t gate) { fEmcTimeGate = gate; }\r
   \r
   /** Starts clusterization of the event */ \r
-  virtual Int_t ClusterizeEvent(UInt_t availableSize, UInt_t& totSize);\r
+  virtual Int_t ClusterizeEvent(Int_t nDigits);\r
   \r
   /**\r
    * For a given digit this digit scans for neighbouring digits which \r
@@ -127,7 +108,7 @@ public:
    * @param digIndex index of the digit in the digit container\r
    * @param recPoint pointer to the current rec point\r
    */\r
-  virtual void ScanForNeighbourDigits(Int_t digIndex, AliHLTCaloRecPointDataStruct* recPoint);\r
+  virtual Int_t ScanForNeighbourDigits(Int_t digIndex, AliHLTCaloRecPointDataStruct* recPoint);\r
 \r
   /**\r
    * Checks if two digits are neighbours\r
@@ -136,14 +117,84 @@ public:
    */\r
   virtual Int_t AreNeighbours(AliHLTCaloDigitDataStruct* d1, AliHLTCaloDigitDataStruct* d2);\r
 \r
-\r
+  /**\r
+  * Get pointer to the rec points array\r
+  */\r
+  AliHLTCaloRecPointDataStruct** GetRecPoints() const { return fRecPointArray; }\r
+\r
+  /** \r
+  * Sort the digits by energy\r
+  */\r
+  void SetSortDigitsByEnergy();\r
+  \r
+  /** \r
+  * Sort the digits by position\r
+  */\r
+  void SetSortDigitsByPosition();\r
+  \r
+  /** \r
+  * Set the sorting function (as required by stdlib's qsort) if you don't want to use the provided ones \r
+  */\r
+  void SetSortingFunction(Int_t (*compare)(const void*, const void*)) { fCompareFunction = compare; }\r
+  \r
+  \r
+  \r
 protected:\r
 \r
-  /** Pointer to the rec point output */\r
-  AliHLTCaloRecPointDataStruct* fRecPointDataPtr;              //! transient\r
+   /** \r
+   * Check the rec point buffer size and resize the buffer if necessary\r
+   */\r
+  virtual Int_t CheckBuffer(); //COMMENT\r
+  \r
+   /** \r
+   * Check the rec point array size and resize the array if necessary\r
+   */\r
+  virtual Int_t CheckArray(); //COMMENT\r
+  \r
+  /** \r
+  * Sort the digits\r
+  */\r
+  void SortDigits();\r
+\r
+  /** \r
+  * Compare digits by position\r
+  */\r
+  static Int_t CompareDigitsByPosition(const void *dig0, const void *dig);\r
+  \r
+  /** \r
+  * Compare digits by energy\r
+  */\r
+  static Int_t CompareDigitsByEnergy(const void *dig0, const void *dig);\r
+  \r
+  /** \r
+  * Pointer to the compare function for the sorting of digits\r
+  */\r
+  //Int_t (AliHLTCaloClusterizer::*fCompareFunction)(const void*, const void*);\r
+  Int_t (*fCompareFunction)(const void*, const void*);\r
+  \r
+  /** Array of pointers to the rec point output */\r
+  AliHLTCaloRecPointDataStruct **fRecPointArray; //COMMENT\r
+\r
+   /** Pointer to the rec point output */\r
+  AliHLTCaloRecPointDataStruct *fRecPointDataPtr; //COMMENT\r
+\r
+  /** The first rec point in the list */\r
+  AliHLTCaloRecPointDataStruct *fFirstRecPointPtr; //COMMENT\r
 \r
-  /** Pointer to the digit output */\r
-  AliHLTCaloDigitDataStruct* fDigitDataPtr;                    //! transient\r
+  /** Size of the rec point array */\r
+  Int_t fArraySize;\r
+  \r
+  /** Available size for the rec point output */\r
+  Int_t fAvailableSize;\r
+\r
+  /** The used size for the rec point output */\r
+  Int_t fUsedSize;\r
+  \r
+  /** Number of rec points created so far */\r
+  Int_t fNRecPoints;\r
+  \r
+  /** Pointer to the digit index array in the rec point */\r
+  Int_t* fDigitIndexPtr;                                       //! transient\r
 \r
   /** Energy threshold for starting a cluster for the calorimeter */\r
   Float_t fEmcClusteringThreshold;                             //COMMENT\r
@@ -157,17 +208,39 @@ protected:
   /** Counts the digits in a rec point */\r
   Int_t fDigitsInCluster;                                      //COMMENT\r
 \r
+  /** Array of our digits */\r
+  AliHLTCaloDigitDataStruct **fDigitsPointerArray;             //! transient\r
+\r
   /** Contains the digits from one event */\r
   AliHLTCaloDigitContainerDataStruct *fDigitContainerPtr;      //! transient\r
 \r
   /** Maximum difference in index to be a neighbour */\r
   Int_t fMaxDigitIndexDiff;                                    //COMMENT\r
 \r
+  /** Number of digits in event */\r
+  Int_t fNDigits;                                              //COMMENT\r
+  \r
+  /** Are we sorting digits by position? */\r
+  Bool_t fSortedByPosition; //COMMENT\r
+\r
+  /** Are we sorting digits by energy? */\r
+  Bool_t fSortedByEnergy; //COMMENT\r
+\r
+   /** Are we sorting at all? */\r
+   Bool_t fSortDigits; //COMMENT\r
+\r
 private:\r
-  AliHLTCaloClusterizer();\r
 \r
-  ClassDef(AliHLTCaloClusterizer, 0);\r
+  /** Default constructor, prohibited */\r
+  AliHLTCaloClusterizer();                          // COMMENT\r
+  \r
+  /** Copy constructor, prohibited */\r
+  AliHLTCaloClusterizer (const AliHLTCaloClusterizer &); //COMMENT\r
+  \r
+  /** Assignment operator, prohibited */\r
+  AliHLTCaloClusterizer & operator = (const AliHLTCaloClusterizer &); //COMMENT\r
 \r
+  ClassDef(AliHLTCaloClusterizer, 0);\r
 \r
 };\r
 \r