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"
29 #include "AliRawDataHeader.h"
32 #include <sys/types.h>
34 //#include "AliHLTEMCALConstant.h"
35 #include "AliHLTCaloConstants.h"
37 using EMCAL::NZROWSMOD;
38 using EMCAL::NXCOLUMNSMOD;
39 using CALO::HGLGFACTOR;
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)
132 //patch in order to skip calib events
133 const AliRawDataHeader* cdh = NULL;
134 ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL, true);
135 AliHLTUInt64_t triggerMask = cdh->GetTriggerClasses();
136 if(triggerMask == 0) return 0;
139 //see header file for documentation
142 Int_t digitCount = 0;
145 const AliHLTComponentBlockData* iter = 0;
148 UInt_t specification = 0;
149 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
151 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
153 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
155 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
159 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
168 AliHLTEMCALMapper mapper(iter->fSpecification);
169 module = mapper.GetModuleFromSpec(iter->fSpecification);
173 for(Int_t x = 0; x < NXCOLUMNSMOD ; x++) // PTH
174 for(Int_t z = 0; z < NZROWSMOD ; z++) // PTH
176 fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z, x));
177 //delete fBadChannelMap;
178 fBCMInitialised = true;
181 HLTError("Error setting pedestal with module value of %d", module);
185 if(!fGainsInitialised)
188 AliHLTEMCALMapper mapper(iter->fSpecification);
189 module = mapper.GetModuleFromSpec(iter->fSpecification);
193 for(Int_t x = 0; x < NXCOLUMNSMOD; x++) //PTH
194 for(Int_t z = 0; z < NZROWSMOD; z++) //PTH
196 fDigitMakerPtr->SetGain(x, z, HGLGFACTOR, fCalibData->GetADCchannel(module, z, x));
198 fGainsInitialised = true;
201 HLTError("Error setting gains with module value of %d", module);
204 specification |= iter->fSpecification;
205 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
207 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
211 HLTError("Trying to write over buffer size");
217 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
219 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
223 AliHLTComponentBlockData bd;
227 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
228 bd.fSpecification = specification;
229 outputBlocks.push_back(bd);
232 fDigitMakerPtr->Reset();
241 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
243 //see header file for documentation
245 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
247 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
248 fDigitMakerPtr->SetMapper(mapper);
250 for(int i = 0; i < argc; i++)
252 if(!strcmp("-lowgainfactor", argv[i]))
254 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
256 if(!strcmp("-highgainfactor", argv[i]))
258 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
267 if (GetGainsFromCDB())
271 //fDigitMakerPtr->SetDigitThreshold(2);
277 int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
279 // See header file for class documentation
280 fBCMInitialised = false;
281 // HLTInfo("Getting bad channel map...");
282 AliCDBPath path("EMCAL","Calib","Pedestals");
285 // HLTInfo("configure from entry %s", path.GetPath());
286 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
289 fPedestalData = (AliCaloCalibPedestal*)pEntry->GetObject();
293 // HLTError("can not fetch object \"%s\" from CDB", path);
306 int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
308 // See header file for class documentation
309 fGainsInitialised = false;
310 // HLTInfo("Getting bad channel map...");
312 AliCDBPath path("EMCAL","Calib","Data");
315 // HLTInfo("configure from entry %s", path.GetPath());
316 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
319 fCalibData = (AliEMCALCalibData*)pEntry->GetObject();
323 // HLTError("can not fetch object \"%s\" from CDB", path);
327 if(!fCalibData) return -1;
333 AliHLTEMCALDigitMakerComponent::Spawn()
335 //see header file for documentation
336 return new AliHLTEMCALDigitMakerComponent();