]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/CALO/AliHLTCaloDigitMaker.cxx
Porting HLT doxygen documentation to cmake
[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
ebf7a8e8 18 * @file AliHLTCaloDigitMaker.cxx\r
ef44ec64 19 * @author Oystein Djuvsland\r
20 * @date \r
21 * @brief Digit maker for CALO HLT \r
22 */\r
bdaaafe2 23 \r
ef44ec64 24\r
25// see header file for class documentation\r
26// or\r
27// refer to README to build package\r
28// or\r
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt\r
30\r
31#include "AliHLTCaloDigitMaker.h"\r
4f4b7ba4 32#include "AliHLTCaloConstantsHandler.h"\r
ef44ec64 33#include "AliHLTCaloMapper.h"\r
ef44ec64 34#include "AliHLTCaloChannelDataStruct.h"\r
35#include "AliHLTCaloChannelDataHeaderStruct.h"\r
36#include "AliHLTCaloDigitDataStruct.h"\r
f137c3c5 37#include "AliHLTCaloCoordinate.h"\r
ef44ec64 38#include "AliHLTCaloSharedMemoryInterfacev2.h" // added by PTH\r
39//#include "AliPHOSEMCAGeometry.h"\r
40#include "TH2F.h"\r
ef44ec64 41#include "AliHLTCaloConstants.h"\r
4655c95e 42#include "AliHLTLogging.h"\r
ef44ec64 43\r
44ClassImp(AliHLTCaloDigitMaker);\r
45\r
46//using namespace CaloHLTConst;\r
47\r
48AliHLTCaloDigitMaker::AliHLTCaloDigitMaker(TString det) :\r
4f4b7ba4 49 AliHLTCaloConstantsHandler(det),\r
4655c95e 50 AliHLTLogging(),\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
e4d93924 102 delete [] fHighGainFactors;\r
103 delete [] fLowGainFactors;\r
104 delete [] fBadChannelMask; \r
105 delete [] fChannelBook;\r
106 delete fShmPtr;\r
107\r
ef44ec64 108}\r
109\r
110Int_t\r
111AliHLTCaloDigitMaker::MakeDigits(AliHLTCaloChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize)\r
112{\r
113 //See header file for documentation\r
114 \r
37616445 115 Reset();\r
ad44d760 116\r
ef44ec64 117 UInt_t totSize = sizeof(AliHLTCaloDigitDataStruct);\r
118 \r
119// Int_t xMod = -1;\r
120// Int_t zMod = -1;\r
121 \r
f137c3c5 122\r
123 AliHLTCaloCoordinate coord;\r
ef44ec64 124 \r
125 \r
126 AliHLTCaloChannelDataStruct* currentchannel = 0;\r
ef44ec64 127 \r
128 fShmPtr->SetMemory(channelDataHeader);\r
129 currentchannel = fShmPtr->NextChannel();\r
130\r
131 while(currentchannel != 0)\r
132 {\r
133 if(availableSize < totSize) return -1;\r
134\r
f137c3c5 135 fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord);\r
ef44ec64 136 \r
f137c3c5 137 // fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
138 if(UseDigit(coord, currentchannel))\r
37616445 139 {\r
f137c3c5 140 AddDigit(currentchannel, coord);\r
ad44d760 141 // j++; \r
142 totSize += sizeof(AliHLTCaloDigitDataStruct);\r
37616445 143 }\r
37616445 144 currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
ef44ec64 145 }\r
f137c3c5 146// if(currentchannel)\r
147// {\r
148// fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
149// if(UseDigit(coord1, currentchannel))\r
150// {\r
151// AddDigit(currentchannel, coord1, locCoord);\r
152// j++; \r
153// totSize += sizeof(AliHLTCaloDigitDataStruct);\r
154// }\r
155// currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
156// }\r
157// }\r
37616445 158 \r
ad44d760 159// fDigitCount += j;\r
37616445 160 return fDigitCount; \r
ef44ec64 161}\r
162\r
163void \r
164AliHLTCaloDigitMaker::SetGlobalHighGainFactor(Float_t factor)\r
165{\r
166 //See header file for documentation\r
167 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
168 {\r
169 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
170 {\r
171 fHighGainFactors[x][z] = factor;\r
172 }\r
173 }\r
174}\r
175\r
dc3d3428 176\r
ef44ec64 177void\r
178AliHLTCaloDigitMaker::SetGlobalLowGainFactor(Float_t factor)\r
179{\r
180 //See header file for documentation\r
181 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
182 {\r
183 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
184 {\r
185 fLowGainFactors[x][z] = factor;\r
186 }\r
187 }\r
188}\r
189\r
dc3d3428 190\r
ef44ec64 191void\r
192AliHLTCaloDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut)\r
193{\r
194 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
195 {\r
196 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
197 {\r
198 if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0)\r
199 {\r
c1e4a18c 200 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = true;\r
ef44ec64 201 }\r
202 else\r
203 {\r
c1e4a18c 204 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false;\r
ef44ec64 205 }\r
206 if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0)\r
207 {\r
c1e4a18c 208 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false;\r
ef44ec64 209 }\r
210 else\r
211 {\r
c1e4a18c 212 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false;\r
ef44ec64 213 }\r
214 }\r
215 }\r
216}\r
217\r
218void\r
219AliHLTCaloDigitMaker::Reset()\r
220{\r
221 fDigitCount = 0;\r
222 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
223 {\r
224 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
225 {\r
226 fChannelBook[x][z] = 0;\r
227 }\r
228 } \r
229\r
230}\r
231\r
232\r
f137c3c5 233void AliHLTCaloDigitMaker::AddDigit(AliHLTCaloChannelDataStruct* channelData, AliHLTCaloCoordinate &coord)\r
ef44ec64 234{\r
235\r
07c2554e 236 // Some book keeping of the pointers\r
ad44d760 237 AliHLTCaloDigitDataStruct *tmpDigit = fDigitStructPtr + 1;\r
238\r
07c2554e 239 // Check if we already have a digit in this position, and correct the book keeping correspondently\r
240 if(fChannelBook[coord.fX][coord.fZ]) \r
ad44d760 241 {\r
242 tmpDigit = fDigitStructPtr;\r
243 fDigitStructPtr = fChannelBook[coord.fX][coord.fZ];\r
244 fDigitCount--;\r
245 // printf("Going to overwrite digit: x = %d, z = %d, gain = %d, energy = %f\n", fDigitStructPtr->fX, fDigitStructPtr->fZ, fDigitStructPtr->fGain, fDigitStructPtr->fEnergy);\r
246 }\r
247 \r
f137c3c5 248 fChannelBook[coord.fX][coord.fZ] = fDigitStructPtr;\r
7c80a370 249 \r
f137c3c5 250 fDigitStructPtr->fX = coord.fX;\r
251 fDigitStructPtr->fZ = coord.fZ;\r
ad44d760 252 fDigitStructPtr->fGain = coord.fGain;\r
f137c3c5 253 fDigitStructPtr->fOverflow = false;\r
f92543f5 254 fDigitStructPtr->fAssociatedCluster = -1;\r
7c80a370 255 \r
256 fDigitStructPtr->fID = fDigitStructPtr->fZ * fCaloConstants->GetNXCOLUMNSMOD() + fDigitStructPtr->fX;\r
7173b37b 257 \r
f137c3c5 258 if(coord.fGain == fCaloConstants->GetHIGHGAIN() )\r
ef44ec64 259 {\r
f137c3c5 260 fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[coord.fX][coord.fZ];\r
07c2554e 261 fDigitStructPtr->fHgPresent = true;\r
f137c3c5 262 if(channelData->fEnergy >= fMaxEnergy)\r
ef44ec64 263 {\r
264 fDigitStructPtr->fOverflow = true;\r
265 }\r
bdaaafe2 266 \r
bdaaafe2 267 HLTDebug("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", \r
268 coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy);\r
ef44ec64 269 }\r
270 else\r
271 {\r
f137c3c5 272 fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[coord.fX][coord.fZ];\r
ac4d2ac8 273 if(channelData->fEnergy >= fMaxEnergy)\r
ef44ec64 274 {\r
275 fDigitStructPtr->fOverflow = true;\r
276 }\r
bdaaafe2 277 HLTDebug("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); \r
ef44ec64 278 }\r
279 fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO\r
280 fDigitStructPtr->fCrazyness = channelData->fCrazyness;\r
f137c3c5 281 fDigitStructPtr->fModule = coord.fModuleId;\r
ad44d760 282 fDigitStructPtr = tmpDigit;\r
283 // fDigitStructPtr++;\r
284 fDigitCount++;\r
ef44ec64 285}\r
286\r
f137c3c5 287bool AliHLTCaloDigitMaker::UseDigit(AliHLTCaloCoordinate &channelCoordinates, AliHLTCaloChannelDataStruct *channel) \r
ef44ec64 288{\r
7173b37b 289 \r
c1e4a18c 290 if(fBadChannelMask[channelCoordinates.fX][channelCoordinates.fZ][0] == true) return false;\r
7173b37b 291 if(channel->fTime < fMinTime || channel->fTime > fMaxTime) return false;\r
292 \r
f137c3c5 293 AliHLTCaloDigitDataStruct *tmpDigit = fChannelBook[channelCoordinates.fX][channelCoordinates.fZ];\r
7c80a370 294 //printf("UseDigit: Got digit, x: %d, z: %d, gain: %d, amp: %f\n", channelCoordinates.fX, channelCoordinates.fZ, channelCoordinates.fGain, channel->fEnergy);\r
ef44ec64 295 if(tmpDigit)\r
296 {\r
f137c3c5 297 if(channelCoordinates.fGain == fCaloConstants->GetLOWGAIN())\r
ef44ec64 298 {\r
cd9e2797 299 //printf("UseDigit: Already have digit with, x: %d, z: %d, with high gain \n", channelCoordinates.fX, channelCoordinates.fZ);\r
ef44ec64 300 if(tmpDigit->fOverflow)\r
301 {\r
cd9e2797 302 // printf("But it was in overflow! Let's use this low gain!\n");\r
ef44ec64 303 return true;\r
304 }\r
305 return false;\r
306 }\r
307 else\r
308 {\r
cd9e2797 309 //printf("UseDigit: Already have digit with, x: %d, z: %d, with low gain: %d\n", channelCoordinates.fX, channelCoordinates.fZ);\r
f137c3c5 310 if(channel->fEnergy > fMaxEnergy )\r
ef44ec64 311 {\r
07c2554e 312 tmpDigit->fHgPresent = true;\r
ef44ec64 313 return false;\r
314 }\r
315 return true;\r
316 }\r
317 }\r
318 return true;\r
319}\r
c1e4a18c 320\r
321void AliHLTCaloDigitMaker::SetBadChannel(Int_t x, Int_t z, Bool_t bad)\r
322{\r
323 // See header file for class documentation\r
c1e4a18c 324 fBadChannelMask[x][z][0] = bad;\r
325 fBadChannelMask[x][z][1] = bad;\r
326}\r
327\r
328void AliHLTCaloDigitMaker::SetGain(Int_t x, Int_t z, Float_t ratio, Float_t gain)\r
329{\r
330 // See header file for class documentation\r
07c2554e 331 HLTDebug("Applying gain: %f for channel x: %d, z: %d", gain, x, z); \r
c1e4a18c 332 fHighGainFactors[x][z] = gain;\r
333 fLowGainFactors[x][z] = gain * ratio;\r
334 \r
335}\r