Line data Source code
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 :
33 0 : AliHLTCaloClusterizerNbyN::AliHLTCaloClusterizerNbyN(TString det) : AliHLTCaloClusterizer(det)
34 0 : ,fN(3)
35 0 : {
36 : // Constructor
37 0 : }
38 0 : AliHLTCaloClusterizerNbyN::~AliHLTCaloClusterizerNbyN()
39 0 : {
40 : // Destructor
41 0 : }
42 :
43 : Int_t AliHLTCaloClusterizerNbyN::ClusterizeEvent(Int_t nDigits)
44 : {
45 : //see header file for documentation
46 : Int_t nRecPoints = 0;
47 0 : fNRecPoints = 0;
48 0 : fUsedSize = 0;
49 0 : fNDigits = nDigits;
50 0 : fRecPointDataPtr = fFirstRecPointPtr;
51 :
52 : // Sort our digits
53 0 : fSortedByEnergy = true;
54 0 : SortDigits();
55 :
56 : //Clusterization starts
57 0 : for (Int_t i = 0; i < nDigits; i++)
58 : {
59 0 : fDigitsInCluster = 0;
60 :
61 : HLTDebug("Digit with energy: %f", fDigitsPointerArray[i]->fEnergy);
62 :
63 0 : if (fDigitsPointerArray[i]->fEnergy < fEmcClusteringThreshold)
64 : {
65 : // Since we have sorted by energy the next digit will have even lower energy, so we return
66 0 : return fNRecPoints;
67 : }
68 :
69 0 : if (fDigitsPointerArray[i]->fAssociatedCluster != -1) // Digit is neighbour with a higher energy digit
70 : {
71 : continue;
72 : }
73 :
74 : // Check if we enough space to write to, if not we expand it automatically.
75 0 : CheckArray();
76 0 : CheckBuffer();
77 :
78 : // Create the rec point and add the digit.
79 : // First digit is placed at the fDigits member variable in the recpoint
80 0 : fDigitIndexPtr = &(fRecPointDataPtr->fDigits);
81 :
82 0 : fRecPointDataPtr->fAmp = 0;
83 0 : fRecPointDataPtr->fModule = fDigitsPointerArray[i]->fModule;
84 :
85 : // Assigning the digit to this rec point
86 0 : fRecPointDataPtr->fDigits = i;
87 0 : fUsedSize += sizeof(AliHLTCaloRecPointDataStruct);
88 :
89 : // Incrementing the pointer to be ready for new entry
90 0 : fDigitIndexPtr++;
91 :
92 0 : fRecPointDataPtr->fAmp += fDigitsPointerArray[i]->fEnergy;
93 :
94 :
95 : //fDigitsPointerArray[i]->fEnergy = 0;
96 0 : fDigitsPointerArray[i]->fAssociatedCluster = fNRecPoints;
97 :
98 :
99 0 : fDigitsInCluster++;
100 0 : nRecPoints++;
101 :
102 :
103 : // Then we loop over all the other digits (stupid, I know...)
104 0 : Int_t maxDiff = fN/2;
105 0 : for (Int_t j = 0; j < nDigits; j++)
106 : {
107 0 : if (fDigitsPointerArray[j]->fEnergy < fEmcMinEnergyThreshold) break; // Sorted by energy
108 0 : if(fDigitsPointerArray[j]->fAssociatedCluster!=-1) continue;//cell is already associated with a cluster (higher energy seed)
109 0 : if(TMath::Abs(fDigitsPointerArray[i]->fTime-fDigitsPointerArray[j]->fTime) >= fEmcTimeGate) continue;//time difference between cell and seed is larger than cut
110 :
111 0 : if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) <= maxDiff
112 0 : && TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) <= maxDiff) // The digit is in our grid
113 : {
114 0 : if (TMath::Abs(fDigitsPointerArray[i]->fX - fDigitsPointerArray[j]->fX) == 1
115 0 : || TMath::Abs(fDigitsPointerArray[i]->fZ - fDigitsPointerArray[j]->fZ) == 1) // The digit neighbour to the seed
116 : {
117 : // This means the digit is not a local maximum
118 0 : fDigitsPointerArray[j]->fAssociatedCluster = fNRecPoints;
119 :
120 : // Check that the buffer is large enough for adding a digit (can be heavily improved wrt performance)
121 0 : CheckBuffer();
122 :
123 : // Assigning index to digit
124 0 : *fDigitIndexPtr = j;
125 0 : fUsedSize += sizeof(Int_t);
126 :
127 : // Incrementing digit pointer to be ready for new entry
128 0 : fDigitIndexPtr++;
129 :
130 : // Adding the digit energy to the rec point
131 0 : fRecPointDataPtr->fAmp += fDigitsPointerArray[j]->fEnergy;
132 :
133 : // Count it
134 0 : fDigitsInCluster++;
135 0 : }
136 : }
137 : }
138 :
139 0 : fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
140 0 : fRecPointArray[fNRecPoints] = fRecPointDataPtr;
141 :
142 0 : fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitIndexPtr);
143 :
144 0 : fNRecPoints++;
145 :
146 0 : }//end of clusterization
147 :
148 0 : return nRecPoints;
149 0 : }
150 :
|