]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMaker.cxx
Delete GL annotations when going to a new event.
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMaker.cxx
CommitLineData
1b41ab20 1// $Id$
2
2374af72 3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
6 * *
7 * Primary Authors: Oystein Djuvsland *
94594220 8 s* *
2374af72 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
d949e02e 21 * @brief Digit maker for PHOS HLT
2374af72 22 */
94594220 23
24
25
2374af72 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
209a4703 32
33#include "AliHLTPHOSDigitMaker.h"
18af2efc 34
209a4703 35#include "AliHLTPHOSConstants.h"
94594220 36#include "AliHLTPHOSMapper.h"
209a4703 37
94594220 38#include "AliHLTPHOSChannelDataStruct.h"
39#include "AliHLTPHOSChannelDataHeaderStruct.h"
209a4703 40#include "AliHLTPHOSDigitDataStruct.h"
94594220 41#include "AliHLTPHOSSharedMemoryInterfacev2.h" // added by PTH
42
e304ea31 43#include "TH2F.h"
2374af72 44
45ClassImp(AliHLTPHOSDigitMaker);
209a4703 46
47using namespace PhosHLTConst;
48
49AliHLTPHOSDigitMaker::AliHLTPHOSDigitMaker() :
50 AliHLTPHOSBase(),
04da0321 51 fShmPtr(0),
d949e02e 52 fDigitStructPtr(0),
8394d59f 53 fDigitCount(0),
e304ea31 54 fOrdered(true),
55 fMapperPtr(0)
209a4703 56{
2374af72 57 // See header file for documentation
94594220 58
59 fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
60
27029341 61 for(int x = 0; x < NXCOLUMNSMOD; x++)
25b7f84c 62 {
27029341 63 for(int z = 0; z < NZROWSMOD; z++)
25b7f84c 64 {
65 fHighGainFactors[x][z] = 0.005;
66 fLowGainFactors[x][z] = 0.08;
27029341 67 fBadChannelMask[x][z][HIGHGAIN] = 1;
68 fBadChannelMask[x][z][LOWGAIN] = 1;
25b7f84c 69 }
e304ea31 70 }
71 fMapperPtr = new AliHLTPHOSMapper();
7ce40e5c 72
209a4703 73}
7ce40e5c 74
209a4703 75AliHLTPHOSDigitMaker::~AliHLTPHOSDigitMaker()
76{
2374af72 77 //See header file for documentation
209a4703 78}
79
80Int_t
e304ea31 81AliHLTPHOSDigitMaker::MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize)
209a4703 82{
2374af72 83 //See header file for documentation
25b7f84c 84
209a4703 85 Int_t j = 0;
e304ea31 86 UInt_t totSize = sizeof(AliHLTPHOSDigitDataStruct);
87
94594220 88// Int_t xMod = -1;
89// Int_t zMod = -1;
90
94594220 91 UShort_t coord1[4];
92 UShort_t coord2[4];
93
94
95 AliHLTPHOSChannelDataStruct* currentchannel = 0;
96 AliHLTPHOSChannelDataStruct* currentchannelLG = 0;
97 AliHLTPHOSChannelDataStruct* tmpchannel = 0;
e304ea31 98
94594220 99 fShmPtr->SetMemory(channelDataHeader);
7ce40e5c 100 currentchannel = fShmPtr->NextChannel();
7ce40e5c 101
94594220 102 while(currentchannel != 0)
14ff16ed 103 {
e304ea31 104 if(availableSize < totSize) return -1;
105
94594220 106 AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord1);
e304ea31 107
108 if(fOrdered) // High gain comes before low gain
109 {
94594220 110 tmpchannel = currentchannel;
e304ea31 111
27029341 112 if(coord1[2] == HIGHGAIN) // We got a completely new crystal
d949e02e 113 {
94594220 114
27029341 115 if(currentchannel->fEnergy < MAXBINVALUE) // Make sure we don't have signal overflow
94594220 116 {
e304ea31 117
118 AddDigit(currentchannel, coord1);
94594220 119 j++;
e304ea31 120 totSize += sizeof(AliHLTPHOSDigitDataStruct);
121
122 currentchannel = fShmPtr->NextChannel(); // Get the next channel
123
124 if(currentchannel != 0) // There was a next channel!
d8122453 125 {
e304ea31 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 }
d8122453 131 }
94594220 132 }
e304ea31 133
134 else // Ooops, overflow, we try the next channel...
94594220 135 {
136 currentchannel = fShmPtr->NextChannel();
e304ea31 137 if(currentchannel != 0) // There was a next channel
94594220 138 {
e304ea31 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
94594220 157 }
94594220 158 }
159 }
e304ea31 160 else // Well, there seem to be missing a high gain channel for this crystal, let's use the low gain one
94594220 161 {
e304ea31 162 AddDigit(tmpchannel, coord1);
94594220 163 j++;
e304ea31 164 totSize += sizeof(AliHLTPHOSDigitDataStruct);
165 currentchannel = fShmPtr->NextChannel();
d949e02e 166 }
94594220 167
168 }
e304ea31 169 else //Reversed ordered (low gain before high gain)
94594220 170 {
27029341 171 if(coord1[2] == LOWGAIN) // We got a new channel!
d949e02e 172 {
e304ea31 173 currentchannelLG = currentchannel; // Ok, let's back up the low gain channel and look for the fancy high gain one
94594220 174 currentchannel = fShmPtr->NextChannel();
e304ea31 175
176 if(currentchannel != 0) //There was another channel in the event
94594220 177 {
e304ea31 178 AliHLTPHOSMapper::GetChannelCoord(currentchannel->fChannelID, coord2);
179
180 if(coord1[0] == coord2[0] && coord1[1] == coord2[1]) // Aha! Found the high gain channel
94594220 181 {
27029341 182 if(currentchannel->fEnergy < MAXBINVALUE) // To overflow or not to overflow?
e304ea31 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 }
94594220 197 }
18af2efc 198 else // No available high gain channel for this crystal, adding the low gain one
94594220 199 {
e304ea31 200 AddDigit(currentchannelLG, coord1);
94594220 201 j++;
e304ea31 202 totSize += sizeof(AliHLTPHOSDigitDataStruct);
94594220 203 }
204 }
18af2efc 205 else //Fine, no more channels, better add this one...
94594220 206 {
e304ea31 207 AddDigit(currentchannelLG, coord1);
d949e02e 208 j++;
e304ea31 209 totSize += sizeof(AliHLTPHOSDigitDataStruct);
d949e02e 210 }
e304ea31 211 }
212 else // Cool, no annoying low gain channel for this channel
94594220 213 {
e304ea31 214 AddDigit(currentchannel, coord1);
94594220 215 j++;
e304ea31 216 currentchannel = fShmPtr->NextChannel();
94594220 217 }
14ff16ed 218 }
14ff16ed 219 }
94594220 220
14ff16ed 221 fDigitCount += j;
222 return fDigitCount;
223}
224
d949e02e 225void
226AliHLTPHOSDigitMaker::SetGlobalHighGainFactor(Float_t factor)
209a4703 227{
d949e02e 228 //See header file for documentation
27029341 229 for(int x = 0; x < NXCOLUMNSMOD; x++)
d949e02e 230 {
27029341 231 for(int z = 0; z < NZROWSMOD; z++)
d949e02e 232 {
233 fHighGainFactors[x][z] = factor;
234 }
235 }
209a4703 236}
209a4703 237
238void
d949e02e 239AliHLTPHOSDigitMaker::SetGlobalLowGainFactor(Float_t factor)
240{
241 //See header file for documentation
27029341 242 for(int x = 0; x < NXCOLUMNSMOD; x++)
d949e02e 243 {
27029341 244 for(int z = 0; z < NZROWSMOD; z++)
d949e02e 245 {
246 fLowGainFactors[x][z] = factor;
247 }
248 }
209a4703 249}
250
7ce40e5c 251void
252AliHLTPHOSDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut)
253{
27029341 254 for(int x = 0; x < NXCOLUMNSMOD; x++)
7ce40e5c 255 {
27029341 256 for(int z = 0; z < NZROWSMOD; z++)
7ce40e5c 257 {
258 if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0)
259 {
27029341 260 fBadChannelMask[x][z][HIGHGAIN] = 1;
7ce40e5c 261 }
262 else
263 {
27029341 264 fBadChannelMask[x][z][HIGHGAIN] = 0;
7ce40e5c 265 }
266 if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0)
267 {
27029341 268 fBadChannelMask[x][z][LOWGAIN] = 0;
7ce40e5c 269 }
270 else
271 {
27029341 272 fBadChannelMask[x][z][LOWGAIN] = 0;
7ce40e5c 273 }
274 }
275 }
276}
e304ea31 277