1 // $Id: AliHLTCaloClusterAnalyser.cxx 35107 2009-09-30 01:45:06Z phille $
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
7 * Primary Authors: Oystein Djuvsland *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
19 * @file AliHLTCaloClusterAnalyser.cxx
20 * @author Oystein Djuvsland
22 * @brief Cluster analyser for Calo HLT
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31 #include "AliHLTCaloClusterAnalyser.h"
32 #include "AliHLTCaloRecPointHeaderStruct.h"
33 #include "AliHLTCaloRecPointDataStruct.h"
34 #include "AliHLTCaloClusterDataStruct.h"
35 //#include "AliHLTCaloPhysicsAnalyzer.h"
36 #include "AliHLTCaloGeometry.h"
37 #include "AliESDCaloCluster.h"
42 #include "AliHLTCaloClusterizer.h"
44 ClassImp(AliHLTCaloClusterAnalyser);
46 AliHLTCaloClusterAnalyser::AliHLTCaloClusterAnalyser() :
52 fCaloClusterDataPtr(0),
53 fCaloClusterHeaderPtr(0),
58 fHaveDistanceToBadChannel(false),
60 fClusterType(AliESDCaloCluster::kPHOSCluster)
62 //See header file for documentation
65 AliHLTCaloClusterAnalyser::~AliHLTCaloClusterAnalyser()
67 // See header file for class documentation
71 AliHLTCaloClusterAnalyser::SetCaloClusterData(AliHLTCaloClusterDataStruct *caloClusterDataPtr)
73 //see header file for documentation
74 fCaloClusterDataPtr = caloClusterDataPtr;
78 AliHLTCaloClusterAnalyser::SetRecPointArray(AliHLTCaloRecPointDataStruct **recPointDataPtr, Int_t nRecPoints)
80 fRecPointArray = recPointDataPtr;
81 fNRecPoints = nRecPoints;
85 AliHLTCaloClusterAnalyser::SetDigitDataArray(AliHLTCaloDigitDataStruct *digits)
87 // AliHLTCaloClusterizer cl("PHOS");
88 // cl.CheckDigits(fRecPointArray, digits, fNRecPoints);
89 fDigitDataArray = digits;
90 //cl.CheckDigits(fRecPointArray, fDigitDataArray, fNRecPoints);
94 AliHLTCaloClusterAnalyser::CalculateCenterOfGravity()
96 //see header file for documentation
103 AliHLTCaloDigitDataStruct *digit = 0;
107 for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
109 AliHLTCaloRecPointDataStruct *recPoint = fRecPointArray[iRecPoint];
110 // digit = &(recPoint->fDigits);
112 Int_t *digitIndexPtr = &(recPoint->fDigits);
114 for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
117 digit = &(fDigitDataArray[*digitIndexPtr]);
122 if (recPoint->fAmp > 0 && digit->fEnergy > 0)
124 Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
134 recPoint->fX = x/wtot ;
135 recPoint->fZ = z/wtot ;
147 AliHLTCaloClusterAnalyser::CalculateRecPointMoments()
149 //See header file for documentation
154 AliHLTCaloClusterAnalyser::CalculateClusterMoments(AliHLTCaloRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/)
156 //See header file for documentation
162 AliHLTCaloClusterAnalyser::DeconvoluteClusters()
164 //See header file for documentation
169 AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize, UInt_t& totSize)
171 //See header file for documentation
174 totSize += sizeof(AliHLTCaloClusterDataStruct);
175 fNRecPoints = nRecPoints;
179 HLTError("No geometry object is initialised, creation of clusters stopped");
182 CalculateCenterOfGravity();
184 // AliHLTCaloDigitDataStruct* digitPtr = &(recPointPtr->fDigits);
185 AliHLTCaloDigitDataStruct* digitPtr = 0;
187 AliHLTCaloClusterDataStruct* caloClusterPtr = 0;
188 UShort_t* cellIDPtr = 0;
189 Float_t* cellAmpFracPtr = 0;;
194 for(Int_t i = 0; i < fNRecPoints; i++) //TODO needs fix when we start unfolding (number of clusters not necessarily same as number of recpoints gotten from the clusterizer
196 if((availableSize - totSize) < sizeof(AliHLTCaloClusterDataStruct))
198 HLTError("Out of buffer");
202 caloClusterPtr = fCaloClusterDataPtr;
204 cellIDPtr = &(caloClusterPtr->fCellsAbsId);
205 cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
207 AliHLTCaloRecPointDataStruct *recPointPtr = fRecPointArray[i];
209 AliHLTCaloGlobalCoordinate globalCoord;
210 fGeometry->GetGlobalCoordinates(*recPointPtr, globalCoord);
212 caloClusterPtr->fGlobalPos[0] = globalCoord.fX;
213 caloClusterPtr->fGlobalPos[1] = globalCoord.fY;
214 caloClusterPtr->fGlobalPos[2] = globalCoord.fZ;
216 caloClusterPtr->fNCells = 0;//recPointPtr->fMultiplicity;
218 Int_t tmpSize = totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
220 if((availableSize - totSize) < tmpSize)
222 HLTError("Out of buffer");
226 for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++)
228 /* fGeometry->GetCellAbsId(recPointPtr->fModule, digitPtr->fX, digitPtr->fZ, id);
230 *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp;
232 cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t));
233 cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t)); */
238 caloClusterPtr->fEnergy = recPointPtr->fAmp;
242 FitCluster(recPointPtr);
246 caloClusterPtr->fDispersion = 0;
247 caloClusterPtr->fFitQuality = 0;
248 caloClusterPtr->fM20 = 0;
249 caloClusterPtr->fM02 = 0;
254 caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr);
258 caloClusterPtr->fEmcCpvDistance = -1;
262 DoParticleIdentification(caloClusterPtr);
266 for(Int_t k = 0; k < AliPID::kSPECIESN; k++)
268 caloClusterPtr->fPID[k] = 0;
271 if(fHaveDistanceToBadChannel)
273 caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr);
277 caloClusterPtr->fDistanceToBadChannel = -1;
280 caloClusterPtr->fClusterType = fClusterType;
281 // totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells)*(sizeof(Short_t) +sizeof(Float_t)-1);
282 //totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
284 // caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellAmpFracPtr);
285 caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellIDPtr);
287 recPointPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(digitPtr);
288 //digitPtr = &(recPointPtr->fDigits);