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"
27 /** @file AliHLTCaloClusterizerComponent.cxx
28 @author Oystein Djuvsland
30 @brief A clusterizer component for PHOS HLT
33 // see header file for class documentation
35 // refer to README to build package
37 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
39 AliHLTCaloClusterizerComponent gAliHLTCaloClusterizerComponent;
41 AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent():
42 AliHLTPHOSProcessor(),
48 //See headerfile for documentation
51 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
53 //See headerfile for documentation
57 delete fClusterizerPtr;
69 AliHLTCaloClusterizerComponent::Deinit()
71 //See headerfile for documentation
75 delete fClusterizerPtr;
83 AliHLTCaloClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
85 //See headerfile for documentation
87 list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
90 AliHLTComponentDataType
91 AliHLTCaloClusterizerComponent::GetOutputDataType()
93 //See headerfile for documentation
94 return AliHLTPHOSDefinitions::fgkRecPointDataType;
98 AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
101 //See headerfile for documentation
102 constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ;
103 inputMultiplier = 1.5;
107 AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
108 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
109 std::vector<AliHLTComponentBlockData>& outputBlocks)
111 //See headerfile for documentation
113 if(blocks == 0) return 0;
117 Int_t nRecPoints = 0;
120 UInt_t availableSize = size;
121 AliHLTUInt8_t* outBPtr;
123 const AliHLTComponentBlockData* iter = 0;
126 UInt_t specification = 0;
128 AliHLTCaloDigitDataStruct *digitDataPtr = 0;
130 AliHLTCaloRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTCaloRecPointHeaderStruct*>(outBPtr);
132 fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTCaloRecPointDataStruct*>(outBPtr+sizeof(AliHLTCaloRecPointHeaderStruct)));
134 // Adding together all the digits, should be put in standalone method
135 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
138 if (iter->fDataType == AliHLTCaloDefinitions::fgkDigitDataType)
140 // Get the digit header
142 // Update the number of digits
143 nDigits += iter->fSize/sizeof(AliHLTCaloDigitDataStruct);;
144 // Get the specification
145 specification = specification|iter->fSpecification;
147 digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(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 // HLTDebug("Digit energy: %f", digitDataPtr->fEnergy);
154 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
155 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
163 fAllDigitsPtr->fNDigits = j;
164 nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
168 HLTError("Running out of buffer, exiting for safety.");
172 recPointHeaderPtr->fNRecPoints = nRecPoints;
173 mysize += sizeof(AliHLTCaloRecPointHeaderStruct);
175 HLTDebug("Number of clusters: %d", nRecPoints);
177 AliHLTComponentBlockData bd;
181 bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType;
182 bd.fSpecification = specification;
183 outputBlocks.push_back( bd );
191 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
193 // see header file for class documentation
195 const char* path="HLT/ConfigPHOS/ClusterizerComponent";
197 if (cdbEntry) path = cdbEntry;
199 return ConfigureFromCDBTObjString(cdbEntry);
203 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
205 //See header file for documentation
207 if(argc <= 0) return 0;
211 TString argument=argv[i];
213 if (argument.CompareTo("-digitthreshold") == 0)
215 if (++i >= argc) return -EPROTO;
217 fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
221 if (argument.CompareTo("-recpointthreshold") == 0)
223 if (++i >= argc) return -EPROTO;
225 fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
232 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
234 //See headerfile for documentation
236 fAllDigitsPtr = new AliHLTCaloDigitContainerDataStruct();
237 fClusterizerPtr = new AliHLTCaloClusterizer();
238 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
239 fNoCrazyness = false;
242 // const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
244 // ConfigureFromCDBTObjString(path);
246 for (int i = 0; i < argc; i++)
248 ScanConfigurationArgument(i, argv);
255 AliHLTCaloClusterizerComponent::Spawn()
257 //See headerfile for documentation
259 return new AliHLTCaloClusterizerComponent();