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 "AliITSClusterFinderV2SPD.h"
33 #include "AliITSClusterFinderV2SDD.h"
34 #include "AliITSClusterFinderV2SSD.h"
35 #include "AliITSDetTypeRec.h"
36 #include "AliITSgeom.h"
37 #include "AliITSRecPoint.h"
38 #include "AliITSReconstructor.h"
39 #include "AliITSRecoParam.h"
40 #include "AliITSCalibrationSDD.h"
41 #include "AliITSMapSDD.h"
42 #include "AliITSDriftSpeedArraySDD.h"
43 #include "AliITSDriftSpeedSDD.h"
44 #include "AliITSHLTforSDD.h"
45 #include "AliITSCalibrationSSD.h"
46 #include "AliITSNoiseSSDv2.h"
47 #include "AliITSGainSSDv2.h"
48 #include "AliITSBadChannelsSSDv2.h"
49 #include "AliITSNoiseSSD.h"
50 #include "AliITSGainSSD.h"
51 #include "AliITSBadChannelsSSD.h"
52 #include "AliITSsegmentationSPD.h"
53 #include "AliITSsegmentationSDD.h"
54 #include "AliITSsegmentationSSD.h"
58 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
59 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
60 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
61 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
63 ClassImp(AliITSDetTypeRec)
65 //________________________________________________________________
66 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
90 fFastOrFiredMap(1200){
91 // Standard Constructor
99 fReconstruction = new TObjArray(fgkNdettypes);
100 fDigits = new TObjArray(fgkNdettypes);
101 for(Int_t i=0; i<3; i++){
104 fSSDCalibration=new AliITSCalibrationSSD();
105 fNdtype = new Int_t[fgkNdettypes];
106 fCtype = new TObjArray(fgkNdettypes);
107 fNctype = new Int_t[fgkNdettypes];
108 fNMod = new Int_t [fgkNdettypes];
109 fNMod[0] = fgkDefaultNModulesSPD;
110 fNMod[1] = fgkDefaultNModulesSDD;
111 fNMod[2] = fgkDefaultNModulesSSD;
112 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
115 for(Int_t i=0;i<fgkNdettypes;i++){
123 //______________________________________________________________________
124 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
126 fITSgeom(rec.fITSgeom),
127 fReconstruction(rec.fReconstruction),
128 fSegmentation(rec.fSegmentation),
129 fCalibration(rec.fCalibration),
130 fSSDCalibration(rec.fSSDCalibration),
131 fSPDDead(rec.fSPDDead),
132 fSPDFastOr(rec.fSPDFastOr),
133 fPreProcess(rec.fPreProcess),
134 fPostProcess(rec.fPostProcess),
135 fDigits(rec.fDigits),
136 fDDLMapSDD(rec.fDDLMapSDD),
137 fRespSDD(rec.fRespSDD),
138 fAveGainSDD(rec.fAveGainSDD),
139 fIsHLTmodeC(rec.fIsHLTmodeC),
140 fNdtype(rec.fNdtype),
142 fNctype(rec.fNctype),
143 fRecPoints(rec.fRecPoints),
144 fNRecPoints(rec.fNRecPoints),
145 fSelectedVertexer(rec.fSelectedVertexer),
146 fFirstcall(rec.fFirstcall),
147 fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib),
148 fFastOrFiredMap(rec.fFastOrFiredMap){
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"};
327 const Char_t* digclass;
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");
398 if(fLoadOnlySPDCalib==kFALSE){
400 seg = new AliITSsegmentationSDD();
401 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
402 if(cal->IsAMAt20MHz()){
403 seg->SetPadSize(seg->Dpz(0),20.);
404 seg->SetNPads(seg->Npz()/2,128);
406 SetSegmentationModel(dettype,seg);
407 SetDigitClassName(dettype,"AliITSdigitSDD");
411 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
412 SetSegmentationModel(dettype,seg2);
413 SetDigitClassName(dettype,"AliITSdigitSSD");
417 //______________________________________________________________________
418 Bool_t AliITSDetTypeRec::GetCalibration() {
419 // Get Default calibration if a storage is not defined.
422 AliITSCalibration* cal = GetCalibrationModel(0);
428 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
429 // Int_t run=GetRunNumber();
431 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
432 if (fCalibration==0) {
433 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
434 fCalibration->SetOwner(!cacheStatus);
435 fCalibration->Clear();
438 Bool_t retCode=GetCalibrationSPD(cacheStatus);
439 if(retCode==kFALSE) return kFALSE;
441 if(fLoadOnlySPDCalib==kFALSE){
442 retCode=GetCalibrationSDD(cacheStatus);
443 if(retCode==kFALSE) return kFALSE;
444 retCode=GetCalibrationSSD(cacheStatus);
445 if(retCode==kFALSE) return kFALSE;
448 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
449 fNMod[0], fNMod[1], fNMod[2]));
452 //______________________________________________________________________
453 Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
454 // Get SPD calibration objects from OCDB
455 // dead pixel are not used for local reconstruction
457 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
458 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
459 AliCDBEntry *fastOrSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFastOr");
460 if(!entrySPD || !deadSPD || !fastOrSPD ){
461 AliFatal("SPD Calibration object retrieval failed! ");
465 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
466 if(!cacheStatus)entrySPD->SetObject(NULL);
467 entrySPD->SetOwner(kTRUE);
469 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
470 if(!cacheStatus)deadSPD->SetObject(NULL);
471 deadSPD->SetOwner(kTRUE);
473 AliITSFastOrCalibrationSPD *calfastOrSPD = (AliITSFastOrCalibrationSPD *)fastOrSPD->GetObject();
474 if(!cacheStatus)fastOrSPD->SetObject(NULL);
475 fastOrSPD->SetOwner(kTRUE);
482 if ((!calSPD) || (!caldeadSPD) || (!calfastOrSPD)){
483 AliWarning("Can not get SPD calibration from calibration database !");
487 fNMod[0] = calSPD->GetEntries();
489 AliITSCalibration* cal;
490 for (Int_t i=0; i<fNMod[0]; i++) {
491 cal = (AliITSCalibration*) calSPD->At(i);
492 SetCalibrationModel(i, cal);
493 cal = (AliITSCalibration*) caldeadSPD->At(i);
494 SetSPDDeadModel(i, cal);
496 fSPDFastOr = calfastOrSPD;
501 //______________________________________________________________________
502 Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) {
503 // Get SDD calibration objects from OCDB
505 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
506 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
507 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
508 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
509 AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
510 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
511 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
513 if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){
514 AliFatal("SDD Calibration object retrieval failed! ");
520 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
521 if(!cacheStatus)entrySDD->SetObject(NULL);
522 entrySDD->SetOwner(kTRUE);
524 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
525 if(!cacheStatus)entry2SDD->SetObject(NULL);
526 entry2SDD->SetOwner(kTRUE);
528 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
529 if(!cacheStatus)drSpSDD->SetObject(NULL);
530 drSpSDD->SetOwner(kTRUE);
532 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
533 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
534 ddlMapSDD->SetOwner(kTRUE);
536 AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject();
537 if(!cacheStatus)hltforSDD->SetObject(NULL);
538 hltforSDD->SetOwner(kTRUE);
540 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
541 // if(!cacheStatus)mapASDD->SetObject(NULL);
542 // mapASDD->SetOwner(kTRUE);
544 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
545 if(!cacheStatus)mapTSDD->SetObject(NULL);
546 mapTSDD->SetOwner(kTRUE);
549 // DB entries are deleted. In this way metadeta objects are deleted as well
560 if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) || (!mapT) ){
561 AliWarning("Can not get SDD calibration from calibration database !");
565 fNMod[1] = calSDD->GetEntries();
569 fIsHLTmodeC=hltsdd->IsHLTmodeC();
570 AliITSCalibration* cal;
573 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
574 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
575 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
576 if(iMod==-1) continue;
577 Int_t i=iMod - fgkDefaultNModulesSPD;
578 cal = (AliITSCalibration*) calSDD->At(i);
581 for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
582 if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
583 avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
586 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
587 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
588 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
589 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
590 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
591 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
592 cal->SetDriftSpeed(0,arr0);
593 cal->SetDriftSpeed(1,arr1);
594 // cal->SetMapA(0,ma0);
595 // cal->SetMapA(1,ma1);
598 SetCalibrationModel(iMod, cal);
601 if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
606 //______________________________________________________________________
607 Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
608 // Get SSD calibration objects from OCDB
609 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
611 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
612 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
613 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
615 if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){
616 AliFatal("SSD Calibration object retrieval failed! ");
620 TObject *emptyssd = 0; TString ssdobjectname = 0;
621 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
622 emptyssd = (TObject *)entryNoiseSSD->GetObject();
623 ssdobjectname = emptyssd->GetName();
624 if(ssdobjectname=="TObjArray") {
625 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
626 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
628 else if(ssdobjectname=="AliITSNoiseSSDv2")
629 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
630 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
631 entryNoiseSSD->SetOwner(kTRUE);
633 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
634 emptyssd = (TObject *)entryGainSSD->GetObject();
635 ssdobjectname = emptyssd->GetName();
636 if(ssdobjectname=="Gain") {
637 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
638 ReadOldSSDGain(gainSSDOld, gainSSD);
640 else if(ssdobjectname=="AliITSGainSSDv2")
641 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
642 if(!cacheStatus)entryGainSSD->SetObject(NULL);
643 entryGainSSD->SetOwner(kTRUE);
645 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
646 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
647 ssdobjectname = emptyssd->GetName();
648 if(ssdobjectname=="TObjArray") {
649 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
650 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
652 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
653 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
654 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
655 entryBadChannelsSSD->SetOwner(kTRUE);
657 // DB entries are deleted. In this way metadeta objects are deleted as well
659 delete entryNoiseSSD;
661 delete entryBadChannelsSSD;
664 if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
665 AliWarning("Can not get SSD calibration from calibration database !");
669 fSSDCalibration->SetNoise(noiseSSD);
670 fSSDCalibration->SetGain(gainSSD);
671 fSSDCalibration->SetBadChannels(badChannelsSSD);
672 //fSSDCalibration->FillBadChipMap();
677 //________________________________________________________________
678 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
680 //Set defaults for cluster finder V2
683 Warning("SetDefaults","Null pointer to AliITSgeom !");
687 AliITSClusterFinder *clf;
689 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
692 if(!GetReconstructionModel(dettype)){
693 clf = new AliITSClusterFinderV2SPD(this);
695 if(!rawdata) clf->SetDigits(DigitsAddress(0));
696 SetReconstructionModel(dettype,clf);
702 if(!GetReconstructionModel(dettype)){
703 clf = new AliITSClusterFinderV2SDD(this);
705 if(!rawdata) clf->SetDigits(DigitsAddress(1));
706 SetReconstructionModel(dettype,clf);
713 if(!GetReconstructionModel(dettype)){
714 clf = new AliITSClusterFinderV2SSD(this);
716 if(!rawdata) clf->SetDigits(DigitsAddress(2));
717 SetReconstructionModel(dettype,clf);
724 //______________________________________________________________________
725 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
727 //Creates branches for clusters and recpoints
728 Bool_t cR = (strstr(option,"R")!=0);
729 Bool_t cRF = (strstr(option,"RF")!=0);
733 if(cR) MakeBranchR(tree);
734 if(cRF) MakeBranchRF(tree);
738 //___________________________________________________________________
739 void AliITSDetTypeRec::ResetDigits(){
740 // Reset number of digits and the digits array for the ITS detector.
743 for(Int_t i=0;i<fgkNdettypes;i++){
747 //___________________________________________________________________
748 void AliITSDetTypeRec::ResetDigits(Int_t branch){
749 // Reset number of digits and the digits array for this branch.
751 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
752 if(fNdtype) fNdtype[branch]=0;
756 //__________________________________________________________________
757 void AliITSDetTypeRec::ResetClusters(){
759 //Resets number of clusters and the cluster array
760 for(Int_t i=0;i<fgkNdettypes;i++){
765 //__________________________________________________________________
766 void AliITSDetTypeRec::ResetClusters(Int_t i){
768 //Resets number of clusters and the cluster array for this branch
770 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
771 if (fNctype) fNctype[i]=0;
773 //__________________________________________________________________
774 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
776 //Creates tree branches for recpoints
778 // cont char *file File name where RecPoints branch is to be written
779 // to. If blank it write the SDigits to the same
780 // file in which the Hits were found.
785 // only one branch for rec points for all detector types
786 Bool_t oFast= (strstr(opt,"Fast")!=0);
788 Char_t detname[10] = "ITS";
792 sprintf(branchname,"%sRecPointsF",detname);
794 sprintf(branchname,"%sRecPoints",detname);
797 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
799 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
801 //______________________________________________________________________
802 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
803 // Set branch address for the Reconstructed points Trees.
805 // TTree *treeR Tree containing the RecPoints.
811 Char_t namedet[10]="ITS";
814 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
816 sprintf(branchname,"%sRecPoints",namedet);
817 branch = treeR->GetBranch(branchname);
819 branch->SetAddress(&fRecPoints);
821 sprintf(branchname,"%sRecPointsF",namedet);
822 branch = treeR->GetBranch(branchname);
824 branch->SetAddress(&fRecPoints);
829 //____________________________________________________________________
830 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
831 // Add a reconstructed space point to the list
833 // const AliITSRecPoint &r RecPoint class to be added to the tree
834 // of reconstructed points TreeR.
840 TClonesArray &lrecp = *fRecPoints;
841 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
844 //______________________________________________________________________
845 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){
846 // cluster finding and reconstruction of space points
847 // the condition below will disappear when the geom class will be
848 // initialized for all versions - for the moment it is only for v5 !
849 // 7 is the SDD beam test version
851 // TTree *treeD Digits tree
852 // TTree *treeR Clusters tree
853 // Int_t lastentry Offset for module when not all of the modules
855 // Option_t *opt String indicating which ITS sub-detectors should
856 // be processed. If ="All" then all of the ITS
857 // sub detectors are processed.
859 const char *all = strstr(opt,"All");
860 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
863 SetDefaultClusterFindersV2();
864 AliInfo("V2 cluster finder has been selected \n");
866 SetDefaultClusterFindersV2();
867 AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be udes \n");
870 AliITSClusterFinder *rec = 0;
871 Int_t id,module,first=0;
872 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
873 id = GetITSgeom()->GetModuleType(module);
874 if (!all && !det[id]) continue;
875 if(det[id]) first = GetITSgeom()->GetStartDet(id);
876 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
877 TClonesArray *itsDigits = DigitsAddress(id);
879 AliFatal("The reconstruction class was not instanciated!");
880 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
882 treeD->GetEvent(lastentry+module);
884 treeD->GetEvent(lastentry+(module-first));
886 Int_t ndigits = itsDigits->GetEntriesFast();
888 rec->SetDetTypeRec(this);
889 rec->SetDigits(DigitsAddress(id));
890 // rec->SetClusters(ClustersAddress(id));
891 rec->FindRawClusters(module);
898 //______________________________________________________________________
899 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
900 // cluster finding and reconstruction of space points
901 // the condition below will disappear when the geom class will be
902 // initialized for all versions - for the moment it is only for v5 !
903 // 7 is the SDD beam test version
905 // AliRawReader *rawReader Pointer to the raw-data reader
906 // TTree *treeR Clusters tree
911 const char *all = strstr(opt,"All");
912 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
914 AliITSClusterFinder *rec = 0;
917 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
918 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
921 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
922 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
923 clusters[iModule] = NULL;
926 if (!all && !det[id]) continue;
927 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
929 AliFatal("The reconstruction class was not instantiated");
930 rec->SetDetTypeRec(this);
931 rec->RawdataToClusters(rawReader,clusters);
934 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
935 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
936 id = GetITSgeom()->GetModuleType(iModule);
937 if (!all && !det[id]) continue;
938 array = clusters[iModule];
940 AliDebug(1,Form("data for module %d missing!",iModule));
943 branch->SetAddress(&array);
945 nClusters+=array->GetEntriesFast();
947 if (array != emptyArray) {
955 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
960 //______________________________________________________________________
961 void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
962 AliITSNoiseSSDv2 *noiseSSD) {
963 //Reads the old SSD calibration object and converts it to the new format
964 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
965 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
967 Int_t gNMod = array->GetEntries();
968 cout<<"Converting old calibration object for noise..."<<endl;
971 Double_t noise = 0.0;
972 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
973 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
974 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
975 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
976 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
977 noiseSSD->AddNoiseP(iModule,iStrip,noise);
978 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
979 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
984 //______________________________________________________________________
985 void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
986 AliITSBadChannelsSSDv2 *badChannelsSSD) {
987 //Reads the old SSD calibration object and converts it to the new format
988 Int_t gNMod = array->GetEntries();
989 cout<<"Converting old calibration object for bad channels..."<<endl;
990 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
991 //for (Int_t iModule = 0; iModule < 1; iModule++) {
992 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
993 TArrayI arrayPSide = bad->GetBadPChannelsList();
994 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
995 badChannelsSSD->AddBadChannelP(iModule,
997 (Char_t)arrayPSide.At(iPCounter));
999 TArrayI arrayNSide = bad->GetBadNChannelsList();
1000 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1001 badChannelsSSD->AddBadChannelN(iModule,
1003 (Char_t)arrayNSide.At(iNCounter));
1005 }//loop over modules
1008 //______________________________________________________________________
1009 void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
1010 AliITSGainSSDv2 *gainSSD) {
1011 //Reads the old SSD calibration object and converts it to the new format
1013 Int_t gNMod = array->GetEntries();
1014 cout<<"Converting old calibration object for gain..."<<endl;
1017 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
1018 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1019 TArrayF arrayPSide = gainModule->GetGainP();
1020 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1021 gainSSD->AddGainP(iModule,
1023 arrayPSide.At(iPCounter));
1024 TArrayF arrayNSide = gainModule->GetGainN();
1025 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1026 gainSSD->AddGainN(iModule,
1028 arrayNSide.At(iNCounter));
1029 }//loop over modules