]>
Commit | Line | Data |
---|---|---|
1 | /*************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Conributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Id$ | |
18 | */ | |
19 | ||
20 | //////////////////////////////////////////////////////////////////////// | |
21 | // This class defines the "Standard" reconstruction for the ITS // | |
22 | // detector. // | |
23 | // // | |
24 | //////////////////////////////////////////////////////////////////////// | |
25 | #include "TObjArray.h" | |
26 | #include "TTree.h" | |
27 | ||
28 | #include "AliCDBManager.h" | |
29 | #include "AliCDBEntry.h" | |
30 | #include "AliITSClusterFinder.h" | |
31 | #include "AliITSClusterFinderV2SPD.h" | |
32 | #include "AliITSClusterFinderV2SDD.h" | |
33 | #include "AliITSClusterFinderV2SSD.h" | |
34 | #include "AliITSDetTypeRec.h" | |
35 | #include "AliITSDDLModuleMapSDD.h" | |
36 | #include "AliITSRecPoint.h" | |
37 | #include "AliITSRecPointContainer.h" | |
38 | #include "AliITSCalibrationSDD.h" | |
39 | #include "AliITSMapSDD.h" | |
40 | #include "AliITSCalibrationSSD.h" | |
41 | #include "AliITSNoiseSSDv2.h" | |
42 | #include "AliITSGainSSDv2.h" | |
43 | #include "AliITSBadChannelsSSDv2.h" | |
44 | #include "AliITSNoiseSSD.h" | |
45 | #include "AliITSGainSSD.h" | |
46 | #include "AliITSBadChannelsSSD.h" | |
47 | #include "AliITSresponseSDD.h" | |
48 | #include "AliITSsegmentationSPD.h" | |
49 | #include "AliITSsegmentationSDD.h" | |
50 | #include "AliITSsegmentationSSD.h" | |
51 | #include "AliLog.h" | |
52 | #include "AliITSRawStreamSPD.h" | |
53 | #include "AliITSTriggerConditions.h" | |
54 | #include "AliITSFOSignalsSPD.h" | |
55 | #include "AliRunLoader.h" | |
56 | #include "AliDataLoader.h" | |
57 | #include "AliITSLoader.h" | |
58 | ||
59 | class AliITSDriftSpeedArraySDD; | |
60 | class AliITSCorrMapSDD; | |
61 | class AliITSRecoParam; | |
62 | ||
63 | const Int_t AliITSDetTypeRec::fgkNdettypes = 3; | |
64 | const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240; | |
65 | const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260; | |
66 | const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698; | |
67 | ||
68 | ClassImp(AliITSDetTypeRec) | |
69 | ||
70 | //________________________________________________________________ | |
71 | AliITSDetTypeRec::AliITSDetTypeRec(): TObject(), | |
72 | fNMod(0), | |
73 | fITSgeom(0), | |
74 | fReconstruction(0), | |
75 | fSegmentation(0), | |
76 | fCalibration(0), | |
77 | fSSDCalibration(0), | |
78 | fSPDDead(0), | |
79 | fSPDSparseDead(0), | |
80 | fTriggerConditions(0), | |
81 | fDigits(0), | |
82 | fFOSignals(0), | |
83 | fDDLMapSDD(0), | |
84 | fRespSDD(0), | |
85 | fAveGainSDD(0), | |
86 | fRecPoints(0), | |
87 | fNRecPoints(0), | |
88 | fFirstcall(kTRUE), | |
89 | fLoadOnlySPDCalib(0), | |
90 | fFastOrFiredMap(1200){ | |
91 | // Standard Constructor | |
92 | // Inputs: | |
93 | // none. | |
94 | // Outputs: | |
95 | // none. | |
96 | // Return: | |
97 | // | |
98 | ||
99 | fReconstruction = new TObjArray(fgkNdettypes); | |
100 | fDigits = new TObjArray(fgkNdettypes); | |
101 | for(Int_t i=0; i<3; i++){ | |
102 | fkDigClassName[i]=0; | |
103 | } | |
104 | fSSDCalibration=new AliITSCalibrationSSD(); | |
105 | fNMod = new Int_t [fgkNdettypes]; | |
106 | fNMod[0] = fgkDefaultNModulesSPD; | |
107 | fNMod[1] = fgkDefaultNModulesSDD; | |
108 | fNMod[2] = fgkDefaultNModulesSSD; | |
109 | fNRecPoints = 0; | |
110 | ||
111 | ||
112 | } | |
113 | ||
114 | //______________________________________________________________________ | |
115 | AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec), | |
116 | fNMod(rec.fNMod), | |
117 | fITSgeom(rec.fITSgeom), | |
118 | fReconstruction(rec.fReconstruction), | |
119 | fSegmentation(rec.fSegmentation), | |
120 | fCalibration(rec.fCalibration), | |
121 | fSSDCalibration(rec.fSSDCalibration), | |
122 | fSPDDead(rec.fSPDDead), | |
123 | fSPDSparseDead(rec.fSPDSparseDead), | |
124 | fTriggerConditions(rec.fTriggerConditions), | |
125 | fDigits(rec.fDigits), | |
126 | fFOSignals(rec.fFOSignals), | |
127 | fDDLMapSDD(rec.fDDLMapSDD), | |
128 | fRespSDD(rec.fRespSDD), | |
129 | fAveGainSDD(rec.fAveGainSDD), | |
130 | fRecPoints(rec.fRecPoints), | |
131 | fNRecPoints(rec.fNRecPoints), | |
132 | fFirstcall(rec.fFirstcall), | |
133 | fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib), | |
134 | fFastOrFiredMap(rec.fFastOrFiredMap){ | |
135 | ||
136 | // Copy constructor. | |
137 | for(Int_t i=0; i<3; i++){ | |
138 | fkDigClassName[i]=rec.fkDigClassName[i]; // NB only copies Char_t*, so not so safe, but this code should never be reached anyways | |
139 | } | |
140 | } | |
141 | //______________________________________________________________________ | |
142 | AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){ | |
143 | // Assignment operator. | |
144 | this->~AliITSDetTypeRec(); | |
145 | new(this) AliITSDetTypeRec(source); | |
146 | return *this; | |
147 | ||
148 | } | |
149 | ||
150 | //_____________________________________________________________________ | |
151 | AliITSDetTypeRec::~AliITSDetTypeRec(){ | |
152 | //Destructor | |
153 | ||
154 | if(fReconstruction){ | |
155 | fReconstruction->Delete(); | |
156 | delete fReconstruction; | |
157 | } | |
158 | if(fSegmentation){ | |
159 | fSegmentation->Delete(); | |
160 | delete fSegmentation; | |
161 | } | |
162 | if(fCalibration){ | |
163 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
164 | fCalibration->Delete(); | |
165 | delete fCalibration; | |
166 | if(fRespSDD) delete fRespSDD; | |
167 | if(fDDLMapSDD) delete fDDLMapSDD; | |
168 | } | |
169 | } | |
170 | if(fSSDCalibration){ | |
171 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
172 | delete fSSDCalibration; | |
173 | } | |
174 | } | |
175 | if(fSPDDead){ | |
176 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
177 | fSPDDead->Delete(); | |
178 | delete fSPDDead; | |
179 | } | |
180 | } | |
181 | if(fSPDSparseDead){ | |
182 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
183 | fSPDSparseDead->Delete(); | |
184 | delete fSPDSparseDead; | |
185 | } | |
186 | } | |
187 | if(fTriggerConditions){ | |
188 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
189 | fTriggerConditions->Delete(); | |
190 | delete fTriggerConditions; | |
191 | } | |
192 | } | |
193 | if(fDigits){ | |
194 | fDigits->Delete(); | |
195 | delete fDigits; | |
196 | } | |
197 | if(fRecPoints){ | |
198 | fRecPoints->Delete(); | |
199 | delete fRecPoints; | |
200 | } | |
201 | delete [] fNMod; | |
202 | ||
203 | if (fITSgeom) delete fITSgeom; | |
204 | ||
205 | } | |
206 | ||
207 | //___________________________________________________________________ | |
208 | void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){ | |
209 | ||
210 | //Set reconstruction model for detector type | |
211 | ||
212 | if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes); | |
213 | if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype); | |
214 | fReconstruction->AddAt(clf,dettype); | |
215 | } | |
216 | //______________________________________________________________________ | |
217 | AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype) const{ | |
218 | ||
219 | //Get reconstruction model for detector type | |
220 | if(fReconstruction==0) { | |
221 | Warning("GetReconstructionModel","fReconstruction is 0!"); | |
222 | return 0; | |
223 | } | |
224 | return (AliITSClusterFinder*)fReconstruction->At(dettype); | |
225 | } | |
226 | ||
227 | //______________________________________________________________________ | |
228 | void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){ | |
229 | ||
230 | //Set segmentation model for detector type | |
231 | ||
232 | if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes); | |
233 | if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype); | |
234 | fSegmentation->AddAt(seg,dettype); | |
235 | ||
236 | } | |
237 | //______________________________________________________________________ | |
238 | AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype) const { | |
239 | ||
240 | //Get segmentation model for detector type | |
241 | ||
242 | if(fSegmentation==0) { | |
243 | Warning("GetSegmentationModel","fSegmentation is 0!"); | |
244 | return 0; | |
245 | } | |
246 | return (AliITSsegmentation*)fSegmentation->At(dettype); | |
247 | ||
248 | } | |
249 | //_______________________________________________________________________ | |
250 | void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){ | |
251 | ||
252 | //Set calibration (response) for the module iMod of type dettype | |
253 | if (fCalibration==0) { | |
254 | fCalibration = new TObjArray(GetITSgeom()->GetIndexMax()); | |
255 | fCalibration->SetOwner(kTRUE); | |
256 | fCalibration->Clear(); | |
257 | } | |
258 | ||
259 | if (fCalibration->At(iMod) != 0) | |
260 | delete (AliITSCalibration*) fCalibration->At(iMod); | |
261 | fCalibration->AddAt(cal,iMod); | |
262 | ||
263 | } | |
264 | //_______________________________________________________________________ | |
265 | void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){ | |
266 | ||
267 | //Set dead pixel info for the SPD module iMod | |
268 | if (fSPDDead==0) { | |
269 | fSPDDead = new TObjArray(fgkDefaultNModulesSPD); | |
270 | fSPDDead->SetOwner(kTRUE); | |
271 | fSPDDead->Clear(); | |
272 | } | |
273 | ||
274 | if (fSPDDead->At(iMod) != 0) | |
275 | delete (AliITSCalibration*) fSPDDead->At(iMod); | |
276 | fSPDDead->AddAt(cal,iMod); | |
277 | } | |
278 | //_______________________________________________________________________ | |
279 | void AliITSDetTypeRec::SetSPDSparseDeadModel(Int_t iMod, AliITSCalibration *cal){ | |
280 | ||
281 | //Set dead pixel info for the SPD ACTIVE module iMod | |
282 | if (fSPDSparseDead==0) { | |
283 | fSPDSparseDead = new TObjArray(fgkDefaultNModulesSPD); | |
284 | fSPDSparseDead->SetOwner(kTRUE); | |
285 | fSPDSparseDead->Clear(); | |
286 | } | |
287 | ||
288 | if (fSPDSparseDead->At(iMod) != 0) | |
289 | delete (AliITSCalibration*) fSPDSparseDead->At(iMod); | |
290 | fSPDSparseDead->AddAt(cal,iMod); | |
291 | } | |
292 | //_______________________________________________________________________ | |
293 | AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod) const { | |
294 | ||
295 | //Get calibration model for module type | |
296 | ||
297 | if(fCalibration==0) { | |
298 | Warning("GetalibrationModel","fCalibration is 0!"); | |
299 | return 0; | |
300 | } | |
301 | ||
302 | if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){ | |
303 | return (AliITSCalibration*)fCalibration->At(iMod); | |
304 | }else{ | |
305 | Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD); | |
306 | fSSDCalibration->SetModule(i); | |
307 | return (AliITSCalibration*)fSSDCalibration; | |
308 | } | |
309 | ||
310 | } | |
311 | //_______________________________________________________________________ | |
312 | AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const { | |
313 | ||
314 | //Get SPD dead for module iMod | |
315 | ||
316 | if(fSPDDead==0) { | |
317 | AliWarning("fSPDDead is 0!"); | |
318 | return 0; | |
319 | } | |
320 | return (AliITSCalibration*)fSPDDead->At(iMod); | |
321 | } | |
322 | //_______________________________________________________________________ | |
323 | AliITSCalibration* AliITSDetTypeRec::GetSPDSparseDeadModel(Int_t iMod) const { | |
324 | ||
325 | //Get SPD dead for module iMod | |
326 | ||
327 | if(fSPDSparseDead==0) { | |
328 | AliWarning("fSPDSparseDead is 0!"); | |
329 | return 0; | |
330 | } | |
331 | return (AliITSCalibration*)fSPDSparseDead->At(iMod); | |
332 | } | |
333 | //_______________________________________________________________________ | |
334 | AliITSTriggerConditions* AliITSDetTypeRec::GetTriggerConditions() const { | |
335 | //Get Pixel Trigger Conditions | |
336 | if (fTriggerConditions==0) { | |
337 | AliWarning("fTriggerConditions is 0!"); | |
338 | } | |
339 | return fTriggerConditions; | |
340 | } | |
341 | //______________________________________________________________________ | |
342 | void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){ | |
343 | // Set branch address for the tree of digits. | |
344 | ||
345 | const char *det[4] = {"SPD","SDD","SSD","ITS"}; | |
346 | TBranch *branch; | |
347 | const Char_t* digclass; | |
348 | Int_t i; | |
349 | char branchname[30]; | |
350 | ||
351 | if(!treeD) return; | |
352 | if (fDigits == 0x0) { | |
353 | fDigits = new TObjArray(fgkNdettypes); | |
354 | } | |
355 | else { | |
356 | ResetDigits(); | |
357 | } | |
358 | for (i=0; i<fgkNdettypes; i++) { | |
359 | digclass = GetDigitClassName(i); | |
360 | fDigits->AddAt(new TClonesArray(digclass,1000),i); | |
361 | if (fgkNdettypes==3) snprintf(branchname,29,"%sDigits%s",det[3],det[i]); | |
362 | else snprintf(branchname,29,"%sDigits%d",det[3],i+1); | |
363 | branch = treeD->GetBranch(branchname); | |
364 | if (branch) branch->SetAddress(&((*fDigits)[i])); | |
365 | } | |
366 | ||
367 | } | |
368 | ||
369 | //_______________________________________________________________________ | |
370 | TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree* const tree, | |
371 | const char* name, const char *classname, | |
372 | void* address,Int_t size,Int_t splitlevel) | |
373 | { | |
374 | // | |
375 | // Makes branch in given tree and diverts them to a separate file | |
376 | // | |
377 | // | |
378 | // | |
379 | ||
380 | if (tree == 0x0) { | |
381 | Error("MakeBranchInTree","Making Branch %s Tree is NULL",name); | |
382 | return 0x0; | |
383 | } | |
384 | TBranch *branch = tree->GetBranch(name); | |
385 | if (branch) { | |
386 | return branch; | |
387 | } | |
388 | if (classname){ | |
389 | branch = tree->Branch(name,classname,address,size,splitlevel); | |
390 | } | |
391 | else { | |
392 | branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel); | |
393 | } | |
394 | ||
395 | return branch; | |
396 | } | |
397 | ||
398 | //____________________________________________________________________ | |
399 | void AliITSDetTypeRec::SetDefaults(){ | |
400 | ||
401 | //Set defaults for segmentation and response | |
402 | ||
403 | if(!GetITSgeom()){ | |
404 | Warning("SetDefaults","null pointer to AliITSgeomGeom !"); | |
405 | return; | |
406 | } | |
407 | ||
408 | AliITSsegmentation* seg; | |
409 | if(!GetCalibration()) {AliFatal("Exit");exit(0);} | |
410 | ||
411 | for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){ | |
412 | if(dettype==0){ | |
413 | seg = new AliITSsegmentationSPD(); | |
414 | SetSegmentationModel(dettype,seg); | |
415 | SetDigitClassName(dettype,"AliITSdigitSPD"); | |
416 | } | |
417 | if(dettype==1){ | |
418 | seg = new AliITSsegmentationSDD(); | |
419 | if(fLoadOnlySPDCalib==kFALSE){ | |
420 | AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1); | |
421 | if(cal->IsAMAt20MHz()){ | |
422 | seg->SetPadSize(seg->Dpz(0),20.); | |
423 | seg->SetNPads(seg->Npz()/2,128); | |
424 | } | |
425 | } | |
426 | SetSegmentationModel(dettype,seg); | |
427 | SetDigitClassName(dettype,"AliITSdigitSDD"); | |
428 | } | |
429 | if(dettype==2){ | |
430 | AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(); | |
431 | SetSegmentationModel(dettype,seg2); | |
432 | SetDigitClassName(dettype,"AliITSdigitSSD"); | |
433 | } | |
434 | } | |
435 | } | |
436 | //______________________________________________________________________ | |
437 | Bool_t AliITSDetTypeRec::GetCalibration() { | |
438 | // Get Default calibration if a storage is not defined. | |
439 | ||
440 | if(!fFirstcall){ | |
441 | AliITSCalibration* cal = GetCalibrationModel(0); | |
442 | if(cal)return kTRUE; | |
443 | }else { | |
444 | fFirstcall = kFALSE; | |
445 | } | |
446 | ||
447 | // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun()); | |
448 | // Int_t run=GetRunNumber(); | |
449 | ||
450 | Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag(); | |
451 | if (fCalibration==0) { | |
452 | fCalibration = new TObjArray(GetITSgeom()->GetIndexMax()); | |
453 | fCalibration->SetOwner(!cacheStatus); | |
454 | fCalibration->Clear(); | |
455 | } | |
456 | ||
457 | Bool_t retCode=GetCalibrationSPD(cacheStatus); | |
458 | if(retCode==kFALSE) return kFALSE; | |
459 | ||
460 | if(fLoadOnlySPDCalib==kFALSE){ | |
461 | retCode=GetCalibrationSDD(cacheStatus); | |
462 | if(retCode==kFALSE) return kFALSE; | |
463 | retCode=GetCalibrationSSD(cacheStatus); | |
464 | if(retCode==kFALSE) return kFALSE; | |
465 | } | |
466 | ||
467 | AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database", | |
468 | fNMod[0], fNMod[1], fNMod[2])); | |
469 | return kTRUE; | |
470 | } | |
471 | //______________________________________________________________________ | |
472 | Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) { | |
473 | // Get SPD calibration objects from OCDB | |
474 | // dead pixel are not used for local reconstruction | |
475 | ||
476 | ||
477 | AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy"); | |
478 | AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead"); | |
479 | AliCDBEntry *deadSparseSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDSparseDead"); | |
480 | AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("TRIGGER/SPD/PITConditions"); | |
481 | if(!noisySPD || !deadSPD || !pitCond ){ | |
482 | AliFatal("SPD Calibration object retrieval failed! "); | |
483 | return kFALSE; | |
484 | } | |
485 | ||
486 | TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject(); | |
487 | if (!cacheStatus) noisySPD->SetObject(NULL); | |
488 | noisySPD->SetOwner(kTRUE); | |
489 | ||
490 | TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject(); | |
491 | if (!cacheStatus) deadSPD->SetObject(NULL); | |
492 | deadSPD->SetOwner(kTRUE); | |
493 | ||
494 | TObjArray *calSparseDeadSPD = (TObjArray*) deadSparseSPD->GetObject(); | |
495 | if (!cacheStatus) deadSparseSPD->SetObject(NULL); | |
496 | deadSparseSPD->SetOwner(kTRUE); | |
497 | ||
498 | ||
499 | AliITSTriggerConditions *calPitCond = (AliITSTriggerConditions*) pitCond->GetObject(); | |
500 | if (!cacheStatus) pitCond->SetObject(NULL); | |
501 | pitCond->SetOwner(kTRUE); | |
502 | ||
503 | if(!cacheStatus){ | |
504 | delete noisySPD; | |
505 | delete deadSPD; | |
506 | delete deadSparseSPD; | |
507 | delete pitCond; | |
508 | } | |
509 | if ((!calNoisySPD) || (!calDeadSPD) || (!calSparseDeadSPD) || (!calPitCond)){ | |
510 | AliWarning("Can not get SPD calibration from calibration database !"); | |
511 | return kFALSE; | |
512 | } | |
513 | ||
514 | fNMod[0] = calNoisySPD->GetEntries(); | |
515 | ||
516 | AliITSCalibration* cal; | |
517 | for (Int_t i=0; i<fNMod[0]; i++) { | |
518 | cal = (AliITSCalibration*) calNoisySPD->At(i); | |
519 | SetCalibrationModel(i, cal); | |
520 | cal = (AliITSCalibration*) calDeadSPD->At(i); | |
521 | SetSPDDeadModel(i, cal); | |
522 | cal = (AliITSCalibration*) calSparseDeadSPD->At(i); | |
523 | SetSPDSparseDeadModel(i, cal); | |
524 | } | |
525 | fTriggerConditions = calPitCond; | |
526 | ||
527 | return kTRUE; | |
528 | } | |
529 | ||
530 | //______________________________________________________________________ | |
531 | Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) { | |
532 | // Get SDD calibration objects from OCDB | |
533 | ||
534 | AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD"); | |
535 | AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD"); | |
536 | AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD"); | |
537 | AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD"); | |
538 | // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD"); | |
539 | AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD"); | |
540 | ||
541 | if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !mapTSDD ){ | |
542 | AliFatal("SDD Calibration object retrieval failed! "); | |
543 | return kFALSE; | |
544 | } | |
545 | ||
546 | ||
547 | ||
548 | TObjArray *calSDD = (TObjArray *)entrySDD->GetObject(); | |
549 | if(!cacheStatus)entrySDD->SetObject(NULL); | |
550 | entrySDD->SetOwner(kTRUE); | |
551 | ||
552 | AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject(); | |
553 | if(!cacheStatus)entry2SDD->SetObject(NULL); | |
554 | entry2SDD->SetOwner(kTRUE); | |
555 | ||
556 | TObjArray *drSp = (TObjArray *)drSpSDD->GetObject(); | |
557 | if(!cacheStatus)drSpSDD->SetObject(NULL); | |
558 | drSpSDD->SetOwner(kTRUE); | |
559 | ||
560 | AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject(); | |
561 | if(!cacheStatus)ddlMapSDD->SetObject(NULL); | |
562 | ddlMapSDD->SetOwner(kTRUE); | |
563 | ||
564 | // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject(); | |
565 | // if(!cacheStatus)mapASDD->SetObject(NULL); | |
566 | // mapASDD->SetOwner(kTRUE); | |
567 | ||
568 | TObjArray *mapT = (TObjArray *)mapTSDD->GetObject(); | |
569 | if(!cacheStatus)mapTSDD->SetObject(NULL); | |
570 | mapTSDD->SetOwner(kTRUE); | |
571 | ||
572 | ||
573 | // DB entries are deleted. In this way metadeta objects are deleted as well | |
574 | if(!cacheStatus){ | |
575 | delete entrySDD; | |
576 | delete entry2SDD; | |
577 | //delete mapASDD; | |
578 | delete mapTSDD; | |
579 | delete drSpSDD; | |
580 | delete ddlMapSDD; | |
581 | } | |
582 | ||
583 | if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!mapT) ){ | |
584 | AliWarning("Can not get SDD calibration from calibration database !"); | |
585 | return kFALSE; | |
586 | } | |
587 | ||
588 | fNMod[1] = calSDD->GetEntries(); | |
589 | ||
590 | fDDLMapSDD=ddlsdd; | |
591 | fRespSDD=pSDD; | |
592 | AliITSCalibration* cal; | |
593 | Float_t avegain=0.; | |
594 | Float_t nGdAnodes=0; | |
595 | Bool_t oldMapFormat=kFALSE; | |
596 | TObject* objmap=(TObject*)mapT->At(0); | |
597 | TString cname(objmap->ClassName()); | |
598 | if(cname.CompareTo("AliITSMapSDD")==0){ | |
599 | oldMapFormat=kTRUE; | |
600 | AliInfo("SDD Maps converted to new format"); | |
601 | } | |
602 | for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){ | |
603 | for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){ | |
604 | Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar); | |
605 | if(iMod==-1) continue; | |
606 | Int_t i=iMod - fgkDefaultNModulesSPD; | |
607 | cal = (AliITSCalibration*) calSDD->At(i); | |
608 | Int_t i0=2*i; | |
609 | Int_t i1=1+2*i; | |
610 | for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){ | |
611 | if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue; | |
612 | avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode); | |
613 | nGdAnodes++; | |
614 | } | |
615 | AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0); | |
616 | AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1); | |
617 | ||
618 | AliITSCorrMapSDD* mt0 = 0; | |
619 | AliITSCorrMapSDD* mt1 = 0; | |
620 | if(oldMapFormat){ | |
621 | AliITSMapSDD* oldmap0=(AliITSMapSDD*)mapT->At(i0); | |
622 | AliITSMapSDD* oldmap1=(AliITSMapSDD*)mapT->At(i1); | |
623 | mt0=oldmap0->ConvertToNewFormat(); | |
624 | mt1=oldmap1->ConvertToNewFormat(); | |
625 | }else{ | |
626 | mt0=(AliITSCorrMapSDD*)mapT->At(i0); | |
627 | mt1=(AliITSCorrMapSDD*)mapT->At(i1); | |
628 | } | |
629 | cal->SetDriftSpeed(0,arr0); | |
630 | cal->SetDriftSpeed(1,arr1); | |
631 | cal->SetMapT(0,mt0); | |
632 | cal->SetMapT(1,mt1); | |
633 | SetCalibrationModel(iMod, cal); | |
634 | } | |
635 | } | |
636 | if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes; | |
637 | return kTRUE; | |
638 | } | |
639 | ||
640 | ||
641 | //______________________________________________________________________ | |
642 | Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) { | |
643 | // Get SSD calibration objects from OCDB | |
644 | // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD"); | |
645 | ||
646 | AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD"); | |
647 | AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD"); | |
648 | AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD"); | |
649 | ||
650 | if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){ | |
651 | AliFatal("SSD Calibration object retrieval failed! "); | |
652 | return kFALSE; | |
653 | } | |
654 | ||
655 | TObject *emptyssd = 0; TString ssdobjectname; | |
656 | AliITSNoiseSSDv2 *noiseSSD = NULL; | |
657 | emptyssd = (TObject *)entryNoiseSSD->GetObject(); | |
658 | ssdobjectname = emptyssd->GetName(); | |
659 | if(ssdobjectname=="TObjArray") { | |
660 | TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject(); | |
661 | noiseSSD = new AliITSNoiseSSDv2(); | |
662 | ReadOldSSDNoise(noiseSSDOld, noiseSSD); | |
663 | } | |
664 | else if(ssdobjectname=="AliITSNoiseSSDv2") | |
665 | noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject(); | |
666 | if(!cacheStatus)entryNoiseSSD->SetObject(NULL); | |
667 | entryNoiseSSD->SetOwner(kTRUE); | |
668 | ||
669 | AliITSGainSSDv2 *gainSSD = NULL;; | |
670 | emptyssd = (TObject *)entryGainSSD->GetObject(); | |
671 | ssdobjectname = emptyssd->GetName(); | |
672 | if(ssdobjectname=="Gain") { | |
673 | TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject(); | |
674 | gainSSD = new AliITSGainSSDv2(); | |
675 | ReadOldSSDGain(gainSSDOld, gainSSD); | |
676 | } | |
677 | else if(ssdobjectname=="AliITSGainSSDv2") | |
678 | gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject(); | |
679 | if(!cacheStatus)entryGainSSD->SetObject(NULL); | |
680 | entryGainSSD->SetOwner(kTRUE); | |
681 | ||
682 | AliITSBadChannelsSSDv2 *badChannelsSSD = NULL; | |
683 | emptyssd = (TObject *)entryBadChannelsSSD->GetObject(); | |
684 | ssdobjectname = emptyssd->GetName(); | |
685 | if(ssdobjectname=="TObjArray") { | |
686 | TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject(); | |
687 | badChannelsSSD = new AliITSBadChannelsSSDv2(); | |
688 | ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD); | |
689 | } | |
690 | else if(ssdobjectname=="AliITSBadChannelsSSDv2") | |
691 | badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject(); | |
692 | if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL); | |
693 | entryBadChannelsSSD->SetOwner(kTRUE); | |
694 | ||
695 | // DB entries are deleted. In this way metadeta objects are deleted as well | |
696 | if(!cacheStatus){ | |
697 | delete entryNoiseSSD; | |
698 | delete entryGainSSD; | |
699 | delete entryBadChannelsSSD; | |
700 | } | |
701 | ||
702 | if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) { | |
703 | AliWarning("Can not get SSD calibration from calibration database !"); | |
704 | return kFALSE; | |
705 | } | |
706 | ||
707 | fSSDCalibration->SetNoise(noiseSSD); | |
708 | fSSDCalibration->SetGain(gainSSD); | |
709 | fSSDCalibration->SetBadChannels(badChannelsSSD); | |
710 | //fSSDCalibration->FillBadChipMap(); | |
711 | ||
712 | return kTRUE; | |
713 | } | |
714 | ||
715 | //________________________________________________________________ | |
716 | void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){ | |
717 | ||
718 | //Set defaults for cluster finder V2 | |
719 | ||
720 | if(!GetITSgeom()){ | |
721 | Warning("SetDefaults","Null pointer to AliITSgeom !"); | |
722 | return; | |
723 | } | |
724 | ||
725 | AliITSClusterFinder *clf; | |
726 | ||
727 | for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){ | |
728 | //SPD | |
729 | if(dettype==0){ | |
730 | if(!GetReconstructionModel(dettype)){ | |
731 | clf = new AliITSClusterFinderV2SPD(this); | |
732 | clf->InitGeometry(); | |
733 | if(!rawdata) clf->SetDigits(DigitsAddress(0)); | |
734 | SetReconstructionModel(dettype,clf); | |
735 | ||
736 | } | |
737 | } | |
738 | //SDD | |
739 | if(dettype==1){ | |
740 | if(!GetReconstructionModel(dettype)){ | |
741 | clf = new AliITSClusterFinderV2SDD(this); | |
742 | clf->InitGeometry(); | |
743 | if(!rawdata) clf->SetDigits(DigitsAddress(1)); | |
744 | SetReconstructionModel(dettype,clf); | |
745 | } | |
746 | ||
747 | } | |
748 | ||
749 | //SSD | |
750 | if(dettype==2){ | |
751 | if(!GetReconstructionModel(dettype)){ | |
752 | clf = new AliITSClusterFinderV2SSD(this); | |
753 | clf->InitGeometry(); | |
754 | if(!rawdata) clf->SetDigits(DigitsAddress(2)); | |
755 | SetReconstructionModel(dettype,clf); | |
756 | } | |
757 | } | |
758 | ||
759 | } | |
760 | ||
761 | } | |
762 | //______________________________________________________________________ | |
763 | void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){ | |
764 | ||
765 | //Creates branches for clusters and recpoints | |
766 | Bool_t cR = (strstr(option,"R")!=0); | |
767 | Bool_t cRF = (strstr(option,"RF")!=0); | |
768 | ||
769 | if(cRF)cR = kFALSE; | |
770 | ||
771 | if(cR) MakeBranchR(tree); | |
772 | if(cRF) MakeBranchRF(tree); | |
773 | ||
774 | } | |
775 | ||
776 | //___________________________________________________________________ | |
777 | void AliITSDetTypeRec::ResetDigits(){ | |
778 | // Reset number of digits and the digits array for the ITS detector. | |
779 | ||
780 | if(!fDigits) return; | |
781 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
782 | ResetDigits(i); | |
783 | } | |
784 | } | |
785 | //___________________________________________________________________ | |
786 | void AliITSDetTypeRec::ResetDigits(Int_t branch){ | |
787 | // Reset number of digits and the digits array for this branch. | |
788 | ||
789 | if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear(); | |
790 | ||
791 | } | |
792 | //__________________________________________________________________ | |
793 | void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){ | |
794 | ||
795 | //Creates tree branches for recpoints | |
796 | // Inputs: | |
797 | // cont char *file File name where RecPoints branch is to be written | |
798 | // to. If blank it write the SDigits to the same | |
799 | // file in which the Hits were found. | |
800 | ||
801 | Int_t buffsz = 4000; | |
802 | char branchname[30]; | |
803 | ||
804 | // only one branch for rec points for all detector types | |
805 | Bool_t oFast= (strstr(opt,"Fast")!=0); | |
806 | ||
807 | Char_t detname[10] = "ITS"; | |
808 | ||
809 | ||
810 | if(oFast){ | |
811 | snprintf(branchname,29,"%sRecPointsF",detname); | |
812 | } else { | |
813 | snprintf(branchname,29,"%sRecPoints",detname); | |
814 | } | |
815 | ||
816 | if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
817 | if (treeR) | |
818 | MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99); | |
819 | } | |
820 | //______________________________________________________________________ | |
821 | void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){ | |
822 | // Set branch address for the Reconstructed points Trees. | |
823 | // Inputs: | |
824 | // TTree *treeR Tree containing the RecPoints. | |
825 | // Outputs: | |
826 | // none. | |
827 | // Return: | |
828 | ||
829 | char branchname[30]; | |
830 | Char_t namedet[10]="ITS"; | |
831 | ||
832 | if(!treeR) return; | |
833 | if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
834 | TBranch *branch; | |
835 | snprintf(branchname,29,"%sRecPoints",namedet); | |
836 | branch = treeR->GetBranch(branchname); | |
837 | if (branch) { | |
838 | branch->SetAddress(&fRecPoints); | |
839 | } | |
840 | else { | |
841 | snprintf(branchname,29,"%sRecPointsF",namedet); | |
842 | branch = treeR->GetBranch(branchname); | |
843 | if (branch) { | |
844 | branch->SetAddress(&fRecPoints); | |
845 | } | |
846 | } | |
847 | } | |
848 | //____________________________________________________________________ | |
849 | void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){ | |
850 | // Add a reconstructed space point to the list | |
851 | // Inputs: | |
852 | // const AliITSRecPoint &r RecPoint class to be added to the tree | |
853 | // of reconstructed points TreeR. | |
854 | // Outputs: | |
855 | // none. | |
856 | // Return: | |
857 | // none. | |
858 | TClonesArray &lrecp = *fRecPoints; | |
859 | new(lrecp[fNRecPoints++]) AliITSRecPoint(r); | |
860 | } | |
861 | ||
862 | //______________________________________________________________________ | |
863 | void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){ | |
864 | // cluster finding and reconstruction of space points | |
865 | // the condition below will disappear when the geom class will be | |
866 | // initialized for all versions - for the moment it is only for v5 ! | |
867 | // 7 is the SDD beam test version | |
868 | // Inputs: | |
869 | // TTree *treeD Digits tree | |
870 | // TTree *treeR Clusters tree | |
871 | // Int_t lastentry Offset for module when not all of the modules | |
872 | // are processed. | |
873 | // Option_t *opt String indicating which ITS sub-detectors should | |
874 | // be processed. If ="All" then all of the ITS | |
875 | // sub detectors are processed. | |
876 | ||
877 | const char *all = strstr(opt,"All"); | |
878 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
879 | strstr(opt,"SSD")}; | |
880 | if(optCluFind==0){ | |
881 | SetDefaultClusterFindersV2(); | |
882 | AliDebug(1,"V2 cluster finder has been selected \n"); | |
883 | }else{ | |
884 | SetDefaultClusterFindersV2(); | |
885 | AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n"); | |
886 | } | |
887 | ||
888 | ||
889 | // Reset Fast-OR fired map | |
890 | ResetFastOrFiredMap(); | |
891 | ||
892 | if (all || det[0]) { // SPD present | |
893 | // Get the FO signals for this event | |
894 | AliRunLoader* runLoader = AliRunLoader::Instance(); | |
895 | AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader"); | |
896 | if (!itsLoader) { | |
897 | AliError("ITS loader is NULL."); | |
898 | } | |
899 | else { | |
900 | fFOSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD"); | |
901 | if(!fFOSignals) AliError("FO signals not retrieved"); | |
902 | } | |
903 | ||
904 | } | |
905 | ||
906 | ||
907 | AliITSClusterFinder *rec = 0; | |
908 | Int_t id,module,first=0; | |
909 | for(module=0;module<GetITSgeom()->GetIndexMax();module++){ | |
910 | id = GetITSgeom()->GetModuleType(module); | |
911 | if (!all && !det[id]) continue; | |
912 | if(det[id]) first = GetITSgeom()->GetStartDet(id); | |
913 | rec = (AliITSClusterFinder*)GetReconstructionModel(id); | |
914 | TClonesArray *itsDigits = DigitsAddress(id); | |
915 | if (!rec){ | |
916 | AliFatal("The reconstruction class was not instanciated!"); | |
917 | return; | |
918 | } | |
919 | ResetDigits(); // MvL: Not sure we neeed this when rereading anyways | |
920 | if (all) { | |
921 | treeD->GetEvent(lastentry+module); | |
922 | } | |
923 | else { | |
924 | treeD->GetEvent(lastentry+(module-first)); | |
925 | } | |
926 | Int_t ndigits = itsDigits->GetEntriesFast(); | |
927 | if (ndigits>0 || id==0) { // for SPD we always want to call FindRawClusters (to process FO signals) | |
928 | rec->SetDetTypeRec(this); | |
929 | rec->SetDigits(DigitsAddress(id)); | |
930 | // rec->SetClusters(ClustersAddress(id)); | |
931 | rec->FindRawClusters(module); | |
932 | } // end if | |
933 | treeR->Fill(); | |
934 | ResetRecPoints(); | |
935 | } | |
936 | ||
937 | // Remove PIT in-active chips from Fast-OR fired map | |
938 | if (all || det[0]) { // SPD present | |
939 | RemoveFastOrFiredInActive(); | |
940 | // here removing bits which have no associated clusters | |
941 | RemoveFastOrFiredFromDead(GetFiredChipMap(treeR)); | |
942 | } | |
943 | ||
944 | AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance(); | |
945 | Int_t nClu[6]; | |
946 | nClu[0]=rpcont->GetNClustersInLayer(1,treeR); | |
947 | for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay); | |
948 | AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d", | |
949 | nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5])); | |
950 | } | |
951 | //______________________________________________________________________ | |
952 | void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){ | |
953 | // cluster finding and reconstruction of space points | |
954 | // the condition below will disappear when the geom class will be | |
955 | // initialized for all versions - for the moment it is only for v5 ! | |
956 | // 7 is the SDD beam test version | |
957 | // Inputs: | |
958 | // AliRawReader *rawReader Pointer to the raw-data reader | |
959 | // TTree *treeR Clusters tree | |
960 | // Outputs: | |
961 | // none. | |
962 | // Return: | |
963 | // none. | |
964 | const char *all = strstr(opt,"All"); | |
965 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
966 | strstr(opt,"SSD")}; | |
967 | ||
968 | Int_t id=0; | |
969 | AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance(); | |
970 | rpc->FullReset(); | |
971 | TClonesArray* array = rpc->UncheckedGetClusters(0); | |
972 | TBranch *branch = treeR->Branch("ITSRecPoints",&array); | |
973 | DigitsToRecPoints(rawReader,opt); | |
974 | ||
975 | Int_t nClusters =0; | |
976 | for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){ | |
977 | id = GetITSgeom()->GetModuleType(iModule); | |
978 | if (!all && !det[id]) continue; | |
979 | array = rpc->UncheckedGetClusters(iModule); | |
980 | if(!array){ | |
981 | AliDebug(1,Form("data for module %d missing!",iModule)); | |
982 | } | |
983 | branch->SetAddress(&array); | |
984 | treeR->Fill(); | |
985 | nClusters+=array->GetEntriesFast(); | |
986 | } | |
987 | ||
988 | rpc->FullReset(); | |
989 | ||
990 | AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance(); | |
991 | Int_t nClu[6]; | |
992 | nClu[0]=rpcont->GetNClustersInLayer(1,treeR); | |
993 | for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay); | |
994 | AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d, Total = %d", | |
995 | nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5],nClusters)); | |
996 | } | |
997 | //______________________________________________________________________ | |
998 | void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,Option_t *opt){ | |
999 | // cluster finding and reconstruction of space points | |
1000 | // the condition below will disappear when the geom class will be | |
1001 | // initialized for all versions - for the moment it is only for v5 ! | |
1002 | // 7 is the SDD beam test version | |
1003 | // Inputs: | |
1004 | // AliRawReader *rawReader Pointer to the raw-data reader | |
1005 | // Outputs: | |
1006 | // none. | |
1007 | // Return: | |
1008 | // none. | |
1009 | const char *all = strstr(opt,"All"); | |
1010 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
1011 | strstr(opt,"SSD")}; | |
1012 | ||
1013 | // Reset Fast-OR fired map | |
1014 | ResetFastOrFiredMap(); | |
1015 | ||
1016 | AliITSClusterFinder *rec = 0; | |
1017 | Int_t id=0; | |
1018 | ||
1019 | for(id=0;id<3;id++){ | |
1020 | if (!all && !det[id]) continue; | |
1021 | rec = (AliITSClusterFinder*)GetReconstructionModel(id); | |
1022 | if (!rec){ | |
1023 | AliFatal("The reconstruction class was not instantiated"); | |
1024 | return; | |
1025 | } | |
1026 | rec->SetDetTypeRec(this); | |
1027 | rec->RawdataToClusters(rawReader); | |
1028 | } | |
1029 | ||
1030 | // Remove PIT in-active chips from Fast-OR fired map | |
1031 | if (all || det[0]) { // SPD present | |
1032 | RemoveFastOrFiredInActive(); | |
1033 | // here removing bits which have no associated clusters | |
1034 | RemoveFastOrFiredFromDead(GetFiredChipMap()); | |
1035 | ||
1036 | } | |
1037 | } | |
1038 | //______________________________________________________________________ | |
1039 | void AliITSDetTypeRec::ReadOldSSDNoise(const TObjArray *array, | |
1040 | AliITSNoiseSSDv2 *noiseSSD) { | |
1041 | //Reads the old SSD calibration object and converts it to the new format | |
1042 | const Int_t fgkSSDSTRIPSPERMODULE = 1536; | |
1043 | const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768; | |
1044 | ||
1045 | Int_t gNMod = array->GetEntries(); | |
1046 | AliInfo("Converting old calibration object for noise...\n"); | |
1047 | ||
1048 | //NOISE | |
1049 | Double_t noise = 0.0; | |
1050 | for (Int_t iModule = 0; iModule < gNMod; iModule++) { | |
1051 | AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule)); | |
1052 | for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) { | |
1053 | noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip); | |
1054 | if(iStrip < fgkSSDPSIDESTRIPSPERMODULE) | |
1055 | noiseSSD->AddNoiseP(iModule,iStrip,noise); | |
1056 | if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE) | |
1057 | noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise); | |
1058 | }//loop over strips | |
1059 | }//loop over modules | |
1060 | } | |
1061 | ||
1062 | //______________________________________________________________________ | |
1063 | void AliITSDetTypeRec::ReadOldSSDBadChannels(const TObjArray *array, | |
1064 | AliITSBadChannelsSSDv2 *badChannelsSSD) { | |
1065 | //Reads the old SSD calibration object and converts it to the new format | |
1066 | Int_t gNMod = array->GetEntries(); | |
1067 | AliInfo("Converting old calibration object for bad channels..."); | |
1068 | for (Int_t iModule = 0; iModule < gNMod; iModule++) { | |
1069 | //for (Int_t iModule = 0; iModule < 1; iModule++) { | |
1070 | AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule)); | |
1071 | TArrayI arrayPSide = bad->GetBadPChannelsList(); | |
1072 | for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) | |
1073 | badChannelsSSD->AddBadChannelP(iModule, | |
1074 | iPCounter, | |
1075 | (Char_t)arrayPSide.At(iPCounter)); | |
1076 | ||
1077 | TArrayI arrayNSide = bad->GetBadNChannelsList(); | |
1078 | for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) | |
1079 | badChannelsSSD->AddBadChannelN(iModule, | |
1080 | iNCounter, | |
1081 | (Char_t)arrayNSide.At(iNCounter)); | |
1082 | ||
1083 | }//loop over modules | |
1084 | } | |
1085 | ||
1086 | //______________________________________________________________________ | |
1087 | void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array, | |
1088 | AliITSGainSSDv2 *gainSSD) { | |
1089 | //Reads the old SSD calibration object and converts it to the new format | |
1090 | ||
1091 | Int_t gNMod = array->GetEntries(); | |
1092 | AliInfo("Converting old calibration object for gain...\n"); | |
1093 | ||
1094 | //GAIN | |
1095 | for (Int_t iModule = 0; iModule < gNMod; iModule++) { | |
1096 | AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule)); | |
1097 | TArrayF arrayPSide = gainModule->GetGainP(); | |
1098 | for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) | |
1099 | gainSSD->AddGainP(iModule, | |
1100 | iPCounter, | |
1101 | arrayPSide.At(iPCounter)); | |
1102 | TArrayF arrayNSide = gainModule->GetGainN(); | |
1103 | for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) | |
1104 | gainSSD->AddGainN(iModule, | |
1105 | iNCounter, | |
1106 | arrayNSide.At(iNCounter)); | |
1107 | }//loop over modules | |
1108 | } | |
1109 | //______________________________________________________________________ | |
1110 | void AliITSDetTypeRec::RemoveFastOrFiredInActive() { | |
1111 | // Removes the chips that were in-active in the pixel trigger (from fast-or fired map) | |
1112 | ||
1113 | if (fTriggerConditions==NULL) { | |
1114 | AliError("Pixel trigger conditions are missing."); | |
1115 | return; | |
1116 | } | |
1117 | Int_t eq = -1; | |
1118 | Int_t hs = -1; | |
1119 | Int_t chip = -1; | |
1120 | while (fTriggerConditions->GetNextInActiveChip(eq,hs,chip)) { | |
1121 | UInt_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); | |
1122 | fFastOrFiredMap.SetBitNumber(chipKey,kFALSE); | |
1123 | } | |
1124 | } | |
1125 | //______________________________________________________________________ | |
1126 | TBits AliITSDetTypeRec::GetFiredChipMap() const { | |
1127 | ||
1128 | // | |
1129 | // TBits of the fired chips | |
1130 | // | |
1131 | ||
1132 | AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance(); | |
1133 | ||
1134 | TBits isfiredchip(1200); | |
1135 | ||
1136 | AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0); | |
1137 | if(!segSPD) { | |
1138 | AliError("no segmentation model for SPD available, the fired chip map is empty. Exiting"); | |
1139 | return isfiredchip; | |
1140 | } | |
1141 | ||
1142 | ||
1143 | for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){ | |
1144 | TClonesArray *array = rpc->UncheckedGetClusters(imod); | |
1145 | if(!array) continue; | |
1146 | Int_t nCluster = array->GetEntriesFast(); | |
1147 | ||
1148 | while(nCluster--) { | |
1149 | AliITSRecPoint* cluster = (AliITSRecPoint*)array->UncheckedAt(nCluster); | |
1150 | if (cluster->GetLayer()>1)continue; | |
1151 | Float_t local[3]={-1,-1}; | |
1152 | local[1]=cluster->GetDetLocalX(); | |
1153 | local[0]=cluster->GetDetLocalZ(); | |
1154 | ||
1155 | Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod); | |
1156 | Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod); | |
1157 | Int_t row, col; | |
1158 | segSPD->LocalToDet(0.5,local[0],row,col); | |
1159 | Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col); | |
1160 | Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); | |
1161 | isfiredchip.SetBitNumber(chipkey,kTRUE); | |
1162 | } | |
1163 | ||
1164 | } | |
1165 | ||
1166 | return isfiredchip; | |
1167 | ||
1168 | } | |
1169 | //______________________________________________________________________ | |
1170 | TBits AliITSDetTypeRec::GetFiredChipMap(TTree *treeR) const{ | |
1171 | // | |
1172 | // TBits of the fired chips | |
1173 | // | |
1174 | TBits isfiredchip(1200); | |
1175 | ||
1176 | if(!treeR) { | |
1177 | AliError("no treeR. fired chip map stays empty. Exiting."); | |
1178 | return isfiredchip; | |
1179 | } | |
1180 | ||
1181 | AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance(); | |
1182 | TClonesArray *recpoints = NULL; | |
1183 | rpcont->FetchClusters(0,treeR); | |
1184 | if(!rpcont->GetStatusOK() || !rpcont->IsSPDActive()){ | |
1185 | AliError("no clusters. fired chip map stays empty. Exiting."); | |
1186 | return isfiredchip; | |
1187 | } | |
1188 | ||
1189 | AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0); | |
1190 | ||
1191 | for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){ | |
1192 | recpoints = rpcont->UncheckedGetClusters(imod); | |
1193 | Int_t nCluster = recpoints->GetEntriesFast(); | |
1194 | ||
1195 | // loop over clusters | |
1196 | while(nCluster--) { | |
1197 | AliITSRecPoint* cluster = (AliITSRecPoint*)recpoints->UncheckedAt(nCluster); | |
1198 | if (cluster->GetLayer()>1)continue; | |
1199 | Float_t local[3]={-1,-1}; | |
1200 | local[1]=cluster->GetDetLocalX(); | |
1201 | local[0]=cluster->GetDetLocalZ(); | |
1202 | ||
1203 | Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod); | |
1204 | Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod); | |
1205 | Int_t row, col; | |
1206 | segSPD->LocalToDet(0.5,local[0],row,col); | |
1207 | Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col); | |
1208 | Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); | |
1209 | isfiredchip.SetBitNumber(chipkey,kTRUE); | |
1210 | } | |
1211 | } | |
1212 | ||
1213 | return isfiredchip; | |
1214 | } | |
1215 | //______________________________________________________________________ | |
1216 | void AliITSDetTypeRec::RemoveFastOrFiredFromDead(TBits firedchipmap){ | |
1217 | // | |
1218 | // resetting of the fast-or bit on cluster basis. | |
1219 | // fast-or bits can be remnant from SPD ideal simulation (no dead channels) | |
1220 | // | |
1221 | ||
1222 | for(Int_t chipKey=0; chipKey<1200; chipKey++){ | |
1223 | // FO masked chips have been previously removed | |
1224 | if(!fFastOrFiredMap.TestBitNumber(chipKey)) continue; | |
1225 | if(!firedchipmap.TestBitNumber(chipKey)) { | |
1226 | fFastOrFiredMap.SetBitNumber(chipKey,kFALSE); | |
1227 | AliDebug(2,Form("removing bit in key %i \n ",chipKey)); | |
1228 | } | |
1229 | } | |
1230 | ||
1231 | } | |
1232 | //______________________________________________________________________ | |
1233 | void AliITSDetTypeRec::SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip) { | |
1234 | // Set fast-or fired map for this chip | |
1235 | Int_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); | |
1236 | return SetFastOrFiredMap(chipKey); | |
1237 | } | |
1238 |