]>
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 | //* * | |
29d7dbc9 | 6 | //* Primary Authors: Gaute Ovrebekk <st05886@alf.uib.no> * |
6b7742a2 | 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 | ||
29d7dbc9 | 18 | /// @file AliHLTITSClusterFinderComponent.cxx |
19 | /// @author Gaute Ovrebekk <st05886@alf.uib.no> | |
20 | /// @date | |
21 | /// @brief Component to run offline clusterfinders | |
22 | /// | |
6b7742a2 | 23 | |
6b7742a2 | 24 | #include "AliHLTITSClusterFinderComponent.h" |
25 | ||
26 | #include "AliCDBEntry.h" | |
27 | #include "AliCDBManager.h" | |
6b7742a2 | 28 | #include "AliITSgeomTGeo.h" |
29 | #include "AliITSRecPoint.h" | |
30 | #include "AliHLTITSSpacePointData.h" | |
31 | #include "AliHLTITSClusterDataFormat.h" | |
32 | #include <AliHLTDAQ.h> | |
33 | #include "AliGeomManager.h" | |
060f29ad | 34 | #include "AliITSRecoParam.h" |
35 | #include "AliITSReconstructor.h" | |
3f61e9ce | 36 | #include "AliHLTITSClusterFinderSPD.h" |
a2a2a7ce | 37 | #include "AliHLTITSClusterFinderSSD.h" |
6eb9783a | 38 | #include "TMap.h" |
01ef1bd4 | 39 | #include "AliITSRecPointContainer.h" |
29d7dbc9 | 40 | #include "AliRunLoader.h" |
41 | #include "AliLoader.h" | |
6b7742a2 | 42 | |
43 | #include <cstdlib> | |
44 | #include <cerrno> | |
9f2cda35 | 45 | #include "TFile.h" |
6b7742a2 | 46 | #include "TString.h" |
47 | #include "TObjString.h" | |
48 | #include <sys/time.h> | |
49 | ||
8e0f6ca3 | 50 | using namespace std; |
51 | ||
6b7742a2 | 52 | /** ROOT macro for the implementation of ROOT specific class methods */ |
53 | ClassImp(AliHLTITSClusterFinderComponent); | |
54 | ||
55 | AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode) | |
56 | : | |
57 | fModeSwitch(mode), | |
a2a2a7ce | 58 | fInputDataType(kAliHLTVoidDataType), |
59 | fOutputDataType(kAliHLTVoidDataType), | |
60 | fUseOfflineFinder(0), | |
6b7742a2 | 61 | fNModules(0), |
62 | fId(0), | |
63 | fNddl(0), | |
6b7742a2 | 64 | fRawReader(NULL), |
65 | fDettype(NULL), | |
66 | fgeom(NULL), | |
3f61e9ce | 67 | fgeomInit(NULL), |
a2a2a7ce | 68 | fSPD(NULL), |
618f422f | 69 | fSSD(NULL), |
70 | tD(NULL), | |
71 | tR(NULL), | |
01ef1bd4 | 72 | fSPDNModules(0), |
73 | fSDDNModules(0), | |
74 | fSSDNModules(0), | |
8e5edf3c | 75 | fFirstModule(0), |
76 | fLastModule(0), | |
77 | fnClusters(0), | |
57a4102f | 78 | fclusters(), |
29d7dbc9 | 79 | fBenchmark(GetComponentID()), |
80 | fOutputSizeOffset(0), | |
81 | fInputMultiplierDigits(20), | |
82 | fpLoader(NULL) | |
6b7742a2 | 83 | { |
84 | // see header file for class documentation | |
85 | // or | |
86 | // refer to README to build package | |
87 | // or | |
88 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
a2a2a7ce | 89 | |
90 | switch(fModeSwitch){ | |
91 | case kClusterFinderSPD: | |
92 | fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD; | |
93 | fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD; | |
94 | break; | |
95 | case kClusterFinderSDD: | |
96 | fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD; | |
97 | fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD; | |
98 | break; | |
99 | case kClusterFinderSSD: | |
100 | fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD; | |
101 | fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD; | |
102 | break; | |
618f422f | 103 | case kClusterFinderDigits: |
59b3dd4b | 104 | fInputDataType = kAliHLTDataTypeAliTreeD|kAliHLTDataOriginITS; |
618f422f | 105 | fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITS; |
106 | break; | |
a2a2a7ce | 107 | default: |
6b7742a2 | 108 | HLTFatal("unknown cluster finder"); |
109 | } | |
110 | } | |
111 | ||
3f61e9ce | 112 | AliHLTITSClusterFinderComponent::~AliHLTITSClusterFinderComponent() |
113 | { | |
6b7742a2 | 114 | // see header file for class documentation |
3f61e9ce | 115 | delete fRawReader; |
116 | delete fDettype; | |
117 | delete fgeomInit; | |
118 | delete fSPD; | |
a2a2a7ce | 119 | delete fSSD; |
6b7742a2 | 120 | } |
121 | ||
122 | // Public functions to implement AliHLTComponent's interface. | |
123 | // These functions are required for the registration process | |
124 | ||
125 | const char* AliHLTITSClusterFinderComponent::GetComponentID() | |
126 | { | |
127 | // see header file for class documentation | |
128 | switch(fModeSwitch){ | |
129 | case kClusterFinderSPD: | |
130 | return "ITSClusterFinderSPD"; | |
131 | break; | |
132 | case kClusterFinderSDD: | |
133 | return "ITSClusterFinderSDD"; | |
134 | break; | |
135 | case kClusterFinderSSD: | |
136 | return "ITSClusterFinderSSD"; | |
137 | break; | |
618f422f | 138 | case kClusterFinderDigits: |
139 | return "ITSClusterFinderDigits"; | |
140 | break; | |
6b7742a2 | 141 | } |
142 | return ""; | |
143 | } | |
144 | ||
a2a2a7ce | 145 | void AliHLTITSClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
146 | { | |
6b7742a2 | 147 | // see header file for class documentation |
148 | list.clear(); | |
a2a2a7ce | 149 | list.push_back( fInputDataType ); |
6b7742a2 | 150 | } |
151 | ||
a2a2a7ce | 152 | AliHLTComponentDataType AliHLTITSClusterFinderComponent::GetOutputDataType() |
153 | { | |
6b7742a2 | 154 | // see header file for class documentation |
a2a2a7ce | 155 | return fOutputDataType; |
6b7742a2 | 156 | } |
157 | ||
158 | void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
159 | // see header file for class documentation | |
29d7dbc9 | 160 | constBase = fOutputSizeOffset; |
dc549b2c | 161 | switch(fModeSwitch){ |
162 | case kClusterFinderDigits: | |
29d7dbc9 | 163 | inputMultiplier = fInputMultiplierDigits; |
dc549b2c | 164 | break; |
165 | case kClusterFinderSPD: | |
166 | case kClusterFinderSDD: | |
167 | case kClusterFinderSSD: | |
168 | default: | |
169 | inputMultiplier = 20; | |
170 | } | |
6b7742a2 | 171 | } |
172 | ||
173 | AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() { | |
174 | // see header file for class documentation | |
175 | return new AliHLTITSClusterFinderComponent(fModeSwitch); | |
176 | } | |
177 | ||
1ea949fd | 178 | Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) { |
6b7742a2 | 179 | // see header file for class documentation |
57a4102f | 180 | fBenchmark.Reset(); |
181 | fBenchmark.SetTimer(0,"total"); | |
182 | fBenchmark.SetTimer(1,"reco"); | |
183 | ||
6b7742a2 | 184 | if(fModeSwitch==kClusterFinderSPD) { |
185 | HLTDebug("using ClusterFinder for SPD"); | |
d293cef8 | 186 | //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2); |
6b7742a2 | 187 | fId=AliHLTDAQ::DdlIDOffset("ITSSPD"); |
188 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSPD"); | |
189 | } | |
190 | else if(fModeSwitch==kClusterFinderSDD) { | |
191 | HLTDebug("using ClusterFinder for SDD"); | |
d293cef8 | 192 | //fNModules=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3) + AliITSgeomTGeo::GetNDetectors(4)*AliITSgeomTGeo::GetNLadders(4); |
6b7742a2 | 193 | fId=AliHLTDAQ::DdlIDOffset("ITSSDD"); |
194 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSDD"); | |
195 | } | |
196 | else if(fModeSwitch==kClusterFinderSSD) { | |
197 | HLTDebug("using ClusterFinder for SSD"); | |
d293cef8 | 198 | //fNModules=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5) + AliITSgeomTGeo::GetNDetectors(6)*AliITSgeomTGeo::GetNLadders(6); |
6b7742a2 | 199 | fId=AliHLTDAQ::DdlIDOffset("ITSSSD"); |
200 | fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD"); | |
201 | } | |
ec0e5f0f | 202 | else if(fModeSwitch==kClusterFinderDigits) { |
8e5edf3c | 203 | tR = new TTree(); |
618f422f | 204 | } |
6b7742a2 | 205 | else{ |
206 | HLTFatal("No mode set for clusterfindercomponent"); | |
207 | } | |
208 | ||
060f29ad | 209 | //Removed the warning for loading default RecoParam in HLT |
210 | AliITSRecoParam *par = AliITSRecoParam::GetLowFluxParam(); | |
211 | AliITSReconstructor *rec = new AliITSReconstructor(); | |
212 | rec->SetRecoParam(par); | |
213 | ||
6b7742a2 | 214 | AliCDBManager* man = AliCDBManager::Instance(); |
215 | if (!man->IsDefaultStorageSet()){ | |
216 | HLTError("Default CDB storage has not been set !"); | |
217 | return -ENOENT; | |
218 | } | |
219 | ||
220 | if(AliGeomManager::GetGeometry()==NULL){ | |
221 | AliGeomManager::LoadGeometry(); | |
222 | } | |
3f61e9ce | 223 | |
3384df26 | 224 | fgeomInit = new AliITSInitGeometry(); |
225 | //fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2); | |
6b7742a2 | 226 | //fgeomInit->InitAliITSgeom(fgeom); |
227 | fgeom = fgeomInit->CreateAliITSgeom(); | |
3f61e9ce | 228 | |
d293cef8 | 229 | fNModules = fgeom->GetIndexMax(); |
01ef1bd4 | 230 | Int_t modperlay[6]; |
231 | for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i); | |
232 | fSPDNModules=modperlay[0]+modperlay[1]; | |
233 | fSDDNModules=modperlay[2]+modperlay[3]; | |
234 | fSSDNModules=modperlay[4]+modperlay[5]; | |
235 | ||
236 | if(fModeSwitch==kClusterFinderSPD) { | |
237 | fFirstModule=0; | |
238 | fLastModule=fSPDNModules; | |
239 | } | |
240 | else if(fModeSwitch==kClusterFinderSDD) { | |
241 | fFirstModule=fSPDNModules; | |
242 | fLastModule=fFirstModule + fSDDNModules; | |
243 | } | |
244 | else if(fModeSwitch==kClusterFinderSSD) { | |
245 | fFirstModule=fSPDNModules + fSDDNModules; | |
246 | fLastModule=fFirstModule + fSSDNModules; | |
247 | } | |
248 | ||
6b7742a2 | 249 | //set dettype |
250 | fDettype = new AliITSDetTypeRec(); | |
3f61e9ce | 251 | fDettype->SetITSgeom(fgeom); |
6b7742a2 | 252 | fDettype->SetDefaults(); |
86e746ed | 253 | fDettype->SetDefaultClusterFindersV2(kTRUE); |
254 | ||
6b7742a2 | 255 | if ( fRawReader ) |
256 | return -EINPROGRESS; | |
257 | ||
258 | fRawReader = new AliRawReaderMemory(); | |
3f61e9ce | 259 | fSPD = new AliHLTITSClusterFinderSPD( fDettype ); |
a2a2a7ce | 260 | fSSD = new AliHLTITSClusterFinderSSD( fDettype, fRawReader ); |
6b7742a2 | 261 | |
1ea949fd | 262 | TString arguments = ""; |
263 | for ( int i = 0; i < argc; i++ ) { | |
264 | if ( !arguments.IsNull() ) arguments += " "; | |
265 | arguments += argv[i]; | |
266 | } | |
267 | ||
618f422f | 268 | tD = NULL; |
8e5edf3c | 269 | //tR = NULL; |
618f422f | 270 | |
1ea949fd | 271 | return Configure( arguments.Data() ); |
6b7742a2 | 272 | } |
273 | ||
274 | Int_t AliHLTITSClusterFinderComponent::DoDeinit() { | |
275 | // see header file for class documentation | |
276 | ||
277 | if ( fRawReader ) | |
278 | delete fRawReader; | |
279 | fRawReader = NULL; | |
280 | ||
6b7742a2 | 281 | if ( fDettype ) |
282 | delete fDettype; | |
283 | fDettype = NULL; | |
284 | ||
285 | if ( fgeomInit ) | |
286 | delete fgeomInit; | |
287 | fgeomInit = NULL; | |
3f61e9ce | 288 | |
289 | delete fSPD; | |
290 | fSPD = 0; | |
6b7742a2 | 291 | |
a2a2a7ce | 292 | delete fSSD; |
293 | fSSD = 0; | |
294 | ||
a2a2a7ce | 295 | fUseOfflineFinder = 0; |
296 | ||
29d7dbc9 | 297 | if (fpLoader) { |
298 | fpLoader->UnloadDigits(); | |
299 | } | |
300 | fpLoader=NULL; | |
301 | ||
6b7742a2 | 302 | return 0; |
303 | } | |
304 | ||
a2a2a7ce | 305 | int AliHLTITSClusterFinderComponent::DoEvent |
306 | ( | |
307 | const AliHLTComponentEventData& evtData, | |
5ae74c42 | 308 | const AliHLTComponentBlockData* /*blocks*/, |
a2a2a7ce | 309 | AliHLTComponentTriggerData& /*trigData*/, |
310 | AliHLTUInt8_t* outputPtr, | |
311 | AliHLTUInt32_t& size, | |
312 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
313 | { | |
314 | // see header file for class documentation | |
315 | ||
316 | AliHLTUInt32_t maxBufferSize = size; | |
317 | size = 0; // output size | |
6b7742a2 | 318 | |
a2a2a7ce | 319 | if (!IsDataEvent()) return 0; |
320 | ||
6b7742a2 | 321 | if ( evtData.fBlockCnt<=0 ) |
a2a2a7ce | 322 | { |
323 | HLTDebug("no blocks in event" ); | |
324 | return 0; | |
325 | } | |
57a4102f | 326 | |
29d7dbc9 | 327 | AliHLTUInt32_t totalInputSize=0; |
57a4102f | 328 | fBenchmark.StartNewEvent(); |
329 | fBenchmark.Start(0); | |
330 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(fInputDataType); i!=NULL; i=GetNextInputBlock() ){ | |
29d7dbc9 | 331 | totalInputSize+=i->fSize; |
57a4102f | 332 | fBenchmark.AddInput(i->fSize); |
333 | } | |
334 | ||
a2a2a7ce | 335 | Int_t ret = 0; |
57a4102f | 336 | |
618f422f | 337 | if(fModeSwitch==kClusterFinderDigits) { |
57a4102f | 338 | |
618f422f | 339 | for ( const TObject *iter = GetFirstInputObject(fInputDataType); iter != NULL; iter = GetNextInputObject() ) { |
340 | tD = dynamic_cast<TTree*>(const_cast<TObject*>( iter ) ); | |
341 | if(!tD){ | |
342 | HLTFatal("No Digit Tree found"); | |
343 | return -1; | |
344 | } | |
9f2cda35 | 345 | // 2010-04-17 very crude workaround: TTree objects are difficult to send |
346 | // The actual case: Running ITS and TPC reconstruction fails at the second event | |
347 | // to read the ITS digits from the TreeD | |
348 | // | |
349 | // Reason: reading fails in TBranch::GetBasket, there a new basket is opened from | |
350 | // a TFile object. The function TBranch::GetFile returns the file object from | |
351 | // an internal fDirectory (TDirectory) object. This file is at the second event | |
352 | // set to the TPC.Digits.root. The internal mismatch creates a seg fault | |
353 | // | |
354 | // Investigation: TBranch::Streamer uses a crude assignment after creating the | |
355 | // TBranch object | |
356 | // fDirectory = gDirectory; | |
357 | // gDirectory is obviously not set correctly. Setting the directory to a TFile | |
358 | // object for the ITS digits helps to fix the internal mess. Tried also to set | |
359 | // the Directory for the TreeD to NULL (This has only effect if ones sets it | |
360 | // to something not NULL first, and then to NULL). But then no content, i.e. | |
361 | // ITS clusters could be retrieved. | |
362 | // | |
363 | // Conclusion: TTree objects are hardly to be sent via TMessage, there are direct | |
364 | // links to the file required anyhow. | |
29d7dbc9 | 365 | // |
366 | // 2011-01-28 hotfix reloaded: accessing the files like that fails if there are | |
367 | // multiple digit files because of a large number of events. New ugly fix is to | |
368 | // use the global runloader instance to get hold on the digits tree. | |
8e5edf3c | 369 | fnClusters = 0; |
29d7dbc9 | 370 | AliRunLoader* pRunLoader=AliRunLoader::Instance(); |
371 | if (!pRunLoader) { | |
372 | HLTError("failed to get global runloader instance"); | |
373 | return -ENOSYS; | |
374 | } | |
375 | // get the specific loader for the module | |
376 | if (!fpLoader) { | |
377 | const char* loaderType="ITSLoader"; | |
378 | fpLoader=pRunLoader->GetLoader(loaderType); | |
379 | if (!fpLoader) { | |
380 | HLTError("can not get loader \"%s\" from runloader", loaderType); | |
381 | return -ENOSYS; | |
382 | } | |
383 | // prepare the loader | |
384 | fpLoader->LoadDigits("read"); | |
385 | } | |
386 | pRunLoader->GetEvent(GetEventCount()); | |
387 | ||
388 | tD=fpLoader->TreeD(); | |
8e5edf3c | 389 | tR->Reset(); |
9f2cda35 | 390 | tR->SetDirectory(0); |
618f422f | 391 | fDettype->SetTreeAddressD(tD); |
392 | fDettype->MakeBranch(tR,"R"); | |
393 | fDettype->SetTreeAddressR(tR); | |
394 | Option_t *opt="All"; | |
57a4102f | 395 | fBenchmark.Start(1); |
3384df26 | 396 | fDettype->DigitsToRecPoints(tD,tR,0,opt,0); |
57a4102f | 397 | fBenchmark.Stop(1); |
9f2cda35 | 398 | TClonesArray * fRecPoints = NULL; |
618f422f | 399 | tR->SetBranchAddress("ITSRecPoints",&fRecPoints); |
400 | for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){ | |
401 | tR->GetEntry(treeEntry); | |
8e5edf3c | 402 | fnClusters += fRecPoints->GetEntries(); |
618f422f | 403 | } |
9f2cda35 | 404 | |
8e5edf3c | 405 | UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData); |
618f422f | 406 | if( size + bufferSize > maxBufferSize ){ |
29d7dbc9 | 407 | //HLTWarning( "Output buffer size exceed (buffer size %d, required size %d)", maxBufferSize, size+bufferSize); |
408 | if (totalInputSize>0) { | |
409 | fInputMultiplierDigits=(float)(size+bufferSize)/totalInputSize; | |
410 | fInputMultiplierDigits+=1.; | |
411 | } else { | |
412 | fOutputSizeOffset=totalInputSize; | |
413 | fInputMultiplierDigits=1.; | |
414 | } | |
618f422f | 415 | ret = -ENOSPC; |
416 | break; | |
417 | } | |
8e5edf3c | 418 | if( fnClusters>0 ){ |
57a4102f | 419 | fBenchmark.Start(1); |
618f422f | 420 | RecPointToSpacePoint(outputPtr,size); |
57a4102f | 421 | fBenchmark.Stop(1); |
618f422f | 422 | AliHLTComponentBlockData bd; |
423 | FillBlockData( bd ); | |
424 | bd.fOffset = size; | |
425 | bd.fSize = bufferSize; | |
426 | bd.fSpecification = 0x00000000; | |
427 | bd.fDataType = GetOutputDataType(); | |
428 | outputBlocks.push_back( bd ); | |
429 | size += bufferSize; | |
57a4102f | 430 | fBenchmark.AddOutput(bd.fSize); |
618f422f | 431 | } |
432 | } | |
433 | } | |
434 | else{ | |
01ef1bd4 | 435 | |
436 | AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance(); | |
437 | ||
618f422f | 438 | // -- Loop over blocks |
439 | for( const AliHLTComponentBlockData* iter = GetFirstInputBlock(fInputDataType); iter != NULL; iter = GetNextInputBlock() ) { | |
8e5edf3c | 440 | |
441 | if(fUseOfflineFinder){ | |
442 | if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();} | |
443 | if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();} | |
444 | } | |
445 | if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();} | |
618f422f | 446 | |
447 | // -- Debug output of datatype -- | |
448 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
6b7742a2 | 449 | evtData.fEventID, evtData.fEventID, |
450 | DataType2Text(iter->fDataType).c_str(), | |
df7307a2 | 451 | DataType2Text(fInputDataType).c_str()); |
618f422f | 452 | |
453 | // -- Check for the correct data type | |
454 | if ( iter->fDataType != (fInputDataType) ) | |
455 | continue; | |
456 | ||
457 | // -- Get equipment ID out of specification | |
458 | AliHLTUInt32_t spec = iter->fSpecification; | |
459 | ||
460 | Int_t id = fId; | |
461 | for ( Int_t ii = 0; ii < fNddl ; ii++ ) { //number of ddl's | |
462 | if ( spec & 0x00000001 ) { | |
463 | id += ii; | |
464 | break; | |
465 | } | |
466 | spec = spec >> 1 ; | |
6b7742a2 | 467 | } |
618f422f | 468 | |
469 | // -- Set equipment ID to the raw reader | |
470 | ||
544538fb | 471 | if(!fRawReader){ |
472 | HLTWarning("The fRawReader pointer is NULL"); | |
473 | continue; | |
474 | } | |
475 | ||
618f422f | 476 | if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){ |
477 | HLTWarning("Could not add buffer"); | |
478 | } | |
57a4102f | 479 | |
480 | fBenchmark.Start(1); | |
481 | ||
8e5edf3c | 482 | fnClusters = 0; |
483 | ||
618f422f | 484 | if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); } |
485 | else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); } | |
486 | else{ | |
01ef1bd4 | 487 | if(fModeSwitch==kClusterFinderSPD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SPD");} |
488 | if(fModeSwitch==kClusterFinderSSD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SSD");} | |
489 | if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,"SDD");} | |
01ef1bd4 | 490 | TClonesArray* clusters = NULL; |
491 | for(int i=fFirstModule;i<fLastModule;i++){ | |
492 | clusters = rpc->UncheckedGetClusters(i); | |
493 | if(clusters != NULL){ | |
8e5edf3c | 494 | fnClusters += clusters->GetEntriesFast(); |
3f61e9ce | 495 | } |
618f422f | 496 | } |
a2a2a7ce | 497 | } |
8e5edf3c | 498 | |
499 | /* Do not work | |
500 | if(fModeSwitch==kClusterfinderSPD){ | |
501 | fnClusters = rpc->GetNClustersInLayerFast(1) + rpc->GetNClustersInLayerFast(2); | |
502 | } | |
503 | if(fModeSwitch==kClusterfinderSDD){ | |
504 | fnClusters = rpc->GetNClustersInLayerFast(3) + rpc->GetNClustersInLayerFast(4); | |
505 | } | |
506 | if(fModeSwitch==kClusterfinderSSD){ | |
507 | fnClusters = rpc->GetNClustersInLayerFast(5) + rpc->GetNClustersInLayerFast(6); | |
508 | } | |
509 | */ | |
510 | ||
57a4102f | 511 | fBenchmark.Stop(1); |
618f422f | 512 | |
513 | fRawReader->ClearBuffers(); | |
618f422f | 514 | |
8e5edf3c | 515 | UInt_t nClusters=fclusters.size(); |
516 | if(nClusters>0){fnClusters = nClusters;} | |
517 | ||
518 | UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData); | |
618f422f | 519 | if( size + bufferSize > maxBufferSize ){ |
520 | HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, size+bufferSize); | |
521 | ret = -ENOSPC; | |
522 | break; | |
523 | } | |
8e5edf3c | 524 | if( fnClusters>0 ){ |
618f422f | 525 | |
526 | RecPointToSpacePoint(outputPtr,size); | |
527 | ||
528 | AliHLTComponentBlockData bd; | |
529 | FillBlockData( bd ); | |
530 | bd.fOffset = size; | |
531 | bd.fSize = bufferSize; | |
532 | bd.fSpecification = iter->fSpecification; | |
533 | bd.fDataType = GetOutputDataType(); | |
534 | outputBlocks.push_back( bd ); | |
535 | size += bufferSize; | |
57a4102f | 536 | fBenchmark.AddOutput(bd.fSize); |
8e5edf3c | 537 | if(nClusters>0){fclusters.clear();} |
618f422f | 538 | } |
539 | ||
540 | } // input blocks | |
541 | } | |
3f61e9ce | 542 | |
57a4102f | 543 | fBenchmark.Stop(0); |
544 | HLTInfo(fBenchmark.GetStatistics()); | |
a2a2a7ce | 545 | return ret; |
6b7742a2 | 546 | } |
547 | ||
548 | int AliHLTITSClusterFinderComponent::Configure(const char* arguments) | |
549 | { | |
550 | ||
551 | int iResult=0; | |
552 | ||
553 | if (!arguments) return iResult; | |
554 | ||
555 | TString allArgs=arguments; | |
556 | TString argument; | |
557 | ||
558 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
559 | ||
560 | if (pTokens) { | |
561 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
562 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
a2a2a7ce | 563 | if (argument.IsNull()) continue; |
564 | if (argument.CompareTo("-use-offline-finder")==0) { | |
565 | fUseOfflineFinder = 1; | |
566 | HLTInfo("Off-line ClusterFinder will be used"); | |
6b7742a2 | 567 | continue; |
568 | } | |
a2a2a7ce | 569 | /* |
6b7742a2 | 570 | else if (argument.CompareTo("")==0) { |
571 | HLTInfo(""); | |
572 | continue; | |
573 | } | |
574 | */ | |
575 | else { | |
576 | HLTError("unknown argument %s", argument.Data()); | |
577 | iResult=-EINVAL; | |
578 | break; | |
579 | } | |
580 | } | |
581 | delete pTokens; | |
582 | } | |
583 | ||
584 | return iResult; | |
585 | } | |
586 | ||
587 | int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
588 | { | |
589 | // see header file for class documentation | |
590 | int iResult=0; | |
591 | ||
a3479b55 | 592 | const char* path=""; |
593 | ||
594 | switch(fModeSwitch){ | |
595 | case kClusterFinderSPD: | |
596 | path = "HLT/ConfigITS/ITSClusterFinderSPD"; | |
597 | break; | |
598 | case kClusterFinderSDD: | |
599 | path = "HLT/ConfigITS/ITSClusterFinderSDD"; | |
600 | break; | |
601 | case kClusterFinderSSD: | |
602 | path = "HLT/ConfigITS/ITSClusterFinderSSD"; | |
603 | break; | |
604 | case kClusterFinderDigits: | |
605 | path = ""; | |
606 | break; | |
607 | default: | |
608 | HLTFatal("unknown cluster finder"); | |
609 | } | |
610 | ||
6b7742a2 | 611 | const char* defaultNotify=""; |
612 | if (cdbEntry) { | |
613 | path=cdbEntry; | |
614 | defaultNotify=" (default)"; | |
615 | } | |
616 | if (path) { | |
617 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
618 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); | |
619 | if (pEntry) { | |
620 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
621 | if (pString) { | |
622 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
623 | iResult=Configure(pString->GetString().Data()); | |
624 | } else { | |
625 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
626 | } | |
627 | } else { | |
628 | HLTError("can not fetch object \"%s\" from CDB", path); | |
629 | } | |
630 | } | |
631 | ||
632 | return iResult; | |
633 | } | |
6eb9783a | 634 | void AliHLTITSClusterFinderComponent::GetOCDBObjectDescription( TMap* const targetMap) |
635 | { | |
636 | // Get a list of OCDB object description. | |
637 | if (!targetMap) return; | |
638 | //SPD | |
639 | targetMap->Add(new TObjString("ITS/Calib/SPDNoisy"),new TObjString("Calibration object for SPD" )); | |
640 | targetMap->Add(new TObjString("ITS/Calib/SPDDead"),new TObjString("Calibration object for SPD" )); | |
641 | targetMap->Add(new TObjString("TRIGGER/SPD/PITConditions"),new TObjString("Calibration object for SPD" )); | |
642 | //SDD | |
643 | targetMap->Add(new TObjString("ITS/Calib/CalibSDD"),new TObjString("Calibration object for SDD" )); | |
644 | targetMap->Add(new TObjString("ITS/Calib/RespSDD"),new TObjString("Calibration object for SDD" )); | |
645 | targetMap->Add(new TObjString("ITS/Calib/DriftSpeedSDD"),new TObjString("Calibration object for SDD" )); | |
646 | targetMap->Add(new TObjString("ITS/Calib/DDLMapSDD"),new TObjString("Calibration object for SDD" )); | |
647 | targetMap->Add(new TObjString("ITS/Calib/MapsTimeSDD"),new TObjString("Calibration object for SDD" )); | |
648 | //SSD | |
649 | targetMap->Add(new TObjString("ITS/Calib/NoiseSSD"),new TObjString("Calibration object for SSD" )); | |
650 | targetMap->Add(new TObjString("ITS/Calib/GainSSD"),new TObjString("Calibration object for SSD" )); | |
651 | targetMap->Add(new TObjString("ITS/Calib/BadChannelsSSD"),new TObjString("Calibration object for SSD" )); | |
652 | //General reconstruction | |
653 | targetMap->Add(new TObjString("GRP/CTP/Scalers"),new TObjString("General reconstruction object" )); | |
654 | } | |
655 | ||
656 | ||
618f422f | 657 | void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* outputPtr,AliHLTUInt32_t& size){ |
658 | AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size); | |
8e5edf3c | 659 | outputClusters->fSpacePointCnt=fnClusters; |
618f422f | 660 | int clustIdx=0; |
8e5edf3c | 661 | if(fModeSwitch==kClusterFinderDigits) { |
662 | TClonesArray * fRecPoints = NULL; | |
663 | tR->SetBranchAddress("ITSRecPoints",&fRecPoints); | |
664 | for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){ | |
665 | tR->GetEntry(treeEntry); | |
666 | fnClusters += fRecPoints->GetEntries(); | |
667 | for(Int_t tCloneEntry=0;tCloneEntry<fRecPoints->GetEntries();tCloneEntry++){ | |
668 | AliITSRecPoint *recpoint=(AliITSRecPoint*)fRecPoints->At(tCloneEntry); | |
669 | RecpointToOutput(outputClusters,recpoint,clustIdx); | |
670 | } | |
671 | } | |
672 | } | |
673 | else if(fclusters.size()>0){ | |
674 | for(UInt_t i=0;i<fclusters.size();i++){ | |
675 | AliITSRecPoint *recpoint = (AliITSRecPoint*) &(fclusters[i]); | |
676 | RecpointToOutput(outputClusters,recpoint,clustIdx); | |
677 | } | |
618f422f | 678 | } |
8e5edf3c | 679 | else{ |
680 | AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance(); | |
681 | TClonesArray* clusters = NULL; | |
682 | for(Int_t i=fFirstModule;i<fLastModule;i++){ | |
683 | clusters = rpc->UncheckedGetClusters(i); | |
684 | for(Int_t j=0;j<clusters->GetEntriesFast();j++){ | |
685 | AliITSRecPoint *recpoint = (AliITSRecPoint*) clusters->At(j); | |
686 | RecpointToOutput(outputClusters,recpoint,clustIdx); | |
687 | } | |
688 | } | |
689 | } | |
690 | } | |
691 | ||
692 | void AliHLTITSClusterFinderComponent::RecpointToOutput(AliHLTITSClusterData *outputClusters, AliITSRecPoint *recpoint, int &clustIdx){ | |
693 | outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY(); | |
694 | outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ(); | |
695 | outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2(); | |
696 | outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2(); | |
697 | outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ(); | |
698 | outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ(); | |
699 | outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy(); | |
700 | outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz(); | |
701 | outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer(); | |
702 | outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex(); | |
703 | outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0); | |
704 | outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1); | |
705 | outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2); | |
706 | clustIdx++; | |
618f422f | 707 | } |