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