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