]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
Improved Clusterizer and rawanalyzer
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterAnalyserComponent.cxx
CommitLineData
fa0a9bec 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
5 * *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
14
15#include "AliHLTPHOSClusterAnalyserComponent.h"
16#include "AliHLTPHOSClusterAnalyser.h"
17#include "AliHLTPHOSRecPointContainerStruct.h"
18#include "AliHLTPHOSCaloClusterContainerStruct.h"
19
20/** @file AliHLTPHOSClusterAnalyserComponent.cxx
21 @author Oystein Djuvsland
22 @date
23 @brief A cluster analyser component for PHOS HLT
24*/
25
26// see header file for class documentation
27// or
28// refer to README to build package
29// or
30// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31
32#if __GNUC__>= 3
33using namespace std;
34#endif
35
36const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]=
37 {
38 kAliHLTVoidDataType,{0,"",""}
39 };
40
41AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
42
43
b444d727 44AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(),
45 fClusterAnalyserPtr(0),
46 fDoDeconvolution(0),
47 fDoCalculateMoments(0)
fa0a9bec 48{
49 //See headerfile for documentation
50}
51
52AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
53{
54 //See headerfile for documentation
55
56 if (fClusterAnalyserPtr)
57 {
58 delete fClusterAnalyserPtr;
59 fClusterAnalyserPtr = 0;
60 }
61}
62
63int
64AliHLTPHOSClusterAnalyserComponent::Deinit()
65{
66 //See headerfile for documentation
67
68 if (fClusterAnalyserPtr)
69 {
70 delete fClusterAnalyserPtr;
71 fClusterAnalyserPtr = 0;
72 }
73 return 0;
74}
75
76const Char_t*
77AliHLTPHOSClusterAnalyserComponent::GetComponentID()
78{
79 //See headerfile for documentation
80
81 return "PhosClusterAnalyser";
82}
83
84void
85AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
86{
87 //See headerfile for documentation
94594220 88 list.clear();
89 list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
90// const AliHLTComponentDataType* pType=fgkInputDataTypes;
91// while (pType->fID!=0)
92// {
93// list.push_back(*pType);
94// pType++;
95// }
fa0a9bec 96}
97
98AliHLTComponentDataType
99AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
100{
101 //See headerfile for documentation
102
25b7f84c 103 return AliHLTPHOSDefinitions::fgkClusterDataType;
fa0a9bec 104}
105
106void
107AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
108
109{
110 //See headerfile for documentation
111
9bf87c6f 112 constBase = sizeof(AliHLTPHOSCaloClusterContainerStruct);
fa0a9bec 113 inputMultiplier = 1;
114}
115
116AliHLTComponent*
117AliHLTPHOSClusterAnalyserComponent::Spawn()
118{
119 //See headerfile for documentation
120
121 return new AliHLTPHOSClusterAnalyserComponent();
122}
123
124int
125AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
126 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
127 std::vector<AliHLTComponentBlockData>& outputBlocks)
128{
129 //See headerfile for documentation
130
131 UInt_t tSize = 0;
132 UInt_t offset = 0;
133 UInt_t mysize = 0;
25b7f84c 134 Int_t nClusters = 0;
fa0a9bec 135
136 AliHLTUInt8_t* outBPtr;
137 outBPtr = outputPtr;
138 const AliHLTComponentBlockData* iter = 0;
139 unsigned long ndx;
140
141 UInt_t specification = 0;
142
143 AliHLTPHOSRecPointContainerStruct* recPointContainerPtr = 0;
144 fClusterAnalyserPtr->SetCaloClusterContainer((AliHLTPHOSCaloClusterContainerStruct*)outBPtr);
145 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
146 {
25b7f84c 147 iter = blocks+ndx;
148 if (iter->fDataType != AliHLTPHOSDefinitions::fgkClusterDataType)
fa0a9bec 149 {
150 continue;
151 }
152 specification = specification|iter->fSpecification;
153 recPointContainerPtr = reinterpret_cast<AliHLTPHOSRecPointContainerStruct*>(iter->fPtr);
154 fClusterAnalyserPtr->SetRecPointContainer(recPointContainerPtr);
155 if(fDoDeconvolution)
156 {
157 fClusterAnalyserPtr->DeconvoluteClusters();
158 }
159 fClusterAnalyserPtr->CalculateCenterOfGravity();
160 if(fDoCalculateMoments)
161 {
162 fClusterAnalyserPtr->CalculateRecPointMoments();
163 }
25b7f84c 164 nClusters = fClusterAnalyserPtr->CreateClusters();
fa0a9bec 165 }
166
25b7f84c 167 mysize = 0;
fa0a9bec 168 offset = tSize;
fa0a9bec 169 mysize += sizeof(AliHLTPHOSCaloClusterContainerStruct);
25b7f84c 170
fa0a9bec 171 AliHLTComponentBlockData bd;
172 FillBlockData( bd );
173 bd.fOffset = offset;
174 bd.fSize = mysize;
175 bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType;
176 bd.fSpecification = specification;
177 outputBlocks.push_back( bd );
178
179 tSize += mysize;
180 outBPtr += mysize;
25b7f84c 181
fa0a9bec 182 if ( tSize > size )
183 {
8efbf5fe 184 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
fa0a9bec 185 return EMSGSIZE;
186 }
25b7f84c 187
188 fPhosEventCount++;
04751caa 189 if(fPrintInfoModule == kTRUE)
25b7f84c 190 {
04751caa 191 if(fPhosEventCount%fPrintInfoFrequncyModule == 0)
25b7f84c 192 {
8efbf5fe 193 Logging( kHLTLogInfo, __FILE__ , "Clusters analyzed", "Has analyzed %lu for this event", nClusters);
25b7f84c 194 }
195 }
9bf87c6f 196
197 size = mysize;
fa0a9bec 198 return 0;
199
200}
201
202int
203AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
204{
25b7f84c 205
fa0a9bec 206 //See headerfile for documentation
207
208 fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
04751caa 209 ScanArgumentsModule(argc, argv);
fa0a9bec 210 for (int i = 0; i < argc; i++)
211 {
212 if(!strcmp("-dodeconvolution", argv[i]))
213 {
214 fDoDeconvolution = true;
215 }
216 if(!strcmp("-doclusterfit", argv[i]))
217 {
218 fClusterAnalyserPtr->SetDoClusterFit();
219 fDoCalculateMoments = true;
220 }
221 if(!strcmp("-haveCPV", argv[i]))
222 {
223 fClusterAnalyserPtr->SetHaveCPVInfo();
224 }
225 if(!strcmp("-doPID", argv[i]))
226 {
227 fClusterAnalyserPtr->SetDoPID();
228 }
229 if(!strcmp("-havedistbadchannel", argv[i]))
230 {
231 fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
232 }
233
234 }
235
236 return 0;
237}