]>
Commit | Line | Data |
---|---|---|
6b7742a2 | 1 | // $Id$ |
2 | //************************************************************************** | |
3 | //* This file is property of and copyright by the ALICE HLT Project * | |
4 | //* ALICE Experiment at CERN, All rights reserved. * | |
5 | //* * | |
6 | //* Primary Authors: Gaute Øvrebekk <st05886@alf.uib.no> * | |
7 | //* for The ALICE HLT Project. * | |
8 | //* * | |
9 | //* Permission to use, copy, modify and distribute this software and its * | |
10 | //* documentation strictly for non-commercial purposes is hereby granted * | |
11 | //* without fee, provided that the above copyright notice appears in all * | |
12 | //* copies and that both the copyright notice and this permission notice * | |
13 | //* appear in the supporting documentation. The authors make no claims * | |
14 | //* about the suitability of this software for any purpose. It is * | |
15 | //* provided "as is" without express or implied warranty. * | |
16 | //************************************************************************** | |
17 | ||
18 | /** @file AliHLTITSClusterFinderComponent.cxx | |
19 | @author Gaute Øvrebekk <st05886@alf.uib.no> | |
20 | @date | |
21 | @brief Component to run offline clusterfinders | |
22 | */ | |
23 | ||
24 | #if __GNUC__>= 3 | |
25 | using namespace std; | |
26 | #endif | |
27 | ||
28 | #include "AliHLTITSClusterFinderComponent.h" | |
29 | ||
30 | #include "AliCDBEntry.h" | |
31 | #include "AliCDBManager.h" | |
32 | #include "AliHLTDataTypes.h" | |
33 | #include "AliITSgeomTGeo.h" | |
34 | #include "AliITSRecPoint.h" | |
35 | #include "AliHLTITSSpacePointData.h" | |
36 | #include "AliHLTITSClusterDataFormat.h" | |
37 | #include <AliHLTDAQ.h> | |
38 | #include "AliGeomManager.h" | |
060f29ad | 39 | #include "AliITSRecoParam.h" |
40 | #include "AliITSReconstructor.h" | |
3f61e9ce | 41 | #include "AliHLTITSClusterFinderSPD.h" |
6b7742a2 | 42 | |
43 | #include <cstdlib> | |
44 | #include <cerrno> | |
45 | #include "TString.h" | |
46 | #include "TObjString.h" | |
47 | #include <sys/time.h> | |
48 | ||
49 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
50 | ClassImp(AliHLTITSClusterFinderComponent); | |
51 | ||
52 | AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode) | |
53 | : | |
54 | fModeSwitch(mode), | |
55 | fNModules(0), | |
56 | fId(0), | |
57 | fNddl(0), | |
d293cef8 | 58 | fClusters(NULL), |
6b7742a2 | 59 | fRawReader(NULL), |
60 | fDettype(NULL), | |
61 | fgeom(NULL), | |
3f61e9ce | 62 | fgeomInit(NULL), |
63 | fSPD(NULL) | |
6b7742a2 | 64 | { |
65 | // see header file for class documentation | |
66 | // or | |
67 | // refer to README to build package | |
68 | // or | |
69 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
70 | if (fModeSwitch!=kClusterFinderSPD && | |
71 | fModeSwitch!=kClusterFinderSDD && | |
72 | fModeSwitch!=kClusterFinderSSD) { | |
73 | HLTFatal("unknown cluster finder"); | |
74 | } | |
75 | } | |
76 | ||
3f61e9ce | 77 | AliHLTITSClusterFinderComponent::~AliHLTITSClusterFinderComponent() |
78 | { | |
6b7742a2 | 79 | // see header file for class documentation |
3f61e9ce | 80 | delete fRawReader; |
81 | delete fDettype; | |
82 | delete fgeomInit; | |
83 | delete fSPD; | |
6b7742a2 | 84 | } |
85 | ||
86 | // Public functions to implement AliHLTComponent's interface. | |
87 | // These functions are required for the registration process | |
88 | ||
89 | const char* AliHLTITSClusterFinderComponent::GetComponentID() | |
90 | { | |
91 | // see header file for class documentation | |
92 | switch(fModeSwitch){ | |
93 | case kClusterFinderSPD: | |
94 | return "ITSClusterFinderSPD"; | |
95 | break; | |
96 | case kClusterFinderSDD: | |
97 | return "ITSClusterFinderSDD"; | |
98 | break; | |
99 | case kClusterFinderSSD: | |
100 | return "ITSClusterFinderSSD"; | |
101 | break; | |
102 | } | |
103 | return ""; | |
104 | } | |
105 | ||
106 | void AliHLTITSClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
107 | // see header file for class documentation | |
108 | list.clear(); | |
109 | switch(fModeSwitch){ | |
110 | case kClusterFinderSPD: | |
111 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD ); | |
112 | break; | |
113 | case kClusterFinderSDD: | |
114 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD ); | |
115 | break; | |
116 | case kClusterFinderSSD: | |
117 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD ); | |
118 | break; | |
119 | } | |
120 | } | |
121 | ||
122 | AliHLTComponentDataType AliHLTITSClusterFinderComponent::GetOutputDataType() { | |
123 | // see header file for class documentation | |
41625b12 | 124 | switch(fModeSwitch){ |
125 | case kClusterFinderSPD: | |
126 | return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD; | |
127 | break; | |
128 | case kClusterFinderSDD: | |
129 | return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD; | |
130 | break; | |
131 | case kClusterFinderSSD: | |
132 | return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD; | |
133 | break; | |
134 | } | |
135 | return kAliHLTVoidDataType; | |
6b7742a2 | 136 | } |
137 | ||
138 | void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
139 | // see header file for class documentation | |
140 | constBase = 0; | |
141 | inputMultiplier = 100; | |
142 | } | |
143 | ||
144 | AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() { | |
145 | // see header file for class documentation | |
146 | return new AliHLTITSClusterFinderComponent(fModeSwitch); | |
147 | } | |
148 | ||
149 | Int_t AliHLTITSClusterFinderComponent::DoInit( int /*argc*/, const char** /*argv*/ ) { | |
150 | // see header file for class documentation | |
3f61e9ce | 151 | |
152 | fStatTime = 0; | |
153 | fStatTimeAll = 0; | |
154 | fStatTimeC = 0; | |
155 | fStatTimeAllC = 0; | |
156 | fStatNEv = 0; | |
157 | ||
6b7742a2 | 158 | if(fModeSwitch==kClusterFinderSPD) { |
159 | HLTDebug("using ClusterFinder for SPD"); | |
d293cef8 | 160 | //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2); |
6b7742a2 | 161 | fId=AliHLTDAQ::DdlIDOffset("ITSSPD"); |
162 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSPD"); | |
163 | } | |
164 | else if(fModeSwitch==kClusterFinderSDD) { | |
165 | HLTDebug("using ClusterFinder for SDD"); | |
d293cef8 | 166 | //fNModules=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3) + AliITSgeomTGeo::GetNDetectors(4)*AliITSgeomTGeo::GetNLadders(4); |
6b7742a2 | 167 | fId=AliHLTDAQ::DdlIDOffset("ITSSDD"); |
168 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSDD"); | |
169 | } | |
170 | else if(fModeSwitch==kClusterFinderSSD) { | |
171 | HLTDebug("using ClusterFinder for SSD"); | |
d293cef8 | 172 | //fNModules=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5) + AliITSgeomTGeo::GetNDetectors(6)*AliITSgeomTGeo::GetNLadders(6); |
6b7742a2 | 173 | fId=AliHLTDAQ::DdlIDOffset("ITSSSD"); |
174 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD"); | |
175 | } | |
176 | else{ | |
177 | HLTFatal("No mode set for clusterfindercomponent"); | |
178 | } | |
179 | ||
060f29ad | 180 | //Removed the warning for loading default RecoParam in HLT |
181 | AliITSRecoParam *par = AliITSRecoParam::GetLowFluxParam(); | |
182 | AliITSReconstructor *rec = new AliITSReconstructor(); | |
183 | rec->SetRecoParam(par); | |
184 | ||
6b7742a2 | 185 | AliCDBManager* man = AliCDBManager::Instance(); |
186 | if (!man->IsDefaultStorageSet()){ | |
187 | HLTError("Default CDB storage has not been set !"); | |
188 | return -ENOENT; | |
189 | } | |
190 | ||
191 | if(AliGeomManager::GetGeometry()==NULL){ | |
192 | AliGeomManager::LoadGeometry(); | |
193 | } | |
3f61e9ce | 194 | |
195 | //fgeomInit = new AliITSInitGeometry(kvSPD02,2); | |
6b7742a2 | 196 | fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2); |
197 | //fgeomInit->InitAliITSgeom(fgeom); | |
198 | fgeom = fgeomInit->CreateAliITSgeom(); | |
3f61e9ce | 199 | |
d293cef8 | 200 | fNModules = fgeom->GetIndexMax(); |
201 | ||
202 | fClusters = new TClonesArray*[fNModules]; | |
203 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { | |
204 | fClusters[iModule] = NULL; | |
205 | } | |
206 | ||
6b7742a2 | 207 | //set dettype |
208 | fDettype = new AliITSDetTypeRec(); | |
3f61e9ce | 209 | fDettype->SetITSgeom(fgeom); |
6b7742a2 | 210 | fDettype->SetDefaults(); |
86e746ed | 211 | fDettype->SetDefaultClusterFindersV2(kTRUE); |
212 | ||
6b7742a2 | 213 | if ( fRawReader ) |
214 | return -EINPROGRESS; | |
215 | ||
216 | fRawReader = new AliRawReaderMemory(); | |
3f61e9ce | 217 | fSPD = new AliHLTITSClusterFinderSPD( fDettype ); |
6b7742a2 | 218 | |
219 | return 0; | |
220 | } | |
221 | ||
222 | Int_t AliHLTITSClusterFinderComponent::DoDeinit() { | |
223 | // see header file for class documentation | |
224 | ||
225 | if ( fRawReader ) | |
226 | delete fRawReader; | |
227 | fRawReader = NULL; | |
228 | ||
6b7742a2 | 229 | if ( fDettype ) |
230 | delete fDettype; | |
231 | fDettype = NULL; | |
232 | ||
233 | if ( fgeomInit ) | |
234 | delete fgeomInit; | |
235 | fgeomInit = NULL; | |
3f61e9ce | 236 | |
237 | delete fSPD; | |
238 | fSPD = 0; | |
6b7742a2 | 239 | |
d293cef8 | 240 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { |
241 | if(fClusters[iModule] != NULL){ | |
242 | fClusters[iModule]->Delete(); | |
243 | delete fClusters[iModule]; | |
244 | } | |
245 | fClusters[iModule] = NULL; | |
246 | } | |
247 | ||
6b7742a2 | 248 | return 0; |
249 | } | |
250 | ||
3f61e9ce | 251 | #include "TStopwatch.h" |
252 | ||
6b7742a2 | 253 | Int_t AliHLTITSClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/) |
254 | { // see header file for class documentation | |
255 | ||
256 | // -- Iterator over Data Blocks -- | |
257 | const AliHLTComponentBlockData* iter = NULL; | |
3f61e9ce | 258 | |
259 | //if (!IsDataEvent()) return 0; | |
6b7742a2 | 260 | |
261 | if ( evtData.fBlockCnt<=0 ) | |
262 | { | |
41625b12 | 263 | HLTDebug("no blocks in event" ); |
6b7742a2 | 264 | return 0; |
265 | } | |
3f61e9ce | 266 | |
267 | ||
6b7742a2 | 268 | AliHLTComponentDataType datatype; |
269 | if(fModeSwitch==kClusterFinderSPD) { datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD;} | |
270 | else if(fModeSwitch==kClusterFinderSDD) {datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD;} | |
271 | else if(fModeSwitch==kClusterFinderSSD) {datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD;} | |
272 | ||
3f61e9ce | 273 | TStopwatch timer; |
274 | ||
6b7742a2 | 275 | // -- Loop over blocks |
276 | for ( iter = GetFirstInputBlock(datatype); iter != NULL; iter = GetNextInputBlock() ) { | |
277 | ||
278 | // -- Debug output of datatype -- | |
279 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
280 | evtData.fEventID, evtData.fEventID, | |
281 | DataType2Text(iter->fDataType).c_str(), | |
282 | DataType2Text(datatype).c_str()); | |
283 | ||
284 | // -- Check for the correct data type | |
285 | if ( iter->fDataType != (datatype) ) | |
286 | continue; | |
287 | ||
288 | // -- Get equipment ID out of specification | |
289 | AliHLTUInt32_t spec = iter->fSpecification; | |
290 | ||
291 | Int_t id = fId; | |
292 | for ( Int_t ii = 0; ii < fNddl ; ii++ ) { //number of ddl's | |
293 | if ( spec & 0x00000001 ) { | |
294 | id += ii; | |
295 | break; | |
296 | } | |
297 | spec = spec >> 1 ; | |
298 | } | |
299 | ||
300 | // -- Set equipment ID to the raw reader | |
301 | ||
302 | if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){ | |
303 | HLTWarning("Could not add buffer"); | |
304 | } | |
3f61e9ce | 305 | TStopwatch timer1; |
306 | ||
307 | std::vector<AliITSRecPoint> vclusters; | |
6b7742a2 | 308 | |
3f61e9ce | 309 | if(fModeSwitch==kClusterFinderSPD) {fSPD->RawdataToClusters( fRawReader, vclusters );} |
310 | else{ | |
311 | if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SDD");} | |
312 | if(fModeSwitch==kClusterFinderSSD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SSD");} | |
313 | for(int i=0;i<fNModules;i++){ | |
314 | if(fClusters[i] != NULL){ | |
315 | for(int j=0;j<fClusters[i]->GetEntriesFast();j++){ | |
316 | AliITSRecPoint *recpoint = (AliITSRecPoint*) (fClusters[i]->At(j)); | |
317 | vclusters.push_back(*recpoint); | |
318 | } | |
319 | fClusters[i]->Delete(); | |
320 | delete fClusters[i]; | |
321 | } | |
322 | fClusters[i] = NULL; | |
323 | } | |
6b7742a2 | 324 | } |
325 | ||
3f61e9ce | 326 | timer1.Stop(); |
327 | fStatTime+=timer1.RealTime(); | |
328 | fStatTimeC+=timer1.CpuTime(); | |
329 | ||
330 | UInt_t nClusters=vclusters.size(); | |
331 | ||
6b7742a2 | 332 | UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData); |
333 | AliHLTUInt8_t *buffer = new AliHLTUInt8_t[bufferSize]; | |
334 | AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(buffer); | |
335 | outputClusters->fSpacePointCnt=nClusters; | |
d293cef8 | 336 | |
6b7742a2 | 337 | int clustIdx=0; |
3f61e9ce | 338 | for(int i=0;i<vclusters.size();i++){ |
339 | AliITSRecPoint *recpoint = (AliITSRecPoint*) &(vclusters[i]); | |
340 | outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY(); | |
341 | outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ(); | |
342 | outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2(); | |
343 | outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2(); | |
344 | outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ(); | |
345 | outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ(); | |
346 | outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy(); | |
347 | outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz(); | |
348 | outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer(); | |
349 | outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex(); | |
350 | outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0); | |
351 | outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1); | |
352 | outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2); | |
353 | ||
354 | clustIdx++; | |
6b7742a2 | 355 | } |
3f61e9ce | 356 | |
6b7742a2 | 357 | if(fModeSwitch==kClusterFinderSPD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD,iter->fSpecification);} |
358 | else if(fModeSwitch==kClusterFinderSDD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD,iter->fSpecification);} | |
359 | else if(fModeSwitch==kClusterFinderSSD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD,iter->fSpecification);} | |
3f61e9ce | 360 | |
361 | delete[] buffer; | |
6b7742a2 | 362 | fRawReader->ClearBuffers(); |
363 | ||
364 | } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { | |
3f61e9ce | 365 | |
366 | timer.Stop(); | |
367 | ||
368 | fStatTimeAll+=timer.RealTime(); | |
369 | fStatTimeAllC+=timer.CpuTime(); | |
370 | fStatNEv++; | |
371 | //if( fStatNEv%10000==0 && fStatTimeAll>0.0 && fStatTime>0.0 && fStatTimeAllC>0.0 && fStatTimeC>0.0) | |
372 | //cout<<fStatTimeAll/fStatNEv*1.e3<<" "<<fStatTime/fStatNEv*1.e3<<" " | |
373 | //<<fStatTimeAllC/fStatNEv*1.e3<<" "<<fStatTimeC/fStatNEv*1.e3<<" ms"<<endl; | |
374 | ||
6b7742a2 | 375 | return 0; |
376 | } | |
377 | ||
378 | int AliHLTITSClusterFinderComponent::Configure(const char* arguments) | |
379 | { | |
380 | ||
381 | int iResult=0; | |
382 | ||
383 | if (!arguments) return iResult; | |
384 | ||
385 | TString allArgs=arguments; | |
386 | TString argument; | |
387 | ||
388 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
389 | ||
390 | if (pTokens) { | |
391 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
392 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
393 | if (argument.IsNull()) continue; | |
394 | /* | |
395 | if (argument.CompareTo("")==0) { | |
396 | HLTInfo(""); | |
397 | continue; | |
398 | } | |
399 | ||
400 | else if (argument.CompareTo("")==0) { | |
401 | HLTInfo(""); | |
402 | continue; | |
403 | } | |
404 | */ | |
405 | else { | |
406 | HLTError("unknown argument %s", argument.Data()); | |
407 | iResult=-EINVAL; | |
408 | break; | |
409 | } | |
410 | } | |
411 | delete pTokens; | |
412 | } | |
413 | ||
414 | return iResult; | |
415 | } | |
416 | ||
417 | int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
418 | { | |
419 | // see header file for class documentation | |
420 | int iResult=0; | |
421 | ||
422 | const char* path="HLT/ConfigITS/ClusterFinderComponent"; | |
423 | const char* defaultNotify=""; | |
424 | if (cdbEntry) { | |
425 | path=cdbEntry; | |
426 | defaultNotify=" (default)"; | |
427 | } | |
428 | if (path) { | |
429 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
430 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); | |
431 | if (pEntry) { | |
432 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
433 | if (pString) { | |
434 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
435 | iResult=Configure(pString->GetString().Data()); | |
436 | } else { | |
437 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
438 | } | |
439 | } else { | |
440 | HLTError("can not fetch object \"%s\" from CDB", path); | |
441 | } | |
442 | } | |
443 | ||
444 | return iResult; | |
445 | } | |
446 |