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