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 fDigitContainerPtr(0),
\r
50 fMaxDigitIndexDiff(0)
\r
52 //See header file for documentation
\r
53 fEmcClusteringThreshold = 0.2;
\r
54 fEmcMinEnergyThreshold = 0.03;
\r
55 fEmcTimeGate = 1.e-6 ;
\r
57 fMaxDigitIndexDiff = 2*fCaloConstants->GetNZROWSMOD();
\r
62 //BALLE how do you set the right detector?
\r
63 AliHLTCaloClusterizer::AliHLTCaloClusterizer(const AliHLTCaloClusterizer &) :
\r
64 AliHLTCaloConstantsHandler("BALLE"),
\r
65 fRecPointDataPtr(0),
\r
67 fEmcClusteringThreshold(0),
\r
68 fEmcMinEnergyThreshold(0),
\r
70 fDigitsInCluster(0),
\r
71 fDigitContainerPtr(0),
\r
72 fMaxDigitIndexDiff(0)
\r
74 // dummy copy constructor
\r
78 AliHLTCaloClusterizer::~AliHLTCaloClusterizer()
\r
80 //See header file for documentation
\r
84 AliHLTCaloClusterizer::SetRecPointDataPtr(AliHLTCaloRecPointDataStruct* recPointDataPtr)
\r
86 // See header file for documentation
\r
87 fRecPointDataPtr = recPointDataPtr;
\r
91 AliHLTCaloClusterizer::ClusterizeEvent(UInt_t availableSize, UInt_t& totSize)
\r
93 //see header file for documentation
\r
94 Int_t nRecPoints = 0;
\r
96 UInt_t maxRecPointSize = sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate...
\r
98 //Clusterization starts
\r
99 for(UInt_t i = 0; i < fDigitContainerPtr->fNDigits; i++)
\r
101 fDigitsInCluster = 0;
\r
103 if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold)
\r
107 if(availableSize < (totSize + maxRecPointSize))
\r
109 return -1; //Might get out of buffer, exiting
\r
112 // First digit is placed at the fDigits member variable in the recpoint
\r
113 fDigitDataPtr = &(fRecPointDataPtr->fDigits);
\r
115 fRecPointDataPtr->fAmp = 0;
\r
116 fRecPointDataPtr->fModule = fDigitContainerPtr->fDigitDataStruct[i].fModule;
\r
118 // Assigning digit data to the digit pointer
\r
119 fRecPointDataPtr->fDigits = fDigitContainerPtr->fDigitDataStruct[i];
\r
121 // Incrementing the pointer to be ready for new entry
\r
124 fRecPointDataPtr->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy;
\r
125 fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0;
\r
126 fDigitsInCluster++;
\r
129 // Scanning for the neighbours
\r
130 ScanForNeighbourDigits(i, fRecPointDataPtr);
\r
132 totSize += sizeof(AliHLTCaloRecPointDataStruct) + (fDigitsInCluster-1)*sizeof(AliHLTCaloDigitDataStruct);
\r
133 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
\r
135 fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitDataPtr);
\r
136 }//end of clusterization
\r
142 AliHLTCaloClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTCaloRecPointDataStruct* recPoint)
\r
144 //see header file for documentation
\r
145 Int_t max = TMath::Min((Int_t)fDigitContainerPtr->fNDigits, (Int_t)fMaxDigitIndexDiff+index);
\r
146 Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff));
\r
148 max = fDigitContainerPtr->fNDigits;
\r
150 for(Int_t j = min; j < max; j++)
\r
152 if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold)
\r
156 if(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]),
\r
157 &(fDigitContainerPtr->fDigitDataStruct[j])))
\r
159 // Assigning value to digit ptr
\r
160 *fDigitDataPtr = fDigitContainerPtr->fDigitDataStruct[j];
\r
161 // Incrementing digit pointer to be ready for new entry
\r
164 recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy;
\r
165 fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0;
\r
166 fDigitsInCluster++;
\r
167 ScanForNeighbourDigits(j, recPoint);
\r
176 AliHLTCaloClusterizer::AreNeighbours(AliHLTCaloDigitDataStruct* digit1,
\r
177 AliHLTCaloDigitDataStruct* digit2)
\r
179 //see header file for documentation
\r
180 if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module
\r
182 // Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
183 // Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
184 // if (( coldiff <= 1 && rowdiff == 0 ) || ( coldiff == 0 && rowdiff <= 1 ))
\r
186 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
187 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
189 // if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
195 Float_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
196 Float_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
197 if (( coldiff <= 2.4 && rowdiff < 0.4 ) || ( coldiff < 0.4 && rowdiff <= 2.4 ))
\r
199 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
200 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
202 if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
209 // cout << "Not neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
210 // " is not neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r