]>
Commit | Line | Data |
---|---|---|
187229ab | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Kenneth Aamodt * | |
8 | * Kalliopi Kanaki * | |
9 | * for The ALICE HLT Project. * | |
10 | * * | |
11 | * Permission to use, copy, modify and distribute this software and its * | |
12 | * documentation strictly for non-commercial purposes is hereby granted * | |
13 | * without fee, provided that the above copyright notice appears in all * | |
14 | * copies and that both the copyright notice and this permission notice * | |
15 | * appear in the supporting documentation. The authors make no claims * | |
16 | * about the suitability of this software for any purpose. It is * | |
17 | * provided "as is" without express or implied warranty. * | |
18 | **************************************************************************/ | |
19 | ||
20 | /** @file AliHLTTPCKryptonClusterFinderComponent.cxx | |
21 | @author Kenneth Aamodt, Kalliopi Kanaki | |
22 | @date | |
23 | @brief The TPC krypton cluster finder processing component | |
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 | |
33 | using namespace std; | |
34 | #endif | |
35 | #include "AliHLTTPCKryptonClusterFinderComponent.h" | |
36 | #include "AliHLTTPCDigitReaderDecoder.h" | |
37 | #include "AliHLTTPCKryptonClusterFinder.h" | |
38 | #include "AliHLTTPCSpacePointData.h" | |
39 | #include "AliHLTTPCClusterDataFormat.h" | |
40 | #include "AliHLTTPCTransform.h" | |
41 | #include "AliHLTTPCClusters.h" | |
42 | #include "AliHLTTPCDefinitions.h" | |
43 | #include "AliCDBEntry.h" | |
44 | #include "AliCDBManager.h" | |
98034d0d | 45 | #include "TH1F.h" |
187229ab | 46 | |
47 | #include <cstdlib> | |
48 | #include <cerrno> | |
49 | #include "TString.h" | |
50 | #include "TObjString.h" | |
51 | #include <sys/time.h> | |
52 | ||
53 | AliHLTTPCKryptonClusterFinderComponent gAliHLTTPCKryptonClusterFinderComponent; | |
54 | ||
55 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
56 | ClassImp(AliHLTTPCKryptonClusterFinderComponent) | |
57 | ||
58 | AliHLTTPCKryptonClusterFinderComponent::AliHLTTPCKryptonClusterFinderComponent() | |
59 | : | |
98034d0d | 60 | fKryptonClusterFinder(NULL), |
b7625c4d | 61 | fReader(NULL), |
62 | fSpecification(0) | |
187229ab | 63 | { |
64 | // see header file for class documentation | |
65 | // or | |
66 | // refer to README to build package | |
67 | // or | |
68 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
69 | } | |
70 | ||
71 | AliHLTTPCKryptonClusterFinderComponent::~AliHLTTPCKryptonClusterFinderComponent() | |
72 | { | |
73 | // see header file for class documentation | |
74 | } | |
75 | ||
76 | // Public functions to implement AliHLTComponent's interface. | |
77 | // These functions are required for the registration process | |
78 | ||
79 | const char* AliHLTTPCKryptonClusterFinderComponent::GetComponentID() | |
80 | { | |
81 | // see header file for class documentation | |
82 | return "TPCKryptonClusterFinder"; | |
83 | } | |
84 | ||
85 | void AliHLTTPCKryptonClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
86 | { | |
87 | // see header file for class documentation | |
88 | list.clear(); | |
89 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC ); | |
90 | } | |
91 | ||
92 | AliHLTComponentDataType AliHLTTPCKryptonClusterFinderComponent::GetOutputDataType() | |
93 | { | |
94 | // see header file for class documentation | |
0efebbac | 95 | return kAliHLTMultipleDataType; |
96 | // return kAliHLTDataTypeHistogram; | |
187229ab | 97 | } |
98 | ||
99 | int AliHLTTPCKryptonClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
100 | ||
101 | { | |
102 | // see header file for class documentation | |
103 | tgtList.clear(); | |
0efebbac | 104 | tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType); |
105 | tgtList.push_back(kAliHLTDataTypeHwAddr16); | |
187229ab | 106 | return tgtList.size(); |
107 | } | |
108 | ||
109 | void AliHLTTPCKryptonClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
110 | { | |
111 | // see header file for class documentation | |
112 | // XXX TODO: Find more realistic values. | |
113 | constBase = 0; | |
b7625c4d | 114 | inputMultiplier = (100 * 0.4); |
187229ab | 115 | } |
116 | ||
117 | AliHLTComponent* AliHLTTPCKryptonClusterFinderComponent::Spawn() | |
118 | { | |
119 | // see header file for class documentation | |
120 | return new AliHLTTPCKryptonClusterFinderComponent(); | |
121 | } | |
122 | ||
123 | int AliHLTTPCKryptonClusterFinderComponent::DoInit( int argc, const char** argv ) | |
124 | { | |
125 | // see header file for class documentation | |
0efebbac | 126 | |
127 | // HLTFatal("Initializing the kryptonclusterfindercomponent"); | |
128 | ||
98034d0d | 129 | if ( fKryptonClusterFinder ) |
187229ab | 130 | return EINPROGRESS; |
131 | ||
98034d0d | 132 | fKryptonClusterFinder = new AliHLTTPCKryptonClusterFinder(); |
187229ab | 133 | |
134 | Int_t i = 0; | |
135 | ||
136 | while ( i < argc ) { | |
137 | ||
138 | //No arguments so far | |
139 | ||
140 | Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
141 | return EINVAL; | |
142 | ||
143 | } | |
144 | ||
145 | fReader = new AliHLTTPCDigitReaderDecoder(); | |
98034d0d | 146 | fKryptonClusterFinder->SetReader(fReader); |
187229ab | 147 | |
148 | return 0; | |
149 | } | |
150 | ||
151 | int AliHLTTPCKryptonClusterFinderComponent::DoDeinit() | |
152 | { | |
153 | // see header file for class documentation | |
154 | ||
98034d0d | 155 | if ( fKryptonClusterFinder ) |
156 | delete fKryptonClusterFinder; | |
157 | fKryptonClusterFinder = NULL; | |
187229ab | 158 | |
159 | if ( fReader ) | |
160 | delete fReader; | |
161 | fReader = NULL; | |
162 | ||
163 | return 0; | |
164 | } | |
165 | ||
0efebbac | 166 | int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, |
167 | const AliHLTComponentBlockData* blocks, | |
168 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
169 | AliHLTUInt32_t& size, | |
170 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
171 | { | |
187229ab | 172 | // see header file for class documentation |
173 | ||
b7625c4d | 174 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0; |
175 | ||
187229ab | 176 | // == init iter (pointer to datablock) |
177 | const AliHLTComponentBlockData* iter = NULL; | |
187229ab | 178 | |
179 | Int_t slice, patch, row[2]; | |
187229ab | 180 | |
b7625c4d | 181 | unsigned long maxPoints = 0; |
98034d0d | 182 | |
0efebbac | 183 | AliHLTTPCClusterData* outPtr; |
184 | ||
185 | outPtr = (AliHLTTPCClusterData*)outputPtr; | |
186 | ||
b7625c4d | 187 | for (iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){ |
187229ab | 188 | |
b7625c4d | 189 | HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", |
190 | evtData.fEventID, evtData.fEventID, | |
191 | DataType2Text(iter->fDataType).c_str(), | |
192 | DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); | |
187229ab | 193 | |
b7625c4d | 194 | if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){ |
195 | HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", | |
196 | DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(), | |
197 | DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); | |
198 | } | |
199 | ||
200 | if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) && | |
201 | iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue; | |
187229ab | 202 | |
b7625c4d | 203 | fSpecification = iter->fSpecification; |
187229ab | 204 | |
b7625c4d | 205 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
206 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
207 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); | |
208 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
187229ab | 209 | |
210 | ||
b7625c4d | 211 | fKryptonClusterFinder->SetPatch(patch); |
187229ab | 212 | |
b7625c4d | 213 | fKryptonClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints ); |
214 | ||
0efebbac | 215 | fKryptonClusterFinder->SetOutputArray((AliHLTTPCSpacePointData*)outPtr->fSpacePoints); |
216 | ||
217 | fKryptonClusterFinder->SetMaxOutputSize(size-sizeof(AliHLTUInt32_t)); | |
218 | ||
b7625c4d | 219 | fKryptonClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize); |
187229ab | 220 | |
b7625c4d | 221 | fKryptonClusterFinder->FindRowClusters(); |
98034d0d | 222 | |
b7625c4d | 223 | fKryptonClusterFinder->FindKryptonClusters(); |
0efebbac | 224 | |
225 | // if(fKryptonClusterFinder->GetNKryptonClusters()>0){ | |
226 | ||
227 | // HLTFatal("Number of kryptonClusters: %d",(Int_t)fKryptonClusterFinder->GetNKryptonClusters()); | |
228 | ||
229 | if (sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData)>=size) { | |
230 | HLTFatal("Buffer too small too add more spacepoints: %d of %d byte(s) already used",sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData) ,size); | |
231 | return -ENOSPC; | |
232 | } | |
233 | ||
234 | outPtr->fSpacePointCnt=fKryptonClusterFinder->GetNKryptonClusters(); | |
235 | ||
236 | AliHLTComponentBlockData bd; | |
237 | FillBlockData( bd ); | |
238 | bd.fOffset = 0; | |
239 | bd.fSize = sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData); | |
240 | bd.fSpecification = iter->fSpecification; | |
241 | bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType; | |
242 | outputBlocks.push_back( bd ); | |
243 | ||
244 | //adding the list of hardware addresses to the outpot buffer | |
245 | ||
246 | AliHLTUInt32_t dataOffsetBeforeHW=sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData); | |
247 | AliHLTUInt32_t sizeOfHWArray=fKryptonClusterFinder->fHWAddressVector.size()*sizeof(AliHLTUInt16_t); | |
248 | // cout<<"size of array: "<<sizeOfHWArray<<" number of entries"<<fKryptonClusterFinder->fHWAddressVector.size()<<endl; | |
249 | ||
250 | if (dataOffsetBeforeHW+sizeOfHWArray>=size){ | |
251 | HLTFatal("Buffer too small too add the HW address list: %d of %d byte(s) already used",dataOffsetBeforeHW+sizeOfHWArray ,size); | |
252 | return -ENOSPC; | |
253 | } | |
98034d0d | 254 | |
0efebbac | 255 | AliHLTUInt16_t *outputHWPtr=(AliHLTUInt16_t*)(outputPtr+dataOffsetBeforeHW); |
256 | for(UInt_t hw=0;hw<fKryptonClusterFinder->fHWAddressVector.size();hw++){ | |
257 | *outputHWPtr = fKryptonClusterFinder->fHWAddressVector[hw]; | |
258 | outputHWPtr++; | |
259 | } | |
260 | ||
261 | AliHLTComponentBlockData bdHW; | |
262 | FillBlockData( bdHW ); | |
263 | bdHW.fOffset = dataOffsetBeforeHW; | |
264 | bdHW.fSize = sizeOfHWArray; | |
265 | bdHW.fSpecification = iter->fSpecification; | |
266 | bdHW.fDataType = kAliHLTDataTypeHwAddr16; | |
267 | outputBlocks.push_back( bdHW ); | |
268 | ||
269 | size=dataOffsetBeforeHW+sizeOfHWArray; | |
270 | ||
271 | /* } | |
272 | else{ | |
273 | size=0; | |
274 | }*/ | |
b7625c4d | 275 | } |
b7625c4d | 276 | return 0; |
277 | } | |
187229ab | 278 | |
b7625c4d | 279 | int AliHLTTPCKryptonClusterFinderComponent::Configure(const char* arguments) { |
280 | // see header file for class documentation | |
187229ab | 281 | |
b7625c4d | 282 | int iResult=0; |
283 | if (!arguments) return iResult; | |
284 | HLTInfo("parsing configuration string \'%s\'", arguments); | |
285 | /* | |
286 | TString allArgs=arguments; | |
287 | TString argument; | |
288 | int bMissingParam=0; | |
289 | ||
290 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
291 | if (pTokens) { | |
292 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
293 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
294 | if (argument.IsNull()) continue; | |
295 | ||
296 | if (argument.CompareTo("-apply-noisemap")==0) { | |
297 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
298 | HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
299 | ||
300 | } | |
301 | else if (argument.CompareTo("-plot-side-c")==0) { | |
302 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
303 | HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
304 | ||
305 | } | |
306 | else if (argument.CompareTo("-plot-side-a")==0) { | |
307 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
308 | HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
309 | ||
310 | } | |
311 | else { | |
312 | HLTError("unknown argument %s", argument.Data()); | |
313 | iResult=-EINVAL; | |
314 | break; | |
315 | } | |
316 | } // end for | |
187229ab | 317 | |
b7625c4d | 318 | delete pTokens; |
187229ab | 319 | |
b7625c4d | 320 | } // end if pTokens |
187229ab | 321 | |
b7625c4d | 322 | if (bMissingParam) { |
323 | HLTError("missing parameter for argument %s", argument.Data()); | |
324 | iResult=-EINVAL; | |
325 | } | |
326 | */ | |
327 | return iResult; | |
187229ab | 328 | } |
329 | ||
330 | int AliHLTTPCKryptonClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
331 | { | |
332 | // see header file for class documentation | |
333 | const char* path="HLT/ConfigTPC"; | |
334 | if (cdbEntry) path=cdbEntry; | |
335 | if (path) { | |
336 | HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
337 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
338 | if (pEntry) { | |
339 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
340 | if (pString) { | |
341 | HLTInfo("received configuration object: %s", pString->GetString().Data()); | |
342 | } else { | |
343 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
344 | } | |
345 | } else { | |
346 | HLTError("can not fetch object \"%s\" from CDB", path); | |
347 | } | |
348 | } | |
349 | return 0; | |
350 | } |