]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSClusterizer.cxx
- Bug fix: in the creation/reading of the trigger DCS values, the HV and currents...
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterizer.cxx
CommitLineData
1b41ab20 1// $Id$
2
ab38011b 3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
6 * *
1804b020 7 * Primary Authors: Oystein Djuvsland *
ab38011b 8 * *
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 **************************************************************************/
aac22523 17
2374af72 18/**
19 * @file AliHLTPHOSClusterizer.cxx
20 * @author Oystein Djuvsland
21 * @date
22 * @brief Clusterizer for PHOS HLT
23 */
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
aac22523 30
aac22523 31#include "AliHLTPHOSClusterizer.h"
9cc0deb1 32#include "AliHLTPHOSBase.h"
d8122453 33#include "AliHLTLogging.h"
aac22523 34#include "TMath.h"
9cc0deb1 35#include "AliHLTPHOSRecPointContainerStruct.h"
91b95d47 36#include "AliHLTPHOSRecPointDataStruct.h"
9cc0deb1 37#include "AliHLTPHOSDigitDataStruct.h"
38#include "AliHLTPHOSDigitContainerDataStruct.h"
39#include "TClonesArray.h"
9cc0deb1 40#include "AliPHOSDigit.h"
27029341 41#ifndef HAVENOT__PHOSRECOPARAMEMC // set from configure if EMC functionality not available in AliPHOSRecoParam
7e88424f 42#include "AliPHOSRecoParam.h"
ae1c1854 43#else
44#include "AliPHOSRecoParamEmc.h"
45#endif
94594220 46#include <iostream>
47
48using namespace std;
9cc0deb1 49
50ClassImp(AliHLTPHOSClusterizer);
51
52AliHLTPHOSClusterizer::AliHLTPHOSClusterizer():
53 AliHLTPHOSBase(),
e304ea31 54 fRecPointDataPtr(0),
55 fDigitDataPtr(0),
9cc0deb1 56 fEmcClusteringThreshold(0),
57 fEmcMinEnergyThreshold(0),
58 fEmcTimeGate(0),
9cc0deb1 59 fDigitsInCluster(0),
9cc0deb1 60 fDigitContainerPtr(0),
27029341 61 fMaxDigitIndexDiff(2*NZROWSMOD)
e304ea31 62{
6e709a0d 63 //See header file for documentation
9cc0deb1 64 fEmcClusteringThreshold = 0.2;
65 fEmcMinEnergyThreshold = 0.03;
d949e02e 66 fEmcTimeGate = 1.e-6 ;
aac22523 67}//end
68
9c9d15d6 69
9cc0deb1 70AliHLTPHOSClusterizer::~AliHLTPHOSClusterizer()
aac22523 71{
2374af72 72 //See header file for documentation
aac22523 73}
74
25b7f84c 75void
e304ea31 76AliHLTPHOSClusterizer::SetRecPointDataPtr(AliHLTPHOSRecPointDataStruct* recPointDataPtr)
77{
87434909 78 // See header file for documentation
e304ea31 79 fRecPointDataPtr = recPointDataPtr;
80}
2374af72 81
9cc0deb1 82void
e304ea31 83AliHLTPHOSClusterizer::SetRecoParameters(AliPHOSRecoParam* params)
9cc0deb1 84{
2374af72 85 //see header file for documentation
ae1c1854 86#ifndef HAVE_NOT_PHOSRECOPARAMEMC // set from configure if EMC functionality not available in AliPHOSRecoParam
87 // the new AliPHOSRecoParam functions, available from revision
94594220 88 // fEmcClusteringThreshold = params->GetEMCClusteringThreshold();
89 // fEmcMinEnergyThreshold = params->GetEMCMinE();
90 // fLogWeight = params->GetEMCLogWeight();
e304ea31 91 params++;
92 params--;
ae1c1854 93#else
94 fEmcClusteringThreshold = params->GetClusteringThreshold();
95 fEmcMinEnergyThreshold = params->GetMinE();
96 fLogWeight = params->GetLogWeight();
97#endif
94594220 98}
aac22523 99
9cc0deb1 100Int_t
e304ea31 101AliHLTPHOSClusterizer::ClusterizeEvent(UInt_t availableSize, UInt_t& totSize)
aac22523 102{
2374af72 103 //see header file for documentation
aac22523 104 Int_t nRecPoints = 0;
e304ea31 105
106 UInt_t maxRecPointSize = sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate...
107
9cc0deb1 108 //Clusterization starts
e304ea31 109 for(UInt_t i = 0; i < fDigitContainerPtr->fNDigits; i++)
9cc0deb1 110 {
d949e02e 111 fDigitsInCluster = 0;
e304ea31 112
9cc0deb1 113 if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold)
aac22523 114 {
9cc0deb1 115 continue;
aac22523 116 }
e304ea31 117 if(availableSize < (totSize + maxRecPointSize))
118 {
119 return -1; //Might get out of buffer, exiting
120 }
121
122 // First digit is placed at the fDigits member variable in the recpoint
123 fDigitDataPtr = &(fRecPointDataPtr->fDigits);
124
125 fRecPointDataPtr->fAmp = 0;
126 fRecPointDataPtr->fModule = fDigitContainerPtr->fDigitDataStruct[i].fModule;
87434909 127
e304ea31 128 // Assigning digit data to the digit pointer
129 fRecPointDataPtr->fDigits = fDigitContainerPtr->fDigitDataStruct[i];
130
131 // Incrementing the pointer to be ready for new entry
132 fDigitDataPtr++;
133
134 fRecPointDataPtr->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy;
9cc0deb1 135 fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0;
136 fDigitsInCluster++;
137 nRecPoints++;
e304ea31 138
139 // Scanning for the neighbours
140 ScanForNeighbourDigits(i, fRecPointDataPtr);
141
142 totSize += sizeof(AliHLTPHOSRecPointDataStruct) + (fDigitsInCluster-1)*sizeof(AliHLTPHOSDigitDataStruct);
143 fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
144
145 fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(fDigitDataPtr);
9cc0deb1 146 }//end of clusterization
e304ea31 147
148 return nRecPoints;
9cc0deb1 149}
aac22523 150
9cc0deb1 151void
152AliHLTPHOSClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTPHOSRecPointDataStruct* recPoint)
aac22523 153{
2374af72 154 //see header file for documentation
e304ea31 155 Int_t max = TMath::Min((Int_t)fDigitContainerPtr->fNDigits, (Int_t)fMaxDigitIndexDiff+index);
156 Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff));
157
158 max = fDigitContainerPtr->fNDigits;
159 min = 0;
160 for(Int_t j = min; j < max; j++)
aac22523 161 {
9cc0deb1 162 if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold)
163 {
e304ea31 164 if(j != index)
9cc0deb1 165 {
e304ea31 166 if(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]),
167 &(fDigitContainerPtr->fDigitDataStruct[j])))
168 {
169 // Assigning value to digit ptr
170 *fDigitDataPtr = fDigitContainerPtr->fDigitDataStruct[j];
171 // Incrementing digit pointer to be ready for new entry
172 fDigitDataPtr++;
173
174 recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy;
175 fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0;
176 fDigitsInCluster++;
177 ScanForNeighbourDigits(j, recPoint);
178 }
9cc0deb1 179 }
aac22523 180 }
e304ea31 181 }
9cc0deb1 182 return;
183}
6e709a0d 184
9cc0deb1 185Int_t
186AliHLTPHOSClusterizer::AreNeighbours(AliHLTPHOSDigitDataStruct* digit1,
187 AliHLTPHOSDigitDataStruct* digit2)
6e709a0d 188{
2374af72 189 //see header file for documentation
9cc0deb1 190 if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module
191 {
87434909 192// Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
193// Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
194// if (( coldiff <= 1 && rowdiff == 0 ) || ( coldiff == 0 && rowdiff <= 1 ))
195// {
196// cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
197// " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
198
199// if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
200// {
201// return 1;
202// }
203// }
204
205 Float_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ );
206 Float_t coldiff = TMath::Abs( digit1->fX - digit2->fX );
207 if (( coldiff <= 2.4 && rowdiff < 0.4 ) || ( coldiff < 0.4 && rowdiff <= 2.4 ))
6e709a0d 208 {
87434909 209 // cout << "Are neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
210 // " is neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
211
9cc0deb1 212 if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate)
d949e02e 213 {
d949e02e 214 return 1;
215 }
6e709a0d 216 }
87434909 217 else
218 {
219 // cout << "Not neighbours: digit (E = " << digit1->fEnergy << ") with x = " << digit1->fX << " and z = " << digit1->fZ <<
220 // " is not neighbour with digit (E = " << digit2->fEnergy << ") with x = " << digit2->fX << " and z = " << digit2->fZ << endl;
221 }
6e709a0d 222 }
223 return 0;
224}