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 "AliHLTCaloBase.h"
\r
33 #include "AliHLTLogging.h"
\r
35 #include "AliHLTCaloRecPointContainerStruct.h"
\r
36 #include "AliHLTCaloRecPointDataStruct.h"
\r
37 #include "AliHLTCaloDigitDataStruct.h"
\r
38 #include "AliHLTCaloDigitContainerDataStruct.h"
\r
39 #include "TClonesArray.h"
\r
40 #include "AliHLTCaloConstants.h"
\r
43 //#ifndef HAVENOT__PHOSRECOPARAMEMC // set from configure if EMC functionality not available in AliPHOSRecoParam
\r
44 //#include "AliPHOSRecoParam.h"
\r
46 //#include "AliPHOSRecoParamEmc.h"
\r
51 using namespace std;
\r
53 ClassImp(AliHLTCaloClusterizer);
\r
55 AliHLTCaloClusterizer::AliHLTCaloClusterizer(TString det):
\r
56 fRecPointDataPtr(0),
\r
58 fEmcClusteringThreshold(0),
\r
59 fEmcMinEnergyThreshold(0),
\r
61 fDigitsInCluster(0),
\r
62 fDigitContainerPtr(0),
\r
63 fMaxDigitIndexDiff(0),
\r
64 fCaloConstants(NULL)
\r
66 //See header file for documentation
\r
67 fEmcClusteringThreshold = 0.2;
\r
68 fEmcMinEnergyThreshold = 0.03;
\r
69 fEmcTimeGate = 1.e-6 ;
\r
71 fMaxDigitIndexDiff = 2*fCaloConstants->GetNZROWSMOD();
\r
73 fCaloConstants = new AliHLTCaloConstants(det);
\r
76 AliHLTCaloClusterizer::AliHLTCaloClusterizer(const AliHLTCaloClusterizer &) :
\r
77 fRecPointDataPtr(0),
\r
79 fEmcClusteringThreshold(0),
\r
80 fEmcMinEnergyThreshold(0),
\r
82 fDigitsInCluster(0),
\r
83 fDigitContainerPtr(0),
\r
84 fMaxDigitIndexDiff(0),
\r
85 fCaloConstants(NULL)
\r
87 // dummy copy constructor
\r
91 AliHLTCaloClusterizer::~AliHLTCaloClusterizer()
\r
93 //See header file for documentation
\r
97 AliHLTCaloClusterizer::SetRecPointDataPtr(AliHLTCaloRecPointDataStruct* recPointDataPtr)
\r
99 // See header file for documentation
\r
100 fRecPointDataPtr = recPointDataPtr;
\r
104 // AliHLTCaloClusterizer::SetRecoParameters(AliPHOSRecoParam* params)
\r
106 // //see header file for documentation
\r
107 // #ifndef HAVE_NOT_PHOSRECOPARAMEMC // set from configure if EMC functionality not available in AliPHOSRecoParam
\r
108 // // the new AliPHOSRecoParam functions, available from revision
\r
109 // // fEmcClusteringThreshold = params->GetEMCClusteringThreshold();
\r
110 // // fEmcMinEnergyThreshold = params->GetEMCMinE();
\r
111 // // fLogWeight = params->GetEMCLogWeight();
\r
115 // fEmcClusteringThreshold = params->GetClusteringThreshold();
\r
116 // fEmcMinEnergyThreshold = params->GetMinE();
\r
117 // fLogWeight = params->GetLogWeight();
\r
122 AliHLTCaloClusterizer::ClusterizeEvent(UInt_t availableSize, UInt_t& totSize)
\r
124 //see header file for documentation
\r
125 Int_t nRecPoints = 0;
\r
127 UInt_t maxRecPointSize = sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate...
\r
129 //Clusterization starts
\r
130 for(UInt_t i = 0; i < fDigitContainerPtr->fNDigits; i++)
\r
132 fDigitsInCluster = 0;
\r
134 if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold)
\r
138 if(availableSize < (totSize + maxRecPointSize))
\r
140 return -1; //Might get out of buffer, exiting
\r
143 // First digit is placed at the fDigits member variable in the recpoint
\r
144 fDigitDataPtr = &(fRecPointDataPtr->fDigits);
\r
146 fRecPointDataPtr->fAmp = 0;
\r
147 fRecPointDataPtr->fModule = fDigitContainerPtr->fDigitDataStruct[i].fModule;
\r
149 // Assigning digit data to the digit pointer
\r
150 fRecPointDataPtr->fDigits = fDigitContainerPtr->fDigitDataStruct[i];
\r
152 // Incrementing the pointer to be ready for new entry
\r
155 fRecPointDataPtr->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy;
\r
156 fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0;
\r
157 fDigitsInCluster++;
\r
160 // Scanning for the neighbours
\r
161 ScanForNeighbourDigits(i, fRecPointDataPtr);
\r
163 totSize += sizeof(AliHLTCaloRecPointDataStruct) + (fDigitsInCluster-1)*sizeof(AliHLTCaloDigitDataStruct);
\r
164 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
\r
166 fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(fDigitDataPtr);
\r
167 }//end of clusterization
\r
173 AliHLTCaloClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTCaloRecPointDataStruct* recPoint)
\r
175 //see header file for documentation
\r
176 Int_t max = TMath::Min((Int_t)fDigitContainerPtr->fNDigits, (Int_t)fMaxDigitIndexDiff+index);
\r
177 Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff));
\r
179 max = fDigitContainerPtr->fNDigits;
\r
181 for(Int_t j = min; j < max; j++)
\r
183 if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold)
\r
187 if(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]),
\r
188 &(fDigitContainerPtr->fDigitDataStruct[j])))
\r
190 // Assigning value to digit ptr
\r
191 *fDigitDataPtr = fDigitContainerPtr->fDigitDataStruct[j];
\r
192 // Incrementing digit pointer to be ready for new entry
\r
195 recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy;
\r
196 fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0;
\r
197 fDigitsInCluster++;
\r
198 ScanForNeighbourDigits(j, recPoint);
\r
207 AliHLTCaloClusterizer::AreNeighbours(AliHLTCaloDigitDataStruct* digit1,
\r
208 AliHLTCaloDigitDataStruct* digit2)
\r
210 //see header file for documentation
\r
211 if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module
\r
213 // Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
214 // Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
215 // if (( coldiff <= 1 && rowdiff == 0 ) || ( coldiff == 0 && rowdiff <= 1 ))
\r
217 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
218 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
220 // if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
226 Float_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
\r
227 Float_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
\r
228 if (( coldiff <= 2.4 && rowdiff < 0.4 ) || ( coldiff < 0.4 && rowdiff <= 2.4 ))
\r
230 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
231 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r
233 if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
\r
240 // cout << "Not neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
\r
241 // " is not neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
\r