]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Oystein Djuvsland * | |
8 | s* * | |
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 | **************************************************************************/ | |
17 | /** | |
18 | * @file AliHLTPHOSClusterizer.cxx | |
19 | * @author Oystein Djuvsland | |
20 | * @date | |
21 | * @brief Digit maker for PHOS HLT | |
22 | */ | |
23 | ||
24 | ||
25 | ||
26 | ||
27 | // see header file for class documentation | |
28 | // or | |
29 | // refer to README to build package | |
30 | // or | |
31 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
32 | ||
33 | #include "AliHLTPHOSDigitMaker.h" | |
34 | ||
35 | #include "AliHLTPHOSConstants.h" | |
36 | #include "AliHLTPHOSMapper.h" | |
37 | ||
38 | #include "AliHLTPHOSChannelDataStruct.h" | |
39 | #include "AliHLTPHOSChannelDataHeaderStruct.h" | |
40 | #include "AliHLTPHOSDigitDataStruct.h" | |
41 | #include "AliHLTPHOSSharedMemoryInterfacev2.h" // added by PTH | |
42 | ||
43 | #include "TH2F.h" | |
44 | ||
45 | ClassImp(AliHLTPHOSDigitMaker); | |
46 | ||
47 | using namespace PhosHLTConst; | |
48 | ||
49 | AliHLTPHOSDigitMaker::AliHLTPHOSDigitMaker() : | |
50 | AliHLTPHOSBase(), | |
51 | fShmPtr(0), | |
52 | fDigitStructPtr(0), | |
53 | fDigitCount(0), | |
54 | fOrdered(true), | |
55 | fMapperPtr(0) | |
56 | { | |
57 | // See header file for documentation | |
58 | ||
59 | fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2(); | |
60 | ||
61 | for(int x = 0; x < NXCOLUMNSMOD; x++) | |
62 | { | |
63 | for(int z = 0; z < NZROWSMOD; z++) | |
64 | { | |
65 | fHighGainFactors[x][z] = 0.005; | |
66 | fLowGainFactors[x][z] = 0.08; | |
67 | fBadChannelMask[x][z][HIGHGAIN] = 1; | |
68 | fBadChannelMask[x][z][LOWGAIN] = 1; | |
69 | } | |
70 | } | |
71 | fMapperPtr = new AliHLTPHOSMapper(); | |
72 | ||
73 | } | |
74 | ||
75 | AliHLTPHOSDigitMaker::~AliHLTPHOSDigitMaker() | |
76 | { | |
77 | //See header file for documentation | |
78 | } | |
79 | ||
80 | Int_t | |
81 | AliHLTPHOSDigitMaker::MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize) | |
82 | { | |
83 | //See header file for documentation | |
84 | ||
85 | Int_t j = 0; | |
86 | UInt_t totSize = sizeof(AliHLTPHOSDigitDataStruct); | |
87 | ||
88 | // Int_t xMod = -1; | |
89 | // Int_t zMod = -1; | |
90 | ||
91 | UShort_t coord1[4]; | |
92 | UShort_t coord2[4]; | |
93 | ||
94 | ||
95 | AliHLTPHOSChannelDataStruct* currentchannel = 0; | |
96 | AliHLTPHOSChannelDataStruct* currentchannelLG = 0; | |
97 | AliHLTPHOSChannelDataStruct* tmpchannel = 0; | |
98 | ||
99 | fShmPtr->SetMemory(channelDataHeader); | |
100 | currentchannel = fShmPtr->NextChannel(); | |
101 | ||
102 | while(currentchannel != 0) | |
103 | { | |
104 | if(availableSize < totSize) return -1; | |
105 | ||
106 | AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord1); | |
107 | ||
108 | if(fOrdered) // High gain comes before low gain | |
109 | { | |
110 | tmpchannel = currentchannel; | |
111 | ||
112 | if(coord1[2] == HIGHGAIN) // We got a completely new crystal | |
113 | { | |
114 | ||
115 | if(currentchannel->fEnergy < MAXBINVALUE) // Make sure we don't have signal overflow | |
116 | { | |
117 | ||
118 | AddDigit(currentchannel, coord1); | |
119 | j++; | |
120 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
121 | ||
122 | currentchannel = fShmPtr->NextChannel(); // Get the next channel | |
123 | ||
124 | if(currentchannel != 0) // There was a next channel! | |
125 | { | |
126 | AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord2); | |
127 | if(coord1[0] == coord2[0] && coord1[1] == coord2[1]) // Did we get the low gain channel for this crystal? | |
128 | { | |
129 | currentchannel = fShmPtr->NextChannel(); // In that case, jump to next channel | |
130 | } | |
131 | } | |
132 | } | |
133 | ||
134 | else // Ooops, overflow, we try the next channel... | |
135 | { | |
136 | currentchannel = fShmPtr->NextChannel(); | |
137 | if(currentchannel != 0) // There was a next channel | |
138 | { | |
139 | AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord2); | |
140 | if(coord2[0] == coord1[0] && coord2[1] == coord1[1]) // It is a low gain channel with the same coordinates, we may use it | |
141 | { | |
142 | ||
143 | AddDigit(currentchannel, coord2); | |
144 | j++; | |
145 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
146 | currentchannel = fShmPtr->NextChannel(); | |
147 | } | |
148 | ||
149 | else // No low gain channel with information about the overflow channel so we just use the overflowed one... | |
150 | { | |
151 | AddDigit(tmpchannel, coord1); | |
152 | j++; | |
153 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
154 | // no need to get the next channel here, we already did... | |
155 | } | |
156 | ||
157 | } | |
158 | } | |
159 | } | |
160 | else // Well, there seem to be missing a high gain channel for this crystal, let's use the low gain one | |
161 | { | |
162 | AddDigit(tmpchannel, coord1); | |
163 | j++; | |
164 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
165 | currentchannel = fShmPtr->NextChannel(); | |
166 | } | |
167 | ||
168 | } | |
169 | else //Reversed ordered (low gain before high gain) | |
170 | { | |
171 | if(coord1[2] == LOWGAIN) // We got a new channel! | |
172 | { | |
173 | currentchannelLG = currentchannel; // Ok, let's back up the low gain channel and look for the fancy high gain one | |
174 | currentchannel = fShmPtr->NextChannel(); | |
175 | ||
176 | if(currentchannel != 0) //There was another channel in the event | |
177 | { | |
178 | AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord2); | |
179 | ||
180 | if(coord1[0] == coord2[0] && coord1[1] == coord2[1]) // Aha! Found the high gain channel | |
181 | { | |
182 | if(currentchannel->fEnergy < MAXBINVALUE) // To overflow or not to overflow? | |
183 | { | |
184 | ||
185 | AddDigit(currentchannel, coord2); | |
186 | j++; | |
187 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
188 | currentchannel = fShmPtr->NextChannel(); | |
189 | } | |
190 | else // Oh well, better use the low gain channel then | |
191 | { | |
192 | AddDigit(currentchannelLG, coord1); | |
193 | j++; | |
194 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
195 | currentchannel = fShmPtr->NextChannel(); | |
196 | } | |
197 | } | |
198 | else // No available high gain channel for this crystal, adding the low gain one | |
199 | { | |
200 | AddDigit(currentchannelLG, coord1); | |
201 | j++; | |
202 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
203 | } | |
204 | } | |
205 | else //Fine, no more channels, better add this one... | |
206 | { | |
207 | AddDigit(currentchannelLG, coord1); | |
208 | j++; | |
209 | totSize += sizeof(AliHLTPHOSDigitDataStruct); | |
210 | } | |
211 | } | |
212 | else // Cool, no annoying low gain channel for this channel | |
213 | { | |
214 | AddDigit(currentchannel, coord1); | |
215 | j++; | |
216 | currentchannel = fShmPtr->NextChannel(); | |
217 | } | |
218 | } | |
219 | } | |
220 | ||
221 | fDigitCount += j; | |
222 | return fDigitCount; | |
223 | } | |
224 | ||
225 | void | |
226 | AliHLTPHOSDigitMaker::SetGlobalHighGainFactor(Float_t factor) | |
227 | { | |
228 | //See header file for documentation | |
229 | for(int x = 0; x < NXCOLUMNSMOD; x++) | |
230 | { | |
231 | for(int z = 0; z < NZROWSMOD; z++) | |
232 | { | |
233 | fHighGainFactors[x][z] = factor; | |
234 | } | |
235 | } | |
236 | } | |
237 | ||
238 | void | |
239 | AliHLTPHOSDigitMaker::SetGlobalLowGainFactor(Float_t factor) | |
240 | { | |
241 | //See header file for documentation | |
242 | for(int x = 0; x < NXCOLUMNSMOD; x++) | |
243 | { | |
244 | for(int z = 0; z < NZROWSMOD; z++) | |
245 | { | |
246 | fLowGainFactors[x][z] = factor; | |
247 | } | |
248 | } | |
249 | } | |
250 | ||
251 | void | |
252 | AliHLTPHOSDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut) | |
253 | { | |
254 | for(int x = 0; x < NXCOLUMNSMOD; x++) | |
255 | { | |
256 | for(int z = 0; z < NZROWSMOD; z++) | |
257 | { | |
258 | if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0) | |
259 | { | |
260 | fBadChannelMask[x][z][HIGHGAIN] = 1; | |
261 | } | |
262 | else | |
263 | { | |
264 | fBadChannelMask[x][z][HIGHGAIN] = 0; | |
265 | } | |
266 | if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0) | |
267 | { | |
268 | fBadChannelMask[x][z][LOWGAIN] = 0; | |
269 | } | |
270 | else | |
271 | { | |
272 | fBadChannelMask[x][z][LOWGAIN] = 0; | |
273 | } | |
274 | } | |
275 | } | |
276 | } | |
277 |