]>
Commit | Line | Data |
---|---|---|
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 | ||
48 | using namespace std; | |
9cc0deb1 | 49 | |
50 | ClassImp(AliHLTPHOSClusterizer); | |
51 | ||
52 | AliHLTPHOSClusterizer::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 | 70 | AliHLTPHOSClusterizer::~AliHLTPHOSClusterizer() |
aac22523 | 71 | { |
2374af72 | 72 | //See header file for documentation |
aac22523 | 73 | } |
74 | ||
25b7f84c | 75 | void |
e304ea31 | 76 | AliHLTPHOSClusterizer::SetRecPointDataPtr(AliHLTPHOSRecPointDataStruct* recPointDataPtr) |
77 | { | |
78 | fRecPointDataPtr = recPointDataPtr; | |
79 | } | |
2374af72 | 80 | |
9cc0deb1 | 81 | void |
e304ea31 | 82 | AliHLTPHOSClusterizer::SetRecoParameters(AliPHOSRecoParam* params) |
9cc0deb1 | 83 | { |
2374af72 | 84 | //see header file for documentation |
ae1c1854 | 85 | #ifndef HAVE_NOT_PHOSRECOPARAMEMC // set from configure if EMC functionality not available in AliPHOSRecoParam |
86 | // the new AliPHOSRecoParam functions, available from revision | |
94594220 | 87 | // fEmcClusteringThreshold = params->GetEMCClusteringThreshold(); |
88 | // fEmcMinEnergyThreshold = params->GetEMCMinE(); | |
89 | // fLogWeight = params->GetEMCLogWeight(); | |
e304ea31 | 90 | params++; |
91 | params--; | |
ae1c1854 | 92 | #else |
93 | fEmcClusteringThreshold = params->GetClusteringThreshold(); | |
94 | fEmcMinEnergyThreshold = params->GetMinE(); | |
95 | fLogWeight = params->GetLogWeight(); | |
96 | #endif | |
94594220 | 97 | } |
aac22523 | 98 | |
9cc0deb1 | 99 | Int_t |
e304ea31 | 100 | AliHLTPHOSClusterizer::ClusterizeEvent(UInt_t availableSize, UInt_t& totSize) |
aac22523 | 101 | { |
2374af72 | 102 | //see header file for documentation |
aac22523 | 103 | Int_t nRecPoints = 0; |
e304ea31 | 104 | |
105 | UInt_t maxRecPointSize = sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate... | |
106 | ||
9cc0deb1 | 107 | //Clusterization starts |
e304ea31 | 108 | for(UInt_t i = 0; i < fDigitContainerPtr->fNDigits; i++) |
9cc0deb1 | 109 | { |
d949e02e | 110 | fDigitsInCluster = 0; |
e304ea31 | 111 | |
9cc0deb1 | 112 | if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold) |
aac22523 | 113 | { |
9cc0deb1 | 114 | continue; |
aac22523 | 115 | } |
e304ea31 | 116 | if(availableSize < (totSize + maxRecPointSize)) |
117 | { | |
118 | return -1; //Might get out of buffer, exiting | |
119 | } | |
120 | ||
121 | // First digit is placed at the fDigits member variable in the recpoint | |
122 | fDigitDataPtr = &(fRecPointDataPtr->fDigits); | |
123 | ||
124 | fRecPointDataPtr->fAmp = 0; | |
125 | fRecPointDataPtr->fModule = fDigitContainerPtr->fDigitDataStruct[i].fModule; | |
126 | // Assigning digit data to the digit pointer | |
127 | fRecPointDataPtr->fDigits = fDigitContainerPtr->fDigitDataStruct[i]; | |
128 | ||
129 | // Incrementing the pointer to be ready for new entry | |
130 | fDigitDataPtr++; | |
131 | ||
132 | fRecPointDataPtr->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy; | |
9cc0deb1 | 133 | fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0; |
134 | fDigitsInCluster++; | |
135 | nRecPoints++; | |
e304ea31 | 136 | |
137 | // Scanning for the neighbours | |
138 | ScanForNeighbourDigits(i, fRecPointDataPtr); | |
139 | ||
140 | totSize += sizeof(AliHLTPHOSRecPointDataStruct) + (fDigitsInCluster-1)*sizeof(AliHLTPHOSDigitDataStruct); | |
141 | fRecPointDataPtr->fMultiplicity = fDigitsInCluster; | |
142 | ||
143 | fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(fDigitDataPtr); | |
9cc0deb1 | 144 | }//end of clusterization |
e304ea31 | 145 | |
146 | return nRecPoints; | |
9cc0deb1 | 147 | } |
aac22523 | 148 | |
9cc0deb1 | 149 | void |
150 | AliHLTPHOSClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTPHOSRecPointDataStruct* recPoint) | |
aac22523 | 151 | { |
2374af72 | 152 | //see header file for documentation |
e304ea31 | 153 | Int_t max = TMath::Min((Int_t)fDigitContainerPtr->fNDigits, (Int_t)fMaxDigitIndexDiff+index); |
154 | Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff)); | |
155 | ||
156 | max = fDigitContainerPtr->fNDigits; | |
157 | min = 0; | |
158 | for(Int_t j = min; j < max; j++) | |
aac22523 | 159 | { |
9cc0deb1 | 160 | if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold) |
161 | { | |
e304ea31 | 162 | if(j != index) |
9cc0deb1 | 163 | { |
e304ea31 | 164 | if(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]), |
165 | &(fDigitContainerPtr->fDigitDataStruct[j]))) | |
166 | { | |
167 | // Assigning value to digit ptr | |
168 | *fDigitDataPtr = fDigitContainerPtr->fDigitDataStruct[j]; | |
169 | // Incrementing digit pointer to be ready for new entry | |
170 | fDigitDataPtr++; | |
171 | ||
172 | recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy; | |
173 | fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0; | |
174 | fDigitsInCluster++; | |
175 | ScanForNeighbourDigits(j, recPoint); | |
176 | } | |
9cc0deb1 | 177 | } |
aac22523 | 178 | } |
e304ea31 | 179 | } |
9cc0deb1 | 180 | return; |
181 | } | |
6e709a0d | 182 | |
9cc0deb1 | 183 | Int_t |
184 | AliHLTPHOSClusterizer::AreNeighbours(AliHLTPHOSDigitDataStruct* digit1, | |
185 | AliHLTPHOSDigitDataStruct* digit2) | |
6e709a0d | 186 | { |
2374af72 | 187 | //see header file for documentation |
9cc0deb1 | 188 | if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module |
189 | { | |
9cc0deb1 | 190 | Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ ); |
191 | Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX ); | |
94594220 | 192 | if (( coldiff <= 1 && rowdiff < 1 ) || ( coldiff < 1 && rowdiff <= 1 )) |
6e709a0d | 193 | { |
9cc0deb1 | 194 | if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate) |
d949e02e | 195 | { |
d949e02e | 196 | return 1; |
197 | } | |
6e709a0d | 198 | } |
6e709a0d | 199 | } |
200 | return 0; | |
201 | } |