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