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>
36 * @file AliHLTEMCALDigitMakerComponent.cxx
37 * @author Oystein Djuvsland
39 * @brief A digit maker component for EMCAL HLT
42 // see below for class documentation
44 // refer to README to build package
46 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 ClassImp(AliHLTEMCALDigitMakerComponent)
51 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
53 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
54 AliHLTCaloProcessor(),
55 AliHLTCaloConstantsHandler("EMCAL"),
57 fDigitContainerPtr(0),
60 fBCMInitialised(true),
61 fGainsInitialised(true)
63 //see header file for documentation
67 AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent()
69 //see header file for documentation
73 AliHLTEMCALDigitMakerComponent::Deinit()
75 //see header file for documentation
78 delete fDigitMakerPtr;
85 AliHLTEMCALDigitMakerComponent::GetComponentID()
87 //see header file for documentation
88 return "EmcalDigitMaker";
93 AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
95 //see header file for documentation
97 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
100 AliHLTComponentDataType
101 AliHLTEMCALDigitMakerComponent::GetOutputDataType()
103 //see header file for documentation
104 // return AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL;
105 return AliHLTEMCALDefinitions::fgkDigitDataType;
110 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
112 //see header file for documentation
114 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
118 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
119 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
120 std::vector<AliHLTComponentBlockData>& outputBlocks)
122 //see header file for documentation
125 Int_t digitCount = 0;
128 AliHLTUInt8_t* outBPtr;
130 const AliHLTComponentBlockData* iter = 0;
133 UInt_t specification = 0;
134 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
136 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
138 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
140 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
144 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
150 AliHLTEMCALMapper mapper(iter->fSpecification);
151 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
152 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
154 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
156 fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z+1, x+1));
159 //delete fBadChannelMap;
160 fBCMInitialised = true;
162 if(!fGainsInitialised)
164 AliHLTEMCALMapper mapper(iter->fSpecification);;
165 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
166 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
168 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
170 module = 0; //removing warning
171 //fDigitMakerPtr->SetGain(x, z, fCalibData->GE(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1));
174 fGainsInitialised = true;
176 specification |= iter->fSpecification;
177 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
179 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
182 HLTError("Trying to write over buffer size");
188 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
190 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
194 AliHLTComponentBlockData bd;
198 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
199 bd.fSpecification = specification;
200 outputBlocks.push_back(bd);
203 fDigitMakerPtr->Reset();
212 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
214 //see header file for documentation
216 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
218 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
219 fDigitMakerPtr->SetMapper(mapper);
221 for(int i = 0; i < argc; i++)
223 if(!strcmp("-lowgainfactor", argv[i]))
225 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
227 if(!strcmp("-highgainfactor", argv[i]))
229 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
233 //fDigitMakerPtr->SetDigitThreshold(2);
238 int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
240 // See header file for class documentation
242 fBCMInitialised = false;
244 // HLTInfo("Getting bad channel map...");
246 AliCDBPath path("EMCAL","Calib","Pedestals");
249 // HLTInfo("configure from entry %s", path.GetPath());
250 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
253 fPedestalData = (AliCaloCalibPedestal*)pEntry->GetObject();
257 // HLTError("can not fetch object \"%s\" from CDB", path);
269 int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
271 // See header file for class documentation
273 fGainsInitialised = false;
275 // HLTInfo("Getting bad channel map...");
277 AliCDBPath path("EMCAL","Calib","Data");
280 // HLTInfo("configure from entry %s", path.GetPath());
281 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
284 fCalibData = (AliEMCALCalibData*)pEntry->GetObject();
288 // HLTError("can not fetch object \"%s\" from CDB", path);
292 if(!fCalibData) return -1;
302 AliHLTEMCALDigitMakerComponent::Spawn()
304 //see header file for documentation
305 return new AliHLTEMCALDigitMakerComponent();