]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
- remove unnecessary cut on the number of ITS clusters
[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);
166 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
167 {
168 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
169 {
ca232979 170 fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(5-module, z+1, x+1), fCalibData->GetADCchannelEmc(5-module, z+1, x+1));
c1e4a18c 171 }
172 }
173 fGainsInitialised = true;
174 }
e304ea31 175
176 specification |= iter->fSpecification;
f137c3c5 177 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
94594220 178
f137c3c5 179 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
e304ea31 180 if(ret == -1)
181 {
cc244597 182 HLTError("Trying to write over buffer size");
e304ea31 183 return -ENOBUFS;
184 }
185 digitCount += ret;
209a4703 186 }
209a4703 187
f137c3c5 188 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
e304ea31 189
cc244597 190 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
87434909 191
87434909 192 if(mysize > 0)
209a4703 193 {
87434909 194 AliHLTComponentBlockData bd;
195 FillBlockData( bd );
196 bd.fOffset = offset;
197 bd.fSize = mysize;
198 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
199 bd.fSpecification = specification;
200 outputBlocks.push_back(bd);
209a4703 201 }
ab521ae4 202
94594220 203 fDigitMakerPtr->Reset();
9bf87c6f 204
205 size = mysize;
206
209a4703 207 return 0;
208}
209
209a4703 210int
211AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
212{
2374af72 213 //see header file for documentation
209a4703 214
f137c3c5 215 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
216
217 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
218 fDigitMakerPtr->SetMapper(mapper);
209a4703 219
7173b37b 220 Float_t mintime = 0.;
221 Float_t maxtime =50.;
222
209a4703 223 for(int i = 0; i < argc; i++)
224 {
d949e02e 225 if(!strcmp("-lowgainfactor", argv[i]))
226 {
227 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
d949e02e 228 }
229 if(!strcmp("-highgainfactor", argv[i]))
230 {
231 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
d949e02e 232 }
7173b37b 233 if(!strcmp("-mintime", argv[i]))
234 {
235 mintime = atof(argv[i+1]);
236 }
237 if(!strcmp("-maxtime", argv[i]))
238 {
239 maxtime = atof(argv[i+1]);
240 }
209a4703 241 }
242
7173b37b 243 fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
244
c1e4a18c 245 if(GetBCMFromCDB()) return -1;
246 if(GetGainsFromCDB()) return -1;
247
209a4703 248 //fDigitMakerPtr->SetDigitThreshold(2);
249
250 return 0;
251}
252
c1e4a18c 253
254int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
255{
256 fBCMInitialised = false;
257
258// HLTInfo("Getting bad channel map...");
259
260 AliCDBPath path("PHOS","Calib","EmcBadChannels");
261 if(path.GetPath())
262 {
263 // HLTInfo("configure from entry %s", path.GetPath());
264 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
c1e4a18c 265 if (pEntry)
266 {
267 fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
268 }
269 else
270 {
398dc010 271 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
c1e4a18c 272 return -1;
273 }
274 }
275 if(!fBadChannelMap) return -1;
276 return 0;
277}
278
279int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
280{
281 fGainsInitialised = false;
282
283// HLTInfo("Getting bad channel map...");
284
285 AliCDBPath path("PHOS","Calib","EmcGainPedestals");
286 if(path.GetPath())
287 {
288 // HLTInfo("configure from entry %s", path.GetPath());*/
289 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
290 if (pEntry)
291 {
292 fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
293 }
294 else
295 {
398dc010 296 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
c1e4a18c 297 return -1;
298 }
299 }
300
301 if(!fCalibData) return -1;
302 return 0;
303
304}
305
306
209a4703 307AliHLTComponent*
308AliHLTPHOSDigitMakerComponent::Spawn()
309{
2374af72 310 //see header file for documentation
209a4703 311 return new AliHLTPHOSDigitMakerComponent();
312}