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"
27 #include <sys/types.h>
31 * @file AliHLTEMCALDigitMakerComponent.cxx
32 * @author Oystein Djuvsland
34 * @brief A digit maker component for EMCAL HLT
37 // see below for class documentation
39 // refer to README to build package
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
46 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
47 AliHLTCaloProcessor(),
51 //see header file for documentation
55 AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent()
57 //see header file for documentation
61 AliHLTEMCALDigitMakerComponent::Deinit()
63 //see header file for documentation
66 delete fDigitMakerPtr;
73 AliHLTEMCALDigitMakerComponent::GetComponentID()
75 //see header file for documentation
76 return "EmcalDigitMaker";
81 AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
83 //see header file for documentation
85 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
88 AliHLTComponentDataType
89 AliHLTEMCALDigitMakerComponent::GetOutputDataType()
91 //see header file for documentation
92 return AliHLTEMCALDefinitions::fgkDigitDataType;
97 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
99 //see header file for documentation
101 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
105 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
106 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
107 std::vector<AliHLTComponentBlockData>& outputBlocks)
109 //see header file for documentation
112 Int_t digitCount = 0;
115 AliHLTUInt8_t* outBPtr;
117 const AliHLTComponentBlockData* iter = 0;
120 UInt_t specification = 0;
121 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
123 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
125 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
127 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
131 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
133 HLTError("Data block is not of type fgkChannelDataType");
137 specification |= iter->fSpecification;
138 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
140 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
143 HLTError("Trying to write over buffer size");
149 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
151 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
155 AliHLTComponentBlockData bd;
159 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
160 bd.fSpecification = specification;
161 outputBlocks.push_back(bd);
164 fDigitMakerPtr->Reset();
173 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
175 //see header file for documentation
177 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
179 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
180 fDigitMakerPtr->SetMapper(mapper);
182 for(int i = 0; i < argc; i++)
184 if(!strcmp("-lowgainfactor", argv[i]))
186 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
188 if(!strcmp("-highgainfactor", argv[i]))
190 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
194 //fDigitMakerPtr->SetDigitThreshold(2);
200 AliHLTEMCALDigitMakerComponent::Spawn()
202 //see header file for documentation
203 return new AliHLTEMCALDigitMakerComponent();