]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/CALO/AliHLTCaloDigitMaker.cxx
- added HLT logging to the digit maker
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloDigitMaker.cxx
CommitLineData
ef44ec64 1// $Id$\r
2\r
3/**************************************************************************\r
4 * This file is property of and copyright by the ALICE HLT Project * \r
5 * All rights reserved. *\r
6 * *\r
7 * Primary Authors: Oystein Djuvsland *\r
8 * *\r
9 * Permission to use, copy, modify and distribute this software and its *\r
10 * documentation strictly for non-commercial purposes is hereby granted *\r
11 * without fee, provided that the above copyright notice appears in all *\r
12 * copies and that both the copyright notice and this permission notice *\r
13 * appear in the supporting documentation. The authors make no claims *\r
14 * about the suitability of this software for any purpose. It is * \r
15 * provided "as is" without express or implied warranty. *\r
16 **************************************************************************/\r
17 /** \r
18 * @file AliHLTCALOClusterizer.cxx\r
19 * @author Oystein Djuvsland\r
20 * @date \r
21 * @brief Digit maker for CALO HLT \r
22 */\r
23 \r
24\r
25 \r
26\r
27// see header file for class documentation\r
28// or\r
29// refer to README to build package\r
30// or\r
31// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt\r
32\r
33#include "AliHLTCaloDigitMaker.h"\r
4f4b7ba4 34#include "AliHLTCaloConstantsHandler.h"\r
ef44ec64 35#include "AliHLTCaloMapper.h"\r
ef44ec64 36#include "AliHLTCaloChannelDataStruct.h"\r
37#include "AliHLTCaloChannelDataHeaderStruct.h"\r
38#include "AliHLTCaloDigitDataStruct.h"\r
f137c3c5 39#include "AliHLTCaloCoordinate.h"\r
ef44ec64 40#include "AliHLTCaloSharedMemoryInterfacev2.h" // added by PTH\r
41//#include "AliPHOSEMCAGeometry.h"\r
42#include "TH2F.h"\r
ef44ec64 43#include "AliHLTCaloConstants.h"\r
44\r
45ClassImp(AliHLTCaloDigitMaker);\r
46\r
47//using namespace CaloHLTConst;\r
48\r
49AliHLTCaloDigitMaker::AliHLTCaloDigitMaker(TString det) :\r
4f4b7ba4 50 AliHLTCaloConstantsHandler(det),\r
ef44ec64 51 fShmPtr(0),\r
52 fDigitStructPtr(0),\r
53 fDigitCount(0),\r
ef44ec64 54 fMapperPtr(0),\r
55 fHighGainFactors(0),\r
56 fLowGainFactors(0),\r
57 fBadChannelMask(0),\r
f137c3c5 58 fChannelBook(0),\r
7173b37b 59 fMaxEnergy(900),\r
60 fMinTime(0.0),\r
61 fMaxTime(1008.0)\r
ef44ec64 62{\r
ef44ec64 63 // See header file for documentation\r
64\r
4f4b7ba4 65 fShmPtr = new AliHLTCaloSharedMemoryInterfacev2(det);\r
ef44ec64 66\r
67 fHighGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()];\r
68 fLowGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 69 \r
c1e4a18c 70 fBadChannelMask = new Bool_t**[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 71 \r
ef44ec64 72 fChannelBook= new AliHLTCaloDigitDataStruct**[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 73 \r
ef44ec64 74 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
75 {\r
76 fHighGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()];\r
77 fLowGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()];\r
78\r
c1e4a18c 79 fBadChannelMask[x] = new Bool_t*[fCaloConstants->GetNZROWSMOD()];\r
ef44ec64 80\r
81 fChannelBook[x] = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNZROWSMOD()];\r
82\r
83 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
84 {\r
85\r
7173b37b 86 fHighGainFactors[x][z] = 0.0153;\r
87 fLowGainFactors[x][z] = 0.245;\r
ef44ec64 88 \r
c1e4a18c 89 fBadChannelMask[x][z] = new Bool_t[fCaloConstants->GetNGAINS()];\r
90 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false;\r
91 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; \r
ef44ec64 92 \r
93 fChannelBook[x][z] = 0;\r
94 \r
95 }\r
96 } \r
c375e15d 97}\r
98\r
ef44ec64 99AliHLTCaloDigitMaker::~AliHLTCaloDigitMaker() \r
100{\r
101 //See header file for documentation\r
102}\r
103\r
104Int_t\r
105AliHLTCaloDigitMaker::MakeDigits(AliHLTCaloChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize)\r
106{\r
107 //See header file for documentation\r
108 \r
37616445 109 Reset();\r
ad44d760 110\r
ef44ec64 111 UInt_t totSize = sizeof(AliHLTCaloDigitDataStruct);\r
112 \r
113// Int_t xMod = -1;\r
114// Int_t zMod = -1;\r
115 \r
f137c3c5 116\r
117 AliHLTCaloCoordinate coord;\r
ef44ec64 118 \r
119 \r
120 AliHLTCaloChannelDataStruct* currentchannel = 0;\r
ef44ec64 121 \r
122 fShmPtr->SetMemory(channelDataHeader);\r
123 currentchannel = fShmPtr->NextChannel();\r
124\r
125 while(currentchannel != 0)\r
126 {\r
127 if(availableSize < totSize) return -1;\r
128\r
f137c3c5 129 fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord);\r
ef44ec64 130 \r
f137c3c5 131 // fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
132 if(UseDigit(coord, currentchannel))\r
37616445 133 {\r
f137c3c5 134 AddDigit(currentchannel, coord);\r
ad44d760 135 // j++; \r
136 totSize += sizeof(AliHLTCaloDigitDataStruct);\r
37616445 137 }\r
37616445 138 currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
ef44ec64 139 }\r
f137c3c5 140// if(currentchannel)\r
141// {\r
142// fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
143// if(UseDigit(coord1, currentchannel))\r
144// {\r
145// AddDigit(currentchannel, coord1, locCoord);\r
146// j++; \r
147// totSize += sizeof(AliHLTCaloDigitDataStruct);\r
148// }\r
149// currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
150// }\r
151// }\r
37616445 152 \r
ad44d760 153// fDigitCount += j;\r
37616445 154 return fDigitCount; \r
ef44ec64 155}\r
156\r
157void \r
158AliHLTCaloDigitMaker::SetGlobalHighGainFactor(Float_t factor)\r
159{\r
160 //See header file for documentation\r
161 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
162 {\r
163 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
164 {\r
165 fHighGainFactors[x][z] = factor;\r
166 }\r
167 }\r
168}\r
169\r
dc3d3428 170\r
ef44ec64 171void\r
172AliHLTCaloDigitMaker::SetGlobalLowGainFactor(Float_t factor)\r
173{\r
174 //See header file for documentation\r
175 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
176 {\r
177 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
178 {\r
179 fLowGainFactors[x][z] = factor;\r
180 }\r
181 }\r
182}\r
183\r
dc3d3428 184\r
ef44ec64 185void\r
186AliHLTCaloDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut)\r
187{\r
188 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
189 {\r
190 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
191 {\r
192 if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0)\r
193 {\r
c1e4a18c 194 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = true;\r
ef44ec64 195 }\r
196 else\r
197 {\r
c1e4a18c 198 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false;\r
ef44ec64 199 }\r
200 if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0)\r
201 {\r
c1e4a18c 202 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false;\r
ef44ec64 203 }\r
204 else\r
205 {\r
c1e4a18c 206 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false;\r
ef44ec64 207 }\r
208 }\r
209 }\r
210}\r
211\r
212void\r
213AliHLTCaloDigitMaker::Reset()\r
214{\r
215 fDigitCount = 0;\r
216 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
217 {\r
218 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
219 {\r
220 fChannelBook[x][z] = 0;\r
221 }\r
222 } \r
223\r
224}\r
225\r
226\r
f137c3c5 227void AliHLTCaloDigitMaker::AddDigit(AliHLTCaloChannelDataStruct* channelData, AliHLTCaloCoordinate &coord)\r
ef44ec64 228{\r
229\r
ad44d760 230 AliHLTCaloDigitDataStruct *tmpDigit = fDigitStructPtr + 1;\r
231\r
232 if(fChannelBook[coord.fX][coord.fZ])\r
233 {\r
234 tmpDigit = fDigitStructPtr;\r
235 fDigitStructPtr = fChannelBook[coord.fX][coord.fZ];\r
236 fDigitCount--;\r
237 // printf("Going to overwrite digit: x = %d, z = %d, gain = %d, energy = %f\n", fDigitStructPtr->fX, fDigitStructPtr->fZ, fDigitStructPtr->fGain, fDigitStructPtr->fEnergy);\r
238 }\r
239 \r
f137c3c5 240 fChannelBook[coord.fX][coord.fZ] = fDigitStructPtr;\r
ef44ec64 241\r
7c80a370 242 \r
f137c3c5 243 fDigitStructPtr->fX = coord.fX;\r
244 fDigitStructPtr->fZ = coord.fZ;\r
ad44d760 245 fDigitStructPtr->fGain = coord.fGain;\r
f137c3c5 246 fDigitStructPtr->fOverflow = false;\r
7c80a370 247 \r
248 fDigitStructPtr->fID = fDigitStructPtr->fZ * fCaloConstants->GetNXCOLUMNSMOD() + fDigitStructPtr->fX;\r
7173b37b 249 \r
f137c3c5 250 if(coord.fGain == fCaloConstants->GetHIGHGAIN() )\r
ef44ec64 251 {\r
f137c3c5 252 fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[coord.fX][coord.fZ];\r
253 if(channelData->fEnergy >= fMaxEnergy)\r
ef44ec64 254 {\r
255 fDigitStructPtr->fOverflow = true;\r
256 }\r
cd9e2797 257 //printf("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy);\r
ef44ec64 258 }\r
259 else\r
260 {\r
f137c3c5 261 fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[coord.fX][coord.fZ];\r
ac4d2ac8 262 if(channelData->fEnergy >= fMaxEnergy)\r
ef44ec64 263 {\r
264 fDigitStructPtr->fOverflow = true;\r
265 }\r
c1e4a18c 266 // printf("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); \r
ef44ec64 267 }\r
268 fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO\r
269 fDigitStructPtr->fCrazyness = channelData->fCrazyness;\r
f137c3c5 270 fDigitStructPtr->fModule = coord.fModuleId;\r
ad44d760 271 fDigitStructPtr = tmpDigit;\r
272 // fDigitStructPtr++;\r
273 fDigitCount++;\r
ef44ec64 274}\r
275\r
f137c3c5 276bool AliHLTCaloDigitMaker::UseDigit(AliHLTCaloCoordinate &channelCoordinates, AliHLTCaloChannelDataStruct *channel) \r
ef44ec64 277{\r
7173b37b 278 \r
c1e4a18c 279 if(fBadChannelMask[channelCoordinates.fX][channelCoordinates.fZ][0] == true) return false;\r
7173b37b 280 if(channel->fTime < fMinTime || channel->fTime > fMaxTime) return false;\r
281 \r
f137c3c5 282 AliHLTCaloDigitDataStruct *tmpDigit = fChannelBook[channelCoordinates.fX][channelCoordinates.fZ];\r
7c80a370 283 //printf("UseDigit: Got digit, x: %d, z: %d, gain: %d, amp: %f\n", channelCoordinates.fX, channelCoordinates.fZ, channelCoordinates.fGain, channel->fEnergy);\r
ef44ec64 284 if(tmpDigit)\r
285 {\r
f137c3c5 286 if(channelCoordinates.fGain == fCaloConstants->GetLOWGAIN())\r
ef44ec64 287 {\r
cd9e2797 288 //printf("UseDigit: Already have digit with, x: %d, z: %d, with high gain \n", channelCoordinates.fX, channelCoordinates.fZ);\r
ef44ec64 289 if(tmpDigit->fOverflow)\r
290 {\r
cd9e2797 291 // printf("But it was in overflow! Let's use this low gain!\n");\r
ef44ec64 292 return true;\r
293 }\r
294 return false;\r
295 }\r
296 else\r
297 {\r
cd9e2797 298 //printf("UseDigit: Already have digit with, x: %d, z: %d, with low gain: %d\n", channelCoordinates.fX, channelCoordinates.fZ);\r
f137c3c5 299 if(channel->fEnergy > fMaxEnergy )\r
ef44ec64 300 {\r
301 return false;\r
302 }\r
303 return true;\r
304 }\r
305 }\r
306 return true;\r
307}\r
c1e4a18c 308\r
309void AliHLTCaloDigitMaker::SetBadChannel(Int_t x, Int_t z, Bool_t bad)\r
310{\r
311 // See header file for class documentation\r
c1e4a18c 312 fBadChannelMask[x][z][0] = bad;\r
313 fBadChannelMask[x][z][1] = bad;\r
314}\r
315\r
316void AliHLTCaloDigitMaker::SetGain(Int_t x, Int_t z, Float_t ratio, Float_t gain)\r
317{\r
318 // See header file for class documentation\r
319 \r
320 fHighGainFactors[x][z] = gain;\r
321 fLowGainFactors[x][z] = gain * ratio;\r
322 \r
323}\r