1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
5 * Primary Authors: Oystein Djuvsland *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliHLTPHOSDigitMakerComponent.h"
17 #include "AliHLTPHOSDigitMaker.h"
19 #include "AliHLTPHOSProcessor.h"
20 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
21 #include "AliHLTPHOSDigitContainerDataStruct.h"
22 #include "AliHLTPHOSChannelDataHeaderStruct.h"
23 #include "TClonesArray.h"
26 #include <sys/types.h>
30 * @file AliHLTPHOSDigitMakerComponent.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 const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
45 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
47 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
48 AliHLTPHOSProcessor(),
53 //see header file for documentation
56 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
58 //see header file for documentation
62 AliHLTPHOSDigitMakerComponent::Deinit()
64 //see header file for documentation
67 delete fDigitMakerPtr;
74 AliHLTPHOSDigitMakerComponent::GetComponentID()
76 //see header file for documentation
77 return "PhosDigitMaker";
82 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
84 //see header file for documentation
86 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
88 // const AliHLTComponentDataType* pType=fgkInputDataTypes;
89 // while (pType->fID!=0) {
90 // list.push_back(*pType);
95 AliHLTComponentDataType
96 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
98 //see header file for documentation
99 return AliHLTPHOSDefinitions::fgkDigitDataType;
104 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
106 //see header file for documentation
107 constBase = sizeof(AliHLTPHOSDigitContainerDataStruct);
112 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
113 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
114 std::vector<AliHLTComponentBlockData>& outputBlocks)
116 //see header file for documentation
120 Int_t digitCount = 0;
122 AliHLTUInt8_t* outBPtr;
124 const AliHLTComponentBlockData* iter = 0;
127 UInt_t specification = 0;
128 AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
130 fDigitMakerPtr->SetDigitContainerStruct(reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr));
132 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
136 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
138 HLTDebug("Data block is not of type fgkChannelDataType");
141 if(iter == 0) continue;
142 if((reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr))->fNChannels == 0) continue;
143 specification = specification|iter->fSpecification;
144 tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
146 digitCount += fDigitMakerPtr->MakeDigits(tmpChannelData);
152 mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
153 (reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr))->fNDigits = digitCount;
154 AliHLTComponentBlockData bd;
158 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
159 bd.fSpecification = specification;
160 outputBlocks.push_back(bd);
163 // outputPtr += mysize;
167 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
171 fDigitMakerPtr->Reset();
180 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
182 //see header file for documentation
184 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
186 for(int i = 0; i < argc; i++)
188 if(!strcmp("-rmsfilepath", argv[i]))
190 fDigitMakerPtr->SetDigitThresholds(argv[i+1], 3);
192 if(!strcmp("-lowgainfactor", argv[i]))
194 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
196 if(!strcmp("-highgainfactor", argv[i]))
198 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
200 if(!strcmp("-digitthresholds", argv[i]))
202 fDigitMakerPtr->SetDigitThresholds(atof(argv[i+1]), atof(argv[i+2]));
206 //fDigitMakerPtr->SetDigitThreshold(2);
212 AliHLTPHOSDigitMakerComponent::Spawn()
214 //see header file for documentation
215 return new AliHLTPHOSDigitMakerComponent();