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 "AliHLTPHOSDigitMakerComponent.h"
19 #include "AliHLTPHOSDigitMaker.h"
20 #include "AliHLTPHOSDigitDataStruct.h"
21 #include "AliHLTPHOSChannelDataHeaderStruct.h"
22 #include "AliHLTPHOSChannelDataStruct.h"
25 #include <sys/types.h>
29 * @file AliHLTPHOSDigitMakerComponent.cxx
30 * @author Oystein Djuvsland
32 * @brief A digit maker component for PHOS HLT
35 // see below for class documentation
37 // refer to README to build package
39 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
42 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
44 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
45 AliHLTPHOSProcessor(),
49 //see header file for documentation
53 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
55 //see header file for documentation
59 AliHLTPHOSDigitMakerComponent::Deinit()
61 //see header file for documentation
64 delete fDigitMakerPtr;
71 AliHLTPHOSDigitMakerComponent::GetComponentID()
73 //see header file for documentation
74 return "PhosDigitMaker";
79 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
81 //see header file for documentation
83 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
86 AliHLTComponentDataType
87 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
89 //see header file for documentation
90 return AliHLTPHOSDefinitions::fgkDigitDataType;
95 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
97 //see header file for documentation
99 inputMultiplier = (float)sizeof(AliHLTPHOSDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
103 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
104 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
105 std::vector<AliHLTComponentBlockData>& outputBlocks)
107 //see header file for documentation
110 Int_t digitCount = 0;
113 AliHLTUInt8_t* outBPtr;
115 const AliHLTComponentBlockData* iter = 0;
118 UInt_t specification = 0;
119 AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
121 fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(outputPtr));
123 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
127 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
129 HLTDebug("Data block is not of type fgkChannelDataType");
133 specification |= iter->fSpecification;
134 tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
136 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTPHOSDigitDataStruct)));
139 HLTError("Trying to write over buffer size");
145 mysize += digitCount*sizeof(AliHLTPHOSDigitDataStruct);
147 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
151 AliHLTComponentBlockData bd;
155 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
156 bd.fSpecification = specification;
157 outputBlocks.push_back(bd);
160 fDigitMakerPtr->Reset();
169 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
171 //see header file for documentation
173 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
175 for(int i = 0; i < argc; i++)
177 if(!strcmp("-lowgainfactor", argv[i]))
179 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
181 if(!strcmp("-highgainfactor", argv[i]))
183 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
185 if(!strcmp("-reverseorder", argv[i]))
187 fDigitMakerPtr->SetOrdered(false);
191 //fDigitMakerPtr->SetDigitThreshold(2);
197 AliHLTPHOSDigitMakerComponent::Spawn()
199 //see header file for documentation
200 return new AliHLTPHOSDigitMakerComponent();