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"
40 #include "AliHLTCaloClusterizer.h"
42 ClassImp(AliHLTCaloClusterAnalyser);
44 AliHLTCaloClusterAnalyser::AliHLTCaloClusterAnalyser() :
50 fCaloClusterDataPtr(0),
51 fCaloClusterHeaderPtr(0),
56 fHaveDistanceToBadChannel(false),
59 //See header file for documentation
62 AliHLTCaloClusterAnalyser::~AliHLTCaloClusterAnalyser()
67 AliHLTCaloClusterAnalyser::SetCaloClusterData(AliHLTCaloClusterDataStruct *caloClusterDataPtr)
69 //see header file for documentation
70 fCaloClusterDataPtr = caloClusterDataPtr;
74 AliHLTCaloClusterAnalyser::SetRecPointArray(AliHLTCaloRecPointDataStruct **recPointDataPtr, Int_t nRecPoints)
76 fRecPointArray = recPointDataPtr;
77 fNRecPoints = nRecPoints;
81 AliHLTCaloClusterAnalyser::SetDigitDataArray(AliHLTCaloDigitDataStruct *digits)
83 // AliHLTCaloClusterizer cl("PHOS");
84 // cl.CheckDigits(fRecPointArray, digits, fNRecPoints);
85 fDigitDataArray = digits;
86 //cl.CheckDigits(fRecPointArray, fDigitDataArray, fNRecPoints);
90 AliHLTCaloClusterAnalyser::CalculateCenterOfGravity()
92 //see header file for documentation
99 AliHLTCaloDigitDataStruct *digit = 0;
100 //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
103 //AliHLTCaloClusterizer cl("PHOS");
104 //cl.CheckDigits(fRecPointArray, fDigitDataArray, fNRecPoints);
108 for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
110 AliHLTCaloRecPointDataStruct *recPoint = fRecPointArray[iRecPoint];
111 // digit = &(recPoint->fDigits);
112 cout << "COG: Rec point multiplicity: " << recPoint->fMultiplicity << ", rec point energy: " << recPoint->fAmp << endl;
113 Int_t *digitIndexPtr = &(recPoint->fDigits);
115 for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
117 //cout << "1. Digit array: " << fDigitDataArray << ", Digit: " << digit << ", Index: " << *digitIndexPtr << ", ID: " << digit->fID << endl;
119 digit = &(fDigitDataArray[*digitIndexPtr]);
120 cout << "COG: 2. Digit array: " << fDigitDataArray << ", Digit: " << digit << ", Index: " << *digitIndexPtr << ", index pointer: " << digitIndexPtr<< endl;
121 cout << ", dig Energy: " << digit->fEnergy << ", Index: " << *digitIndexPtr << ", ID: " << digit->fID << endl;
124 // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
125 if (recPoint->fAmp > 0 && digit->fEnergy > 0)
127 Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
137 recPoint->fX = x/wtot ;
138 recPoint->fZ = z/wtot ;
150 AliHLTCaloClusterAnalyser::CalculateRecPointMoments()
152 //See header file for documentation
157 AliHLTCaloClusterAnalyser::CalculateClusterMoments(AliHLTCaloRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/)
159 //See header file for documentation
165 AliHLTCaloClusterAnalyser::DeconvoluteClusters()
167 //See header file for documentation
172 AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize, UInt_t& totSize)
174 //See header file for documentation
176 fNRecPoints = nRecPoints;
180 HLTError("No geometry object is initialised, creation of clusters stopped");
183 CalculateCenterOfGravity();
185 UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
187 // AliHLTCaloDigitDataStruct* digitPtr = &(recPointPtr->fDigits);
188 AliHLTCaloDigitDataStruct* digitPtr = 0;
190 AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
191 UShort_t* cellIDPtr = &(caloClusterPtr->fCellsAbsId);
192 Float_t* cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
197 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
200 AliHLTCaloRecPointDataStruct *recPointPtr = fRecPointArray[i];
201 cout << "CA: rec point energy: " << recPointPtr->fAmp << ", rec point multiplicity: " << recPointPtr->fMultiplicity << endl;
202 if(availableSize < (totSize + maxClusterSize))
204 return -1; //Might get out of buffer, exiting
206 // cout << "Local Position (x:z:module): " << recPointPtr->fX << " : "<< recPointPtr->fZ << " : " << recPointPtr->fModule << endl;
208 AliHLTCaloGlobalCoordinate globalCoord;
209 fGeometry->GetGlobalCoordinates(*recPointPtr, globalCoord);
210 // cout << "Global Position (x:y:z): " << globalPos[0] << " : "<< globalPos[1] << " : " << globalPos[2] << endl << endl;
212 caloClusterPtr->fGlobalPos[0] = globalCoord.fX;
213 caloClusterPtr->fGlobalPos[1] = globalCoord.fY;
214 caloClusterPtr->fGlobalPos[2] = globalCoord.fZ;
216 caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
218 cellIDPtr = &(caloClusterPtr->fCellsAbsId);
219 cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
221 for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++)
223 // fPHOSGeometry->RelPosToAbsId((Int_t)(recPointPtr->fModule), (double)(digitPtr->fX), (double)(digitPtr->fZ), id);
225 *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp;
227 cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t));
228 cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t)); */
231 caloClusterPtr->fEnergy = recPointPtr->fAmp;
232 cout << "CA: cluster energy: " << caloClusterPtr->fEnergy << endl;
233 cout << "CA: recpoint energy: " << recPointPtr->fAmp << endl;
236 FitCluster(recPointPtr);
240 caloClusterPtr->fDispersion = 0;
241 caloClusterPtr->fFitQuality = 0;
242 caloClusterPtr->fM20 = 0;
243 caloClusterPtr->fM02 = 0;
248 caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr);
252 caloClusterPtr->fEmcCpvDistance = -1;
256 DoParticleIdentification(caloClusterPtr);
260 for(Int_t k = 0; k < AliPID::kSPECIESN; k++)
262 caloClusterPtr->fPID[k] = 0;
265 if(fHaveDistanceToBadChannel)
267 caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr);
271 caloClusterPtr->fDistanceToBadChannel = -1;
274 caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster);
275 // totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells)*(sizeof(Short_t) +sizeof(Float_t)-1);
276 totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
279 // caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellAmpFracPtr);
280 caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellIDPtr);
282 recPointPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(digitPtr);
283 ///digitPtr = &(recPointPtr->fDigits);
285 // cout << "CA: Energy End: " << fCaloClusterDataPtr->fEnergy << endl;
286 //cout << "CA totSize: " << totSize << endl;