1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Øystein Djuvsland <oysteind@ift.uib.no> *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
16 /** @file AliHLTPHOSClusterizer.cxx
17 @author Øystein Djuvsland
19 @brief A temporary clusterizer for PHOS
24 #include "AliHLTPHOSPhysicsDefinitions.h"
25 #include "AliHLTPHOSClusterizer.h"
26 #include "AliHLTPHOSCommonDefs.h"
29 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
30 #include "AliHLTPHOSRecPointListDataStruct.h"
31 #include "AliHLTPHOSValidCellDataStruct.h"
32 #include "AliHLTPHOSRecPointDataStruct.h"
33 #include "AliHLTPHOSClusterDataStruct.h"
36 ClassImp(AliHLTPHOSClusterizer);
41 AliHLTPHOSClusterizer::AliHLTPHOSClusterizer():fPHOSModule(-1), fThreshold(0), fClusterThreshold(0),
42 fHighGainFactor(0.005), fLowGainFactor(0.08),
43 fArraySize(3), fMultiplicity(fArraySize*fArraySize)
49 AliHLTPHOSClusterizer::AliHLTPHOSClusterizer(const AliHLTPHOSClusterizer &):fPHOSModule(-1), fThreshold(0), fClusterThreshold(0),
50 fHighGainFactor(0.005), fLowGainFactor(0.08),
51 fArraySize(3), fMultiplicity(fArraySize*fArraySize)
53 //Copy constructor, not implemented
56 AliHLTPHOSClusterizer:: ~AliHLTPHOSClusterizer()
62 * Building a 2D array of cell energies of the PHOS detector
63 * @param cellData object containing the cell energies from one event
64 * @param recPointList list to be filled with coordinates of local maxima in the detector
68 AliHLTPHOSClusterizer::BuildCellEnergyArray(AliHLTPHOSRcuCellEnergyDataStruct* cellData,
69 AliHLTPHOSRecPointListDataStruct* recPointList)
71 //Build the cell energy array of the detector
79 Double_t energyCount = 0;
81 for(Int_t cell = 0; cell < cellData->fCnt; cell++)
84 z = (cellData->fValidData[cell]).fZ;
85 x = (cellData->fValidData[cell]).fX;
86 gain = (cellData->fValidData[cell]).fGain;
88 zMod = z + (cellData->fRcuZ)*N_ROWS_RCU;
89 xMod = x + (cellData->fRcuX)*N_COLUMNS_RCU;
91 energyCount = (cellData->fValidData[cell]).fEnergy;
93 if(gain == 0 && energyCount < 1023)
95 fEnergyArray[xMod][zMod] = fHighGainFactor * energyCount;
97 if(fEnergyArray[xMod][zMod] > fClusterThreshold)
99 recPointList[index].fZ = zMod;
100 recPointList[index].fX = xMod;
102 for(Int_t j = 0; j < index; j++)
104 if(recPointList[j].fZ == zMod && recPointList[j].fX == xMod)
105 recPointList[j].fZ = -1;
111 else if(gain == 1 && fEnergyArray[xMod][zMod] == 0)
113 fEnergyArray[xMod][zMod] = fLowGainFactor * energyCount;
114 if(fEnergyArray[xMod][zMod] > fClusterThreshold)
116 recPointList[index].fZ = zMod;
117 recPointList[index].fX = xMod;
118 recPointList[index].fModule = cellData->fModuleID;
125 fPHOSModule = cellData->fModuleID;
128 }//end BuildCellEnergyArray
133 * Creating an array of rec points
134 * @param recPointStructArrayPtr array to store the rec points
135 * @param list list of rec points
136 * @param nPoints number of points
139 AliHLTPHOSClusterizer::CreateRecPointStructArray(AliHLTPHOSRecPointDataStruct* recPointStructArrayPtr,
140 AliHLTPHOSRecPointListDataStruct* list,
144 //Create the rec point struct array
147 Int_t edgeFlagRows = 0;
148 Int_t edgeFlagCols = 0;
150 Int_t nRecPoints = 0;
154 Float_t* energiesList = NULL;
156 for(Int_t point = 0; point < nPoints; point++)
160 if(z == -1) continue;
162 if((z-fArraySize/2) < 0/*= - N_ROWS_MOD/2*/ || (z+fArraySize/2) >= N_ROWS_MOD/*/2*/)
167 if((x-fArraySize/2) < 0/*= - N_COLUMNS_MOD/2*/ || (x+fArraySize/2) >= N_COLUMNS_MOD)
174 if(!flag) energiesList = new Float_t[fMultiplicity];
178 for(Int_t i = -fArraySize/2; i <= fArraySize/2; i++)
181 for(Int_t j = -fArraySize/2; j <= fArraySize/2; j++)
184 if(fEnergyArray[x+i][z+j] > fEnergyArray[x][z] && abs(i) < 2 && abs(j) < 2)
189 energiesList[k] = fEnergyArray[x+i][z+j];
197 recPointStructArrayPtr[nRecPoints].fEnergiesListPtr = energiesList;
198 recPointStructArrayPtr[nRecPoints].fCoordinatesPtr[0] = x;
199 recPointStructArrayPtr[nRecPoints].fCoordinatesPtr[1] = z;
200 recPointStructArrayPtr[nRecPoints].fX = x;
201 recPointStructArrayPtr[nRecPoints].fZ = z;
202 recPointStructArrayPtr[nRecPoints].fMultiplicity = fMultiplicity;
203 recPointStructArrayPtr[nRecPoints].fPHOSModule = list[point].fModule;
214 }//end CreateRecPointStructArray
218 * Calculating the center of gravity of a rec point
219 * Not working well at this point!
220 * @param recPointPtr pointer to the rec point
223 AliHLTPHOSClusterizer::CalculateCenterOfGravity(AliHLTPHOSRecPointDataStruct* recPointPtr)
225 //Calculate the center of gravity
235 Int_t x = recPointPtr->fCoordinatesPtr[0];
236 Int_t z = recPointPtr->fCoordinatesPtr[1];
238 for(Int_t i = -fArraySize/2; i <= fArraySize/2; i++)
240 for(Int_t j = -fArraySize/2; j <= fArraySize/2; j++)
244 w = TMath::Max( (Float_t)0., (Float_t)(w0 + log( fEnergyArray[x+i][z+j] / fEnergyArray[x][z]) ) ) ;
254 recPointPtr->fX = xt;
255 recPointPtr->fZ = zt;
259 }//end CalculateCenterOfGravity
264 * Create a simpler data struct for a rec point, containing
265 * only coordinates, energy and timing
266 * @param recPointPtr pointer to the rec point
267 * @param clusterStructPtr pointer to the cluster struct
270 AliHLTPHOSClusterizer::ClusterizeStruct(AliHLTPHOSRecPointDataStruct* recPointPtr, AliHLTPHOSClusterDataStruct* clusterStructPtr)
272 //Simplify the rec points
274 Float_t clusterEnergy = 0;
275 Float_t* energiesListPtr = recPointPtr->fEnergiesListPtr;
277 for(Int_t i = 0; i < recPointPtr->fMultiplicity; i++)
279 clusterEnergy += energiesListPtr[i];
282 clusterStructPtr->fLocalPositionPtr[0] = recPointPtr->fX;
283 clusterStructPtr->fLocalPositionPtr[1] = recPointPtr->fZ;
284 clusterStructPtr->fClusterEnergy = clusterEnergy;
285 clusterStructPtr->fPHOSModule = recPointPtr->fPHOSModule;
289 }//end ClusterizeStruct
295 * Resets the cell energy array
298 AliHLTPHOSClusterizer::ResetCellEnergyArray()
301 //Reset the cell energy array
303 for(Int_t x = 0; x < N_ROWS_MOD; x++)
305 for(Int_t z = 0; z < N_COLUMNS_MOD; z++)
307 fEnergyArray[x][z] = 0;
313 }//end ResetCellEnergyArray