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