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