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 "AliITSCalibrationSSD.h"
53 #include "AliITSNoiseSSDv2.h"
54 #include "AliITSGainSSDv2.h"
55 #include "AliITSBadChannelsSSDv2.h"
56 #include "AliITSNoiseSSD.h"
57 #include "AliITSGainSSD.h"
58 #include "AliITSBadChannelsSSD.h"
59 #include "AliITSsegmentationSPD.h"
60 #include "AliITSsegmentationSDD.h"
61 #include "AliITSsegmentationSSD.h"
65 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
66 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
67 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
68 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
70 ClassImp(AliITSDetTypeRec)
72 //________________________________________________________________
73 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
93 // Standard Constructor
101 fReconstruction = new TObjArray(fgkNdettypes);
102 fDigits = new TObjArray(fgkNdettypes);
103 for(Int_t i=0; i<3; i++){
104 fClusterClassName[i]=0;
106 fRecPointClassName[i]=0;
108 fSSDCalibration=new AliITSCalibrationSSD();
109 fNdtype = new Int_t[fgkNdettypes];
110 fCtype = new TObjArray(fgkNdettypes);
111 fNctype = new Int_t[fgkNdettypes];
112 fNMod = new Int_t [fgkNdettypes];
113 fNMod[0] = fgkDefaultNModulesSPD;
114 fNMod[1] = fgkDefaultNModulesSDD;
115 fNMod[2] = fgkDefaultNModulesSSD;
116 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
119 for(Int_t i=0;i<fgkNdettypes;i++){
127 //______________________________________________________________________
128 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
130 fITSgeom(rec.fITSgeom),
131 fReconstruction(rec.fReconstruction),
132 fSegmentation(rec.fSegmentation),
133 fCalibration(rec.fCalibration),
134 fSSDCalibration(rec.fSSDCalibration),
135 fSPDDead(rec.fSPDDead),
136 fPreProcess(rec.fPreProcess),
137 fPostProcess(rec.fPostProcess),
138 fDigits(rec.fDigits),
139 fDDLMapSDD(rec.fDDLMapSDD),
140 fRespSDD(rec.fRespSDD),
141 fNdtype(rec.fNdtype),
143 fNctype(rec.fNctype),
144 fRecPoints(rec.fRecPoints),
145 fNRecPoints(rec.fNRecPoints),
146 fSelectedVertexer(rec.fSelectedVertexer),
147 fFirstcall(rec.fFirstcall)
153 //______________________________________________________________________
154 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
155 // Assignment operator.
156 this->~AliITSDetTypeRec();
157 new(this) AliITSDetTypeRec(source);
162 //_____________________________________________________________________
163 AliITSDetTypeRec::~AliITSDetTypeRec(){
167 fReconstruction->Delete();
168 delete fReconstruction;
172 fSegmentation->Delete();
173 delete fSegmentation;
177 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
178 fCalibration->Delete();
181 if(fRespSDD) delete fRespSDD;
182 if(fDDLMapSDD) delete fDDLMapSDD;
185 if(fSSDCalibration) delete fSSDCalibration;
187 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
193 if(fPreProcess) delete fPreProcess;
194 if(fPostProcess) delete fPostProcess;
201 fRecPoints->Delete();
214 if (fITSgeom) delete fITSgeom;
218 //___________________________________________________________________
219 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
221 //Set reconstruction model for detector type
223 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
224 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
225 fReconstruction->AddAt(clf,dettype);
227 //______________________________________________________________________
228 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
230 //Get reconstruction model for detector type
231 if(fReconstruction==0) {
232 Warning("GetReconstructionModel","fReconstruction is 0!");
235 return (AliITSClusterFinder*)fReconstruction->At(dettype);
238 //______________________________________________________________________
239 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
241 //Set segmentation model for detector type
243 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
244 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
245 fSegmentation->AddAt(seg,dettype);
248 //______________________________________________________________________
249 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
251 //Get segmentation model for detector type
253 if(fSegmentation==0) {
254 Warning("GetSegmentationModel","fSegmentation is 0!");
257 return (AliITSsegmentation*)fSegmentation->At(dettype);
260 //_______________________________________________________________________
261 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
263 //Set calibration (response) for the module iMod of type dettype
264 if (fCalibration==0) {
265 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
266 fCalibration->SetOwner(kTRUE);
267 fCalibration->Clear();
270 if (fCalibration->At(iMod) != 0)
271 delete (AliITSCalibration*) fCalibration->At(iMod);
272 fCalibration->AddAt(cal,iMod);
275 //_______________________________________________________________________
276 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
278 //Set dead pixel info for the SPD module iMod
280 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
281 fSPDDead->SetOwner(kTRUE);
285 if (fSPDDead->At(iMod) != 0)
286 delete (AliITSCalibration*) fSPDDead->At(iMod);
287 fSPDDead->AddAt(cal,iMod);
289 //_______________________________________________________________________
290 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
292 //Get calibration model for module type
294 if(fCalibration==0) {
295 Warning("GetalibrationModel","fCalibration is 0!");
299 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
300 return (AliITSCalibration*)fCalibration->At(iMod);
302 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
303 fSSDCalibration->SetModule(i);
304 return (AliITSCalibration*)fSSDCalibration;
308 //_______________________________________________________________________
309 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
311 //Get SPD dead for module iMod
314 AliWarning("fSPDDead is 0!");
318 return (AliITSCalibration*)fSPDDead->At(iMod);
321 //______________________________________________________________________
322 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
323 // Set branch address for the tree of digits.
325 const char *det[4] = {"SPD","SDD","SSD","ITS"};
332 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
333 for (i=0; i<fgkNdettypes; i++) {
334 digclass = GetDigitClassName(i);
335 if(!(fDigits->At(i))) {
336 fDigits->AddAt(new TClonesArray(digclass,1000),i);
340 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
341 else sprintf(branchname,"%sDigits%d",det[3],i+1);
343 branch = treeD->GetBranch(branchname);
344 if (branch) branch->SetAddress(&((*fDigits)[i]));
349 //_______________________________________________________________________
350 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
351 const char *classname,
352 void* address,Int_t size,
356 // Makes branch in given tree and diverts them to a separate file
362 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
365 TBranch *branch = tree->GetBranch(name);
370 branch = tree->Branch(name,classname,address,size,splitlevel);
373 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
379 //____________________________________________________________________
380 void AliITSDetTypeRec::SetDefaults(){
382 //Set defaults for segmentation and response
385 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
389 AliITSsegmentation* seg;
390 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
392 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
394 seg = new AliITSsegmentationSPD();
395 SetSegmentationModel(dettype,seg);
396 SetDigitClassName(dettype,"AliITSdigitSPD");
397 SetClusterClassName(dettype,"AliITSRawClusterSPD");
401 seg = new AliITSsegmentationSDD();
402 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
403 if(cal->IsAMAt20MHz()){
404 seg->SetPadSize(seg->Dpz(0),20.);
405 seg->SetNPads(seg->Npz()/2,128);
407 SetSegmentationModel(dettype,seg);
408 SetDigitClassName(dettype,"AliITSdigitSDD");
409 SetClusterClassName(dettype,"AliITSRawClusterSDD");
412 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
413 SetSegmentationModel(dettype,seg2);
414 SetDigitClassName(dettype,"AliITSdigitSSD");
415 SetClusterClassName(dettype,"AliITSRawClusterSSD");
420 //______________________________________________________________________
421 Bool_t AliITSDetTypeRec::GetCalibration() {
422 // Get Default calibration if a storage is not defined.
425 AliITSCalibration* cal = GetCalibrationModel(0);
432 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
433 // Int_t run=GetRunNumber();
435 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
436 if (fCalibration==0) {
437 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
438 fCalibration->SetOwner(!cacheStatus);
439 fCalibration->Clear();
442 // dead pixel are not used for local reconstruction
443 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
444 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
445 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
447 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
448 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
449 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
450 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
451 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
452 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
453 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
454 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
455 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
457 if(!entrySPD || !deadSPD || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
458 !entryBadChannelsSSD ||
459 !entry2SDD || !drSpSDD || !ddlMapSDD || !mapTSDD ){
460 AliFatal("Calibration object retrieval failed! ");
464 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
465 if(!cacheStatus)entrySPD->SetObject(NULL);
466 entrySPD->SetOwner(kTRUE);
468 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
469 if(!cacheStatus)deadSPD->SetObject(NULL);
470 deadSPD->SetOwner(kTRUE);
473 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
474 if(!cacheStatus)entrySDD->SetObject(NULL);
475 entrySDD->SetOwner(kTRUE);
477 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
478 if(!cacheStatus)entry2SDD->SetObject(NULL);
479 entry2SDD->SetOwner(kTRUE);
481 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
482 if(!cacheStatus)drSpSDD->SetObject(NULL);
483 drSpSDD->SetOwner(kTRUE);
485 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
486 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
487 ddlMapSDD->SetOwner(kTRUE);
489 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
490 // if(!cacheStatus)mapASDD->SetObject(NULL);
491 // mapASDD->SetOwner(kTRUE);
493 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
494 if(!cacheStatus)mapTSDD->SetObject(NULL);
495 mapTSDD->SetOwner(kTRUE);
497 TObject *emptyssd = 0; TString ssdobjectname = 0;
498 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
499 emptyssd = (TObject *)entryNoiseSSD->GetObject();
500 ssdobjectname = emptyssd->GetName();
501 if(ssdobjectname=="TObjArray") {
502 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
503 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
505 else if(ssdobjectname=="AliITSNoiseSSDv2")
506 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
507 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
508 entryNoiseSSD->SetOwner(kTRUE);
510 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
511 emptyssd = (TObject *)entryGainSSD->GetObject();
512 ssdobjectname = emptyssd->GetName();
513 if(ssdobjectname=="Gain") {
514 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
515 ReadOldSSDGain(gainSSDOld, gainSSD);
517 else if(ssdobjectname=="AliITSGainSSDv2")
518 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
519 if(!cacheStatus)entryGainSSD->SetObject(NULL);
520 entryGainSSD->SetOwner(kTRUE);
522 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
523 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
524 ssdobjectname = emptyssd->GetName();
525 if(ssdobjectname=="TObjArray") {
526 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
527 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
529 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
530 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
531 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
532 entryBadChannelsSSD->SetOwner(kTRUE);
534 // DB entries are deleted. In this way metadeta objects are deleted as well
539 delete entryNoiseSSD;
541 delete entryBadChannelsSSD;
549 if ((!pSDD)|| (!calSPD) || (!caldeadSPD) ||(!calSDD) || (!drSp) || (!ddlsdd)
550 || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
551 AliWarning("Can not get calibration from calibration database !");
555 fNMod[0] = calSPD->GetEntries();
556 fNMod[1] = calSDD->GetEntries();
557 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
558 fNMod[0], fNMod[1], fNMod[2]));
559 AliITSCalibration* cal;
560 for (Int_t i=0; i<fNMod[0]; i++) {
561 cal = (AliITSCalibration*) calSPD->At(i);
562 SetCalibrationModel(i, cal);
563 cal = (AliITSCalibration*) caldeadSPD->At(i);
564 SetSPDDeadModel(i, cal);
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);
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);
589 SetCalibrationModel(iMod, cal);
593 fSSDCalibration->SetNoise(noiseSSD);
594 fSSDCalibration->SetGain(gainSSD);
595 fSSDCalibration->SetBadChannels(badChannelsSSD);
596 //fSSDCalibration->FillBadChipMap();
604 //________________________________________________________________
605 void AliITSDetTypeRec::SetDefaultClusterFinders(){
607 //set defaults for standard cluster finder
610 Warning("SetDefaults","null pointer to AliITSgeom!");
614 AliITSClusterFinder *clf;
616 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
619 if(!GetReconstructionModel(dettype)){
620 TClonesArray *dig0 = DigitsAddress(0);
621 TClonesArray *rec0 = ClustersAddress(0);
622 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
623 SetReconstructionModel(dettype,clf);
630 if(!GetReconstructionModel(dettype)){
631 TClonesArray *dig1 = DigitsAddress(1);
632 TClonesArray *rec1 = ClustersAddress(1);
633 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
634 SetReconstructionModel(dettype,clf);
640 if(!GetReconstructionModel(dettype)){
641 TClonesArray* dig2 = DigitsAddress(2);
642 clf = new AliITSClusterFinderSSD(this,dig2);
643 SetReconstructionModel(dettype,clf);
652 //________________________________________________________________
653 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
655 //Set defaults for cluster finder V2
658 Warning("SetDefaults","Null pointer to AliITSgeom !");
662 AliITSClusterFinder *clf;
664 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
667 if(!GetReconstructionModel(dettype)){
668 clf = new AliITSClusterFinderV2SPD(this);
670 if(!rawdata) clf->SetDigits(DigitsAddress(0));
671 SetReconstructionModel(dettype,clf);
677 if(!GetReconstructionModel(dettype)){
678 clf = new AliITSClusterFinderV2SDD(this);
680 if(!rawdata) clf->SetDigits(DigitsAddress(1));
681 SetReconstructionModel(dettype,clf);
688 if(!GetReconstructionModel(dettype)){
689 clf = new AliITSClusterFinderV2SSD(this);
691 if(!rawdata) clf->SetDigits(DigitsAddress(2));
692 SetReconstructionModel(dettype,clf);
699 //______________________________________________________________________
700 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
702 //Creates branches for clusters and recpoints
703 Bool_t cR = (strstr(option,"R")!=0);
704 Bool_t cRF = (strstr(option,"RF")!=0);
708 if(cR) MakeBranchR(tree);
709 if(cRF) MakeBranchRF(tree);
713 //___________________________________________________________________
714 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
716 // Adds a raw cluster to the list
717 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
720 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
723 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
726 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
730 //___________________________________________________________________
731 void AliITSDetTypeRec::ResetDigits(){
732 // Reset number of digits and the digits array for the ITS detector.
735 for(Int_t i=0;i<fgkNdettypes;i++){
739 //___________________________________________________________________
740 void AliITSDetTypeRec::ResetDigits(Int_t branch){
741 // Reset number of digits and the digits array for this branch.
743 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
744 if(fNdtype) fNdtype[branch]=0;
748 //__________________________________________________________________
749 void AliITSDetTypeRec::ResetClusters(){
751 //Resets number of clusters and the cluster array
752 for(Int_t i=0;i<fgkNdettypes;i++){
757 //__________________________________________________________________
758 void AliITSDetTypeRec::ResetClusters(Int_t i){
760 //Resets number of clusters and the cluster array for this branch
762 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
763 if (fNctype) fNctype[i]=0;
765 //__________________________________________________________________
766 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
768 //Creates tree branches for recpoints
770 // cont char *file File name where RecPoints branch is to be written
771 // to. If blank it write the SDigits to the same
772 // file in which the Hits were found.
777 // only one branch for rec points for all detector types
778 Bool_t oFast= (strstr(opt,"Fast")!=0);
780 Char_t detname[10] = "ITS";
784 sprintf(branchname,"%sRecPointsF",detname);
786 sprintf(branchname,"%sRecPoints",detname);
789 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
791 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
793 //______________________________________________________________________
794 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
795 // Set branch address for the Reconstructed points Trees.
797 // TTree *treeR Tree containing the RecPoints.
803 Char_t namedet[10]="ITS";
806 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
808 sprintf(branchname,"%sRecPoints",namedet);
809 branch = treeR->GetBranch(branchname);
811 branch->SetAddress(&fRecPoints);
813 sprintf(branchname,"%sRecPointsF",namedet);
814 branch = treeR->GetBranch(branchname);
816 branch->SetAddress(&fRecPoints);
821 //____________________________________________________________________
822 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
823 // Add a reconstructed space point to the list
825 // const AliITSRecPoint &r RecPoint class to be added to the tree
826 // of reconstructed points TreeR.
832 TClonesArray &lrecp = *fRecPoints;
833 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
836 //______________________________________________________________________
837 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
838 // cluster finding and reconstruction of space points
839 // the condition below will disappear when the geom class will be
840 // initialized for all versions - for the moment it is only for v5 !
841 // 7 is the SDD beam test version
843 // TTree *treeD Digits tree
844 // TTree *treeR Clusters tree
845 // Int_t lastentry Offset for module when not all of the modules
847 // Option_t *opt String indicating which ITS sub-detectors should
848 // be processed. If ="All" then all of the ITS
849 // sub detectors are processed.
851 const char *all = strstr(opt,"All");
852 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
855 SetDefaultClusterFinders();
856 AliInfo("Original cluster finder has been selected\n");
859 SetDefaultClusterFindersV2();
860 AliInfo("V2 cluster finder has been selected \n");
863 AliITSClusterFinder *rec = 0;
864 Int_t id,module,first=0;
865 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
866 id = GetITSgeom()->GetModuleType(module);
867 if (!all && !det[id]) continue;
868 if(det[id]) first = GetITSgeom()->GetStartDet(id);
869 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
870 TClonesArray *itsDigits = DigitsAddress(id);
872 AliFatal("The reconstruction class was not instanciated!");
873 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
875 treeD->GetEvent(lastentry+module);
877 treeD->GetEvent(lastentry+(module-first));
879 Int_t ndigits = itsDigits->GetEntriesFast();
881 rec->SetDetTypeRec(this);
882 rec->SetDigits(DigitsAddress(id));
883 // rec->SetClusters(ClustersAddress(id));
884 rec->FindRawClusters(module);
891 //______________________________________________________________________
892 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
893 // cluster finding and reconstruction of space points
894 // the condition below will disappear when the geom class will be
895 // initialized for all versions - for the moment it is only for v5 !
896 // 7 is the SDD beam test version
898 // AliRawReader *rawReader Pointer to the raw-data reader
899 // TTree *treeR Clusters tree
904 const char *all = strstr(opt,"All");
905 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
907 AliITSClusterFinderV2 *rec = 0;
910 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
911 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
914 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
915 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
916 clusters[iModule] = NULL;
919 if (!all && !det[id]) continue;
920 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
922 AliFatal("The reconstruction class was not instanciated");
923 rec->SetDetTypeRec(this);
924 rec->RawdataToClusters(rawReader,clusters);
927 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
928 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
929 id = GetITSgeom()->GetModuleType(iModule);
930 if (!all && !det[id]) continue;
931 array = clusters[iModule];
933 AliDebug(1,Form("data for module %d missing!",iModule));
936 branch->SetAddress(&array);
938 nClusters+=array->GetEntriesFast();
940 if (array != emptyArray) {
948 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
953 //______________________________________________________________________
954 void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
955 AliITSNoiseSSDv2 *noiseSSD) {
956 //Reads the old SSD calibration object and converts it to the new format
957 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
958 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
960 Int_t fNMod = array->GetEntries();
961 cout<<"Converting old calibration object for noise..."<<endl;
964 Double_t noise = 0.0;
965 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
966 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
967 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
968 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
969 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
970 noiseSSD->AddNoiseP(iModule,iStrip,noise);
971 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
972 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
977 //______________________________________________________________________
978 void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
979 AliITSBadChannelsSSDv2 *badChannelsSSD) {
980 //Reads the old SSD calibration object and converts it to the new format
981 Int_t fNMod = array->GetEntries();
982 cout<<"Converting old calibration object for bad channels..."<<endl;
983 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
984 //for (Int_t iModule = 0; iModule < 1; iModule++) {
985 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
986 TArrayI arrayPSide = bad->GetBadPChannelsList();
987 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
988 badChannelsSSD->AddBadChannelP(iModule,
990 (Char_t)arrayPSide.At(iPCounter));
992 TArrayI arrayNSide = bad->GetBadNChannelsList();
993 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
994 badChannelsSSD->AddBadChannelN(iModule,
996 (Char_t)arrayNSide.At(iNCounter));
1001 //______________________________________________________________________
1002 void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
1003 AliITSGainSSDv2 *gainSSD) {
1004 //Reads the old SSD calibration object and converts it to the new format
1006 Int_t fNMod = array->GetEntries();
1007 cout<<"Converting old calibration object for gain..."<<endl;
1010 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
1011 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1012 TArrayF arrayPSide = gainModule->GetGainP();
1013 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1014 gainSSD->AddGainP(iModule,
1016 arrayPSide.At(iPCounter));
1017 TArrayF arrayNSide = gainModule->GetGainN();
1018 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1019 gainSSD->AddGainN(iModule,
1021 arrayNSide.At(iNCounter));
1022 }//loop over modules