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"
21 #include "AliHLTPHOSProcessor.h"
22 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
23 #include "AliHLTPHOSDigitDataStruct.h"
24 #include "AliHLTPHOSChannelDataHeaderStruct.h"
25 #include "AliHLTPHOSChannelDataStruct.h"
26 #include "TClonesArray.h"
29 #include <sys/types.h>
33 * @file AliHLTPHOSDigitMakerComponent.cxx
34 * @author Oystein Djuvsland
36 * @brief A digit maker component for PHOS HLT
39 // see below for class documentation
41 // refer to README to build package
43 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
48 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
50 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
51 AliHLTPHOSProcessor(),
56 //see header file for documentation
60 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
62 //see header file for documentation
66 AliHLTPHOSDigitMakerComponent::Deinit()
68 //see header file for documentation
71 delete fDigitMakerPtr;
78 AliHLTPHOSDigitMakerComponent::GetComponentID()
80 //see header file for documentation
81 return "PhosDigitMaker";
86 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
88 //see header file for documentation
90 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
92 // const AliHLTComponentDataType* pType=fgkInputDataTypes;
93 // while (pType->fID!=0) {
94 // list.push_back(*pType);
99 AliHLTComponentDataType
100 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
102 //see header file for documentation
103 return AliHLTPHOSDefinitions::fgkDigitDataType;
108 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
110 //see header file for documentation
112 inputMultiplier = (float)sizeof(AliHLTPHOSDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
116 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
117 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
118 std::vector<AliHLTComponentBlockData>& outputBlocks)
120 //see header file for documentation
124 Int_t digitCount = 0;
127 AliHLTUInt8_t* outBPtr;
129 const AliHLTComponentBlockData* iter = 0;
132 UInt_t specification = 0;
133 AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
135 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outputPtr));
137 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
141 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
143 HLTDebug("Data block is not of type fgkChannelDataType");
147 specification |= iter->fSpecification;
148 tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
150 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTPHOSDigitDataStruct)));
153 HLTError("Trying to write over buffer size");
159 mysize = digitCount*sizeof(AliHLTPHOSDigitDataStruct);
161 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
163 AliHLTComponentBlockData bd;
167 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
168 bd.fSpecification = specification;
169 outputBlocks.push_back(bd);
173 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
177 fDigitMakerPtr->Reset();
186 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
188 //see header file for documentation
190 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
192 for(int i = 0; i < argc; i++)
194 if(!strcmp("-lowgainfactor", argv[i]))
196 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
198 if(!strcmp("-highgainfactor", argv[i]))
200 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
202 if(!strcmp("-reverseorder", argv[i]))
204 fDigitMakerPtr->SetOrdered(false);
208 //fDigitMakerPtr->SetDigitThreshold(2);
214 AliHLTPHOSDigitMakerComponent::Spawn()
216 //see header file for documentation
217 return new AliHLTPHOSDigitMakerComponent();