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
40 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
42 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():
43 AliHLTPHOSProcessor(),
49 //See headerfile for documentation
52 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
54 //See headerfile for documentation
58 delete fClusterizerPtr;
70 AliHLTPHOSClusterizerComponent::Deinit()
72 //See headerfile for documentation
76 delete fClusterizerPtr;
84 AliHLTPHOSClusterizerComponent::GetComponentID()
86 //See headerfile for documentation
87 return "PhosClusterizer";
91 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
93 //See headerfile for documentation
95 list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
98 AliHLTComponentDataType
99 AliHLTPHOSClusterizerComponent::GetOutputDataType()
101 //See headerfile for documentation
102 return AliHLTPHOSDefinitions::fgkRecPointDataType;
106 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
109 //See headerfile for documentation
110 constBase = sizeof(AliHLTPHOSRecPointHeaderStruct) + sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate... ;
111 inputMultiplier = 1.5;
115 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
116 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
117 std::vector<AliHLTComponentBlockData>& outputBlocks)
119 //See headerfile for documentation
123 Int_t nRecPoints = 0;
127 AliHLTUInt8_t* outBPtr;
129 const AliHLTComponentBlockData* iter = 0;
132 UInt_t specification = 0;
134 AliHLTPHOSDigitDataStruct *digitDataPtr = 0;
136 AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
138 fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
140 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
143 if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
145 specification = specification|iter->fSpecification;
146 nDigits = iter->fSize/sizeof(AliHLTPHOSDigitDataStruct);
147 digitDataPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr);
148 for (Int_t i = 0; i < nDigits; i++)
150 fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX;
151 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ;
152 fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy;
153 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
154 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
155 fAllDigitsPtr->fDigitDataStruct[j].fModule = digitDataPtr->fModule;
162 fAllDigitsPtr->fNDigits = j;
163 HLTDebug("Number of digits: %d", j);
164 nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
168 HLTError("Running out of buffer, exiting for safety.");
172 recPointHeaderPtr->fNRecPoints = nRecPoints;
173 mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
175 HLTDebug("Number of clusters: %d", nRecPoints);
177 AliHLTComponentBlockData clusterBd;
178 FillBlockData( clusterBd );
179 clusterBd.fOffset = offset;
180 clusterBd.fSize = mysize;
181 clusterBd.fDataType = AliHLTPHOSDefinitions::fgkRecPointDataType;
182 clusterBd.fSpecification = specification;
183 outputBlocks.push_back( clusterBd );
187 AliHLTComponentBlockData digitBd;
188 FillBlockData(digitBd);
197 AliHLTPHOSClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
199 // see header file for class documentation
201 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
203 if (cdbEntry) path = cdbEntry;
205 return ConfigureFromCDBTObjString(cdbEntry);
209 AliHLTPHOSClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
211 //See header file for documentation
213 if(argc <= 0) return 0;
217 TString argument=argv[i];
219 if (argument.CompareTo("-digitthreshold") == 0)
221 if (++i >= argc) return -EPROTO;
223 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
227 if (argument.CompareTo("-recpointthreshold") == 0)
229 if (++i >= argc) return -EPROTO;
231 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
238 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
240 //See headerfile for documentation
242 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
243 fClusterizerPtr = new AliHLTPHOSClusterizer();
244 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
245 fNoCrazyness = false;
248 const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
250 ConfigureFromCDBTObjString(path);
252 for (int i = 0; i < argc; i++)
254 ScanConfigurationArgument(i, argv[i]);
261 AliHLTPHOSClusterizerComponent::Spawn()
263 //See headerfile for documentation
265 return new AliHLTPHOSClusterizerComponent();