]>
Commit | Line | Data |
---|---|---|
1b41ab20 | 1 | // $Id$ |
2 | ||
fa0a9bec | 3 | /************************************************************************** |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Oystein Djuvsland <oysteind@ift.uib.no> * | |
7 | * * | |
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 | **************************************************************************/ | |
16 | ||
17 | #include "AliHLTPHOSClusterAnalyserComponent.h" | |
18 | #include "AliHLTPHOSClusterAnalyser.h" | |
87434909 | 19 | #include "AliHLTPHOSRecPointHeaderStruct.h" |
7fc04b67 | 20 | #include "AliHLTCaloClusterDataStruct.h" |
fa0a9bec | 21 | |
22 | /** @file AliHLTPHOSClusterAnalyserComponent.cxx | |
23 | @author Oystein Djuvsland | |
24 | @date | |
25 | @brief A cluster analyser component for PHOS HLT | |
26 | */ | |
27 | ||
28 | // see header file for class documentation | |
29 | // or | |
30 | // refer to README to build package | |
31 | // or | |
32 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
33 | ||
34 | #if __GNUC__>= 3 | |
35 | using namespace std; | |
36 | #endif | |
37 | ||
38 | const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]= | |
39 | { | |
40 | kAliHLTVoidDataType,{0,"",""} | |
41 | }; | |
42 | ||
43 | AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent; | |
44 | ||
45 | ||
b444d727 | 46 | AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(), |
47 | fClusterAnalyserPtr(0), | |
48 | fDoDeconvolution(0), | |
49 | fDoCalculateMoments(0) | |
fa0a9bec | 50 | { |
51 | //See headerfile for documentation | |
52 | } | |
53 | ||
54 | AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent() | |
55 | { | |
56 | //See headerfile for documentation | |
57 | ||
58 | if (fClusterAnalyserPtr) | |
59 | { | |
60 | delete fClusterAnalyserPtr; | |
61 | fClusterAnalyserPtr = 0; | |
62 | } | |
63 | } | |
64 | ||
65 | int | |
66 | AliHLTPHOSClusterAnalyserComponent::Deinit() | |
67 | { | |
68 | //See headerfile for documentation | |
69 | ||
70 | if (fClusterAnalyserPtr) | |
71 | { | |
72 | delete fClusterAnalyserPtr; | |
73 | fClusterAnalyserPtr = 0; | |
74 | } | |
75 | return 0; | |
76 | } | |
77 | ||
78 | const Char_t* | |
79 | AliHLTPHOSClusterAnalyserComponent::GetComponentID() | |
80 | { | |
81 | //See headerfile for documentation | |
82 | ||
83 | return "PhosClusterAnalyser"; | |
84 | } | |
85 | ||
86 | void | |
87 | AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
88 | { | |
89 | //See headerfile for documentation | |
94594220 | 90 | list.clear(); |
e304ea31 | 91 | list.push_back(AliHLTPHOSDefinitions::fgkRecPointDataType); |
fa0a9bec | 92 | } |
93 | ||
94 | AliHLTComponentDataType | |
95 | AliHLTPHOSClusterAnalyserComponent::GetOutputDataType() | |
96 | { | |
97 | //See headerfile for documentation | |
98 | ||
87434909 | 99 | return AliHLTPHOSDefinitions::fgkCaloClusterDataType; |
fa0a9bec | 100 | } |
101 | ||
102 | void | |
103 | AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
104 | ||
105 | { | |
106 | //See headerfile for documentation | |
107 | ||
7fc04b67 | 108 | constBase = sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t); |
e304ea31 | 109 | inputMultiplier = 1.2; |
fa0a9bec | 110 | } |
111 | ||
112 | AliHLTComponent* | |
113 | AliHLTPHOSClusterAnalyserComponent::Spawn() | |
114 | { | |
115 | //See headerfile for documentation | |
116 | ||
117 | return new AliHLTPHOSClusterAnalyserComponent(); | |
118 | } | |
119 | ||
120 | int | |
121 | AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
122 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
123 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
124 | { | |
125 | //See headerfile for documentation | |
126 | ||
e304ea31 | 127 | //UInt_t tSize = 0; |
fa0a9bec | 128 | UInt_t offset = 0; |
129 | UInt_t mysize = 0; | |
25b7f84c | 130 | Int_t nClusters = 0; |
fa0a9bec | 131 | |
132 | AliHLTUInt8_t* outBPtr; | |
133 | outBPtr = outputPtr; | |
134 | const AliHLTComponentBlockData* iter = 0; | |
135 | unsigned long ndx; | |
136 | ||
137 | UInt_t specification = 0; | |
138 | ||
7fc04b67 | 139 | AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr); |
e304ea31 | 140 | |
7fc04b67 | 141 | fClusterAnalyserPtr->SetCaloClusterDataPtr(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr + sizeof(AliHLTCaloClusterHeaderStruct))); |
fa0a9bec | 142 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
143 | { | |
25b7f84c | 144 | iter = blocks+ndx; |
e304ea31 | 145 | if (iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType) |
fa0a9bec | 146 | { |
e304ea31 | 147 | continue; |
fa0a9bec | 148 | } |
149 | specification = specification|iter->fSpecification; | |
e304ea31 | 150 | fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr)); |
87434909 | 151 | HLTDebug("Number of rec points: %d", (reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr))->fNRecPoints); |
152 | ||
fa0a9bec | 153 | if(fDoDeconvolution) |
154 | { | |
155 | fClusterAnalyserPtr->DeconvoluteClusters(); | |
156 | } | |
157 | fClusterAnalyserPtr->CalculateCenterOfGravity(); | |
158 | if(fDoCalculateMoments) | |
159 | { | |
160 | fClusterAnalyserPtr->CalculateRecPointMoments(); | |
161 | } | |
e304ea31 | 162 | nClusters = fClusterAnalyserPtr->CreateClusters(size, mysize); |
fa0a9bec | 163 | } |
e304ea31 | 164 | |
165 | if(nClusters == -1) | |
166 | { | |
167 | HLTError("Running out of buffer, exiting for safety."); | |
168 | return -ENOBUFS; | |
169 | } | |
87434909 | 170 | for(int i = 0; i < nClusters; i++) |
171 | { | |
172 | ||
173 | } | |
174 | ||
e304ea31 | 175 | HLTDebug("Number of clusters: %d", nClusters); |
176 | caloClusterHeaderPtr->fNClusters = nClusters; | |
7fc04b67 | 177 | mysize += sizeof(AliHLTCaloClusterHeaderStruct); |
25b7f84c | 178 | |
fa0a9bec | 179 | AliHLTComponentBlockData bd; |
180 | FillBlockData( bd ); | |
181 | bd.fOffset = offset; | |
182 | bd.fSize = mysize; | |
183 | bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType; | |
184 | bd.fSpecification = specification; | |
185 | outputBlocks.push_back( bd ); | |
25b7f84c | 186 | |
e304ea31 | 187 | if ( mysize > size ) |
fa0a9bec | 188 | { |
e304ea31 | 189 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", mysize, size ); |
fa0a9bec | 190 | return EMSGSIZE; |
191 | } | |
25b7f84c | 192 | |
193 | fPhosEventCount++; | |
9bf87c6f | 194 | |
195 | size = mysize; | |
fa0a9bec | 196 | return 0; |
197 | ||
198 | } | |
199 | ||
200 | int | |
201 | AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv ) | |
202 | { | |
25b7f84c | 203 | |
fa0a9bec | 204 | //See headerfile for documentation |
205 | ||
206 | fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser(); | |
04751caa | 207 | ScanArgumentsModule(argc, argv); |
fa0a9bec | 208 | for (int i = 0; i < argc; i++) |
209 | { | |
210 | if(!strcmp("-dodeconvolution", argv[i])) | |
211 | { | |
212 | fDoDeconvolution = true; | |
213 | } | |
214 | if(!strcmp("-doclusterfit", argv[i])) | |
215 | { | |
216 | fClusterAnalyserPtr->SetDoClusterFit(); | |
217 | fDoCalculateMoments = true; | |
218 | } | |
219 | if(!strcmp("-haveCPV", argv[i])) | |
220 | { | |
221 | fClusterAnalyserPtr->SetHaveCPVInfo(); | |
222 | } | |
223 | if(!strcmp("-doPID", argv[i])) | |
224 | { | |
225 | fClusterAnalyserPtr->SetDoPID(); | |
226 | } | |
227 | if(!strcmp("-havedistbadchannel", argv[i])) | |
228 | { | |
229 | fClusterAnalyserPtr->SetHaveDistanceToBadChannel(); | |
230 | } | |
231 | ||
232 | } | |
233 | ||
234 | return 0; | |
235 | } |