]>
Commit | Line | Data |
---|---|---|
87434909 | 1 | // $Id$ |
1b41ab20 | 2 | |
25b7f84c | 3 | /************************************************************************** |
ab38011b | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Oystein Djuvsland * | |
8 | * * | |
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 | **************************************************************************/ | |
209a4703 | 17 | |
18 | #include "AliHLTPHOSDigitMakerComponent.h" | |
f137c3c5 | 19 | #include "AliHLTCaloDigitMaker.h" |
20 | #include "AliHLTCaloDigitDataStruct.h" | |
21 | #include "AliHLTPHOSMapper.h" | |
94594220 | 22 | #include "AliHLTPHOSChannelDataHeaderStruct.h" |
e304ea31 | 23 | #include "AliHLTPHOSChannelDataStruct.h" |
c1e4a18c | 24 | #include "AliPHOSEmcBadChannelsMap.h" |
25 | #include "AliPHOSEmcCalibData.h" | |
209a4703 | 26 | #include "TFile.h" |
c1e4a18c | 27 | #include "AliCDBEntry.h" |
28 | #include "AliCDBPath.h" | |
29 | #include "AliCDBManager.h" | |
209a4703 | 30 | #include <sys/stat.h> |
31 | #include <sys/types.h> | |
32 | ||
2374af72 | 33 | |
34 | /** | |
ea54e1c8 | 35 | * @file AliHLTPHOSDigitMakerComponent.cxx |
2374af72 | 36 | * @author Oystein Djuvsland |
37 | * @date | |
38 | * @brief A digit maker component for PHOS HLT | |
39 | */ | |
40 | ||
41 | // see below for class documentation | |
42 | // or | |
43 | // refer to README to build package | |
44 | // or | |
45 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
46 | ||
47 | ||
209a4703 | 48 | AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent; |
49 | ||
50 | AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() : | |
51 | AliHLTPHOSProcessor(), | |
c1e4a18c | 52 | AliHLTCaloConstantsHandler("PHOS"), |
25b7f84c | 53 | fDigitMakerPtr(0), |
c1e4a18c | 54 | fDigitContainerPtr(0), |
55 | fBadChannelMap(0), | |
56 | fCalibData(0), | |
57 | fBCMInitialised(true), | |
58 | fGainsInitialised(true) | |
209a4703 | 59 | { |
2374af72 | 60 | //see header file for documentation |
209a4703 | 61 | } |
62 | ||
e304ea31 | 63 | |
209a4703 | 64 | AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent() |
65 | { | |
2374af72 | 66 | //see header file for documentation |
209a4703 | 67 | } |
68 | ||
69 | int | |
70 | AliHLTPHOSDigitMakerComponent::Deinit() | |
71 | { | |
2374af72 | 72 | //see header file for documentation |
209a4703 | 73 | if(fDigitMakerPtr) |
74 | { | |
75 | delete fDigitMakerPtr; | |
76 | fDigitMakerPtr = 0; | |
77 | } | |
52be7fb0 | 78 | return 0; |
209a4703 | 79 | } |
80 | ||
81 | const char* | |
82 | AliHLTPHOSDigitMakerComponent::GetComponentID() | |
83 | { | |
2374af72 | 84 | //see header file for documentation |
209a4703 | 85 | return "PhosDigitMaker"; |
86 | } | |
87 | ||
209a4703 | 88 | |
af6a2273 | 89 | void |
209a4703 | 90 | AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list) |
91 | { | |
2374af72 | 92 | //see header file for documentation |
94594220 | 93 | list.clear(); |
94 | list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType); | |
209a4703 | 95 | } |
96 | ||
97 | AliHLTComponentDataType | |
98 | AliHLTPHOSDigitMakerComponent::GetOutputDataType() | |
99 | { | |
2374af72 | 100 | //see header file for documentation |
25b7f84c | 101 | return AliHLTPHOSDefinitions::fgkDigitDataType; |
209a4703 | 102 | } |
103 | ||
104 | ||
105 | void | |
106 | AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
107 | { | |
2374af72 | 108 | //see header file for documentation |
e304ea31 | 109 | constBase = 0; |
f137c3c5 | 110 | inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1; |
209a4703 | 111 | } |
112 | ||
113 | int | |
114 | AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
115 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
116 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
117 | { | |
2374af72 | 118 | //see header file for documentation |
209a4703 | 119 | UInt_t offset = 0; |
120 | UInt_t mysize = 0; | |
e304ea31 | 121 | Int_t digitCount = 0; |
122 | Int_t ret = 0; | |
209a4703 | 123 | |
124 | AliHLTUInt8_t* outBPtr; | |
125 | outBPtr = outputPtr; | |
126 | const AliHLTComponentBlockData* iter = 0; | |
127 | unsigned long ndx; | |
d949e02e | 128 | |
129 | UInt_t specification = 0; | |
f137c3c5 | 130 | AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0; |
d949e02e | 131 | |
f137c3c5 | 132 | // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr)); |
133 | ||
134 | fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr)); | |
5c6cac96 | 135 | |
209a4703 | 136 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
137 | { | |
c1e4a18c | 138 | |
209a4703 | 139 | iter = blocks+ndx; |
140 | ||
94594220 | 141 | if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType) |
209a4703 | 142 | { |
c1e4a18c | 143 | // HLTDebug("Data block is not of type fgkChannelDataType"); |
209a4703 | 144 | continue; |
209a4703 | 145 | } |
c1e4a18c | 146 | if(!fBCMInitialised) |
147 | { | |
148 | AliHLTPHOSMapper mapper; | |
149 | Int_t module = mapper.GetModuleFromSpec(iter->fSpecification); | |
150 | for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) | |
151 | { | |
152 | for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) | |
153 | { | |
154 | fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1)); | |
155 | } | |
156 | } | |
157 | //delete fBadChannelMap; | |
158 | fBCMInitialised = true; | |
159 | } | |
160 | if(!fGainsInitialised) | |
161 | { | |
162 | AliHLTPHOSMapper mapper; | |
163 | Int_t module = mapper.GetModuleFromSpec(iter->fSpecification); | |
164 | for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) | |
165 | { | |
166 | for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) | |
167 | { | |
168 | fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1)); | |
169 | } | |
170 | } | |
171 | fGainsInitialised = true; | |
172 | } | |
e304ea31 | 173 | |
174 | specification |= iter->fSpecification; | |
f137c3c5 | 175 | tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr); |
94594220 | 176 | |
f137c3c5 | 177 | ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct))); |
e304ea31 | 178 | if(ret == -1) |
179 | { | |
c1e4a18c | 180 | // HLTError("Trying to write over buffer size"); |
e304ea31 | 181 | return -ENOBUFS; |
182 | } | |
183 | digitCount += ret; | |
209a4703 | 184 | } |
209a4703 | 185 | |
f137c3c5 | 186 | mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct); |
e304ea31 | 187 | |
c1e4a18c | 188 | //HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size); |
87434909 | 189 | |
87434909 | 190 | if(mysize > 0) |
209a4703 | 191 | { |
87434909 | 192 | AliHLTComponentBlockData bd; |
193 | FillBlockData( bd ); | |
194 | bd.fOffset = offset; | |
195 | bd.fSize = mysize; | |
196 | bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType; | |
197 | bd.fSpecification = specification; | |
198 | outputBlocks.push_back(bd); | |
209a4703 | 199 | } |
ab521ae4 | 200 | |
94594220 | 201 | fDigitMakerPtr->Reset(); |
9bf87c6f | 202 | |
203 | size = mysize; | |
204 | ||
209a4703 | 205 | return 0; |
206 | } | |
207 | ||
209a4703 | 208 | int |
209 | AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv ) | |
210 | { | |
2374af72 | 211 | //see header file for documentation |
209a4703 | 212 | |
f137c3c5 | 213 | fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS"); |
214 | ||
215 | AliHLTCaloMapper *mapper = new AliHLTPHOSMapper(); | |
216 | fDigitMakerPtr->SetMapper(mapper); | |
209a4703 | 217 | |
218 | for(int i = 0; i < argc; i++) | |
219 | { | |
d949e02e | 220 | if(!strcmp("-lowgainfactor", argv[i])) |
221 | { | |
222 | fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1])); | |
d949e02e | 223 | } |
224 | if(!strcmp("-highgainfactor", argv[i])) | |
225 | { | |
226 | fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1])); | |
d949e02e | 227 | } |
209a4703 | 228 | } |
229 | ||
c1e4a18c | 230 | if(GetBCMFromCDB()) return -1; |
231 | if(GetGainsFromCDB()) return -1; | |
232 | ||
209a4703 | 233 | //fDigitMakerPtr->SetDigitThreshold(2); |
234 | ||
235 | return 0; | |
236 | } | |
237 | ||
c1e4a18c | 238 | |
239 | int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB() | |
240 | { | |
241 | fBCMInitialised = false; | |
242 | ||
243 | // HLTInfo("Getting bad channel map..."); | |
244 | ||
245 | AliCDBPath path("PHOS","Calib","EmcBadChannels"); | |
246 | if(path.GetPath()) | |
247 | { | |
248 | // HLTInfo("configure from entry %s", path.GetPath()); | |
249 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
250 | /* if (pEntry) | |
251 | { | |
252 | fBadChannelMap = new Bool_t**[fCaloConstants->GetNMODULES()]; | |
253 | AliPHOSEmcBadChannelsMap * badMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject(); | |
254 | for(Int_t mod = 0; mod < fCaloConstants->GetNMODULES(); mod++) | |
255 | { | |
256 | fBadChannelMap[mod] = new Bool_t*[fCaloConstants->GetNXCOLUMNSMOD()]; | |
257 | for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) | |
258 | { | |
259 | fBadChannelMap[mod][x] = new Bool_t[fCaloConstants->GetNZROWSMOD()]; | |
260 | for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) | |
261 | { | |
262 | fBadChannelMap[mod][x][z] = badMap->IsBadChannel(5 - mod, z+1, x+1); | |
263 | if(badMap->IsBadChannel(5-mod, z+1, x+1)) printf("Module: %d, channel x: %d, z: %d is: %d\n", mod, x, z, badMap->IsBadChannel(5-mod, z+1, x+1)); | |
264 | } | |
265 | } | |
266 | } | |
267 | }*/ | |
268 | if (pEntry) | |
269 | { | |
270 | fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject(); | |
271 | } | |
272 | else | |
273 | { | |
274 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
275 | return -1; | |
276 | } | |
277 | } | |
278 | if(!fBadChannelMap) return -1; | |
279 | return 0; | |
280 | } | |
281 | ||
282 | int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB() | |
283 | { | |
284 | fGainsInitialised = false; | |
285 | ||
286 | // HLTInfo("Getting bad channel map..."); | |
287 | ||
288 | AliCDBPath path("PHOS","Calib","EmcGainPedestals"); | |
289 | if(path.GetPath()) | |
290 | { | |
291 | // HLTInfo("configure from entry %s", path.GetPath());*/ | |
292 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
293 | if (pEntry) | |
294 | { | |
295 | fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject(); | |
296 | } | |
297 | else | |
298 | { | |
299 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
300 | return -1; | |
301 | } | |
302 | } | |
303 | ||
304 | if(!fCalibData) return -1; | |
305 | return 0; | |
306 | ||
307 | } | |
308 | ||
309 | ||
209a4703 | 310 | AliHLTComponent* |
311 | AliHLTPHOSDigitMakerComponent::Spawn() | |
312 | { | |
2374af72 | 313 | //see header file for documentation |
209a4703 | 314 | return new AliHLTPHOSDigitMakerComponent(); |
315 | } |