]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
Selectiv readout and writing to FXS (oystein)
[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
44AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent():
45AliHLTPHOSProcessor(),
25b7f84c 46fClusterAnalyserPtr(0),
47fDoDeconvolution(0),
48fDoCalculateMoments(0)
fa0a9bec 49{
50 //See headerfile for documentation
51}
52
53AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
54{
55 //See headerfile for documentation
56
57 if (fClusterAnalyserPtr)
58 {
59 delete fClusterAnalyserPtr;
60 fClusterAnalyserPtr = 0;
61 }
62}
63
64int
65AliHLTPHOSClusterAnalyserComponent::Deinit()
66{
67 //See headerfile for documentation
68
69 if (fClusterAnalyserPtr)
70 {
71 delete fClusterAnalyserPtr;
72 fClusterAnalyserPtr = 0;
73 }
74 return 0;
75}
76
77const Char_t*
78AliHLTPHOSClusterAnalyserComponent::GetComponentID()
79{
80 //See headerfile for documentation
81
82 return "PhosClusterAnalyser";
83}
84
85void
86AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
87{
88 //See headerfile for documentation
89
90 const AliHLTComponentDataType* pType=fgkInputDataTypes;
91 while (pType->fID!=0)
92 {
93 list.push_back(*pType);
94 pType++;
95 }
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
112 constBase = 0;
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 {
184 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data",
185 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
186 , tSize, size );
187 return EMSGSIZE;
188 }
25b7f84c 189
190 fPhosEventCount++;
191 if(fPrintInfo == kTRUE)
192 {
193 if(fPhosEventCount%fPrintInfoFrequncy == 0)
194 {
195 cout << "Cluster analyser: # of clusters: " << nClusters << endl;
196 }
197 }
fa0a9bec 198
199 return 0;
200
201}
202
203int
204AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
205{
25b7f84c 206
fa0a9bec 207 //See headerfile for documentation
208
209 fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
25b7f84c 210 ScanArguments(argc, argv);
fa0a9bec 211 for (int i = 0; i < argc; i++)
212 {
213 if(!strcmp("-dodeconvolution", argv[i]))
214 {
215 fDoDeconvolution = true;
216 }
217 if(!strcmp("-doclusterfit", argv[i]))
218 {
219 fClusterAnalyserPtr->SetDoClusterFit();
220 fDoCalculateMoments = true;
221 }
222 if(!strcmp("-haveCPV", argv[i]))
223 {
224 fClusterAnalyserPtr->SetHaveCPVInfo();
225 }
226 if(!strcmp("-doPID", argv[i]))
227 {
228 fClusterAnalyserPtr->SetDoPID();
229 }
230 if(!strcmp("-havedistbadchannel", argv[i]))
231 {
232 fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
233 }
234
235 }
236
237 return 0;
238}