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 **************************************************************************/
17 #include "AliHLTEMCALDigitMakerComponent.h"
18 #include "AliHLTCaloDigitMaker.h"
19 #include "AliHLTCaloDigitDataStruct.h"
20 #include "AliHLTCaloChannelDataHeaderStruct.h"
21 #include "AliHLTCaloChannelDataStruct.h"
22 #include "AliHLTEMCALMapper.h"
23 #include "AliHLTEMCALDefinitions.h"
24 #include "AliCaloCalibPedestal.h"
25 #include "AliEMCALCalibData.h"
26 #include "AliCDBEntry.h"
27 #include "AliCDBPath.h"
28 #include "AliCDBManager.h"
31 #include <sys/types.h>
33 //#include "AliHLTEMCALConstant.h"
34 #include "AliHLTCaloConstants.h"
36 using EMCAL::NZROWSMOD;
37 using EMCAL::NXCOLUMNSMOD;
38 using CALO::HGLGFACTOR;
41 * @file AliHLTEMCALDigitMakerComponent.cxx
42 * @author Oystein Djuvsland
44 * @brief A digit maker component for EMCAL HLT
47 // see below for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 ClassImp(AliHLTEMCALDigitMakerComponent)
56 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
58 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
59 AliHLTCaloProcessor(),
60 // AliHLTCaloConstantsHandler("EMCAL"),
62 fDigitContainerPtr(0),
65 fBCMInitialised(true),
66 fGainsInitialised(true)
69 //see header file for documentation
73 AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent()
75 //see header file for documentation
79 AliHLTEMCALDigitMakerComponent::Deinit()
81 //see header file for documentation
84 delete fDigitMakerPtr;
91 AliHLTEMCALDigitMakerComponent::GetComponentID()
93 //see header file for documentation
94 return "EmcalDigitMaker";
99 AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
101 //see header file for documentation
103 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
106 AliHLTComponentDataType
107 AliHLTEMCALDigitMakerComponent::GetOutputDataType()
109 //see header file for documentation
110 // return AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL;
111 return AliHLTEMCALDefinitions::fgkDigitDataType;
116 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
118 //see header file for documentation
120 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
126 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
127 AliHLTComponentTriggerData& /* trigData */, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
128 std::vector<AliHLTComponentBlockData>& outputBlocks)
131 //patch in order to skip calib events
132 if(! IsDataEvent()) return 0;
134 //see header file for documentation
137 Int_t digitCount = 0;
140 const AliHLTComponentBlockData* iter = 0;
143 UInt_t specification = 0;
144 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
146 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
148 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
150 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
154 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
163 AliHLTEMCALMapper mapper(iter->fSpecification);
164 module = mapper.GetModuleFromSpec(iter->fSpecification);
168 for(Int_t x = 0; x < NXCOLUMNSMOD ; x++) // PTH
169 for(Int_t z = 0; z < NZROWSMOD ; z++) // PTH
171 fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z, x));
172 //delete fBadChannelMap;
173 fBCMInitialised = true;
176 HLTError("Error setting pedestal with module value of %d", module);
180 if(!fGainsInitialised)
183 AliHLTEMCALMapper mapper(iter->fSpecification);
184 module = mapper.GetModuleFromSpec(iter->fSpecification);
188 for(Int_t x = 0; x < NXCOLUMNSMOD; x++) //PTH
189 for(Int_t z = 0; z < NZROWSMOD; z++) //PTH
191 fDigitMakerPtr->SetGain(x, z, HGLGFACTOR, fCalibData->GetADCchannel(module, z, x));
193 fGainsInitialised = true;
196 HLTError("Error setting gains with module value of %d", module);
199 specification |= iter->fSpecification;
200 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
202 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
206 HLTError("Trying to write over buffer size");
212 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
214 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
218 AliHLTComponentBlockData bd;
222 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
223 bd.fSpecification = specification;
224 outputBlocks.push_back(bd);
227 fDigitMakerPtr->Reset();
236 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
238 //see header file for documentation
240 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
242 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
243 fDigitMakerPtr->SetMapper(mapper);
245 for(int i = 0; i < argc; i++)
247 if(!strcmp("-lowgainfactor", argv[i]))
249 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
251 if(!strcmp("-highgainfactor", argv[i]))
253 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
262 if (GetGainsFromCDB())
266 //fDigitMakerPtr->SetDigitThreshold(2);
272 int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
274 // See header file for class documentation
275 fBCMInitialised = false;
276 // HLTInfo("Getting bad channel map...");
277 AliCDBPath path("EMCAL","Calib","Pedestals");
280 // HLTInfo("configure from entry %s", path.GetPath());
281 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
284 fPedestalData = (AliCaloCalibPedestal*)pEntry->GetObject();
288 // HLTError("can not fetch object \"%s\" from CDB", path);
301 int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
303 // See header file for class documentation
304 fGainsInitialised = false;
305 // HLTInfo("Getting bad channel map...");
307 AliCDBPath path("EMCAL","Calib","Data");
310 // HLTInfo("configure from entry %s", path.GetPath());
311 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
314 fCalibData = (AliEMCALCalibData*)pEntry->GetObject();
318 // HLTError("can not fetch object \"%s\" from CDB", path);
322 if(!fCalibData) return -1;
328 AliHLTEMCALDigitMakerComponent::Spawn()
330 //see header file for documentation
331 return new AliHLTEMCALDigitMakerComponent();