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 **************************************************************************/
17 #include "AliHLTPHOSClusterAnalyserComponent.h"
18 #include "AliHLTPHOSClusterAnalyser.h"
19 #include "AliHLTPHOSRecPointHeaderStruct.h"
20 #include "AliHLTPHOSCaloClusterDataStruct.h"
21 #include "AliHLTPHOSCaloClusterHeaderStruct.h"
23 /** @file AliHLTPHOSClusterAnalyserComponent.cxx
24 @author Oystein Djuvsland
26 @brief A cluster analyser component for PHOS HLT
29 // see header file for class documentation
31 // refer to README to build package
33 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
39 const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]=
41 kAliHLTVoidDataType,{0,"",""}
44 AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
47 AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(),
48 fClusterAnalyserPtr(0),
50 fDoCalculateMoments(0)
52 //See headerfile for documentation
55 AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
57 //See headerfile for documentation
59 if (fClusterAnalyserPtr)
61 delete fClusterAnalyserPtr;
62 fClusterAnalyserPtr = 0;
67 AliHLTPHOSClusterAnalyserComponent::Deinit()
69 //See headerfile for documentation
71 if (fClusterAnalyserPtr)
73 delete fClusterAnalyserPtr;
74 fClusterAnalyserPtr = 0;
80 AliHLTPHOSClusterAnalyserComponent::GetComponentID()
82 //See headerfile for documentation
84 return "PhosClusterAnalyser";
88 AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
90 //See headerfile for documentation
92 list.push_back(AliHLTPHOSDefinitions::fgkRecPointDataType);
95 AliHLTComponentDataType
96 AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
98 //See headerfile for documentation
100 return AliHLTPHOSDefinitions::fgkCaloClusterDataType;
104 AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
107 //See headerfile for documentation
109 constBase = sizeof(AliHLTPHOSCaloClusterHeaderStruct) + sizeof(AliHLTPHOSCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t);
110 inputMultiplier = 1.2;
114 AliHLTPHOSClusterAnalyserComponent::Spawn()
116 //See headerfile for documentation
118 return new AliHLTPHOSClusterAnalyserComponent();
122 AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
123 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
124 std::vector<AliHLTComponentBlockData>& outputBlocks)
126 //See headerfile for documentation
133 AliHLTUInt8_t* outBPtr;
135 const AliHLTComponentBlockData* iter = 0;
138 UInt_t specification = 0;
140 AliHLTPHOSCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTPHOSCaloClusterHeaderStruct*>(outBPtr);
142 fClusterAnalyserPtr->SetCaloClusterDataPtr(reinterpret_cast<AliHLTPHOSCaloClusterDataStruct*>(outBPtr + sizeof(AliHLTPHOSCaloClusterHeaderStruct)));
143 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
146 if (iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType)
150 specification = specification|iter->fSpecification;
151 fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr));
152 HLTDebug("Number of rec points: %d", (reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr))->fNRecPoints);
156 fClusterAnalyserPtr->DeconvoluteClusters();
158 fClusterAnalyserPtr->CalculateCenterOfGravity();
159 if(fDoCalculateMoments)
161 fClusterAnalyserPtr->CalculateRecPointMoments();
163 nClusters = fClusterAnalyserPtr->CreateClusters(size, mysize);
168 HLTError("Running out of buffer, exiting for safety.");
171 for(int i = 0; i < nClusters; i++)
176 HLTDebug("Number of clusters: %d", nClusters);
177 caloClusterHeaderPtr->fNClusters = nClusters;
178 mysize += sizeof(AliHLTPHOSCaloClusterHeaderStruct);
180 AliHLTComponentBlockData bd;
184 bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType;
185 bd.fSpecification = specification;
186 outputBlocks.push_back( bd );
190 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", mysize, size );
202 AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
205 //See headerfile for documentation
207 fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
208 ScanArgumentsModule(argc, argv);
209 for (int i = 0; i < argc; i++)
211 if(!strcmp("-dodeconvolution", argv[i]))
213 fDoDeconvolution = true;
215 if(!strcmp("-doclusterfit", argv[i]))
217 fClusterAnalyserPtr->SetDoClusterFit();
218 fDoCalculateMoments = true;
220 if(!strcmp("-haveCPV", argv[i]))
222 fClusterAnalyserPtr->SetHaveCPVInfo();
224 if(!strcmp("-doPID", argv[i]))
226 fClusterAnalyserPtr->SetDoPID();
228 if(!strcmp("-havedistbadchannel", argv[i]))
230 fClusterAnalyserPtr->SetHaveDistanceToBadChannel();