]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/AliHLTCaloClusterizerNbyN.cxx
cleaning up HLT defines
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloClusterizerNbyN.cxx
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 AliHLTCaloClusterizerNbyN::AliHLTCaloClusterizerNbyN(TString det) : AliHLTCaloClusterizer(det)
34 ,fN(3)
35 {
36 // Constructor
37 }
38 AliHLTCaloClusterizerNbyN::~AliHLTCaloClusterizerNbyN()
39 {
40 // Destructor
41 }
42
43 Int_t AliHLTCaloClusterizerNbyN::ClusterizeEvent(Int_t nDigits)
44 {
45     //see header file for documentation
46     Int_t nRecPoints = 0;
47     fNRecPoints = 0;
48     fUsedSize = 0;
49     fNDigits = nDigits;
50     fRecPointDataPtr = fFirstRecPointPtr;
51
52     // Sort our digits
53     fSortedByEnergy = true;
54     SortDigits();
55
56     //Clusterization starts
57     for (Int_t i = 0; i < nDigits; i++)
58     {
59         fDigitsInCluster = 0;
60
61         HLTDebug("Digit with energy: %f", fDigitsPointerArray[i]->fEnergy);
62
63         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             return fNRecPoints;
67         }
68
69         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         CheckArray();
76         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         fDigitIndexPtr = &(fRecPointDataPtr->fDigits);
81
82         fRecPointDataPtr->fAmp = 0;
83         fRecPointDataPtr->fModule = fDigitsPointerArray[i]->fModule;
84
85         // Assigning the digit to this rec point
86         fRecPointDataPtr->fDigits = i;
87         fUsedSize += sizeof(AliHLTCaloRecPointDataStruct);
88
89         // Incrementing the pointer to be ready for new entry
90         fDigitIndexPtr++;
91
92         fRecPointDataPtr->fAmp += fDigitsPointerArray[i]->fEnergy;
93
94
95         //fDigitsPointerArray[i]->fEnergy = 0;
96         fDigitsPointerArray[i]->fAssociatedCluster = fNRecPoints;
97
98
99         fDigitsInCluster++;
100         nRecPoints++;
101
102
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++)
106         {
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
110
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
113             {
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
116                 {
117                     // This means the digit is not a local maximum
118                     fDigitsPointerArray[j]->fAssociatedCluster = fNRecPoints;
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