]>
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" | |
a9705807 | 22 | #include "AliHLTCaloChannelDataHeaderStruct.h" |
23 | #include "AliHLTCaloChannelDataStruct.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; |
a9705807 | 110 | inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 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 | |
7173b37b | 218 | Float_t mintime = 0.; |
219 | Float_t maxtime =50.; | |
220 | ||
209a4703 | 221 | for(int i = 0; i < argc; i++) |
222 | { | |
d949e02e | 223 | if(!strcmp("-lowgainfactor", argv[i])) |
224 | { | |
225 | fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1])); | |
d949e02e | 226 | } |
227 | if(!strcmp("-highgainfactor", argv[i])) | |
228 | { | |
229 | fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1])); | |
d949e02e | 230 | } |
7173b37b | 231 | if(!strcmp("-mintime", argv[i])) |
232 | { | |
233 | mintime = atof(argv[i+1]); | |
234 | } | |
235 | if(!strcmp("-maxtime", argv[i])) | |
236 | { | |
237 | maxtime = atof(argv[i+1]); | |
238 | } | |
209a4703 | 239 | } |
240 | ||
7173b37b | 241 | fDigitMakerPtr->SetTimeWindow(mintime, maxtime); |
242 | ||
c1e4a18c | 243 | if(GetBCMFromCDB()) return -1; |
244 | if(GetGainsFromCDB()) return -1; | |
245 | ||
209a4703 | 246 | //fDigitMakerPtr->SetDigitThreshold(2); |
247 | ||
248 | return 0; | |
249 | } | |
250 | ||
c1e4a18c | 251 | |
252 | int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB() | |
253 | { | |
254 | fBCMInitialised = false; | |
255 | ||
256 | // HLTInfo("Getting bad channel map..."); | |
257 | ||
258 | AliCDBPath path("PHOS","Calib","EmcBadChannels"); | |
259 | if(path.GetPath()) | |
260 | { | |
261 | // HLTInfo("configure from entry %s", path.GetPath()); | |
262 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
c1e4a18c | 263 | if (pEntry) |
264 | { | |
265 | fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject(); | |
266 | } | |
267 | else | |
268 | { | |
269 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
270 | return -1; | |
271 | } | |
272 | } | |
273 | if(!fBadChannelMap) return -1; | |
274 | return 0; | |
275 | } | |
276 | ||
277 | int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB() | |
278 | { | |
279 | fGainsInitialised = false; | |
280 | ||
281 | // HLTInfo("Getting bad channel map..."); | |
282 | ||
283 | AliCDBPath path("PHOS","Calib","EmcGainPedestals"); | |
284 | if(path.GetPath()) | |
285 | { | |
286 | // HLTInfo("configure from entry %s", path.GetPath());*/ | |
287 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
288 | if (pEntry) | |
289 | { | |
290 | fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject(); | |
291 | } | |
292 | else | |
293 | { | |
294 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
295 | return -1; | |
296 | } | |
297 | } | |
298 | ||
299 | if(!fCalibData) return -1; | |
300 | return 0; | |
301 | ||
302 | } | |
303 | ||
304 | ||
209a4703 | 305 | AliHLTComponent* |
306 | AliHLTPHOSDigitMakerComponent::Spawn() | |
307 | { | |
2374af72 | 308 | //see header file for documentation |
209a4703 | 309 | return new AliHLTPHOSDigitMakerComponent(); |
310 | } |