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 AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL;
93 return AliHLTEMCALDefinitions::fgkDigitDataType;
98 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
100 //see header file for documentation
102 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
106 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
107 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
108 std::vector<AliHLTComponentBlockData>& outputBlocks)
110 //see header file for documentation
113 Int_t digitCount = 0;
116 AliHLTUInt8_t* outBPtr;
118 const AliHLTComponentBlockData* iter = 0;
121 UInt_t specification = 0;
122 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
124 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
126 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
128 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
132 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
134 HLTError("Data block is not of type fgkChannelDataType");
138 specification |= iter->fSpecification;
139 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
141 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
144 HLTError("Trying to write over buffer size");
150 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
152 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
156 AliHLTComponentBlockData bd;
160 bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
161 bd.fSpecification = specification;
162 outputBlocks.push_back(bd);
165 fDigitMakerPtr->Reset();
174 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
176 //see header file for documentation
178 fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
180 AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
181 fDigitMakerPtr->SetMapper(mapper);
183 for(int i = 0; i < argc; i++)
185 if(!strcmp("-lowgainfactor", argv[i]))
187 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
189 if(!strcmp("-highgainfactor", argv[i]))
191 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
195 //fDigitMakerPtr->SetDigitThreshold(2);
201 AliHLTEMCALDigitMakerComponent::Spawn()
203 //see header file for documentation
204 return new AliHLTEMCALDigitMakerComponent();