3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
19 #include "AliHLTPHOSClusterizerComponent.h"
20 #include "AliHLTPHOSClusterizer.h"
21 #include "AliHLTPHOSRecPointDataStruct.h"
22 #include "AliHLTPHOSRecPointHeaderStruct.h"
23 #include "AliHLTPHOSDigitDataStruct.h"
24 #include "AliHLTPHOSDigitContainerDataStruct.h"
28 /** @file AliHLTPHOSClusterizerComponent.cxx
29 @author Oystein Djuvsland
31 @brief A clusterizer component for PHOS HLT
34 // see header file for class documentation
36 // refer to README to build package
38 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44 const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
46 kAliHLTVoidDataType,{0,"",""}
49 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
52 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():
53 AliHLTPHOSProcessor(),
56 fRecPointStructArrayPtr(0),
58 fModuleClusterizationMode(true),
61 //See headerfile for documentation
64 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
66 //See headerfile for documentation
70 delete fClusterizerPtr;
73 if(fRecPointStructArrayPtr)
75 for (int i = 0; i < 1000; i++)
77 // fRecPointStructArrayPtr[i].Del();
79 delete fRecPointStructArrayPtr;
80 fRecPointStructArrayPtr = 0;
91 AliHLTPHOSClusterizerComponent::Deinit()
93 //See headerfile for documentation
97 delete fClusterizerPtr;
100 for (int i = 0; i < 1000; i++)
102 // fRecPointStructArrayPtr[i].Del();
105 if (fRecPointStructArrayPtr)
107 for (int i = 0; i < 1000; i++)
109 // fRecPointStructArrayPtr[i].Del();
111 delete fRecPointStructArrayPtr;
112 fRecPointStructArrayPtr = 0;
119 AliHLTPHOSClusterizerComponent::GetComponentID()
121 //See headerfile for documentation
123 return "PhosClusterizer";
127 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
130 list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
133 AliHLTComponentDataType
134 AliHLTPHOSClusterizerComponent::GetOutputDataType()
136 //See headerfile for documentation
137 return AliHLTPHOSDefinitions::fgkRecPointDataType;
141 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
144 //See headerfile for documentation
145 constBase = sizeof(AliHLTPHOSRecPointHeaderStruct) + sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate... ;
146 inputMultiplier = 1.5;
150 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
151 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
152 std::vector<AliHLTComponentBlockData>& outputBlocks)
154 //See headerfile for documentation
159 Int_t nRecPoints = 0;
163 AliHLTUInt8_t* outBPtr;
165 const AliHLTComponentBlockData* iter = 0;
168 UInt_t specification = 0;
170 AliHLTPHOSDigitDataStruct *digitDataPtr = 0;
172 AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
174 fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
176 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
179 if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
181 specification = specification|iter->fSpecification;
182 nDigits = iter->fSize/sizeof(AliHLTPHOSDigitDataStruct);
183 //HLTDebug("Number of digits in block: %d", nDigits);
184 digitDataPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr);
185 for (Int_t i = 0; i < nDigits; i++)
187 fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX;
188 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ;
189 fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy;
190 // HLTDebug("Digit energy: %f", digitDataPtr->fEnergy);
191 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
192 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
198 fAllDigitsPtr->fNDigits = j;
199 nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
203 HLTError("Running out of buffer, exiting for safety.");
207 recPointHeaderPtr->fNRecPoints = nRecPoints;
208 mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
210 HLTDebug("Number of clusters: %d", nRecPoints);
212 AliHLTComponentBlockData bd;
216 bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType;
217 bd.fSpecification = specification;
218 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("-partitionmode", argv[i]))
257 fModuleClusterizationMode = false;
264 AliHLTPHOSClusterizerComponent::Spawn()
266 //See headerfile for documentation
268 return new AliHLTPHOSClusterizerComponent();