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