]>
Commit | Line | Data |
---|---|---|
ca071d0a | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
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 | **************************************************************************/ | |
ca071d0a | 17 | #include "AliHLTEMCALDigitMakerComponent.h" |
18 | #include "AliHLTCaloDigitMaker.h" | |
19 | #include "AliHLTCaloDigitDataStruct.h" | |
20 | #include "AliHLTCaloChannelDataHeaderStruct.h" | |
21 | #include "AliHLTCaloChannelDataStruct.h" | |
22 | #include "AliHLTEMCALMapper.h" | |
23 | #include "AliHLTEMCALDefinitions.h" | |
7b3a0a0e | 24 | #include "AliCaloCalibPedestal.h" |
25 | #include "AliEMCALCalibData.h" | |
26 | #include "AliCDBEntry.h" | |
27 | #include "AliCDBPath.h" | |
28 | #include "AliCDBManager.h" | |
ca071d0a | 29 | #include "TFile.h" |
30 | #include <sys/stat.h> | |
31 | #include <sys/types.h> | |
32 | ||
dc3d3428 | 33 | //#include "AliHLTEMCALConstant.h" |
34 | #include "AliHLTCaloConstants.h" | |
35 | ||
36 | using EMCAL::NZROWSMOD; | |
37 | using EMCAL::NXCOLUMNSMOD; | |
72752456 | 38 | using CALO::HGLGFACTOR; |
ca071d0a | 39 | |
40 | /** | |
41 | * @file AliHLTEMCALDigitMakerComponent.cxx | |
42 | * @author Oystein Djuvsland | |
43 | * @date | |
44 | * @brief A digit maker component for EMCAL HLT | |
45 | */ | |
46 | ||
47 | // see below for class documentation | |
48 | // or | |
49 | // refer to README to build package | |
50 | // or | |
51 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
52 | ||
53 | ||
8daca632 | 54 | ClassImp(AliHLTEMCALDigitMakerComponent) |
55 | ||
ca071d0a | 56 | AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent; |
57 | ||
58 | AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() : | |
59 | AliHLTCaloProcessor(), | |
dc3d3428 | 60 | // AliHLTCaloConstantsHandler("EMCAL"), |
ca071d0a | 61 | fDigitMakerPtr(0), |
7b3a0a0e | 62 | fDigitContainerPtr(0), |
63 | fPedestalData(0), | |
64 | fCalibData(0), | |
65 | fBCMInitialised(true), | |
66 | fGainsInitialised(true) | |
ca071d0a | 67 | { |
dc3d3428 | 68 | |
ca071d0a | 69 | //see header file for documentation |
70 | } | |
71 | ||
72 | ||
73 | AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent() | |
74 | { | |
75 | //see header file for documentation | |
76 | } | |
77 | ||
78 | int | |
79 | AliHLTEMCALDigitMakerComponent::Deinit() | |
80 | { | |
81 | //see header file for documentation | |
82 | if(fDigitMakerPtr) | |
83 | { | |
84 | delete fDigitMakerPtr; | |
85 | fDigitMakerPtr = 0; | |
86 | } | |
87 | return 0; | |
88 | } | |
89 | ||
90 | const char* | |
91 | AliHLTEMCALDigitMakerComponent::GetComponentID() | |
92 | { | |
93 | //see header file for documentation | |
94 | return "EmcalDigitMaker"; | |
95 | } | |
96 | ||
97 | ||
98 | void | |
99 | AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list) | |
100 | { | |
101 | //see header file for documentation | |
102 | list.clear(); | |
103 | list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType); | |
104 | } | |
105 | ||
106 | AliHLTComponentDataType | |
107 | AliHLTEMCALDigitMakerComponent::GetOutputDataType() | |
108 | { | |
109 | //see header file for documentation | |
bb29f0e9 | 110 | // return AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL; |
ca071d0a | 111 | return AliHLTEMCALDefinitions::fgkDigitDataType; |
112 | } | |
113 | ||
114 | ||
115 | void | |
116 | AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
117 | { | |
118 | //see header file for documentation | |
119 | constBase = 0; | |
120 | inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1; | |
121 | } | |
122 | ||
bdaaafe2 | 123 | |
124 | ||
ca071d0a | 125 | int |
126 | AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
16e6f752 | 127 | AliHLTComponentTriggerData& /* trigData */, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, |
ca071d0a | 128 | std::vector<AliHLTComponentBlockData>& outputBlocks) |
129 | { | |
117c143c | 130 | |
16e6f752 | 131 | //patch in order to skip calib events |
132 | if(! IsDataEvent()) return 0; | |
117c143c | 133 | |
ca071d0a | 134 | //see header file for documentation |
135 | UInt_t offset = 0; | |
136 | UInt_t mysize = 0; | |
137 | Int_t digitCount = 0; | |
138 | Int_t ret = 0; | |
6e339f57 | 139 | |
ca071d0a | 140 | const AliHLTComponentBlockData* iter = 0; |
141 | unsigned long ndx; | |
6e339f57 | 142 | |
ca071d0a | 143 | UInt_t specification = 0; |
144 | AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0; | |
145 | ||
146 | // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr)); | |
6e339f57 | 147 | |
ca071d0a | 148 | fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr)); |
6e339f57 | 149 | |
ca071d0a | 150 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
151 | { | |
152 | iter = blocks+ndx; | |
153 | ||
154 | if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType) | |
155 | { | |
ca071d0a | 156 | continue; |
157 | } | |
dc3d3428 | 158 | |
1a619ed3 | 159 | Int_t module = 0; |
72752456 | 160 | |
7b3a0a0e | 161 | if(!fBCMInitialised) |
72752456 | 162 | { |
163 | AliHLTEMCALMapper mapper(iter->fSpecification); | |
6e339f57 | 164 | module = mapper.GetModuleFromSpec(iter->fSpecification); |
165 | ||
166 | if (module>=0) { | |
72752456 | 167 | |
f022ce7e | 168 | for(Int_t x = 0; x < NXCOLUMNSMOD ; x++) // PTH |
f022ce7e | 169 | for(Int_t z = 0; z < NZROWSMOD ; z++) // PTH |
3a42b4ed | 170 | // FR |
171 | fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z, x)); | |
6e339f57 | 172 | //delete fBadChannelMap; |
173 | fBCMInitialised = true; | |
174 | } | |
175 | else | |
176 | HLTError("Error setting pedestal with module value of %d", module); | |
f022ce7e | 177 | |
f022ce7e | 178 | } |
179 | ||
7b3a0a0e | 180 | if(!fGainsInitialised) |
72752456 | 181 | { |
6e339f57 | 182 | |
f022ce7e | 183 | AliHLTEMCALMapper mapper(iter->fSpecification); |
6e339f57 | 184 | module = mapper.GetModuleFromSpec(iter->fSpecification); |
f022ce7e | 185 | |
6e339f57 | 186 | if (module>=0) { |
187 | ||
188 | for(Int_t x = 0; x < NXCOLUMNSMOD; x++) //PTH | |
189 | for(Int_t z = 0; z < NZROWSMOD; z++) //PTH | |
190 | // FR setting gains | |
191 | fDigitMakerPtr->SetGain(x, z, HGLGFACTOR, fCalibData->GetADCchannel(module, z, x)); | |
192 | ||
193 | fGainsInitialised = true; | |
194 | } | |
195 | else | |
196 | HLTError("Error setting gains with module value of %d", module); | |
f022ce7e | 197 | } |
198 | ||
ca071d0a | 199 | specification |= iter->fSpecification; |
200 | tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr); | |
201 | ||
202 | ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct))); | |
f022ce7e | 203 | |
ca071d0a | 204 | if(ret == -1) |
205 | { | |
206 | HLTError("Trying to write over buffer size"); | |
207 | return -ENOBUFS; | |
208 | } | |
209 | digitCount += ret; | |
210 | } | |
211 | ||
212 | mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct); | |
213 | ||
214 | HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size); | |
215 | ||
216 | if(mysize > 0) | |
217 | { | |
218 | AliHLTComponentBlockData bd; | |
219 | FillBlockData( bd ); | |
220 | bd.fOffset = offset; | |
221 | bd.fSize = mysize; | |
222 | bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType; | |
223 | bd.fSpecification = specification; | |
224 | outputBlocks.push_back(bd); | |
225 | } | |
226 | ||
227 | fDigitMakerPtr->Reset(); | |
228 | ||
229 | size = mysize; | |
230 | ||
231 | return 0; | |
232 | } | |
233 | ||
234 | ||
235 | int | |
236 | AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv ) | |
237 | { | |
238 | //see header file for documentation | |
239 | ||
240 | fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL"); | |
241 | ||
242 | AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2); | |
243 | fDigitMakerPtr->SetMapper(mapper); | |
244 | ||
245 | for(int i = 0; i < argc; i++) | |
246 | { | |
247 | if(!strcmp("-lowgainfactor", argv[i])) | |
248 | { | |
249 | fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1])); | |
250 | } | |
251 | if(!strcmp("-highgainfactor", argv[i])) | |
252 | { | |
253 | fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1])); | |
254 | } | |
72752456 | 255 | |
ca071d0a | 256 | } |
72752456 | 257 | |
258 | ||
259 | if (GetBCMFromCDB()) | |
260 | return -1; | |
261 | ||
262 | if (GetGainsFromCDB()) | |
263 | return -1; | |
264 | ||
265 | //GetBCMFromCDB(); | |
ca071d0a | 266 | //fDigitMakerPtr->SetDigitThreshold(2); |
267 | ||
268 | return 0; | |
269 | } | |
270 | ||
dc3d3428 | 271 | |
12308f2d | 272 | int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB() |
273 | { | |
274 | // See header file for class documentation | |
dc3d3428 | 275 | fBCMInitialised = false; |
276 | // HLTInfo("Getting bad channel map..."); | |
7b3a0a0e | 277 | AliCDBPath path("EMCAL","Calib","Pedestals"); |
278 | if(path.GetPath()) | |
279 | { | |
280 | // HLTInfo("configure from entry %s", path.GetPath()); | |
281 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
282 | if (pEntry) | |
283 | { | |
284 | fPedestalData = (AliCaloCalibPedestal*)pEntry->GetObject(); | |
285 | } | |
286 | else | |
287 | { | |
288 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
289 | return -1; | |
290 | } | |
291 | } | |
292 | if(!fPedestalData) | |
293 | { | |
294 | return -1; | |
295 | } | |
12308f2d | 296 | |
297 | return 0; | |
298 | } | |
299 | ||
dc3d3428 | 300 | |
12308f2d | 301 | int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB() |
302 | { | |
303 | // See header file for class documentation | |
dc3d3428 | 304 | fGainsInitialised = false; |
305 | // HLTInfo("Getting bad channel map..."); | |
7b3a0a0e | 306 | |
307 | AliCDBPath path("EMCAL","Calib","Data"); | |
308 | if(path.GetPath()) | |
309 | { | |
310 | // HLTInfo("configure from entry %s", path.GetPath()); | |
311 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
312 | if (pEntry) | |
313 | { | |
314 | fCalibData = (AliEMCALCalibData*)pEntry->GetObject(); | |
315 | } | |
316 | else | |
317 | { | |
318 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
319 | return -1; | |
320 | } | |
321 | } | |
322 | if(!fCalibData) return -1; | |
12308f2d | 323 | return 0; |
324 | } | |
325 | ||
326 | ||
ca071d0a | 327 | AliHLTComponent* |
328 | AliHLTEMCALDigitMakerComponent::Spawn() | |
329 | { | |
330 | //see header file for documentation | |
331 | return new AliHLTEMCALDigitMakerComponent(); | |
332 | } |