1 // $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $
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 "AliHLTCaloClusterizerComponent.h"
20 #include "AliHLTCaloClusterizer.h"
21 #include "AliHLTCaloRecPointDataStruct.h"
22 #include "AliHLTCaloRecPointHeaderStruct.h"
23 #include "AliHLTCaloDigitDataStruct.h"
24 #include "AliHLTCaloDigitContainerDataStruct.h"
25 #include "AliHLTCaloDefinitions.h"
28 /** @file AliHLTCaloClusterizerComponent.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
41 AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
42 AliHLTCaloProcessor(),
43 AliHLTCaloConstantsHandler(det),
44 fDigitsPointerArray(0),
49 //See headerfile for documentation
51 fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()];
53 fClusterizerPtr = new AliHLTCaloClusterizer(det);
55 fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
59 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
61 //See headerfile for documentation
65 delete fClusterizerPtr;
72 AliHLTCaloClusterizerComponent::Deinit()
74 //See headerfile for documentation
78 delete fClusterizerPtr;
86 // AliHLTCaloClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
88 // //See headerfile for documentation
90 // list.push_back(AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS);
93 // AliHLTComponentDataType
94 // AliHLTCaloClusterizerComponent::GetOutputDataType()
96 // //See headerfile for documentation
97 // return AliHLTCaloDefinitions::fgkRecPointDataType|kAliHLTDataOriginPHOS;
101 // AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
104 // //See headerfile for documentation
105 // constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ;
106 // inputMultiplier = 1.5;
110 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
111 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
112 std::vector<AliHLTComponentBlockData>& outputBlocks)
114 //See headerfile for documentation
116 if(blocks == 0) return 0;
120 Int_t nRecPoints = 0;
124 //UInt_t availableSize = size;
125 AliHLTUInt8_t* outBPtr;
127 const AliHLTComponentBlockData* iter = 0;
130 UInt_t specification = 0;
132 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
134 // Adding together all the digits, should be put in standalone method
135 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
138 // HLTError("Got block");
139 if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS))
141 // Get the digit header
143 // Update the number of digits
144 nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);;
145 // HLTError("Got %d digits", nDigits);
147 specification = specification|iter->fSpecification;
149 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
150 for (Int_t i = 0; i < nDigits; i++)
152 fDigitsPointerArray[digCount] = digitDataPtr;
163 // Sort the digit pointers
164 qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
166 // Copy the digits to the output
167 for(Int_t n = 0; n < digCount; n++)
169 memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
170 outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
173 mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
175 AliHLTComponentBlockData bdDigits;
176 FillBlockData( bdDigits );
177 bdDigits.fOffset = offset;
178 bdDigits.fSize = mysize;
179 bdDigits.fDataType = iter->fDataType;
180 bdDigits.fSpecification = specification;
181 outputBlocks.push_back( bdDigits );
184 AliHLTCaloRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTCaloRecPointHeaderStruct*>(outBPtr);
186 fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTCaloRecPointDataStruct*>(outBPtr+sizeof(AliHLTCaloRecPointHeaderStruct)));
188 // HLTError("Total number of digits: %d", digCount );
190 printf("Total number of digits: %d\n", digCount);
192 nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount, size, mysize);
196 // HLTError("Running out of buffer, exiting for safety.");
200 recPointHeaderPtr->fNRecPoints = nRecPoints;
201 mysize += sizeof(AliHLTCaloRecPointHeaderStruct);
203 // HLTError("Number of clusters: %d", nRecPoints);
205 AliHLTComponentBlockData bd;
209 bd.fDataType = AliHLTCaloDefinitions::fgkClusterDataType;
210 bd.fSpecification = specification;
211 outputBlocks.push_back( bd );
220 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
222 // see header file for class documentation
224 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
226 if (cdbEntry) path = cdbEntry;
228 return ConfigureFromCDBTObjString(cdbEntry);
232 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
234 //See header file for documentation
236 if(argc <= 0) return 0;
240 TString argument=argv[i];
242 if (argument.CompareTo("-digitthreshold") == 0)
244 if (++i >= argc) return -EPROTO;
246 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
250 if (argument.CompareTo("-recpointthreshold") == 0)
252 if (++i >= argc) return -EPROTO;
254 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
261 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
263 //See headerfile for documentation
268 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
270 // ConfigureFromCDBTObjString(path);
272 for (int i = 0; i < argc; i++)
274 ScanConfigurationArgument(i, argv);
281 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
283 // See header file for documentation
284 return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;