1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
17 #include "AliHLTPHOSClusterizerComponent.h"
18 #include "AliHLTPHOSClusterizer.h"
19 #include "AliHLTPHOSRecPointDataStruct.h"
20 #include "AliHLTPHOSDigitContainerDataStruct.h"
24 /** @file AliHLTPHOSClusterizerComponent.cxx
25 @author Oystein Djuvsland
27 @brief A clusterizer component for PHOS HLT
30 // see header file for class documentation
32 // refer to README to build package
34 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
42 kAliHLTVoidDataType,{0,"",""}
45 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
48 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():
49 AliHLTPHOSProcessor(),
52 fRecPointStructArrayPtr(0),
54 fModuleClusterizationMode(false),
57 //See headerfile for documentation
60 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
62 //See headerfile for documentation
66 delete fClusterizerPtr;
69 if(fRecPointStructArrayPtr)
71 for (int i = 0; i < 1000; i++)
73 // fRecPointStructArrayPtr[i].Del();
75 delete fRecPointStructArrayPtr;
76 fRecPointStructArrayPtr = 0;
87 AliHLTPHOSClusterizerComponent::Deinit()
89 //See headerfile for documentation
93 delete fClusterizerPtr;
96 for (int i = 0; i < 1000; i++)
98 // fRecPointStructArrayPtr[i].Del();
101 if (fRecPointStructArrayPtr)
103 for (int i = 0; i < 1000; i++)
105 // fRecPointStructArrayPtr[i].Del();
107 delete fRecPointStructArrayPtr;
108 fRecPointStructArrayPtr = 0;
115 AliHLTPHOSClusterizerComponent::GetComponentID()
117 //See headerfile for documentation
119 return "PhosClusterizer";
123 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
126 list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
129 AliHLTComponentDataType
130 AliHLTPHOSClusterizerComponent::GetOutputDataType()
132 //See headerfile for documentation
133 return AliHLTPHOSDefinitions::fgkClusterDataType;
137 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
140 //See headerfile for documentation
141 constBase = sizeof(AliHLTPHOSRecPointContainerStruct);
146 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
147 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
148 std::vector<AliHLTComponentBlockData>& outputBlocks)
150 //See headerfile for documentation
155 Int_t nRecPoints = 0;
158 AliHLTUInt8_t* outBPtr;
160 const AliHLTComponentBlockData* iter = 0;
163 UInt_t specification = 0;
165 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
166 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
168 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
171 if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
173 specification = specification|iter->fSpecification;
174 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
175 if(fModuleClusterizationMode)
177 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
179 fAllDigitsPtr->fDigitDataStruct[j].fX = digitContainerPtr->fDigitDataStruct[i].fX;
180 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
181 fAllDigitsPtr->fDigitDataStruct[j].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
182 fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitContainerPtr->fDigitDataStruct[i].fEnergy;
183 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
184 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
191 fAllDigitsPtr->fNDigits = j;
192 if(fModuleClusterizationMode && fAllDigitsPtr != 0)
194 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
196 else if(digitContainerPtr != 0)
198 fClusterizerPtr->SetDigitContainer(digitContainerPtr);
200 if(digitContainerPtr != 0)
202 nRecPoints = fClusterizerPtr->ClusterizeEvent();
206 mysize += sizeof(AliHLTPHOSRecPointContainerStruct);
208 AliHLTComponentBlockData bd;
212 bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType;
213 bd.fSpecification = specification;
214 outputBlocks.push_back( bd );
222 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
223 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
234 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
236 //See headerfile for documentation
238 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
239 fClusterizerPtr = new AliHLTPHOSClusterizer();
240 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
241 fNoCrazyness = false;
244 ScanArgumentsModule(argc, argv);
245 for (int i = 0; i < argc; i++)
247 if(!strcmp("-digitthreshold", argv[i]))
249 fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1]));
251 if(!strcmp("-recpointthreshold", argv[i]))
253 fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1]));
255 if(!strcmp("-modulemode", argv[i]))
257 fModuleClusterizationMode = true;
265 AliHLTPHOSClusterizerComponent::Spawn()
267 //See headerfile for documentation
269 return new AliHLTPHOSClusterizerComponent();