1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Conributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 ////////////////////////////////////////////////////////////////////////
21 // This class defines the "Standard" reconstruction for the ITS //
24 ////////////////////////////////////////////////////////////////////////
25 #include "TObjArray.h"
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 "AliITSHLTforSDD.h"
53 #include "AliITSCalibrationSSD.h"
54 #include "AliITSNoiseSSDv2.h"
55 #include "AliITSGainSSDv2.h"
56 #include "AliITSBadChannelsSSDv2.h"
57 #include "AliITSNoiseSSD.h"
58 #include "AliITSGainSSD.h"
59 #include "AliITSBadChannelsSSD.h"
60 #include "AliITSsegmentationSPD.h"
61 #include "AliITSsegmentationSDD.h"
62 #include "AliITSsegmentationSSD.h"
66 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
67 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
68 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
69 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
71 ClassImp(AliITSDetTypeRec)
73 //________________________________________________________________
74 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
97 // Standard Constructor
105 fReconstruction = new TObjArray(fgkNdettypes);
106 fDigits = new TObjArray(fgkNdettypes);
107 for(Int_t i=0; i<3; i++){
108 fClusterClassName[i]=0;
110 fRecPointClassName[i]=0;
112 fSSDCalibration=new AliITSCalibrationSSD();
113 fNdtype = new Int_t[fgkNdettypes];
114 fCtype = new TObjArray(fgkNdettypes);
115 fNctype = new Int_t[fgkNdettypes];
116 fNMod = new Int_t [fgkNdettypes];
117 fNMod[0] = fgkDefaultNModulesSPD;
118 fNMod[1] = fgkDefaultNModulesSDD;
119 fNMod[2] = fgkDefaultNModulesSSD;
120 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
123 for(Int_t i=0;i<fgkNdettypes;i++){
131 //______________________________________________________________________
132 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
134 fITSgeom(rec.fITSgeom),
135 fReconstruction(rec.fReconstruction),
136 fSegmentation(rec.fSegmentation),
137 fCalibration(rec.fCalibration),
138 fSSDCalibration(rec.fSSDCalibration),
139 fSPDDead(rec.fSPDDead),
140 fPreProcess(rec.fPreProcess),
141 fPostProcess(rec.fPostProcess),
142 fDigits(rec.fDigits),
143 fDDLMapSDD(rec.fDDLMapSDD),
144 fRespSDD(rec.fRespSDD),
145 fAveGainSDD(rec.fAveGainSDD),
146 fIsHLTmodeC(rec.fIsHLTmodeC),
147 fNdtype(rec.fNdtype),
149 fNctype(rec.fNctype),
150 fRecPoints(rec.fRecPoints),
151 fNRecPoints(rec.fNRecPoints),
152 fSelectedVertexer(rec.fSelectedVertexer),
153 fFirstcall(rec.fFirstcall),
154 fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib){
159 //______________________________________________________________________
160 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
161 // Assignment operator.
162 this->~AliITSDetTypeRec();
163 new(this) AliITSDetTypeRec(source);
168 //_____________________________________________________________________
169 AliITSDetTypeRec::~AliITSDetTypeRec(){
173 fReconstruction->Delete();
174 delete fReconstruction;
178 fSegmentation->Delete();
179 delete fSegmentation;
183 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
184 fCalibration->Delete();
187 if(fRespSDD) delete fRespSDD;
188 if(fDDLMapSDD) delete fDDLMapSDD;
191 if(fSSDCalibration) delete fSSDCalibration;
193 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
199 if(fPreProcess) delete fPreProcess;
200 if(fPostProcess) delete fPostProcess;
207 fRecPoints->Delete();
220 if (fITSgeom) delete fITSgeom;
224 //___________________________________________________________________
225 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
227 //Set reconstruction model for detector type
229 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
230 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
231 fReconstruction->AddAt(clf,dettype);
233 //______________________________________________________________________
234 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
236 //Get reconstruction model for detector type
237 if(fReconstruction==0) {
238 Warning("GetReconstructionModel","fReconstruction is 0!");
241 return (AliITSClusterFinder*)fReconstruction->At(dettype);
244 //______________________________________________________________________
245 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
247 //Set segmentation model for detector type
249 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
250 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
251 fSegmentation->AddAt(seg,dettype);
254 //______________________________________________________________________
255 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
257 //Get segmentation model for detector type
259 if(fSegmentation==0) {
260 Warning("GetSegmentationModel","fSegmentation is 0!");
263 return (AliITSsegmentation*)fSegmentation->At(dettype);
266 //_______________________________________________________________________
267 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
269 //Set calibration (response) for the module iMod of type dettype
270 if (fCalibration==0) {
271 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
272 fCalibration->SetOwner(kTRUE);
273 fCalibration->Clear();
276 if (fCalibration->At(iMod) != 0)
277 delete (AliITSCalibration*) fCalibration->At(iMod);
278 fCalibration->AddAt(cal,iMod);
281 //_______________________________________________________________________
282 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
284 //Set dead pixel info for the SPD module iMod
286 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
287 fSPDDead->SetOwner(kTRUE);
291 if (fSPDDead->At(iMod) != 0)
292 delete (AliITSCalibration*) fSPDDead->At(iMod);
293 fSPDDead->AddAt(cal,iMod);
295 //_______________________________________________________________________
296 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
298 //Get calibration model for module type
300 if(fCalibration==0) {
301 Warning("GetalibrationModel","fCalibration is 0!");
305 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
306 return (AliITSCalibration*)fCalibration->At(iMod);
308 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
309 fSSDCalibration->SetModule(i);
310 return (AliITSCalibration*)fSSDCalibration;
314 //_______________________________________________________________________
315 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
317 //Get SPD dead for module iMod
320 AliWarning("fSPDDead is 0!");
324 return (AliITSCalibration*)fSPDDead->At(iMod);
327 //______________________________________________________________________
328 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
329 // Set branch address for the tree of digits.
331 const char *det[4] = {"SPD","SDD","SSD","ITS"};
338 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
339 for (i=0; i<fgkNdettypes; i++) {
340 digclass = GetDigitClassName(i);
341 if(!(fDigits->At(i))) {
342 fDigits->AddAt(new TClonesArray(digclass,1000),i);
346 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
347 else sprintf(branchname,"%sDigits%d",det[3],i+1);
349 branch = treeD->GetBranch(branchname);
350 if (branch) branch->SetAddress(&((*fDigits)[i]));
355 //_______________________________________________________________________
356 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
357 const char *classname,
358 void* address,Int_t size,
362 // Makes branch in given tree and diverts them to a separate file
368 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
371 TBranch *branch = tree->GetBranch(name);
376 branch = tree->Branch(name,classname,address,size,splitlevel);
379 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
385 //____________________________________________________________________
386 void AliITSDetTypeRec::SetDefaults(){
388 //Set defaults for segmentation and response
391 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
395 AliITSsegmentation* seg;
396 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
398 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
400 seg = new AliITSsegmentationSPD();
401 SetSegmentationModel(dettype,seg);
402 SetDigitClassName(dettype,"AliITSdigitSPD");
403 SetClusterClassName(dettype,"AliITSRawClusterSPD");
406 if(fLoadOnlySPDCalib==kFALSE){
408 seg = new AliITSsegmentationSDD();
409 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
410 if(cal->IsAMAt20MHz()){
411 seg->SetPadSize(seg->Dpz(0),20.);
412 seg->SetNPads(seg->Npz()/2,128);
414 SetSegmentationModel(dettype,seg);
415 SetDigitClassName(dettype,"AliITSdigitSDD");
416 SetClusterClassName(dettype,"AliITSRawClusterSDD");
420 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
421 SetSegmentationModel(dettype,seg2);
422 SetDigitClassName(dettype,"AliITSdigitSSD");
423 SetClusterClassName(dettype,"AliITSRawClusterSSD");
427 //______________________________________________________________________
428 Bool_t AliITSDetTypeRec::GetCalibration() {
429 // Get Default calibration if a storage is not defined.
432 AliITSCalibration* cal = GetCalibrationModel(0);
438 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
439 // Int_t run=GetRunNumber();
441 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
442 if (fCalibration==0) {
443 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
444 fCalibration->SetOwner(!cacheStatus);
445 fCalibration->Clear();
448 Bool_t retCode=GetCalibrationSPD(cacheStatus);
449 if(retCode==kFALSE) return kFALSE;
451 if(fLoadOnlySPDCalib==kFALSE){
452 retCode=GetCalibrationSDD(cacheStatus);
453 if(retCode==kFALSE) return kFALSE;
454 retCode=GetCalibrationSSD(cacheStatus);
455 if(retCode==kFALSE) return kFALSE;
458 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
459 fNMod[0], fNMod[1], fNMod[2]));
462 //______________________________________________________________________
463 Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
464 // Get SPD calibration objects from OCDB
465 // dead pixel are not used for local reconstruction
467 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
468 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
469 if(!entrySPD || !deadSPD ){
470 AliFatal("SPD Calibration object retrieval failed! ");
474 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
475 if(!cacheStatus)entrySPD->SetObject(NULL);
476 entrySPD->SetOwner(kTRUE);
478 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
479 if(!cacheStatus)deadSPD->SetObject(NULL);
480 deadSPD->SetOwner(kTRUE);
486 if ((!calSPD) || (!caldeadSPD)){
487 AliWarning("Can not get SPD calibration from calibration database !");
491 fNMod[0] = calSPD->GetEntries();
493 AliITSCalibration* cal;
494 for (Int_t i=0; i<fNMod[0]; i++) {
495 cal = (AliITSCalibration*) calSPD->At(i);
496 SetCalibrationModel(i, cal);
497 cal = (AliITSCalibration*) caldeadSPD->At(i);
498 SetSPDDeadModel(i, cal);
504 //______________________________________________________________________
505 Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) {
506 // Get SDD calibration objects from OCDB
508 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
509 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
510 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
511 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
512 AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
513 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
514 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
516 if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){
517 AliFatal("SDD Calibration object retrieval failed! ");
523 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
524 if(!cacheStatus)entrySDD->SetObject(NULL);
525 entrySDD->SetOwner(kTRUE);
527 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
528 if(!cacheStatus)entry2SDD->SetObject(NULL);
529 entry2SDD->SetOwner(kTRUE);
531 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
532 if(!cacheStatus)drSpSDD->SetObject(NULL);
533 drSpSDD->SetOwner(kTRUE);
535 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
536 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
537 ddlMapSDD->SetOwner(kTRUE);
539 AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject();
540 if(!cacheStatus)hltforSDD->SetObject(NULL);
541 hltforSDD->SetOwner(kTRUE);
543 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
544 // if(!cacheStatus)mapASDD->SetObject(NULL);
545 // mapASDD->SetOwner(kTRUE);
547 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
548 if(!cacheStatus)mapTSDD->SetObject(NULL);
549 mapTSDD->SetOwner(kTRUE);
552 // DB entries are deleted. In this way metadeta objects are deleted as well
563 if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) || (!mapT) ){
564 AliWarning("Can not get SDD calibration from calibration database !");
568 fNMod[1] = calSDD->GetEntries();
572 fIsHLTmodeC=hltsdd->IsHLTmodeC();
573 AliITSCalibration* cal;
576 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
577 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
578 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
579 if(iMod==-1) continue;
580 Int_t i=iMod - fgkDefaultNModulesSPD;
581 cal = (AliITSCalibration*) calSDD->At(i);
584 for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
585 if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
586 avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
589 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
590 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
591 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
592 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
593 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
594 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
595 cal->SetDriftSpeed(0,arr0);
596 cal->SetDriftSpeed(1,arr1);
597 // cal->SetMapA(0,ma0);
598 // cal->SetMapA(1,ma1);
601 SetCalibrationModel(iMod, cal);
604 if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
609 //______________________________________________________________________
610 Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
611 // Get SSD calibration objects from OCDB
612 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
614 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
615 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
616 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
618 if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){
619 AliFatal("SSD Calibration object retrieval failed! ");
623 TObject *emptyssd = 0; TString ssdobjectname = 0;
624 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
625 emptyssd = (TObject *)entryNoiseSSD->GetObject();
626 ssdobjectname = emptyssd->GetName();
627 if(ssdobjectname=="TObjArray") {
628 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
629 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
631 else if(ssdobjectname=="AliITSNoiseSSDv2")
632 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
633 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
634 entryNoiseSSD->SetOwner(kTRUE);
636 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
637 emptyssd = (TObject *)entryGainSSD->GetObject();
638 ssdobjectname = emptyssd->GetName();
639 if(ssdobjectname=="Gain") {
640 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
641 ReadOldSSDGain(gainSSDOld, gainSSD);
643 else if(ssdobjectname=="AliITSGainSSDv2")
644 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
645 if(!cacheStatus)entryGainSSD->SetObject(NULL);
646 entryGainSSD->SetOwner(kTRUE);
648 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
649 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
650 ssdobjectname = emptyssd->GetName();
651 if(ssdobjectname=="TObjArray") {
652 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
653 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
655 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
656 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
657 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
658 entryBadChannelsSSD->SetOwner(kTRUE);
660 // DB entries are deleted. In this way metadeta objects are deleted as well
662 delete entryNoiseSSD;
664 delete entryBadChannelsSSD;
667 if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
668 AliWarning("Can not get SSD calibration from calibration database !");
672 fSSDCalibration->SetNoise(noiseSSD);
673 fSSDCalibration->SetGain(gainSSD);
674 fSSDCalibration->SetBadChannels(badChannelsSSD);
675 //fSSDCalibration->FillBadChipMap();
680 //________________________________________________________________
681 void AliITSDetTypeRec::SetDefaultClusterFinders(){
683 //set defaults for standard cluster finder
686 Warning("SetDefaults","null pointer to AliITSgeom!");
690 AliITSClusterFinder *clf;
692 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
695 if(!GetReconstructionModel(dettype)){
696 TClonesArray *dig0 = DigitsAddress(0);
697 TClonesArray *rec0 = ClustersAddress(0);
698 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
699 SetReconstructionModel(dettype,clf);
706 if(!GetReconstructionModel(dettype)){
707 TClonesArray *dig1 = DigitsAddress(1);
708 TClonesArray *rec1 = ClustersAddress(1);
709 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
710 SetReconstructionModel(dettype,clf);
716 if(!GetReconstructionModel(dettype)){
717 TClonesArray* dig2 = DigitsAddress(2);
718 clf = new AliITSClusterFinderSSD(this,dig2);
719 SetReconstructionModel(dettype,clf);
728 //________________________________________________________________
729 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
731 //Set defaults for cluster finder V2
734 Warning("SetDefaults","Null pointer to AliITSgeom !");
738 AliITSClusterFinder *clf;
740 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
743 if(!GetReconstructionModel(dettype)){
744 clf = new AliITSClusterFinderV2SPD(this);
746 if(!rawdata) clf->SetDigits(DigitsAddress(0));
747 SetReconstructionModel(dettype,clf);
753 if(!GetReconstructionModel(dettype)){
754 clf = new AliITSClusterFinderV2SDD(this);
756 if(!rawdata) clf->SetDigits(DigitsAddress(1));
757 SetReconstructionModel(dettype,clf);
764 if(!GetReconstructionModel(dettype)){
765 clf = new AliITSClusterFinderV2SSD(this);
767 if(!rawdata) clf->SetDigits(DigitsAddress(2));
768 SetReconstructionModel(dettype,clf);
775 //______________________________________________________________________
776 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
778 //Creates branches for clusters and recpoints
779 Bool_t cR = (strstr(option,"R")!=0);
780 Bool_t cRF = (strstr(option,"RF")!=0);
784 if(cR) MakeBranchR(tree);
785 if(cRF) MakeBranchRF(tree);
789 //___________________________________________________________________
790 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
792 // Adds a raw cluster to the list
793 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
796 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
799 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
802 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
806 //___________________________________________________________________
807 void AliITSDetTypeRec::ResetDigits(){
808 // Reset number of digits and the digits array for the ITS detector.
811 for(Int_t i=0;i<fgkNdettypes;i++){
815 //___________________________________________________________________
816 void AliITSDetTypeRec::ResetDigits(Int_t branch){
817 // Reset number of digits and the digits array for this branch.
819 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
820 if(fNdtype) fNdtype[branch]=0;
824 //__________________________________________________________________
825 void AliITSDetTypeRec::ResetClusters(){
827 //Resets number of clusters and the cluster array
828 for(Int_t i=0;i<fgkNdettypes;i++){
833 //__________________________________________________________________
834 void AliITSDetTypeRec::ResetClusters(Int_t i){
836 //Resets number of clusters and the cluster array for this branch
838 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
839 if (fNctype) fNctype[i]=0;
841 //__________________________________________________________________
842 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
844 //Creates tree branches for recpoints
846 // cont char *file File name where RecPoints branch is to be written
847 // to. If blank it write the SDigits to the same
848 // file in which the Hits were found.
853 // only one branch for rec points for all detector types
854 Bool_t oFast= (strstr(opt,"Fast")!=0);
856 Char_t detname[10] = "ITS";
860 sprintf(branchname,"%sRecPointsF",detname);
862 sprintf(branchname,"%sRecPoints",detname);
865 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
867 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
869 //______________________________________________________________________
870 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
871 // Set branch address for the Reconstructed points Trees.
873 // TTree *treeR Tree containing the RecPoints.
879 Char_t namedet[10]="ITS";
882 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
884 sprintf(branchname,"%sRecPoints",namedet);
885 branch = treeR->GetBranch(branchname);
887 branch->SetAddress(&fRecPoints);
889 sprintf(branchname,"%sRecPointsF",namedet);
890 branch = treeR->GetBranch(branchname);
892 branch->SetAddress(&fRecPoints);
897 //____________________________________________________________________
898 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
899 // Add a reconstructed space point to the list
901 // const AliITSRecPoint &r RecPoint class to be added to the tree
902 // of reconstructed points TreeR.
908 TClonesArray &lrecp = *fRecPoints;
909 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
912 //______________________________________________________________________
913 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
914 // cluster finding and reconstruction of space points
915 // the condition below will disappear when the geom class will be
916 // initialized for all versions - for the moment it is only for v5 !
917 // 7 is the SDD beam test version
919 // TTree *treeD Digits tree
920 // TTree *treeR Clusters tree
921 // Int_t lastentry Offset for module when not all of the modules
923 // Option_t *opt String indicating which ITS sub-detectors should
924 // be processed. If ="All" then all of the ITS
925 // sub detectors are processed.
927 const char *all = strstr(opt,"All");
928 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
931 SetDefaultClusterFinders();
932 AliInfo("Original cluster finder has been selected\n");
935 SetDefaultClusterFindersV2();
936 AliInfo("V2 cluster finder has been selected \n");
939 AliITSClusterFinder *rec = 0;
940 Int_t id,module,first=0;
941 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
942 id = GetITSgeom()->GetModuleType(module);
943 if (!all && !det[id]) continue;
944 if(det[id]) first = GetITSgeom()->GetStartDet(id);
945 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
946 TClonesArray *itsDigits = DigitsAddress(id);
948 AliFatal("The reconstruction class was not instanciated!");
949 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
951 treeD->GetEvent(lastentry+module);
953 treeD->GetEvent(lastentry+(module-first));
955 Int_t ndigits = itsDigits->GetEntriesFast();
957 rec->SetDetTypeRec(this);
958 rec->SetDigits(DigitsAddress(id));
959 // rec->SetClusters(ClustersAddress(id));
960 rec->FindRawClusters(module);
967 //______________________________________________________________________
968 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
969 // cluster finding and reconstruction of space points
970 // the condition below will disappear when the geom class will be
971 // initialized for all versions - for the moment it is only for v5 !
972 // 7 is the SDD beam test version
974 // AliRawReader *rawReader Pointer to the raw-data reader
975 // TTree *treeR Clusters tree
980 const char *all = strstr(opt,"All");
981 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
983 AliITSClusterFinderV2 *rec = 0;
986 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
987 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
990 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
991 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
992 clusters[iModule] = NULL;
995 if (!all && !det[id]) continue;
996 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
998 AliFatal("The reconstruction class was not instanciated");
999 rec->SetDetTypeRec(this);
1000 rec->RawdataToClusters(rawReader,clusters);
1003 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
1004 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
1005 id = GetITSgeom()->GetModuleType(iModule);
1006 if (!all && !det[id]) continue;
1007 array = clusters[iModule];
1009 AliDebug(1,Form("data for module %d missing!",iModule));
1012 branch->SetAddress(&array);
1014 nClusters+=array->GetEntriesFast();
1016 if (array != emptyArray) {
1024 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
1029 //______________________________________________________________________
1030 void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
1031 AliITSNoiseSSDv2 *noiseSSD) {
1032 //Reads the old SSD calibration object and converts it to the new format
1033 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
1034 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
1036 Int_t gNMod = array->GetEntries();
1037 cout<<"Converting old calibration object for noise..."<<endl;
1040 Double_t noise = 0.0;
1041 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
1042 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
1043 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
1044 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
1045 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
1046 noiseSSD->AddNoiseP(iModule,iStrip,noise);
1047 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
1048 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
1050 }//loop over modules
1053 //______________________________________________________________________
1054 void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
1055 AliITSBadChannelsSSDv2 *badChannelsSSD) {
1056 //Reads the old SSD calibration object and converts it to the new format
1057 Int_t gNMod = array->GetEntries();
1058 cout<<"Converting old calibration object for bad channels..."<<endl;
1059 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
1060 //for (Int_t iModule = 0; iModule < 1; iModule++) {
1061 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
1062 TArrayI arrayPSide = bad->GetBadPChannelsList();
1063 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1064 badChannelsSSD->AddBadChannelP(iModule,
1066 (Char_t)arrayPSide.At(iPCounter));
1068 TArrayI arrayNSide = bad->GetBadNChannelsList();
1069 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1070 badChannelsSSD->AddBadChannelN(iModule,
1072 (Char_t)arrayNSide.At(iNCounter));
1074 }//loop over modules
1077 //______________________________________________________________________
1078 void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
1079 AliITSGainSSDv2 *gainSSD) {
1080 //Reads the old SSD calibration object and converts it to the new format
1082 Int_t gNMod = array->GetEntries();
1083 cout<<"Converting old calibration object for gain..."<<endl;
1086 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
1087 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1088 TArrayF arrayPSide = gainModule->GetGainP();
1089 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1090 gainSSD->AddGainP(iModule,
1092 arrayPSide.At(iPCounter));
1093 TArrayF arrayNSide = gainModule->GetGainN();
1094 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1095 gainSSD->AddGainN(iModule,
1097 arrayNSide.At(iNCounter));
1098 }//loop over modules