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 "AliHLTPHOSDigitReader.h"
37 #include "AliPHOSGeoUtils.h"
38 #include "AliESDCaloCluster.h"
42 ClassImp(AliHLTPHOSClusterAnalyser);
44 AliHLTPHOSClusterAnalyser::AliHLTPHOSClusterAnalyser() :
49 fCaloClusterDataPtr(0),
50 fCaloClusterHeaderPtr(0),
55 fHaveDistanceToBadChannel(false),
58 //See header file for documentation
61 AliHLTPHOSClusterAnalyser::~AliHLTPHOSClusterAnalyser()
66 AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTCaloClusterDataStruct *caloClusterDataPtr)
68 //see header file for documentation
69 fCaloClusterDataPtr = caloClusterDataPtr;
72 AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr, AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
74 fNRecPoints = recPointDataPtr->fNRecPoints;
76 fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct));
77 fDigitHeaderPtr = digitHeaderPtr;
81 AliHLTPHOSClusterAnalyser::CalculateCenterOfGravity()
83 //see header file for documentation
90 AliHLTPHOSDigitDataStruct *digit = 0;
91 //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
93 AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr;
95 if(!recPoint) return 0;
96 for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
98 // cout << "CA: start digit offset: " << recPoint->fStartDigitOffset << endl;
99 digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<UChar_t*>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
100 // cout << "CA: digit offset: " << digit->fMemOffsetNext << endl;
101 AliHLTPHOSDigitReader reader;
102 reader.SetNextDigit(digit);
107 // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
108 if (recPoint->fAmp > 0 && digit->fEnergy > 0)
110 Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
115 digit = reader.NextDigit();
119 recPoint->fX = x/wtot ;
120 recPoint->fZ = z/wtot ;
136 AliHLTPHOSClusterAnalyser::CalculateRecPointMoments()
138 //See header file for documentation
143 AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/)
145 //See header file for documentation
151 AliHLTPHOSClusterAnalyser::DeconvoluteClusters()
153 //See header file for documentation
158 AliHLTPHOSClusterAnalyser::CreateClusters(UInt_t availableSize, UInt_t& totSize)
160 //See header file for documentation
162 UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
164 AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr;
165 AliHLTPHOSDigitDataStruct* digitPtr = 0;
167 AliHLTPHOSDigitReader reader;
169 AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
174 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
176 digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPointPtr->fStartDigitOffset);
177 reader.SetNextDigit(digitPtr);
179 if(availableSize < (totSize + maxClusterSize))
181 return -1; //Might get out of buffer, exiting
183 fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos);
185 caloClusterPtr->fGlobalPos[0] = globalPos[0];
186 caloClusterPtr->fGlobalPos[1] = globalPos[1];
187 caloClusterPtr->fGlobalPos[2] = globalPos[2];
188 cout << "Global position: " << globalPos[0] << ", " << globalPos[1] << ", " << globalPos[2] << endl;
189 caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
195 caloClusterPtr->fEnergy = recPointPtr->fAmp;
199 FitCluster(recPointPtr);
203 caloClusterPtr->fDispersion = 0;
204 caloClusterPtr->fFitQuality = 0;
205 caloClusterPtr->fM20 = 0;
206 caloClusterPtr->fM02 = 0;
211 caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr);
215 caloClusterPtr->fEmcCpvDistance = -1;
219 DoParticleIdentification(caloClusterPtr);
223 for(Int_t k = 0; k < AliPID::kSPECIESN; k++)
225 caloClusterPtr->fPID[k] = 0;
228 if(fHaveDistanceToBadChannel)
230 caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr);
234 caloClusterPtr->fDistanceToBadChannel = -1;
237 caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster);
239 totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
241 // recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr);