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