]>
Commit | Line | Data |
---|---|---|
91b95d47 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Authors: Øystein 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 | **************************************************************************/ | |
aac22523 | 14 | |
aac22523 | 15 | |
91b95d47 | 16 | #include "AliHLTPHOSClusterizerComponent.h" |
aac22523 | 17 | #include "AliHLTPHOSClusterizer.h" |
18 | #include "AliHLTPHOSPhysicsDefinitions.h" | |
19 | #include "AliHLTPHOSDefinitions.h" | |
91b95d47 | 20 | #include "AliHLTPHOSRecPointDataStruct.h" |
21 | #include "AliHLTPHOSClusterDataStruct.h" | |
22 | #include "AliHLTPHOSRecPointListDataStruct.h" | |
23 | ||
24 | using namespace std; | |
aac22523 | 25 | |
26 | ||
91b95d47 | 27 | const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; |
aac22523 | 28 | |
29 | AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent; | |
30 | ||
31 | AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0), | |
32 | fRecPointStructArrayPtr(0), fRecPointListPtr(0) | |
33 | { | |
91b95d47 | 34 | //Constructor |
aac22523 | 35 | |
36 | } | |
37 | ||
38 | AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent() | |
39 | { | |
91b95d47 | 40 | //Destructor |
41 | ||
42 | if(fClusterizerPtr) | |
43 | { | |
44 | delete fClusterizerPtr; | |
45 | fClusterizerPtr = 0; | |
46 | } | |
47 | ||
48 | if(fRecPointListPtr) | |
49 | { | |
50 | delete fRecPointListPtr; | |
51 | fRecPointListPtr = 0; | |
52 | } | |
53 | ||
54 | if(fRecPointStructArrayPtr) | |
55 | { | |
56 | delete fRecPointStructArrayPtr; | |
57 | fRecPointStructArrayPtr = 0; | |
58 | } | |
59 | ||
aac22523 | 60 | } |
61 | ||
62 | AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(), | |
63 | fClusterizerPtr(0), | |
64 | fOutPtr(0), | |
65 | fRecPointStructArrayPtr(0), | |
66 | fRecPointListPtr(0) | |
67 | { | |
91b95d47 | 68 | //Copy constructor, not implemented |
aac22523 | 69 | } |
70 | ||
71 | Int_t | |
72 | AliHLTPHOSClusterizerComponent::Deinit() | |
73 | { | |
91b95d47 | 74 | //Deinitialization |
75 | ||
76 | if(fClusterizerPtr) | |
77 | { | |
78 | delete fClusterizerPtr; | |
79 | fClusterizerPtr = 0; | |
80 | } | |
81 | ||
82 | if(fRecPointListPtr) | |
83 | { | |
84 | delete fRecPointListPtr; | |
85 | fRecPointListPtr = 0; | |
86 | } | |
87 | ||
88 | if(fRecPointStructArrayPtr) | |
89 | { | |
90 | delete fRecPointStructArrayPtr; | |
91 | fRecPointStructArrayPtr = 0; | |
92 | } | |
93 | ||
aac22523 | 94 | return 0; |
95 | } | |
96 | ||
97 | Int_t | |
98 | AliHLTPHOSClusterizerComponent::DoDeinit() | |
99 | { | |
91b95d47 | 100 | //Do deinitialization |
aac22523 | 101 | Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit"); |
102 | ||
103 | return 0; | |
104 | } | |
105 | ||
106 | ||
107 | const Char_t* | |
108 | AliHLTPHOSClusterizerComponent::GetComponentID() | |
109 | { | |
110 | return "AliHltPhosClusterizer"; | |
111 | } | |
112 | ||
113 | void | |
114 | AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
115 | { | |
91b95d47 | 116 | //Get datatypes for input |
117 | const AliHLTComponentDataType* pType=fgkInputDataTypes; | |
aac22523 | 118 | while (pType->fID!=0) { |
119 | list.push_back(*pType); | |
120 | pType++; | |
121 | } | |
122 | } | |
123 | ||
124 | AliHLTComponentDataType | |
125 | AliHLTPHOSClusterizerComponent::GetOutputDataType() | |
126 | { | |
127 | return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType; | |
128 | } | |
129 | ||
130 | void | |
131 | AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
132 | ||
133 | { | |
134 | constBase = 30; | |
135 | inputMultiplier = 1; | |
136 | } | |
137 | ||
138 | Int_t | |
139 | AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
91b95d47 | 140 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, |
aac22523 | 141 | std::vector<AliHLTComponentBlockData>& outputBlocks) |
142 | { | |
91b95d47 | 143 | //Do event |
aac22523 | 144 | |
145 | UInt_t tSize = 0; | |
146 | UInt_t offset = 0; | |
147 | UInt_t mysize = 0; | |
148 | Int_t nRecPoints = 0; | |
149 | Int_t index = 0; | |
150 | ||
151 | AliHLTUInt8_t* outBPtr; | |
152 | outBPtr = outputPtr; | |
153 | const AliHLTComponentBlockData* iter = 0; | |
154 | unsigned long ndx; | |
155 | ||
156 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
157 | { | |
158 | iter = blocks+ndx; | |
159 | ||
160 | if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType) | |
161 | { | |
162 | cout << "Warning: data type is not fgkCellEnergyDataType " << endl; | |
163 | continue; | |
164 | } | |
165 | index = fClusterizerPtr->BuildCellEnergyArray( reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr), | |
166 | fRecPointListPtr); | |
167 | ||
168 | } | |
169 | ||
170 | nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index); | |
171 | ||
172 | for(Int_t i = 0; i < nRecPoints; i++) | |
173 | { | |
174 | mysize = 0; | |
175 | offset = tSize; | |
176 | ||
177 | fOutPtr = (AliHLTPHOSClusterDataStruct*)outBPtr; | |
178 | fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]); | |
179 | fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr); | |
180 | ||
181 | mysize += sizeof(AliHLTPHOSClusterDataStruct); | |
182 | ||
183 | AliHLTComponentBlockData bd; | |
184 | FillBlockData( bd ); | |
185 | bd.fOffset = offset; | |
186 | bd.fSize = mysize; | |
187 | bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType; | |
188 | bd.fSpecification = 0xFFFFFFFF; | |
189 | outputBlocks.push_back( bd ); | |
190 | ||
191 | tSize += mysize; | |
192 | outBPtr += mysize; | |
193 | ||
194 | if( tSize > size ) | |
195 | { | |
196 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data", | |
197 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
198 | , tSize, size ); | |
199 | return EMSGSIZE; | |
200 | } | |
201 | } | |
202 | ||
aac22523 | 203 | size = tSize; |
204 | fClusterizerPtr->ResetCellEnergyArray(); | |
205 | ||
206 | return 0; | |
207 | ||
208 | } | |
209 | ||
210 | Int_t | |
9be2600f | 211 | AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv ) |
aac22523 | 212 | { |
91b95d47 | 213 | //Do initialization |
aac22523 | 214 | |
215 | fClusterizerPtr = new AliHLTPHOSClusterizer(); | |
216 | fClusterizerPtr->SetThreshold(atof(argv[0])); | |
217 | fClusterizerPtr->SetClusterThreshold(atof(argv[1])); | |
218 | fClusterizerPtr->SetHighGainFactor(atof(argv[2])); | |
219 | fClusterizerPtr->SetLowGainFactor(atof(argv[3])); | |
220 | fClusterizerPtr->SetArraySize(atoi(argv[4])); | |
221 | fClusterizerPtr->ResetCellEnergyArray(); | |
222 | fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ROWS_MOD*N_COLUMNS_MOD]; | |
223 | fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000]; | |
224 | ||
225 | if (argc==0 && argv==NULL) { | |
226 | // this is currently just to get rid of the warning "unused parameter" | |
227 | } | |
228 | ||
229 | return 0; | |
230 | } | |
231 | ||
232 | AliHLTComponent* | |
233 | AliHLTPHOSClusterizerComponent::Spawn() | |
234 | { | |
91b95d47 | 235 | //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework |
aac22523 | 236 | return new AliHLTPHOSClusterizerComponent(); |
237 | } |