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(),
95 // Standard Constructor
103 fReconstruction = new TObjArray(fgkNdettypes);
104 fDigits = new TObjArray(fgkNdettypes);
105 for(Int_t i=0; i<3; i++){
106 fClusterClassName[i]=0;
108 fRecPointClassName[i]=0;
110 fSSDCalibration=new AliITSCalibrationSSD();
111 fNdtype = new Int_t[fgkNdettypes];
112 fCtype = new TObjArray(fgkNdettypes);
113 fNctype = new Int_t[fgkNdettypes];
114 fNMod = new Int_t [fgkNdettypes];
115 fNMod[0] = fgkDefaultNModulesSPD;
116 fNMod[1] = fgkDefaultNModulesSDD;
117 fNMod[2] = fgkDefaultNModulesSSD;
118 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
121 for(Int_t i=0;i<fgkNdettypes;i++){
129 //______________________________________________________________________
130 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
132 fITSgeom(rec.fITSgeom),
133 fReconstruction(rec.fReconstruction),
134 fSegmentation(rec.fSegmentation),
135 fCalibration(rec.fCalibration),
136 fSSDCalibration(rec.fSSDCalibration),
137 fSPDDead(rec.fSPDDead),
138 fPreProcess(rec.fPreProcess),
139 fPostProcess(rec.fPostProcess),
140 fDigits(rec.fDigits),
141 fDDLMapSDD(rec.fDDLMapSDD),
142 fRespSDD(rec.fRespSDD),
143 fIsHLTmodeC(rec.fIsHLTmodeC),
144 fNdtype(rec.fNdtype),
146 fNctype(rec.fNctype),
147 fRecPoints(rec.fRecPoints),
148 fNRecPoints(rec.fNRecPoints),
149 fSelectedVertexer(rec.fSelectedVertexer),
150 fFirstcall(rec.fFirstcall)
156 //______________________________________________________________________
157 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
158 // Assignment operator.
159 this->~AliITSDetTypeRec();
160 new(this) AliITSDetTypeRec(source);
165 //_____________________________________________________________________
166 AliITSDetTypeRec::~AliITSDetTypeRec(){
170 fReconstruction->Delete();
171 delete fReconstruction;
175 fSegmentation->Delete();
176 delete fSegmentation;
180 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
181 fCalibration->Delete();
184 if(fRespSDD) delete fRespSDD;
185 if(fDDLMapSDD) delete fDDLMapSDD;
188 if(fSSDCalibration) delete fSSDCalibration;
190 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
196 if(fPreProcess) delete fPreProcess;
197 if(fPostProcess) delete fPostProcess;
204 fRecPoints->Delete();
217 if (fITSgeom) delete fITSgeom;
221 //___________________________________________________________________
222 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
224 //Set reconstruction model for detector type
226 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
227 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
228 fReconstruction->AddAt(clf,dettype);
230 //______________________________________________________________________
231 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
233 //Get reconstruction model for detector type
234 if(fReconstruction==0) {
235 Warning("GetReconstructionModel","fReconstruction is 0!");
238 return (AliITSClusterFinder*)fReconstruction->At(dettype);
241 //______________________________________________________________________
242 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
244 //Set segmentation model for detector type
246 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
247 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
248 fSegmentation->AddAt(seg,dettype);
251 //______________________________________________________________________
252 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
254 //Get segmentation model for detector type
256 if(fSegmentation==0) {
257 Warning("GetSegmentationModel","fSegmentation is 0!");
260 return (AliITSsegmentation*)fSegmentation->At(dettype);
263 //_______________________________________________________________________
264 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
266 //Set calibration (response) for the module iMod of type dettype
267 if (fCalibration==0) {
268 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
269 fCalibration->SetOwner(kTRUE);
270 fCalibration->Clear();
273 if (fCalibration->At(iMod) != 0)
274 delete (AliITSCalibration*) fCalibration->At(iMod);
275 fCalibration->AddAt(cal,iMod);
278 //_______________________________________________________________________
279 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
281 //Set dead pixel info for the SPD module iMod
283 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
284 fSPDDead->SetOwner(kTRUE);
288 if (fSPDDead->At(iMod) != 0)
289 delete (AliITSCalibration*) fSPDDead->At(iMod);
290 fSPDDead->AddAt(cal,iMod);
292 //_______________________________________________________________________
293 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
295 //Get calibration model for module type
297 if(fCalibration==0) {
298 Warning("GetalibrationModel","fCalibration is 0!");
302 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
303 return (AliITSCalibration*)fCalibration->At(iMod);
305 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
306 fSSDCalibration->SetModule(i);
307 return (AliITSCalibration*)fSSDCalibration;
311 //_______________________________________________________________________
312 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
314 //Get SPD dead for module iMod
317 AliWarning("fSPDDead is 0!");
321 return (AliITSCalibration*)fSPDDead->At(iMod);
324 //______________________________________________________________________
325 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
326 // Set branch address for the tree of digits.
328 const char *det[4] = {"SPD","SDD","SSD","ITS"};
335 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
336 for (i=0; i<fgkNdettypes; i++) {
337 digclass = GetDigitClassName(i);
338 if(!(fDigits->At(i))) {
339 fDigits->AddAt(new TClonesArray(digclass,1000),i);
343 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
344 else sprintf(branchname,"%sDigits%d",det[3],i+1);
346 branch = treeD->GetBranch(branchname);
347 if (branch) branch->SetAddress(&((*fDigits)[i]));
352 //_______________________________________________________________________
353 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
354 const char *classname,
355 void* address,Int_t size,
359 // Makes branch in given tree and diverts them to a separate file
365 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
368 TBranch *branch = tree->GetBranch(name);
373 branch = tree->Branch(name,classname,address,size,splitlevel);
376 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
382 //____________________________________________________________________
383 void AliITSDetTypeRec::SetDefaults(){
385 //Set defaults for segmentation and response
388 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
392 AliITSsegmentation* seg;
393 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
395 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
397 seg = new AliITSsegmentationSPD();
398 SetSegmentationModel(dettype,seg);
399 SetDigitClassName(dettype,"AliITSdigitSPD");
400 SetClusterClassName(dettype,"AliITSRawClusterSPD");
404 seg = new AliITSsegmentationSDD();
405 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
406 if(cal->IsAMAt20MHz()){
407 seg->SetPadSize(seg->Dpz(0),20.);
408 seg->SetNPads(seg->Npz()/2,128);
410 SetSegmentationModel(dettype,seg);
411 SetDigitClassName(dettype,"AliITSdigitSDD");
412 SetClusterClassName(dettype,"AliITSRawClusterSDD");
415 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
416 SetSegmentationModel(dettype,seg2);
417 SetDigitClassName(dettype,"AliITSdigitSSD");
418 SetClusterClassName(dettype,"AliITSRawClusterSSD");
423 //______________________________________________________________________
424 Bool_t AliITSDetTypeRec::GetCalibration() {
425 // Get Default calibration if a storage is not defined.
428 AliITSCalibration* cal = GetCalibrationModel(0);
435 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
436 // Int_t run=GetRunNumber();
438 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
439 if (fCalibration==0) {
440 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
441 fCalibration->SetOwner(!cacheStatus);
442 fCalibration->Clear();
445 // dead pixel are not used for local reconstruction
446 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
447 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
448 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
450 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
451 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
452 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
453 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
454 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
455 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
456 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
457 AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
458 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
459 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
461 if(!entrySPD || !deadSPD || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
462 !entryBadChannelsSSD ||
463 !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){
464 AliFatal("Calibration object retrieval failed! ");
468 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
469 if(!cacheStatus)entrySPD->SetObject(NULL);
470 entrySPD->SetOwner(kTRUE);
472 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
473 if(!cacheStatus)deadSPD->SetObject(NULL);
474 deadSPD->SetOwner(kTRUE);
477 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
478 if(!cacheStatus)entrySDD->SetObject(NULL);
479 entrySDD->SetOwner(kTRUE);
481 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
482 if(!cacheStatus)entry2SDD->SetObject(NULL);
483 entry2SDD->SetOwner(kTRUE);
485 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
486 if(!cacheStatus)drSpSDD->SetObject(NULL);
487 drSpSDD->SetOwner(kTRUE);
489 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
490 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
491 ddlMapSDD->SetOwner(kTRUE);
493 AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject();
494 if(!cacheStatus)hltforSDD->SetObject(NULL);
495 hltforSDD->SetOwner(kTRUE);
497 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
498 // if(!cacheStatus)mapASDD->SetObject(NULL);
499 // mapASDD->SetOwner(kTRUE);
501 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
502 if(!cacheStatus)mapTSDD->SetObject(NULL);
503 mapTSDD->SetOwner(kTRUE);
505 TObject *emptyssd = 0; TString ssdobjectname = 0;
506 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
507 emptyssd = (TObject *)entryNoiseSSD->GetObject();
508 ssdobjectname = emptyssd->GetName();
509 if(ssdobjectname=="TObjArray") {
510 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
511 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
513 else if(ssdobjectname=="AliITSNoiseSSDv2")
514 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
515 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
516 entryNoiseSSD->SetOwner(kTRUE);
518 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
519 emptyssd = (TObject *)entryGainSSD->GetObject();
520 ssdobjectname = emptyssd->GetName();
521 if(ssdobjectname=="Gain") {
522 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
523 ReadOldSSDGain(gainSSDOld, gainSSD);
525 else if(ssdobjectname=="AliITSGainSSDv2")
526 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
527 if(!cacheStatus)entryGainSSD->SetObject(NULL);
528 entryGainSSD->SetOwner(kTRUE);
530 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
531 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
532 ssdobjectname = emptyssd->GetName();
533 if(ssdobjectname=="TObjArray") {
534 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
535 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
537 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
538 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
539 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
540 entryBadChannelsSSD->SetOwner(kTRUE);
542 // DB entries are deleted. In this way metadeta objects are deleted as well
547 delete entryNoiseSSD;
549 delete entryBadChannelsSSD;
558 if ((!pSDD)|| (!calSPD) || (!caldeadSPD) ||(!calSDD) || (!drSp) || (!ddlsdd)
559 || (!hltsdd) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
560 AliWarning("Can not get calibration from calibration database !");
564 fNMod[0] = calSPD->GetEntries();
565 fNMod[1] = calSDD->GetEntries();
566 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
567 fNMod[0], fNMod[1], fNMod[2]));
568 AliITSCalibration* cal;
569 for (Int_t i=0; i<fNMod[0]; i++) {
570 cal = (AliITSCalibration*) calSPD->At(i);
571 SetCalibrationModel(i, cal);
572 cal = (AliITSCalibration*) caldeadSPD->At(i);
573 SetSPDDeadModel(i, cal);
578 fIsHLTmodeC=hltsdd->IsHLTmodeC();
579 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
580 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
581 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
582 if(iMod==-1) continue;
583 Int_t i=iMod - fgkDefaultNModulesSPD;
584 cal = (AliITSCalibration*) calSDD->At(i);
587 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
588 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
589 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
590 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
591 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
592 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
593 cal->SetDriftSpeed(0,arr0);
594 cal->SetDriftSpeed(1,arr1);
595 // cal->SetMapA(0,ma0);
596 // cal->SetMapA(1,ma1);
599 SetCalibrationModel(iMod, cal);
603 fSSDCalibration->SetNoise(noiseSSD);
604 fSSDCalibration->SetGain(gainSSD);
605 fSSDCalibration->SetBadChannels(badChannelsSSD);
606 //fSSDCalibration->FillBadChipMap();
614 //________________________________________________________________
615 void AliITSDetTypeRec::SetDefaultClusterFinders(){
617 //set defaults for standard cluster finder
620 Warning("SetDefaults","null pointer to AliITSgeom!");
624 AliITSClusterFinder *clf;
626 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
629 if(!GetReconstructionModel(dettype)){
630 TClonesArray *dig0 = DigitsAddress(0);
631 TClonesArray *rec0 = ClustersAddress(0);
632 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
633 SetReconstructionModel(dettype,clf);
640 if(!GetReconstructionModel(dettype)){
641 TClonesArray *dig1 = DigitsAddress(1);
642 TClonesArray *rec1 = ClustersAddress(1);
643 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
644 SetReconstructionModel(dettype,clf);
650 if(!GetReconstructionModel(dettype)){
651 TClonesArray* dig2 = DigitsAddress(2);
652 clf = new AliITSClusterFinderSSD(this,dig2);
653 SetReconstructionModel(dettype,clf);
662 //________________________________________________________________
663 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
665 //Set defaults for cluster finder V2
668 Warning("SetDefaults","Null pointer to AliITSgeom !");
672 AliITSClusterFinder *clf;
674 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
677 if(!GetReconstructionModel(dettype)){
678 clf = new AliITSClusterFinderV2SPD(this);
680 if(!rawdata) clf->SetDigits(DigitsAddress(0));
681 SetReconstructionModel(dettype,clf);
687 if(!GetReconstructionModel(dettype)){
688 clf = new AliITSClusterFinderV2SDD(this);
690 if(!rawdata) clf->SetDigits(DigitsAddress(1));
691 SetReconstructionModel(dettype,clf);
698 if(!GetReconstructionModel(dettype)){
699 clf = new AliITSClusterFinderV2SSD(this);
701 if(!rawdata) clf->SetDigits(DigitsAddress(2));
702 SetReconstructionModel(dettype,clf);
709 //______________________________________________________________________
710 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
712 //Creates branches for clusters and recpoints
713 Bool_t cR = (strstr(option,"R")!=0);
714 Bool_t cRF = (strstr(option,"RF")!=0);
718 if(cR) MakeBranchR(tree);
719 if(cRF) MakeBranchRF(tree);
723 //___________________________________________________________________
724 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
726 // Adds a raw cluster to the list
727 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
730 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
733 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
736 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
740 //___________________________________________________________________
741 void AliITSDetTypeRec::ResetDigits(){
742 // Reset number of digits and the digits array for the ITS detector.
745 for(Int_t i=0;i<fgkNdettypes;i++){
749 //___________________________________________________________________
750 void AliITSDetTypeRec::ResetDigits(Int_t branch){
751 // Reset number of digits and the digits array for this branch.
753 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
754 if(fNdtype) fNdtype[branch]=0;
758 //__________________________________________________________________
759 void AliITSDetTypeRec::ResetClusters(){
761 //Resets number of clusters and the cluster array
762 for(Int_t i=0;i<fgkNdettypes;i++){
767 //__________________________________________________________________
768 void AliITSDetTypeRec::ResetClusters(Int_t i){
770 //Resets number of clusters and the cluster array for this branch
772 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
773 if (fNctype) fNctype[i]=0;
775 //__________________________________________________________________
776 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
778 //Creates tree branches for recpoints
780 // cont char *file File name where RecPoints branch is to be written
781 // to. If blank it write the SDigits to the same
782 // file in which the Hits were found.
787 // only one branch for rec points for all detector types
788 Bool_t oFast= (strstr(opt,"Fast")!=0);
790 Char_t detname[10] = "ITS";
794 sprintf(branchname,"%sRecPointsF",detname);
796 sprintf(branchname,"%sRecPoints",detname);
799 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
801 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
803 //______________________________________________________________________
804 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
805 // Set branch address for the Reconstructed points Trees.
807 // TTree *treeR Tree containing the RecPoints.
813 Char_t namedet[10]="ITS";
816 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
818 sprintf(branchname,"%sRecPoints",namedet);
819 branch = treeR->GetBranch(branchname);
821 branch->SetAddress(&fRecPoints);
823 sprintf(branchname,"%sRecPointsF",namedet);
824 branch = treeR->GetBranch(branchname);
826 branch->SetAddress(&fRecPoints);
831 //____________________________________________________________________
832 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
833 // Add a reconstructed space point to the list
835 // const AliITSRecPoint &r RecPoint class to be added to the tree
836 // of reconstructed points TreeR.
842 TClonesArray &lrecp = *fRecPoints;
843 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
846 //______________________________________________________________________
847 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
848 // cluster finding and reconstruction of space points
849 // the condition below will disappear when the geom class will be
850 // initialized for all versions - for the moment it is only for v5 !
851 // 7 is the SDD beam test version
853 // TTree *treeD Digits tree
854 // TTree *treeR Clusters tree
855 // Int_t lastentry Offset for module when not all of the modules
857 // Option_t *opt String indicating which ITS sub-detectors should
858 // be processed. If ="All" then all of the ITS
859 // sub detectors are processed.
861 const char *all = strstr(opt,"All");
862 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
865 SetDefaultClusterFinders();
866 AliInfo("Original cluster finder has been selected\n");
869 SetDefaultClusterFindersV2();
870 AliInfo("V2 cluster finder has been selected \n");
873 AliITSClusterFinder *rec = 0;
874 Int_t id,module,first=0;
875 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
876 id = GetITSgeom()->GetModuleType(module);
877 if (!all && !det[id]) continue;
878 if(det[id]) first = GetITSgeom()->GetStartDet(id);
879 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
880 TClonesArray *itsDigits = DigitsAddress(id);
882 AliFatal("The reconstruction class was not instanciated!");
883 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
885 treeD->GetEvent(lastentry+module);
887 treeD->GetEvent(lastentry+(module-first));
889 Int_t ndigits = itsDigits->GetEntriesFast();
891 rec->SetDetTypeRec(this);
892 rec->SetDigits(DigitsAddress(id));
893 // rec->SetClusters(ClustersAddress(id));
894 rec->FindRawClusters(module);
901 //______________________________________________________________________
902 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
903 // cluster finding and reconstruction of space points
904 // the condition below will disappear when the geom class will be
905 // initialized for all versions - for the moment it is only for v5 !
906 // 7 is the SDD beam test version
908 // AliRawReader *rawReader Pointer to the raw-data reader
909 // TTree *treeR Clusters tree
914 const char *all = strstr(opt,"All");
915 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
917 AliITSClusterFinderV2 *rec = 0;
920 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
921 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
924 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
925 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
926 clusters[iModule] = NULL;
929 if (!all && !det[id]) continue;
930 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
932 AliFatal("The reconstruction class was not instanciated");
933 rec->SetDetTypeRec(this);
934 rec->RawdataToClusters(rawReader,clusters);
937 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
938 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
939 id = GetITSgeom()->GetModuleType(iModule);
940 if (!all && !det[id]) continue;
941 array = clusters[iModule];
943 AliDebug(1,Form("data for module %d missing!",iModule));
946 branch->SetAddress(&array);
948 nClusters+=array->GetEntriesFast();
950 if (array != emptyArray) {
958 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
963 //______________________________________________________________________
964 void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
965 AliITSNoiseSSDv2 *noiseSSD) {
966 //Reads the old SSD calibration object and converts it to the new format
967 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
968 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
970 Int_t fNMod = array->GetEntries();
971 cout<<"Converting old calibration object for noise..."<<endl;
974 Double_t noise = 0.0;
975 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
976 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
977 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
978 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
979 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
980 noiseSSD->AddNoiseP(iModule,iStrip,noise);
981 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
982 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
987 //______________________________________________________________________
988 void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
989 AliITSBadChannelsSSDv2 *badChannelsSSD) {
990 //Reads the old SSD calibration object and converts it to the new format
991 Int_t fNMod = array->GetEntries();
992 cout<<"Converting old calibration object for bad channels..."<<endl;
993 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
994 //for (Int_t iModule = 0; iModule < 1; iModule++) {
995 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
996 TArrayI arrayPSide = bad->GetBadPChannelsList();
997 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
998 badChannelsSSD->AddBadChannelP(iModule,
1000 (Char_t)arrayPSide.At(iPCounter));
1002 TArrayI arrayNSide = bad->GetBadNChannelsList();
1003 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1004 badChannelsSSD->AddBadChannelN(iModule,
1006 (Char_t)arrayNSide.At(iNCounter));
1008 }//loop over modules
1011 //______________________________________________________________________
1012 void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
1013 AliITSGainSSDv2 *gainSSD) {
1014 //Reads the old SSD calibration object and converts it to the new format
1016 Int_t fNMod = array->GetEntries();
1017 cout<<"Converting old calibration object for gain..."<<endl;
1020 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
1021 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1022 TArrayF arrayPSide = gainModule->GetGainP();
1023 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1024 gainSSD->AddGainP(iModule,
1026 arrayPSide.At(iPCounter));
1027 TArrayF arrayNSide = gainModule->GetGainN();
1028 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1029 gainSSD->AddGainN(iModule,
1031 arrayNSide.At(iNCounter));
1032 }//loop over modules