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 "TClonesArray.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 const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
44 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
46 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
47 AliHLTPHOSProcessor(),
51 //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 const AliHLTComponentDataType* pType=fgkInputDataTypes;
85 while (pType->fID!=0) {
86 list.push_back(*pType);
91 AliHLTComponentDataType
92 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
94 //see header file for documentation
95 return AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
100 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
102 //see header file for documentation
108 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
109 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
110 std::vector<AliHLTComponentBlockData>& outputBlocks)
112 //see header file for documentation
116 Int_t digitCount = 0;
118 AliHLTUInt8_t* outBPtr;
120 const AliHLTComponentBlockData* iter = 0;
122 fDigitContainerPtr = (AliHLTPHOSDigitContainerDataStruct*)outBPtr;
123 //fDigitMakerPtr->SetDigitContainerStruct(fDigitContainerPtr);
124 fDigitMakerPtr->SetDigitContainerStruct((AliHLTPHOSDigitContainerDataStruct*)outBPtr);
126 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
130 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
132 // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
136 digitCount = fDigitMakerPtr->MakeDigits(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
144 mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
145 ((AliHLTPHOSDigitContainerDataStruct*)outBPtr)->fNDigits = digitCount;
146 AliHLTComponentBlockData bd;
150 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
151 bd.fSpecification = 0xFFFFFFFF;
152 outputBlocks.push_back( bd );
159 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data",
160 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
165 fDigitMakerPtr->Reset();
170 if(fPhosEventCount % 10 == 0)
172 cout << "Event #: " << fPhosEventCount << endl;
173 cout << " - Number of digits found: " << digitCount << endl;
181 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
183 //see header file for documentation
185 fDigitMakerPtr = new AliHLTPHOSDigitMaker();
187 for(int i = 0; i < argc; i++)
189 if(!strcmp("-threshold", argv[i]))
190 fDigitMakerPtr->SetDigitThreshold(atoi(argv[i+1]));
191 if(!strcmp("-presamples", argv[i]))
192 fDigitMakerPtr->SetNrPresamples(atoi(argv[i+1]));
195 //fDigitMakerPtr->SetDigitThreshold(2);
201 AliHLTPHOSDigitMakerComponent::Spawn()
203 //see header file for documentation
204 return new AliHLTPHOSDigitMakerComponent();