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 AliHLTPHOSClusterAnalyser.cxx
20 * @author Oystein Djuvsland
22 * @brief Cluster analyser for PHOS 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 "AliHLTPHOSClusterAnalyser.h"
32 #include "AliHLTPHOSRecPointHeaderStruct.h"
33 #include "AliHLTPHOSRecPointDataStruct.h"
34 #include "AliHLTCaloClusterDataStruct.h"
35 #include "AliHLTPHOSPhysicsAnalyzer.h"
36 #include "AliPHOSGeoUtils.h"
37 #include "AliESDCaloCluster.h"
41 ClassImp(AliHLTPHOSClusterAnalyser);
43 AliHLTPHOSClusterAnalyser::AliHLTPHOSClusterAnalyser() :
48 fCaloClusterDataPtr(0),
49 fCaloClusterHeaderPtr(0),
54 fHaveDistanceToBadChannel(false)
56 //See header file for documentation
59 AliHLTPHOSClusterAnalyser::~AliHLTPHOSClusterAnalyser()
64 AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTCaloClusterDataStruct *caloClusterDataPtr)
66 //see header file for documentation
67 fCaloClusterDataPtr = caloClusterDataPtr;
70 AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr, AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
72 fNRecPoints = recPointDataPtr->fNRecPoints;
73 fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct));
74 fDigitHeaderPtr = digitHeaderPtr;
78 AliHLTPHOSClusterAnalyser::CalculateCenterOfGravity()
80 //see header file for documentation
87 AliHLTPHOSDigitDataStruct *digit = 0;
88 //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
90 AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr;
94 for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
96 digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Int_t>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
97 AliHLTPHOSDigitReader reader;
98 reader->SetCurrentDigit(digit);
103 // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
104 if (recPoint->fAmp > 0 && digit->fEnergy > 0)
106 Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
111 digit = reader->NextDigit();
115 recPoint->fX = x/wtot ;
116 recPoint->fZ = z/wtot ;
122 recPoint = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digit);
129 AliHLTPHOSClusterAnalyser::CalculateRecPointMoments()
131 //See header file for documentation
136 AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/)
138 //See header file for documentation
144 AliHLTPHOSClusterAnalyser::DeconvoluteClusters()
146 //See header file for documentation
151 AliHLTPHOSClusterAnalyser::CreateClusters(UInt_t availableSize, UInt_t& totSize)
153 //See header file for documentation
155 UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
157 AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr;
158 AliHLTPHOSDigitDataStruct* digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Int_t>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
160 AliHLTPHOSReader reader;
161 reader.SetCurrentDigit(digitPtr);
163 AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
164 UShort_t* cellIDPtr = &(caloClusterPtr->fCellsAbsId);
165 Float_t* cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
170 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
173 if(availableSize < (totSize + maxClusterSize))
175 return -1; //Might get out of buffer, exiting
177 fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos);
179 caloClusterPtr->fGlobalPos[0] = globalPos[0];
180 caloClusterPtr->fGlobalPos[1] = globalPos[1];
181 caloClusterPtr->fGlobalPos[2] = globalPos[2];
183 caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
185 cellIDPtr = &(caloClusterPtr->fCellsAbsId);
186 cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
190 fPHOSGeometry->RelPosToAbsId((Int_t)(recPointPtr->fModule), (double)(digitPtr->fX), (double)(digitPtr->fZ), id);
192 *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp;
193 cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t));
194 cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t));
195 digitPtr = reader.NextDigit()
198 caloClusterPtr->fEnergy = recPointPtr->fAmp;
202 FitCluster(recPointPtr);
206 caloClusterPtr->fDispersion = 0;
207 caloClusterPtr->fFitQuality = 0;
208 caloClusterPtr->fM20 = 0;
209 caloClusterPtr->fM02 = 0;
214 caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr);
218 caloClusterPtr->fEmcCpvDistance = -1;
222 DoParticleIdentification(caloClusterPtr);
226 for(Int_t k = 0; k < AliPID::kSPECIESN; k++)
228 caloClusterPtr->fPID[k] = 0;
231 if(fHaveDistanceToBadChannel)
233 caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr);
237 caloClusterPtr->fDistanceToBadChannel = -1;
240 caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster);
242 totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
244 caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellIDPtr);
245 recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr);
246 digitPtr = &(recPointPtr->fDigits);