3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
7 * Primary Authors: Oystein Djuvsland *
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 **************************************************************************/
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"
25 #include "AliCaloCalibPedestal.h"
26 #include "AliEMCALCalibData.h"
27 #include "AliCDBEntry.h"
28 #include "AliCDBPath.h"
29 #include "AliCDBManager.h"
32 #include <sys/types.h>
34 //#include "AliHLTEMCALConstant.h"
35 #include "AliHLTCaloConstants.h"
37 using EMCAL::NZROWSMOD;
38 using EMCAL::NXCOLUMNSMOD;
42 * @file AliHLTEMCALDigitMakerComponent.cxx
43 * @author Oystein Djuvsland
45 * @brief A digit maker component for EMCAL HLT
48 // see below for class documentation
50 // refer to README to build package
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
55 ClassImp(AliHLTEMCALDigitMakerComponent)
57 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
59 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
60 AliHLTCaloProcessor(),
61 // AliHLTCaloConstantsHandler("EMCAL"),
63 fDigitContainerPtr(0),
66 fBCMInitialised(true),
67 fGainsInitialised(true)
70 //see header file for documentation
74 AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent()
76 //see header file for documentation
80 AliHLTEMCALDigitMakerComponent::Deinit()
82 //see header file for documentation
85 delete fDigitMakerPtr;
92 AliHLTEMCALDigitMakerComponent::GetComponentID()
94 //see header file for documentation
95 return "EmcalDigitMaker";
100 AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
102 //see header file for documentation
104 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
107 AliHLTComponentDataType
108 AliHLTEMCALDigitMakerComponent::GetOutputDataType()
110 //see header file for documentation
111 // return AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL;
112 return AliHLTEMCALDefinitions::fgkDigitDataType;
117 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
119 //see header file for documentation
121 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
127 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
128 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
129 std::vector<AliHLTComponentBlockData>& outputBlocks)
131 //see header file for documentation
134 Int_t digitCount = 0;
137 const AliHLTComponentBlockData* iter = 0;
140 UInt_t specification = 0;
141 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
143 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
145 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
147 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
151 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
159 AliHLTEMCALMapper mapper(iter->fSpecification);
160 module = mapper.GetModuleFromSpec(iter->fSpecification);
161 // for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
162 for(Int_t x = 0; x < NXCOLUMNSMOD ; x++) // PTH
164 // for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
165 for(Int_t z = 0; z < NZROWSMOD ; z++) // PTH
167 fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z+1, x+1));
170 //delete fBadChannelMap;
171 fBCMInitialised = true;
173 if(!fGainsInitialised)
175 AliHLTEMCALMapper mapper(iter->fSpecification);;
176 module = mapper.GetModuleFromSpec(iter->fSpecification);
177 // for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
178 for(Int_t x = 0; x < NXCOLUMNSMOD; x++) //PTH
180 // for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
181 for(Int_t z = 0; z < NZROWSMOD; z++) //PTH
183 module = 0; //removing warning
184 //fDigitMakerPtr->SetGain(x, z, fCalibData->GE(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1));
187 fGainsInitialised = true;
189 specification |= iter->fSpecification;
190 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
192 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
195 HLTError("Trying to write over buffer size");
201 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
203 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
207 AliHLTComponentBlockData bd;
211 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
212 bd.fSpecification = specification;
213 outputBlocks.push_back(bd);
216 fDigitMakerPtr->Reset();
225 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
227 //see header file for documentation
229 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
231 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
232 fDigitMakerPtr->SetMapper(mapper);
234 for(int i = 0; i < argc; i++)
236 if(!strcmp("-lowgainfactor", argv[i]))
238 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
240 if(!strcmp("-highgainfactor", argv[i]))
242 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
246 //fDigitMakerPtr->SetDigitThreshold(2);
252 int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
254 // See header file for class documentation
255 fBCMInitialised = false;
256 // HLTInfo("Getting bad channel map...");
257 AliCDBPath path("EMCAL","Calib","Pedestals");
260 // HLTInfo("configure from entry %s", path.GetPath());
261 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
264 fPedestalData = (AliCaloCalibPedestal*)pEntry->GetObject();
268 // HLTError("can not fetch object \"%s\" from CDB", path);
281 int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
283 // See header file for class documentation
284 fGainsInitialised = false;
285 // HLTInfo("Getting bad channel map...");
287 AliCDBPath path("EMCAL","Calib","Data");
290 // HLTInfo("configure from entry %s", path.GetPath());
291 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
294 fCalibData = (AliEMCALCalibData*)pEntry->GetObject();
298 // HLTError("can not fetch object \"%s\" from CDB", path);
302 if(!fCalibData) return -1;
308 AliHLTEMCALDigitMakerComponent::Spawn()
310 //see header file for documentation
311 return new AliHLTEMCALDigitMakerComponent();