3 /**************************************************************************
\r
4 * This file is property of and copyright by the ALICE HLT Project *
\r
5 * All rights reserved. *
\r
7 * Primary Authors: Oystein Djuvsland *
\r
9 * Permission to use, copy, modify and distribute this software and its *
\r
10 * documentation strictly for non-commercial purposes is hereby granted *
\r
11 * without fee, provided that the above copyright notice appears in all *
\r
12 * copies and that both the copyright notice and this permission notice *
\r
13 * appear in the supporting documentation. The authors make no claims *
\r
14 * about the suitability of this software for any purpose. It is *
\r
15 * provided "as is" without express or implied warranty. *
\r
16 **************************************************************************/
\r
19 * @file AliHLTCaloClusterizer.cxx
\r
20 * @author Oystein Djuvsland
\r
22 * @brief Clusterizer for PHOS HLT
\r
25 // see header file for class documentation
\r
27 // refer to README to build package
\r
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
\r
31 #include "AliHLTCaloClusterizer.h"
\r
32 #include "AliHLTLogging.h"
\r
34 #include "AliHLTCaloRecPointDataStruct.h"
\r
35 #include "AliHLTCaloDigitDataStruct.h"
\r
36 #include "AliHLTCaloDigitContainerDataStruct.h"
\r
37 #include "AliHLTCaloConstantsHandler.h"
\r
39 ClassImp(AliHLTCaloClusterizer);
\r
41 AliHLTCaloClusterizer::AliHLTCaloClusterizer(TString det):
\r
42 AliHLTCaloConstantsHandler(det),
\r
43 fRecPointDataPtr(0),
\r
45 fEmcClusteringThreshold(0),
\r
46 fEmcMinEnergyThreshold(0),
\r
48 fDigitsInCluster(0),
\r
49 fDigitsPointerArray(0),
\r
50 fDigitContainerPtr(0),
\r
51 fMaxDigitIndexDiff(0),
\r
54 //See header file for documentation
\r
55 fEmcClusteringThreshold = 0.2;
\r
56 fEmcMinEnergyThreshold = 0.03;
\r
57 fEmcTimeGate = 1.e-6 ;
\r
59 fMaxDigitIndexDiff = 2*fCaloConstants->GetNZROWSMOD();
\r
64 //BALLE how do you set the right detector?
\r
65 // AliHLTCaloClusterizer::AliHLTCaloClusterizer(const AliHLTCaloClusterizer &) :
\r
66 // AliHLTCaloConstantsHandler("BALLE"),
\r
67 // fRecPointDataPtr(0),
\r
68 // fDigitDataPtr(0),
\r
69 // fEmcClusteringThreshold(0),
\r
70 // fEmcMinEnergyThreshold(0),
\r
72 // fDigitsInCluster(0),
\r
73 // fDigitContainerPtr(0),
\r
74 // fMaxDigitIndexDiff(0)
\r
76 // // dummy copy constructor
\r
80 AliHLTCaloClusterizer::~AliHLTCaloClusterizer()
\r
82 //See header file for documentation
\r
86 AliHLTCaloClusterizer::SetRecPointDataPtr(AliHLTCaloRecPointDataStruct* recPointDataPtr)
\r
88 // See header file for documentation
\r
89 fRecPointDataPtr = recPointDataPtr;
\r
93 AliHLTCaloClusterizer::ClusterizeEvent(Int_t nDigits, UInt_t availableSize, UInt_t& totSize)
\r
95 //see header file for documentation
\r
96 Int_t nRecPoints = 0;
\r
100 UInt_t maxRecPointSize = sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate...
\r
102 //Clusterization starts
\r
103 for(Int_t i = 0; i < nDigits; i++)
\r
105 fDigitsInCluster = 0;
\r
106 // printf("ENERGY: %f\n", fDigitsPointerArray[i]->fEnergy);
\r
107 if(fDigitsPointerArray[i]->fEnergy < fEmcClusteringThreshold)
\r
111 if(availableSize < (totSize + maxRecPointSize))
\r
113 return -1; //Might get out of buffer, exiting
\r
115 // printf("cluster candidate!\n");
\r
116 // First digit is placed at the fDigits member variable in the recpoint
\r
117 fDigitIndexPtr = &(fRecPointDataPtr->fDigits);
\r
119 fRecPointDataPtr->fAmp = 0;
\r
120 fRecPointDataPtr->fModule = fDigitsPointerArray[i]->fModule;
\r
122 // Assigning the digit to this rec point
\r
123 fRecPointDataPtr->fDigits = i;
\r
125 // Incrementing the pointer to be ready for new entry
\r
128 fRecPointDataPtr->fAmp += fDigitsPointerArray[i]->fEnergy;
\r
129 fDigitsPointerArray[i]->fEnergy = 0;
\r
130 fDigitsInCluster++;
\r
133 // Scanning for the neighbours
\r
134 ScanForNeighbourDigits(i, fRecPointDataPtr);
\r
136 totSize += sizeof(AliHLTCaloRecPointDataStruct) + (fDigitsInCluster-1)*sizeof(AliHLTCaloDigitDataStruct);
\r
137 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
\r
138 // printf("Rec point energy: %f\n", fRecPointDataPtr->fAmp);
\r
139 fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitIndexPtr);
\r
141 }//end of clusterization
\r
147 AliHLTCaloClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTCaloRecPointDataStruct* recPoint)
\r
149 //see header file for documentation
\r
150 Int_t max = TMath::Min(fNDigits, (Int_t)fMaxDigitIndexDiff+index);
\r
151 Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff));
\r
155 for(Int_t j = min; j < max; j++)
\r
157 if(fDigitsPointerArray[j]->fEnergy > fEmcMinEnergyThreshold)
\r
161 if(AreNeighbours(fDigitsPointerArray[index],
\r
162 fDigitsPointerArray[j]))
\r
164 // Assigning value to digit ptr
\r
165 *fDigitIndexPtr = j;
\r
166 // Incrementing digit pointer to be ready for new entry
\r
169 recPoint->fAmp += fDigitsPointerArray[j]->fEnergy;
\r
170 fDigitsPointerArray[j]->fEnergy = 0;
\r
171 fDigitsInCluster++;
\r
172 ScanForNeighbourDigits(j, recPoint);
\r
181 AliHLTCaloClusterizer::AreNeighbours(AliHLTCaloDigitDataStruct* digit1,
\r
182 AliHLTCaloDigitDataStruct* digit2)
\r
184 //see header file for documentation
\r
185 if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module
\r
187 // Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
188 // Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
189 // if (( coldiff <= 1 && rowdiff == 0 ) || ( coldiff == 0 && rowdiff <= 1 ))
\r
191 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
192 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
194 // if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
200 Float_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
201 Float_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
202 if (( coldiff <= 2.4 && rowdiff < 0.4 ) || ( coldiff < 0.4 && rowdiff <= 2.4 ))
\r
204 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
205 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
207 if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
214 // cout << "Not neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
215 // " is not neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r