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