]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSDetTypeRec.cxx
Bug fix in Z and Phi position of the wings on the SSD support cone (M. Sitta)
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeRec.cxx
CommitLineData
3b9df642 1/***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
b17dae48 5 * Conributors are mentioned in the code where appropriate. *
3b9df642 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/*
140e5249 17 $Id$
3b9df642 18*/
19
7d62fb64 20////////////////////////////////////////////////////////////////////////
21// This class defines the "Standard" reconstruction for the ITS //
22// detector. //
23// //
24////////////////////////////////////////////////////////////////////////
25#include "TObjArray.h"
26#include "TTree.h"
27
8ba39da9 28#include "AliCDBManager.h"
e8c4cf33 29#include "AliCDBStorage.h"
8ba39da9 30#include "AliCDBEntry.h"
7d62fb64 31#include "AliITSClusterFinder.h"
7d62fb64 32#include "AliITSClusterFinderV2SPD.h"
33#include "AliITSClusterFinderV2SDD.h"
34#include "AliITSClusterFinderV2SSD.h"
3b9df642 35#include "AliITSDetTypeRec.h"
6cae184e 36#include "AliITSgeom.h"
7d62fb64 37#include "AliITSRecPoint.h"
ed446fa3 38#include "AliITSReconstructor.h"
39#include "AliITSRecoParam.h"
fcf95fc7 40#include "AliITSCalibrationSDD.h"
028a3709 41#include "AliITSMapSDD.h"
18da6e54 42#include "AliITSDriftSpeedArraySDD.h"
140e5249 43#include "AliITSDriftSpeedSDD.h"
2f8ed7ab 44#include "AliITSHLTforSDD.h"
fb4dfab9 45#include "AliITSCalibrationSSD.h"
88128115 46#include "AliITSNoiseSSDv2.h"
47#include "AliITSGainSSDv2.h"
48#include "AliITSBadChannelsSSDv2.h"
fb4dfab9 49#include "AliITSNoiseSSD.h"
50#include "AliITSGainSSD.h"
51#include "AliITSBadChannelsSSD.h"
7d62fb64 52#include "AliITSsegmentationSPD.h"
53#include "AliITSsegmentationSDD.h"
54#include "AliITSsegmentationSSD.h"
00a7cc50 55#include "AliLog.h"
7d62fb64 56
3b9df642 57
7d62fb64 58const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
8ba39da9 59const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
60const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
61const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
62
3b9df642 63ClassImp(AliITSDetTypeRec)
64
7d62fb64 65//________________________________________________________________
e56160b8 66AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
67fNMod(0),
6cae184e 68fITSgeom(0),
e56160b8 69fReconstruction(0),
70fSegmentation(0),
71fCalibration(0),
ced4d9bc 72fSSDCalibration(0),
23197852 73fSPDDead(0),
b457135f 74fSPDFastOr(0),
e56160b8 75fDigits(0),
979b5a5f 76fDDLMapSDD(0),
253e68a0 77fRespSDD(0),
75065a60 78fAveGainSDD(0),
2f8ed7ab 79fIsHLTmodeC(0),
e56160b8 80fRecPoints(0),
81fNRecPoints(0),
62b93da7 82fFirstcall(kTRUE),
ff44c37c 83fLoadOnlySPDCalib(0),
84fFastOrFiredMap(1200){
8e50d897 85 // Standard Constructor
86 // Inputs:
87 // none.
88 // Outputs:
89 // none.
90 // Return:
91 //
7d62fb64 92
7d62fb64 93 fReconstruction = new TObjArray(fgkNdettypes);
7d62fb64 94 fDigits = new TObjArray(fgkNdettypes);
8e50d897 95 for(Int_t i=0; i<3; i++){
8e50d897 96 fDigClassName[i]=0;
8e50d897 97 }
ced4d9bc 98 fSSDCalibration=new AliITSCalibrationSSD();
8e50d897 99 fNMod = new Int_t [fgkNdettypes];
100 fNMod[0] = fgkDefaultNModulesSPD;
101 fNMod[1] = fgkDefaultNModulesSDD;
102 fNMod[2] = fgkDefaultNModulesSSD;
00a7cc50 103 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
7d62fb64 104 fNRecPoints = 0;
7d62fb64 105
7d62fb64 106
7d62fb64 107}
7537d03c 108
7d62fb64 109//______________________________________________________________________
7537d03c 110AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
111fNMod(rec.fNMod),
6cae184e 112fITSgeom(rec.fITSgeom),
7537d03c 113fReconstruction(rec.fReconstruction),
114fSegmentation(rec.fSegmentation),
115fCalibration(rec.fCalibration),
ced4d9bc 116fSSDCalibration(rec.fSSDCalibration),
23197852 117fSPDDead(rec.fSPDDead),
b457135f 118fSPDFastOr(rec.fSPDFastOr),
7537d03c 119fDigits(rec.fDigits),
979b5a5f 120fDDLMapSDD(rec.fDDLMapSDD),
253e68a0 121fRespSDD(rec.fRespSDD),
75065a60 122fAveGainSDD(rec.fAveGainSDD),
2f8ed7ab 123fIsHLTmodeC(rec.fIsHLTmodeC),
7537d03c 124fRecPoints(rec.fRecPoints),
125fNRecPoints(rec.fNRecPoints),
62b93da7 126fFirstcall(rec.fFirstcall),
ff44c37c 127fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib),
128fFastOrFiredMap(rec.fFastOrFiredMap){
7d62fb64 129
e56160b8 130 // Copy constructor.
7537d03c 131
7d62fb64 132}
133//______________________________________________________________________
e56160b8 134AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
7537d03c 135 // Assignment operator.
136 this->~AliITSDetTypeRec();
137 new(this) AliITSDetTypeRec(source);
138 return *this;
7d62fb64 139
e56160b8 140}
7537d03c 141
7d62fb64 142//_____________________________________________________________________
3b9df642 143AliITSDetTypeRec::~AliITSDetTypeRec(){
7d62fb64 144 //Destructor
6cae184e 145
fcf95fc7 146 if(fReconstruction){
147 fReconstruction->Delete();
148 delete fReconstruction;
149 fReconstruction = 0;
150 }
151 if(fSegmentation){
152 fSegmentation->Delete();
153 delete fSegmentation;
154 fSegmentation = 0;
155 }
6cae184e 156 if(fCalibration){
7032f6a2 157 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
7032f6a2 158 fCalibration->Delete();
159 delete fCalibration;
160 fCalibration = 0;
253e68a0 161 if(fRespSDD) delete fRespSDD;
162 if(fDDLMapSDD) delete fDDLMapSDD;
163 }
fcf95fc7 164 }
ced4d9bc 165 if(fSSDCalibration) delete fSSDCalibration;
166 if(fSPDDead){
23197852 167 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
168 fSPDDead->Delete();
169 delete fSPDDead;
170 fSPDDead = 0;
171 }
172 }
7d62fb64 173 if(fDigits){
174 fDigits->Delete();
175 delete fDigits;
176 fDigits=0;
177 }
178 if(fRecPoints){
179 fRecPoints->Delete();
180 delete fRecPoints;
181 fRecPoints=0;
182 }
8e50d897 183 delete [] fNMod;
7d62fb64 184
6cae184e 185 if (fITSgeom) delete fITSgeom;
186
7d62fb64 187}
8e50d897 188
7d62fb64 189//___________________________________________________________________
190void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
191
192 //Set reconstruction model for detector type
193
194 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
195 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
196 fReconstruction->AddAt(clf,dettype);
197}
198//______________________________________________________________________
199AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
200
201 //Get reconstruction model for detector type
202 if(fReconstruction==0) {
203 Warning("GetReconstructionModel","fReconstruction is 0!");
204 return 0;
205 }
206 return (AliITSClusterFinder*)fReconstruction->At(dettype);
207}
208
209//______________________________________________________________________
210void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
211
212 //Set segmentation model for detector type
213
214 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
215 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
216 fSegmentation->AddAt(seg,dettype);
217
218}
219//______________________________________________________________________
220AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
221
222 //Get segmentation model for detector type
223
224 if(fSegmentation==0) {
225 Warning("GetSegmentationModel","fSegmentation is 0!");
226 return 0;
227 }
228 return (AliITSsegmentation*)fSegmentation->At(dettype);
229
230}
231//_______________________________________________________________________
fcf95fc7 232void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
8ba39da9 233
234 //Set calibration (response) for the module iMod of type dettype
235 if (fCalibration==0) {
8e50d897 236 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
8ba39da9 237 fCalibration->SetOwner(kTRUE);
238 fCalibration->Clear();
239 }
240
241 if (fCalibration->At(iMod) != 0)
fcf95fc7 242 delete (AliITSCalibration*) fCalibration->At(iMod);
8ba39da9 243 fCalibration->AddAt(cal,iMod);
7d62fb64 244
7d62fb64 245}
246//_______________________________________________________________________
23197852 247void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
248
249 //Set dead pixel info for the SPD module iMod
250 if (fSPDDead==0) {
251 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
252 fSPDDead->SetOwner(kTRUE);
253 fSPDDead->Clear();
254 }
255
256 if (fSPDDead->At(iMod) != 0)
257 delete (AliITSCalibration*) fSPDDead->At(iMod);
258 fSPDDead->AddAt(cal,iMod);
259}
260//_______________________________________________________________________
fcf95fc7 261AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
7d62fb64 262
8ba39da9 263 //Get calibration model for module type
7d62fb64 264
265 if(fCalibration==0) {
8ba39da9 266 Warning("GetalibrationModel","fCalibration is 0!");
7d62fb64 267 return 0;
268 }
8ba39da9 269
ced4d9bc 270 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
271 return (AliITSCalibration*)fCalibration->At(iMod);
272 }else{
273 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
274 fSSDCalibration->SetModule(i);
275 return (AliITSCalibration*)fSSDCalibration;
276 }
277
7d62fb64 278}
23197852 279//_______________________________________________________________________
280AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
281
282 //Get SPD dead for module iMod
283
284 if(fSPDDead==0) {
285 AliWarning("fSPDDead is 0!");
286 return 0;
287 }
288
289 return (AliITSCalibration*)fSPDDead->At(iMod);
290}
7d62fb64 291
7d62fb64 292//______________________________________________________________________
293void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
294 // Set branch address for the tree of digits.
295
296 const char *det[4] = {"SPD","SDD","SSD","ITS"};
297 TBranch *branch;
a6e0ebfe 298 const Char_t* digclass;
7d62fb64 299 Int_t i;
300 char branchname[30];
301
302 if(!treeD) return;
303 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
304 for (i=0; i<fgkNdettypes; i++) {
305 digclass = GetDigitClassName(i);
306 if(!(fDigits->At(i))) {
307 fDigits->AddAt(new TClonesArray(digclass,1000),i);
308 }else{
309 ResetDigits(i);
310 }
311 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
312 else sprintf(branchname,"%sDigits%d",det[3],i+1);
313 if (fDigits) {
314 branch = treeD->GetBranch(branchname);
315 if (branch) branch->SetAddress(&((*fDigits)[i]));
316 }
317 }
318}
319
320//_______________________________________________________________________
321TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
322 const char *classname,
323 void* address,Int_t size,
6cae184e 324 Int_t splitlevel)
7d62fb64 325{
326//
327// Makes branch in given tree and diverts them to a separate file
328//
329//
330//
331
332 if (tree == 0x0) {
333 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
334 return 0x0;
335 }
336 TBranch *branch = tree->GetBranch(name);
337 if (branch) {
338 return branch;
339 }
340 if (classname){
341 branch = tree->Branch(name,classname,address,size,splitlevel);
342 }
343 else {
344 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
345 }
346
347 return branch;
348}
349
350//____________________________________________________________________
351void AliITSDetTypeRec::SetDefaults(){
352
353 //Set defaults for segmentation and response
354
8e50d897 355 if(!GetITSgeom()){
356 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
7d62fb64 357 return;
358 }
359
360 AliITSsegmentation* seg;
8ba39da9 361 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
7d62fb64 362
363 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
364 if(dettype==0){
d24bc9d6 365 seg = new AliITSsegmentationSPD();
7d62fb64 366 SetSegmentationModel(dettype,seg);
3a7c3e6d 367 SetDigitClassName(dettype,"AliITSdigitSPD");
7d62fb64 368 }
62b93da7 369 if(fLoadOnlySPDCalib==kFALSE){
370 if(dettype==1){
371 seg = new AliITSsegmentationSDD();
372 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
373 if(cal->IsAMAt20MHz()){
374 seg->SetPadSize(seg->Dpz(0),20.);
375 seg->SetNPads(seg->Npz()/2,128);
376 }
377 SetSegmentationModel(dettype,seg);
378 SetDigitClassName(dettype,"AliITSdigitSDD");
b27af87f 379 }
7d62fb64 380 }
381 if(dettype==2){
d24bc9d6 382 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
7d62fb64 383 SetSegmentationModel(dettype,seg2);
7d62fb64 384 SetDigitClassName(dettype,"AliITSdigitSSD");
7d62fb64 385 }
7d62fb64 386 }
7d62fb64 387}
8ba39da9 388//______________________________________________________________________
389Bool_t AliITSDetTypeRec::GetCalibration() {
390 // Get Default calibration if a storage is not defined.
391
b17dae48 392 if(!fFirstcall){
393 AliITSCalibration* cal = GetCalibrationModel(0);
394 if(cal)return kTRUE;
62b93da7 395 }else {
b17dae48 396 fFirstcall = kFALSE;
397 }
06232459 398
6cae184e 399 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
400 // Int_t run=GetRunNumber();
b17dae48 401
6cae184e 402 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
b17dae48 403 if (fCalibration==0) {
404 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
6cae184e 405 fCalibration->SetOwner(!cacheStatus);
b17dae48 406 fCalibration->Clear();
407 }
75065a60 408
409 Bool_t retCode=GetCalibrationSPD(cacheStatus);
410 if(retCode==kFALSE) return kFALSE;
411
412 if(fLoadOnlySPDCalib==kFALSE){
413 retCode=GetCalibrationSDD(cacheStatus);
414 if(retCode==kFALSE) return kFALSE;
415 retCode=GetCalibrationSSD(cacheStatus);
416 if(retCode==kFALSE) return kFALSE;
417 }
418
419 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
420 fNMod[0], fNMod[1], fNMod[2]));
421 return kTRUE;
422}
423//______________________________________________________________________
424Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
425 // Get SPD calibration objects from OCDB
8d37cc87 426 // dead pixel are not used for local reconstruction
75065a60 427
8d37cc87 428 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
23197852 429 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
b457135f 430 AliCDBEntry *fastOrSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFastOr");
431 if(!entrySPD || !deadSPD || !fastOrSPD ){
62b93da7 432 AliFatal("SPD Calibration object retrieval failed! ");
433 return kFALSE;
434 }
75065a60 435
62b93da7 436 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
437 if(!cacheStatus)entrySPD->SetObject(NULL);
438 entrySPD->SetOwner(kTRUE);
fb4dfab9 439
62b93da7 440 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
441 if(!cacheStatus)deadSPD->SetObject(NULL);
442 deadSPD->SetOwner(kTRUE);
443
b457135f 444 AliITSFastOrCalibrationSPD *calfastOrSPD = (AliITSFastOrCalibrationSPD *)fastOrSPD->GetObject();
445 if(!cacheStatus)fastOrSPD->SetObject(NULL);
446 fastOrSPD->SetOwner(kTRUE);
447
62b93da7 448 if(!cacheStatus){
449 delete entrySPD;
450 delete deadSPD;
b457135f 451 delete fastOrSPD;
62b93da7 452 }
b457135f 453 if ((!calSPD) || (!caldeadSPD) || (!calfastOrSPD)){
62b93da7 454 AliWarning("Can not get SPD calibration from calibration database !");
455 return kFALSE;
456 }
457
458 fNMod[0] = calSPD->GetEntries();
459
460 AliITSCalibration* cal;
461 for (Int_t i=0; i<fNMod[0]; i++) {
462 cal = (AliITSCalibration*) calSPD->At(i);
463 SetCalibrationModel(i, cal);
464 cal = (AliITSCalibration*) caldeadSPD->At(i);
465 SetSPDDeadModel(i, cal);
466 }
b457135f 467 fSPDFastOr = calfastOrSPD;
62b93da7 468
62b93da7 469 return kTRUE;
470}
75065a60 471
62b93da7 472//______________________________________________________________________
75065a60 473Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) {
474 // Get SDD calibration objects from OCDB
475
62b93da7 476 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
6cae184e 477 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
18da6e54 478 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
979b5a5f 479 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
2f8ed7ab 480 AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
62b93da7 481 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
028a3709 482 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
06232459 483
75065a60 484 if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){
485 AliFatal("SDD Calibration object retrieval failed! ");
e8c4cf33 486 return kFALSE;
566f73ca 487 }
488
23197852 489
fcf95fc7 490
b17dae48 491 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
6cae184e 492 if(!cacheStatus)entrySDD->SetObject(NULL);
8ba39da9 493 entrySDD->SetOwner(kTRUE);
fcf95fc7 494
495 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
6cae184e 496 if(!cacheStatus)entry2SDD->SetObject(NULL);
fcf95fc7 497 entry2SDD->SetOwner(kTRUE);
498
18da6e54 499 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
500 if(!cacheStatus)drSpSDD->SetObject(NULL);
501 drSpSDD->SetOwner(kTRUE);
502
979b5a5f 503 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
504 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
505 ddlMapSDD->SetOwner(kTRUE);
506
2f8ed7ab 507 AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject();
508 if(!cacheStatus)hltforSDD->SetObject(NULL);
509 hltforSDD->SetOwner(kTRUE);
510
2ebd5518 511// TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
512// if(!cacheStatus)mapASDD->SetObject(NULL);
513// mapASDD->SetOwner(kTRUE);
028a3709 514
515 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
516 if(!cacheStatus)mapTSDD->SetObject(NULL);
517 mapTSDD->SetOwner(kTRUE);
518
75065a60 519
520 // DB entries are deleted. In this way metadeta objects are deleted as well
521 if(!cacheStatus){
522 delete entrySDD;
523 delete entry2SDD;
524 //delete mapASDD;
525 delete hltforSDD;
526 delete mapTSDD;
527 delete drSpSDD;
528 delete ddlMapSDD;
529 }
530
531 if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) || (!mapT) ){
532 AliWarning("Can not get SDD calibration from calibration database !");
533 return kFALSE;
534 }
535
536 fNMod[1] = calSDD->GetEntries();
537
538 fDDLMapSDD=ddlsdd;
539 fRespSDD=pSDD;
540 fIsHLTmodeC=hltsdd->IsHLTmodeC();
541 AliITSCalibration* cal;
542 Float_t avegain=0.;
543 Float_t nGdAnodes=0;
544 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
545 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
546 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
547 if(iMod==-1) continue;
548 Int_t i=iMod - fgkDefaultNModulesSPD;
549 cal = (AliITSCalibration*) calSDD->At(i);
550 Int_t i0=2*i;
551 Int_t i1=1+2*i;
552 for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
553 if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
554 avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
555 nGdAnodes++;
556 }
557 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
558 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
559 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
560 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
561 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
562 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
563 cal->SetDriftSpeed(0,arr0);
564 cal->SetDriftSpeed(1,arr1);
565// cal->SetMapA(0,ma0);
566// cal->SetMapA(1,ma1);
567 cal->SetMapT(0,mt0);
568 cal->SetMapT(1,mt1);
569 SetCalibrationModel(iMod, cal);
570 }
571 }
572 if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
573 return kTRUE;
574}
575
576
577//______________________________________________________________________
578Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
579 // Get SSD calibration objects from OCDB
580 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
581
582 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
583 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
584 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
585
586 if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){
587 AliFatal("SSD Calibration object retrieval failed! ");
588 return kFALSE;
589 }
590
88128115 591 TObject *emptyssd = 0; TString ssdobjectname = 0;
592 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
593 emptyssd = (TObject *)entryNoiseSSD->GetObject();
594 ssdobjectname = emptyssd->GetName();
595 if(ssdobjectname=="TObjArray") {
596 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
597 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
598 }
599 else if(ssdobjectname=="AliITSNoiseSSDv2")
600 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
fb4dfab9 601 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
602 entryNoiseSSD->SetOwner(kTRUE);
603
88128115 604 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
605 emptyssd = (TObject *)entryGainSSD->GetObject();
606 ssdobjectname = emptyssd->GetName();
607 if(ssdobjectname=="Gain") {
608 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
609 ReadOldSSDGain(gainSSDOld, gainSSD);
610 }
611 else if(ssdobjectname=="AliITSGainSSDv2")
612 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
fb4dfab9 613 if(!cacheStatus)entryGainSSD->SetObject(NULL);
614 entryGainSSD->SetOwner(kTRUE);
615
88128115 616 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
617 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
618 ssdobjectname = emptyssd->GetName();
619 if(ssdobjectname=="TObjArray") {
620 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
621 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
622 }
623 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
624 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
fb4dfab9 625 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
626 entryBadChannelsSSD->SetOwner(kTRUE);
fcf95fc7 627
b17dae48 628 // DB entries are deleted. In this way metadeta objects are deleted as well
6cae184e 629 if(!cacheStatus){
fb4dfab9 630 delete entryNoiseSSD;
631 delete entryGainSSD;
632 delete entryBadChannelsSSD;
b17dae48 633 }
06232459 634
75065a60 635 if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
636 AliWarning("Can not get SSD calibration from calibration database !");
8ba39da9 637 return kFALSE;
638 }
fcf95fc7 639
ced4d9bc 640 fSSDCalibration->SetNoise(noiseSSD);
ced4d9bc 641 fSSDCalibration->SetGain(gainSSD);
88128115 642 fSSDCalibration->SetBadChannels(badChannelsSSD);
ced4d9bc 643 //fSSDCalibration->FillBadChipMap();
644
8ba39da9 645 return kTRUE;
646}
647
7d62fb64 648//________________________________________________________________
3a7c3e6d 649void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
7d62fb64 650
651 //Set defaults for cluster finder V2
652
8e50d897 653 if(!GetITSgeom()){
654 Warning("SetDefaults","Null pointer to AliITSgeom !");
7d62fb64 655 return;
656 }
657
7d62fb64 658 AliITSClusterFinder *clf;
659
3a7c3e6d 660 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
7d62fb64 661 //SPD
662 if(dettype==0){
663 if(!GetReconstructionModel(dettype)){
8ba39da9 664 clf = new AliITSClusterFinderV2SPD(this);
7d62fb64 665 clf->InitGeometry();
3a7c3e6d 666 if(!rawdata) clf->SetDigits(DigitsAddress(0));
7d62fb64 667 SetReconstructionModel(dettype,clf);
668
669 }
670 }
671 //SDD
672 if(dettype==1){
673 if(!GetReconstructionModel(dettype)){
8ba39da9 674 clf = new AliITSClusterFinderV2SDD(this);
675 clf->InitGeometry();
3a7c3e6d 676 if(!rawdata) clf->SetDigits(DigitsAddress(1));
7d62fb64 677 SetReconstructionModel(dettype,clf);
678 }
679
680 }
681
682 //SSD
683 if(dettype==2){
684 if(!GetReconstructionModel(dettype)){
8ba39da9 685 clf = new AliITSClusterFinderV2SSD(this);
7d62fb64 686 clf->InitGeometry();
3a7c3e6d 687 if(!rawdata) clf->SetDigits(DigitsAddress(2));
7d62fb64 688 SetReconstructionModel(dettype,clf);
689 }
690 }
691
692 }
693
694}
695//______________________________________________________________________
6cae184e 696void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
7d62fb64 697
698 //Creates branches for clusters and recpoints
699 Bool_t cR = (strstr(option,"R")!=0);
700 Bool_t cRF = (strstr(option,"RF")!=0);
7d62fb64 701
702 if(cRF)cR = kFALSE;
703
6cae184e 704 if(cR) MakeBranchR(tree);
705 if(cRF) MakeBranchRF(tree);
7d62fb64 706
707}
708
7d62fb64 709//___________________________________________________________________
710void AliITSDetTypeRec::ResetDigits(){
711 // Reset number of digits and the digits array for the ITS detector.
712
713 if(!fDigits) return;
714 for(Int_t i=0;i<fgkNdettypes;i++){
715 ResetDigits(i);
716 }
717}
718//___________________________________________________________________
719void AliITSDetTypeRec::ResetDigits(Int_t branch){
720 // Reset number of digits and the digits array for this branch.
721
722 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
7d62fb64 723
7d62fb64 724}
725//__________________________________________________________________
6cae184e 726void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
7d62fb64 727
728 //Creates tree branches for recpoints
729 // Inputs:
730 // cont char *file File name where RecPoints branch is to be written
731 // to. If blank it write the SDigits to the same
732 // file in which the Hits were found.
733
7d62fb64 734 Int_t buffsz = 4000;
735 char branchname[30];
736
737 // only one branch for rec points for all detector types
738 Bool_t oFast= (strstr(opt,"Fast")!=0);
7d62fb64 739
740 Char_t detname[10] = "ITS";
741
742
743 if(oFast){
744 sprintf(branchname,"%sRecPointsF",detname);
7d62fb64 745 } else {
746 sprintf(branchname,"%sRecPoints",detname);
747 }
748
00a7cc50 749 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
6cae184e 750 if (treeR)
751 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
7d62fb64 752}
753//______________________________________________________________________
754void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
755 // Set branch address for the Reconstructed points Trees.
3b9df642 756 // Inputs:
7d62fb64 757 // TTree *treeR Tree containing the RecPoints.
3b9df642 758 // Outputs:
7d62fb64 759 // none.
3b9df642 760 // Return:
7d62fb64 761
762 char branchname[30];
763 Char_t namedet[10]="ITS";
764
765 if(!treeR) return;
766 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 767 TBranch *branch;
768 sprintf(branchname,"%sRecPoints",namedet);
769 branch = treeR->GetBranch(branchname);
770 if (branch) {
771 branch->SetAddress(&fRecPoints);
772 }else {
773 sprintf(branchname,"%sRecPointsF",namedet);
7d62fb64 774 branch = treeR->GetBranch(branchname);
775 if (branch) {
00a7cc50 776 branch->SetAddress(&fRecPoints);
7d62fb64 777 }
00a7cc50 778
7d62fb64 779 }
3b9df642 780}
7d62fb64 781//____________________________________________________________________
782void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
783 // Add a reconstructed space point to the list
784 // Inputs:
785 // const AliITSRecPoint &r RecPoint class to be added to the tree
786 // of reconstructed points TreeR.
787 // Outputs:
788 // none.
789 // Return:
790 // none.
791
792 TClonesArray &lrecp = *fRecPoints;
793 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
794}
7d62fb64 795
796//______________________________________________________________________
5d2c2f86 797void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){
7d62fb64 798 // cluster finding and reconstruction of space points
799 // the condition below will disappear when the geom class will be
800 // initialized for all versions - for the moment it is only for v5 !
801 // 7 is the SDD beam test version
802 // Inputs:
6cae184e 803 // TTree *treeD Digits tree
804 // TTree *treeR Clusters tree
7d62fb64 805 // Int_t lastentry Offset for module when not all of the modules
806 // are processed.
807 // Option_t *opt String indicating which ITS sub-detectors should
808 // be processed. If ="All" then all of the ITS
809 // sub detectors are processed.
810
7d62fb64 811 const char *all = strstr(opt,"All");
812 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
813 strstr(opt,"SSD")};
5d2c2f86 814 if(optCluFind==0){
00a7cc50 815 SetDefaultClusterFindersV2();
816 AliInfo("V2 cluster finder has been selected \n");
5d2c2f86 817 }else{
818 SetDefaultClusterFindersV2();
06a7cbee 819 AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n");
00a7cc50 820 }
7d62fb64 821
7d62fb64 822 AliITSClusterFinder *rec = 0;
823 Int_t id,module,first=0;
8e50d897 824 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
825 id = GetITSgeom()->GetModuleType(module);
7d62fb64 826 if (!all && !det[id]) continue;
8e50d897 827 if(det[id]) first = GetITSgeom()->GetStartDet(id);
7d62fb64 828 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
829 TClonesArray *itsDigits = DigitsAddress(id);
6cae184e 830 if (!rec)
831 AliFatal("The reconstruction class was not instanciated!");
5e5bc8f1 832 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
7d62fb64 833 if (all) {
6cae184e 834 treeD->GetEvent(lastentry+module);
7d62fb64 835 }else {
6cae184e 836 treeD->GetEvent(lastentry+(module-first));
7d62fb64 837 }
838 Int_t ndigits = itsDigits->GetEntriesFast();
839 if(ndigits>0){
840 rec->SetDetTypeRec(this);
7d62fb64 841 rec->SetDigits(DigitsAddress(id));
6cae184e 842 // rec->SetClusters(ClustersAddress(id));
7d62fb64 843 rec->FindRawClusters(module);
844 } // end if
6cae184e 845 treeR->Fill();
7d62fb64 846 ResetRecPoints();
7d62fb64 847 }
7d62fb64 848}
849//______________________________________________________________________
8484b32d 850void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
7d62fb64 851 // cluster finding and reconstruction of space points
852 // the condition below will disappear when the geom class will be
853 // initialized for all versions - for the moment it is only for v5 !
854 // 7 is the SDD beam test version
855 // Inputs:
6cae184e 856 // AliRawReader *rawReader Pointer to the raw-data reader
857 // TTree *treeR Clusters tree
7d62fb64 858 // Outputs:
859 // none.
860 // Return:
861 // none.
8484b32d 862 const char *all = strstr(opt,"All");
863 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
864 strstr(opt,"SSD")};
5d2c2f86 865 AliITSClusterFinder *rec = 0;
7d62fb64 866 Int_t id=0;
867
00a7cc50 868 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
6cae184e 869 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
7d62fb64 870 delete array;
871
8e50d897 872 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
873 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
7d62fb64 874 clusters[iModule] = NULL;
875 }
876 for(id=0;id<3;id++){
8484b32d 877 if (!all && !det[id]) continue;
5d2c2f86 878 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
c157c94e 879 if (!rec)
ff44c37c 880 AliFatal("The reconstruction class was not instantiated");
6cae184e 881 rec->SetDetTypeRec(this);
7d62fb64 882 rec->RawdataToClusters(rawReader,clusters);
883 }
884 Int_t nClusters =0;
c157c94e 885 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
8e50d897 886 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
8484b32d 887 id = GetITSgeom()->GetModuleType(iModule);
888 if (!all && !det[id]) continue;
7d62fb64 889 array = clusters[iModule];
890 if(!array){
c157c94e 891 AliDebug(1,Form("data for module %d missing!",iModule));
892 array = emptyArray;
7d62fb64 893 }
6cae184e 894 branch->SetAddress(&array);
895 treeR->Fill();
7d62fb64 896 nClusters+=array->GetEntriesFast();
5ef4644f 897
898 if (array != emptyArray) {
899 array->Delete();
900 delete array;
901 }
7d62fb64 902 }
c157c94e 903 delete emptyArray;
904
7d62fb64 905 delete[] clusters;
00a7cc50 906 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
7d62fb64 907 nClusters);
908
909}
910
88128115 911//______________________________________________________________________
912void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
913 AliITSNoiseSSDv2 *noiseSSD) {
914 //Reads the old SSD calibration object and converts it to the new format
915 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
916 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
917
3dd31ed2 918 Int_t gNMod = array->GetEntries();
88128115 919 cout<<"Converting old calibration object for noise..."<<endl;
920
921 //NOISE
922 Double_t noise = 0.0;
3dd31ed2 923 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 924 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
925 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
926 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
927 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
928 noiseSSD->AddNoiseP(iModule,iStrip,noise);
929 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
930 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
931 }//loop over strips
932 }//loop over modules
933}
934
935//______________________________________________________________________
936void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
937 AliITSBadChannelsSSDv2 *badChannelsSSD) {
938 //Reads the old SSD calibration object and converts it to the new format
3dd31ed2 939 Int_t gNMod = array->GetEntries();
88128115 940 cout<<"Converting old calibration object for bad channels..."<<endl;
3dd31ed2 941 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 942 //for (Int_t iModule = 0; iModule < 1; iModule++) {
943 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
944 TArrayI arrayPSide = bad->GetBadPChannelsList();
945 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
946 badChannelsSSD->AddBadChannelP(iModule,
947 iPCounter,
948 (Char_t)arrayPSide.At(iPCounter));
949
950 TArrayI arrayNSide = bad->GetBadNChannelsList();
951 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
952 badChannelsSSD->AddBadChannelN(iModule,
953 iNCounter,
954 (Char_t)arrayNSide.At(iNCounter));
955
956 }//loop over modules
957}
958
959//______________________________________________________________________
960void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
961 AliITSGainSSDv2 *gainSSD) {
962 //Reads the old SSD calibration object and converts it to the new format
963
3dd31ed2 964 Int_t gNMod = array->GetEntries();
88128115 965 cout<<"Converting old calibration object for gain..."<<endl;
966
967 //GAIN
3dd31ed2 968 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 969 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
970 TArrayF arrayPSide = gainModule->GetGainP();
971 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
972 gainSSD->AddGainP(iModule,
973 iPCounter,
974 arrayPSide.At(iPCounter));
975 TArrayF arrayNSide = gainModule->GetGainN();
976 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
977 gainSSD->AddGainN(iModule,
978 iNCounter,
979 arrayNSide.At(iNCounter));
980 }//loop over modules
981}
982
8ba39da9 983