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