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