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
122 return "PhosClusterizer";
126 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
128 //See headerfile for documentation
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
158 Int_t nRecPoints = 0;
162 AliHLTUInt8_t* outBPtr;
164 const AliHLTComponentBlockData* iter = 0;
167 UInt_t specification = 0;
169 AliHLTPHOSDigitDataStruct *digitDataPtr = 0;
171 AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
173 fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
175 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
178 if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
180 specification = specification|iter->fSpecification;
181 nDigits = iter->fSize/sizeof(AliHLTPHOSDigitDataStruct);
182 //HLTDebug("Number of digits in block: %d", nDigits);
183 digitDataPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr);
184 for (Int_t i = 0; i < nDigits; i++)
186 fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX;
187 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ;
188 fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy;
189 //HLTDebug("Digit energy: %f", digitDataPtr->fEnergy);
190 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
191 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
192 fAllDigitsPtr->fDigitDataStruct[j].fModule = digitDataPtr->fModule;
199 fAllDigitsPtr->fNDigits = j;
200 HLTDebug("Number of digits: %d", j);
201 nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
205 HLTError("Running out of buffer, exiting for safety.");
209 recPointHeaderPtr->fNRecPoints = nRecPoints;
210 mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
212 HLTDebug("Number of clusters: %d", nRecPoints);
214 // if(nRecPoints > 0)
217 AliHLTComponentBlockData clusterBd;
218 FillBlockData( clusterBd );
219 clusterBd.fOffset = offset;
220 clusterBd.fSize = mysize;
221 clusterBd.fDataType = AliHLTPHOSDefinitions::fgkRecPointDataType;
222 clusterBd.fSpecification = specification;
223 outputBlocks.push_back( clusterBd );
226 // if(fAllDigitsPtr->fNDigits)
229 AliHLTComponentBlockData digitBd;
230 FillBlockData(digitBd);
240 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
242 //See headerfile for documentation
244 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
245 fClusterizerPtr = new AliHLTPHOSClusterizer();
246 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
247 fNoCrazyness = false;
250 ScanArgumentsModule(argc, argv);
251 for (int i = 0; i < argc; i++)
253 if(!strcmp("-digitthreshold", argv[i]))
255 fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1]));
257 if(!strcmp("-recpointthreshold", argv[i]))
259 fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1]));
261 if(!strcmp("-partitionmode", argv[i]))
263 fModuleClusterizationMode = false;
270 AliHLTPHOSClusterizerComponent::Spawn()
272 //See headerfile for documentation
274 return new AliHLTPHOSClusterizerComponent();