]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/CALO/AliHLTCaloDigitMaker.cxx
- adding new test macro for PHOS using the ported classes
[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
39#include "AliHLTCaloSharedMemoryInterfacev2.h" // added by PTH\r
40//#include "AliPHOSEMCAGeometry.h"\r
41#include "TH2F.h"\r
ef44ec64 42#include "AliHLTCaloConstants.h"\r
43\r
44ClassImp(AliHLTCaloDigitMaker);\r
45\r
46//using namespace CaloHLTConst;\r
47\r
48AliHLTCaloDigitMaker::AliHLTCaloDigitMaker(TString det) :\r
4f4b7ba4 49 AliHLTCaloConstantsHandler(det),\r
ef44ec64 50 fShmPtr(0),\r
51 fDigitStructPtr(0),\r
52 fDigitCount(0),\r
ef44ec64 53 fMapperPtr(0),\r
54 fHighGainFactors(0),\r
55 fLowGainFactors(0),\r
56 fBadChannelMask(0),\r
4f4b7ba4 57 fChannelBook(0)\r
ef44ec64 58{\r
ef44ec64 59 // See header file for documentation\r
60\r
4f4b7ba4 61 fShmPtr = new AliHLTCaloSharedMemoryInterfacev2(det);\r
ef44ec64 62\r
63 fHighGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()];\r
64 fLowGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 65 \r
ef44ec64 66 fBadChannelMask = new Float_t**[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 67 \r
ef44ec64 68 fChannelBook= new AliHLTCaloDigitDataStruct**[fCaloConstants->GetNXCOLUMNSMOD()];\r
4f4b7ba4 69 \r
ef44ec64 70 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
71 {\r
72 fHighGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()];\r
73 fLowGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()];\r
74\r
75 fBadChannelMask[x] = new Float_t*[fCaloConstants->GetNZROWSMOD()];\r
76\r
77 fChannelBook[x] = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNZROWSMOD()];\r
78\r
79 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
80 {\r
81\r
82 fHighGainFactors[x][z] = 0.005;\r
83 fLowGainFactors[x][z] = 0.08;\r
84 \r
85 fBadChannelMask[x][z] = new Float_t[fCaloConstants->GetNGAINS()];\r
86 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = 1;\r
87 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = 1; \r
88 \r
89 fChannelBook[x][z] = 0;\r
90 \r
91 }\r
92 } \r
93 \r
94 //Must be set in child instance\r
c375e15d 95 //fMapperPtr = new AliHLTCaloMapper(det);\r
c375e15d 96\r
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
110 \r
ef44ec64 111 Int_t j = 0;\r
112 UInt_t totSize = sizeof(AliHLTCaloDigitDataStruct);\r
113 \r
114// Int_t xMod = -1;\r
115// Int_t zMod = -1;\r
116 \r
117 UShort_t coord1[4];\r
f1bfc65f 118 // UShort_t coord2[4];\r
ef44ec64 119 Float_t locCoord[3];\r
120 \r
121 \r
122 AliHLTCaloChannelDataStruct* currentchannel = 0;\r
f1bfc65f 123 // AliHLTCaloChannelDataStruct* currentchannelLG = 0; \r
ef44ec64 124 AliHLTCaloChannelDataStruct* tmpchannel = 0;\r
125 \r
126 fShmPtr->SetMemory(channelDataHeader);\r
127 currentchannel = fShmPtr->NextChannel();\r
128\r
129 while(currentchannel != 0)\r
130 {\r
131 if(availableSize < totSize) return -1;\r
132\r
133 fMapperPtr->GetChannelCoord(currentchannel->fChannelID, coord1);\r
134 \r
135 tmpchannel = currentchannel;\r
136 \r
37616445 137 fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
138 if(UseDigit(coord1, currentchannel))\r
139 {\r
140 AddDigit(currentchannel, coord1, locCoord);\r
141 j++; \r
142 totSize += sizeof(AliHLTCaloDigitDataStruct);\r
143 }\r
144 \r
145 currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
146\r
147 fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord);\r
148 if(UseDigit(coord1, currentchannel))\r
149 {\r
150 AddDigit(currentchannel, coord1, locCoord);\r
151 j++; \r
152 totSize += sizeof(AliHLTCaloDigitDataStruct);\r
153 }\r
154 currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
ef44ec64 155 }\r
37616445 156 \r
157 fDigitCount += j;\r
158 return fDigitCount; \r
ef44ec64 159}\r
160\r
161void \r
162AliHLTCaloDigitMaker::SetGlobalHighGainFactor(Float_t factor)\r
163{\r
164 //See header file for documentation\r
165 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
166 {\r
167 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
168 {\r
169 fHighGainFactors[x][z] = factor;\r
170 }\r
171 }\r
172}\r
173\r
174void\r
175AliHLTCaloDigitMaker::SetGlobalLowGainFactor(Float_t factor)\r
176{\r
177 //See header file for documentation\r
178 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
179 {\r
180 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
181 {\r
182 fLowGainFactors[x][z] = factor;\r
183 }\r
184 }\r
185}\r
186\r
187void\r
188AliHLTCaloDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut)\r
189{\r
190 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
191 {\r
192 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
193 {\r
194 if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0)\r
195 {\r
196 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = 1;\r
197 }\r
198 else\r
199 {\r
200 fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = 0;\r
201 }\r
202 if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0)\r
203 {\r
204 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = 0;\r
205 }\r
206 else\r
207 {\r
208 fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = 0;\r
209 }\r
210 }\r
211 }\r
212}\r
213\r
214void\r
215AliHLTCaloDigitMaker::Reset()\r
216{\r
217 fDigitCount = 0;\r
218 for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)\r
219 {\r
220 for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)\r
221 {\r
222 fChannelBook[x][z] = 0;\r
223 }\r
224 } \r
225\r
226}\r
227\r
228\r
229void AliHLTCaloDigitMaker::AddDigit(AliHLTCaloChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)\r
230{\r
231\r
232 fChannelBook[channelCoordinates[0]][channelCoordinates[0]] = fDigitStructPtr;\r
233\r
234 fDigitStructPtr->fX = channelCoordinates[0];\r
235 fDigitStructPtr->fZ = channelCoordinates[1];\r
236\r
237 fDigitStructPtr->fLocX = localCoordinates[0];\r
238 fDigitStructPtr->fLocZ = localCoordinates[1];\r
239\r
240 if(channelCoordinates[2] == fCaloConstants->GetHIGHGAIN() )\r
241 {\r
242 fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[channelCoordinates[0]][channelCoordinates[1]];\r
243 if(channelData->fEnergy >= 1023)\r
244 {\r
245 fDigitStructPtr->fOverflow = true;\r
246 }\r
247 // printf("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy);\r
248 }\r
249 else\r
250 {\r
251 fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[channelCoordinates[0]][channelCoordinates[1]];\r
252 if(channelData->fEnergy >= 1023)\r
253 {\r
254 fDigitStructPtr->fOverflow = true;\r
255 }\r
256 // printf("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy); \r
257 }\r
258 fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO\r
259 fDigitStructPtr->fCrazyness = channelData->fCrazyness;\r
260 fDigitStructPtr->fModule = channelCoordinates[3];\r
261 fDigitStructPtr++;\r
262}\r
263\r
264bool AliHLTCaloDigitMaker::UseDigit(UShort_t *channelCoordinates, AliHLTCaloChannelDataStruct *channel) \r
265{\r
266 AliHLTCaloDigitDataStruct *tmpDigit = fChannelBook[channelCoordinates[0]][channelCoordinates[1]];\r
267 if(tmpDigit)\r
268 {\r
269 if(channelCoordinates[2] == fCaloConstants->GetLOWGAIN())\r
270 {\r
271 if(tmpDigit->fOverflow)\r
272 {\r
273 return true;\r
274 }\r
275 return false;\r
276 }\r
277 else\r
278 {\r
279 if(channel->fEnergy >= fCaloConstants->GetMAXBINVALUE() )\r
280 {\r
281 return false;\r
282 }\r
283 return true;\r
284 }\r
285 }\r
286 return true;\r
287}\r