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 "AliHLTCaloClusterizerNbyN.h"
20 * @file AliHLTCaloClusterizerNbyN.cxx
21 * @author Oystein Djuvsland
23 * @brief Clusterizer for PHOS HLT
26 // see header file for class documentation
28 // refer to README to build package
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
33 AliHLTCaloClusterizerNbyN::AliHLTCaloClusterizerNbyN(TString det) : AliHLTCaloClusterizer(det)
38 AliHLTCaloClusterizerNbyN::~AliHLTCaloClusterizerNbyN()
43 Int_t AliHLTCaloClusterizerNbyN::ClusterizeEvent(Int_t nDigits)
45 //see header file for documentation
50 fRecPointDataPtr = fFirstRecPointPtr;
53 fSortedByEnergy = true;
56 //Clusterization starts
57 for (Int_t i = 0; i < nDigits; i++)
61 HLTDebug("Digit with energy: %f", fDigitsPointerArray[i]->fEnergy);
63 if (fDigitsPointerArray[i]->fEnergy < fEmcClusteringThreshold)
65 // Since we have sorted by energy the next digit will have even lower energy, so we return
69 if (fDigitsPointerArray[i]->fAssociatedCluster != -1) // Digit is neighbour with a higher energy digit
74 // Check if we enough space to write to, if not we expand it automatically.
78 // Create the rec point and add the digit.
79 // First digit is placed at the fDigits member variable in the recpoint
80 fDigitIndexPtr = &(fRecPointDataPtr->fDigits);
82 fRecPointDataPtr->fAmp = 0;
83 fRecPointDataPtr->fModule = fDigitsPointerArray[i]->fModule;
85 // Assigning the digit to this rec point
86 fRecPointDataPtr->fDigits = i;
87 fUsedSize += sizeof(AliHLTCaloRecPointDataStruct);
89 // Incrementing the pointer to be ready for new entry
92 fRecPointDataPtr->fAmp += fDigitsPointerArray[i]->fEnergy;
95 //fDigitsPointerArray[i]->fEnergy = 0;
96 fDigitsPointerArray[i]->fAssociatedCluster = fNRecPoints;
103 // Then we loop over all the other digits (stupid, I know...)
104 Int_t maxDiff = fN/2;
105 for (Int_t j = 0; j < nDigits; j++)
107 if (fDigitsPointerArray[j]->fEnergy < fEmcMinEnergyThreshold) break; // Sorted by energy
108 if(fDigitsPointerArray[j]->fAssociatedCluster!=-1) continue;//cell is already associated with a cluster (higher energy seed)
109 if(TMath::Abs(fDigitsPointerArray[i]->fTime-fDigitsPointerArray[j]->fTime) >= fEmcTimeGate) continue;//time difference between cell and seed is larger than cut
111 if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) <= maxDiff
112 && TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) <= maxDiff) // The digit is in our grid
114 if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) == 1
115 || TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) == 1) // The digit neighbour to the seed
117 // This means the digit is not a local maximum
118 fDigitsPointerArray[j]->fAssociatedCluster = fNRecPoints;
120 // Check that the buffer is large enough for adding a digit (can be heavily improved wrt performance)
123 // Assigning index to digit
125 fUsedSize += sizeof(Int_t);
127 // Incrementing digit pointer to be ready for new entry
130 // Adding the digit energy to the rec point
131 fRecPointDataPtr->fAmp += fDigitsPointerArray[j]->fEnergy;
139 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
140 fRecPointArray[fNRecPoints] = fRecPointDataPtr;
142 fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitIndexPtr);
146 }//end of clusterization