]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/CALO/AliHLTCaloClusterizerNbyN.cxx
eliminating resource leaks, implementing data specification for RawReaderPublisher...
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloClusterizerNbyN.cxx
CommitLineData
78943659 1
2
3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
7 * *
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 **************************************************************************/
16
17#include "AliHLTCaloClusterizerNbyN.h"
18
19/**
20 * @file AliHLTCaloClusterizerNbyN.cxx
21 * @author Oystein Djuvsland
22 * @date
23 * @brief Clusterizer for PHOS HLT
24 */
25
26// see header file for class documentation
27// or
28// refer to README to build package
29// or
30// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31
32
33AliHLTCaloClusterizerNbyN::AliHLTCaloClusterizerNbyN(TString det) : AliHLTCaloClusterizer(det)
34,fN(3)
35{
36// Constructor
37}
38AliHLTCaloClusterizerNbyN::~AliHLTCaloClusterizerNbyN()
39{
40// Destructor
41}
42
43Int_t AliHLTCaloClusterizerNbyN::ClusterizeEvent(Int_t nDigits)
44{
45
46 //see header file for documentation
47 Int_t nRecPoints = 0;
48 fNRecPoints = 0;
49 fUsedSize = 0;
50 fNDigits = nDigits;
51 fRecPointDataPtr = fFirstRecPointPtr;
52
53 // Sort our digits
54 fSortedByEnergy = true;
55 SortDigits();
56
57 //Clusterization starts
58 for (Int_t i = 0; i < nDigits; i++)
59 {
60 fDigitsInCluster = 0;
61
62 HLTDebug("Digit with energy: %f", fDigitsPointerArray[i]->fEnergy);
63
64 if (fDigitsPointerArray[i]->fEnergy < fEmcClusteringThreshold)
65 {
66 // Since we have sorted by energy the next digit will have even lower energy, so we return
67 return fNRecPoints;
68 }
69
70 if (fDigitsPointerArray[i]->fAssociatedCluster != -1) // Digit is neighbour with a higher energy digit
71 {
72 continue;
73 }
74
75 // Check if we enough space to write to, if not we expand it automatically.
76 CheckArray();
77 CheckBuffer();
78
79 // Create the rec point and add the digit.
80 // First digit is placed at the fDigits member variable in the recpoint
81 fDigitIndexPtr = &(fRecPointDataPtr->fDigits);
82
83 fRecPointDataPtr->fAmp = 0;
84 fRecPointDataPtr->fModule = fDigitsPointerArray[i]->fModule;
85
86 // Assigning the digit to this rec point
87 fRecPointDataPtr->fDigits = i;
88 fUsedSize += sizeof(AliHLTCaloRecPointDataStruct);
89
90 // Incrementing the pointer to be ready for new entry
91 fDigitIndexPtr++;
92
93 fRecPointDataPtr->fAmp += fDigitsPointerArray[i]->fEnergy;
94
95
96 //fDigitsPointerArray[i]->fEnergy = 0;
97 fDigitsPointerArray[i]->fAssociatedCluster = fNRecPoints;
98
99
100 fDigitsInCluster++;
101 nRecPoints++;
102
103
104 // Then we loop over all the other digits (stupid, I know...)
105 Int_t maxDiff = fN/2;
106 for (Int_t j = 0; j < nDigits; j++)
107 {
108 if (fDigitsPointerArray[j]->fEnergy < fEmcMinEnergyThreshold) break; // Sorted by energy
109
110 if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) <= maxDiff
111 && TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) <= maxDiff) // The digit is in our grid
112 {
113 if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) == 1
114 || TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) == 1) // The digit neighbour to the seed
115 {
116 // This means the digit is not a local maxima
117 fDigitsPointerArray[j]->fAssociatedCluster = fNRecPoints;
118 }
119
120 // Check that the buffer is large enough for adding a digit (can be heavily improved wrt performance)
121 CheckBuffer();
122
123 // Assigning index to digit
124 *fDigitIndexPtr = j;
125 fUsedSize += sizeof(Int_t);
126
127 // Incrementing digit pointer to be ready for new entry
128 fDigitIndexPtr++;
129
130 // Adding the digit energy to the rec point
131 fRecPointDataPtr->fAmp += fDigitsPointerArray[j]->fEnergy;
132
133 // Count it
134 fDigitsInCluster++;
135
136 }
137 }
138
139 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
140 fRecPointArray[fNRecPoints] = fRecPointDataPtr;
141
142 fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitIndexPtr);
143
144 fNRecPoints++;
145
146 }//end of clusterization
147
148 return nRecPoints;
149}
150