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 "AliHLTCaloDigitMaker.h"
20 #include "AliHLTCaloDigitDataStruct.h"
21 #include "AliHLTPHOSMapper.h"
22 #include "AliHLTPHOSChannelDataHeaderStruct.h"
23 #include "AliHLTPHOSChannelDataStruct.h"
26 #include <sys/types.h>
30 * @file AliHLTCaloDigitMakerComponent.cxx
31 * @author Oystein Djuvsland
33 * @brief A digit maker component for PHOS HLT
36 // see below for class documentation
38 // refer to README to build package
40 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
43 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
45 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
46 AliHLTPHOSProcessor(),
50 //see header file for documentation
54 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
56 //see header file for documentation
60 AliHLTPHOSDigitMakerComponent::Deinit()
62 //see header file for documentation
65 delete fDigitMakerPtr;
72 AliHLTPHOSDigitMakerComponent::GetComponentID()
74 //see header file for documentation
75 return "PhosDigitMaker";
80 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
82 //see header file for documentation
84 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
87 AliHLTComponentDataType
88 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
90 //see header file for documentation
91 return AliHLTPHOSDefinitions::fgkDigitDataType;
96 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
98 //see header file for documentation
100 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
104 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
105 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
106 std::vector<AliHLTComponentBlockData>& outputBlocks)
108 //see header file for documentation
111 Int_t digitCount = 0;
114 AliHLTUInt8_t* outBPtr;
116 const AliHLTComponentBlockData* iter = 0;
119 UInt_t specification = 0;
120 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
122 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
124 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
126 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
130 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
132 HLTDebug("Data block is not of type fgkChannelDataType");
136 specification |= iter->fSpecification;
137 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
139 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
142 HLTError("Trying to write over buffer size");
148 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
150 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
154 AliHLTComponentBlockData bd;
158 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
159 bd.fSpecification = specification;
160 outputBlocks.push_back(bd);
163 fDigitMakerPtr->Reset();
172 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
174 //see header file for documentation
176 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
178 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
179 fDigitMakerPtr->SetMapper(mapper);
181 for(int i = 0; i < argc; i++)
183 if(!strcmp("-lowgainfactor", argv[i]))
185 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
187 if(!strcmp("-highgainfactor", argv[i]))
189 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
193 //fDigitMakerPtr->SetDigitThreshold(2);
199 AliHLTPHOSDigitMakerComponent::Spawn()
201 //see header file for documentation
202 return new AliHLTPHOSDigitMakerComponent();