X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSDetTypeRec.cxx;h=7aea9bf380064ba69b2252ad0747e03593aa47e6;hb=9b5048fe034a3c6e2aaf93c9dc36bbfea418ca13;hp=f4bc0d144bdd59ec8a4df317b12c37f8186f17b8;hpb=fa4f0f62df4ac0d6ba95f8e53b076a5468333040;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSDetTypeRec.cxx b/ITS/AliITSDetTypeRec.cxx index f4bc0d144bd..7aea9bf3800 100644 --- a/ITS/AliITSDetTypeRec.cxx +++ b/ITS/AliITSDetTypeRec.cxx @@ -26,39 +26,39 @@ #include "TTree.h" #include "AliCDBManager.h" -#include "AliCDBStorage.h" #include "AliCDBEntry.h" #include "AliITSClusterFinder.h" -#include "AliITSClusterFinderV2.h" #include "AliITSClusterFinderV2SPD.h" #include "AliITSClusterFinderV2SDD.h" #include "AliITSClusterFinderV2SSD.h" -#include "AliITSClusterFinderSPD.h" -#include "AliITSClusterFinderSDD.h" -#include "AliITSClusterFinderSSD.h" #include "AliITSDetTypeRec.h" -#include "AliITSgeom.h" -#include "AliITSRawCluster.h" -#include "AliITSRawClusterSPD.h" -#include "AliITSRawClusterSDD.h" -#include "AliITSRawClusterSSD.h" +#include "AliITSDDLModuleMapSDD.h" #include "AliITSRecPoint.h" -#include "AliITSReconstructor.h" -#include "AliITSRecoParam.h" #include "AliITSCalibrationSDD.h" #include "AliITSMapSDD.h" -#include "AliITSDriftSpeedArraySDD.h" -#include "AliITSDriftSpeedSDD.h" +#include "AliITSHLTforSDD.h" #include "AliITSCalibrationSSD.h" +#include "AliITSNoiseSSDv2.h" +#include "AliITSGainSSDv2.h" +#include "AliITSBadChannelsSSDv2.h" #include "AliITSNoiseSSD.h" #include "AliITSGainSSD.h" #include "AliITSBadChannelsSSD.h" -#include "AliITSPedestalSSD.h" +#include "AliITSresponseSDD.h" #include "AliITSsegmentationSPD.h" #include "AliITSsegmentationSDD.h" #include "AliITSsegmentationSSD.h" #include "AliLog.h" +#include "AliITSRawStreamSPD.h" +#include "AliITSTriggerConditions.h" +#include "AliITSFOSignalsSPD.h" +#include "AliRunLoader.h" +#include "AliDataLoader.h" +#include "AliITSLoader.h" +class AliITSDriftSpeedArraySDD; +class AliITSCorrMapSDD; +class AliITSRecoParam; const Int_t AliITSDetTypeRec::fgkNdettypes = 3; const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240; @@ -74,17 +74,20 @@ fITSgeom(0), fReconstruction(0), fSegmentation(0), fCalibration(0), -fPreProcess(0), -fPostProcess(0), +fSSDCalibration(0), +fSPDDead(0), +fTriggerConditions(0), fDigits(0), +fFOSignals(0), fDDLMapSDD(0), -fNdtype(0), -fCtype(0), -fNctype(0), +fRespSDD(0), +fAveGainSDD(0), +fIsHLTmodeC(0), fRecPoints(0), fNRecPoints(0), -fSelectedVertexer(), -fFirstcall(kTRUE){ +fFirstcall(kTRUE), +fLoadOnlySPDCalib(0), +fFastOrFiredMap(1200){ // Standard Constructor // Inputs: // none. @@ -96,14 +99,9 @@ fFirstcall(kTRUE){ fReconstruction = new TObjArray(fgkNdettypes); fDigits = new TObjArray(fgkNdettypes); for(Int_t i=0; i<3; i++){ - fClusterClassName[i]=0; - fDigClassName[i]=0; - fRecPointClassName[i]=0; - } - fDDLMapSDD=new AliITSDDLModuleMapSDD(); - fNdtype = new Int_t[fgkNdettypes]; - fCtype = new TObjArray(fgkNdettypes); - fNctype = new Int_t[fgkNdettypes]; + fkDigClassName[i]=0; + } + fSSDCalibration=new AliITSCalibrationSSD(); fNMod = new Int_t [fgkNdettypes]; fNMod[0] = fgkDefaultNModulesSPD; fNMod[1] = fgkDefaultNModulesSDD; @@ -111,12 +109,7 @@ fFirstcall(kTRUE){ fRecPoints = new TClonesArray("AliITSRecPoint",3000); fNRecPoints = 0; - for(Int_t i=0;iGetCacheFlag())) { - AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD()))->GetResponse(); - AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSDD()))->GetResponse(); - AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD()))->GetResponse(); - if(rspd) delete rspd; - if(rsdd) delete rsdd; - if(rssd) delete rssd; fCalibration->Delete(); delete fCalibration; fCalibration = 0; - } + if(fRespSDD) delete fRespSDD; + if(fDDLMapSDD) delete fDDLMapSDD; + } } - if(fPreProcess) delete fPreProcess; - if(fPostProcess) delete fPostProcess; - if(fDDLMapSDD) delete fDDLMapSDD; + if(fSSDCalibration) delete fSSDCalibration; + if(fSPDDead){ + if(!(AliCDBManager::Instance()->GetCacheFlag())) { + fSPDDead->Delete(); + delete fSPDDead; + fSPDDead = 0; + } + } + if(fTriggerConditions){ + if(!(AliCDBManager::Instance()->GetCacheFlag())) { + fTriggerConditions->Delete(); + delete fTriggerConditions; + fTriggerConditions = 0; + } + } if(fDigits){ fDigits->Delete(); delete fDigits; @@ -191,13 +194,6 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){ delete fRecPoints; fRecPoints=0; } - if(fCtype) { - fCtype->Delete(); - delete fCtype; - fCtype = 0; - } - delete [] fNctype; - delete [] fNdtype; delete [] fNMod; if (fITSgeom) delete fITSgeom; @@ -214,7 +210,7 @@ void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder fReconstruction->AddAt(clf,dettype); } //______________________________________________________________________ -AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){ +AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype) const{ //Get reconstruction model for detector type if(fReconstruction==0) { @@ -235,7 +231,7 @@ void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *se } //______________________________________________________________________ -AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){ +AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype) const { //Get segmentation model for detector type @@ -262,7 +258,21 @@ void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){ } //_______________________________________________________________________ -AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){ +void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){ + + //Set dead pixel info for the SPD module iMod + if (fSPDDead==0) { + fSPDDead = new TObjArray(fgkDefaultNModulesSPD); + fSPDDead->SetOwner(kTRUE); + fSPDDead->Clear(); + } + + if (fSPDDead->At(iMod) != 0) + delete (AliITSCalibration*) fSPDDead->At(iMod); + fSPDDead->AddAt(cal,iMod); +} +//_______________________________________________________________________ +AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod) const { //Get calibration model for module type @@ -271,42 +281,68 @@ AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){ return 0; } - return (AliITSCalibration*)fCalibration->At(iMod); -} + if(iModAt(iMod); + }else{ + Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD); + fSSDCalibration->SetModule(i); + return (AliITSCalibration*)fSSDCalibration; + } +} +//_______________________________________________________________________ +AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const { + + //Get SPD dead for module iMod + + if(fSPDDead==0) { + AliWarning("fSPDDead is 0!"); + return 0; + } + return (AliITSCalibration*)fSPDDead->At(iMod); +} +//_______________________________________________________________________ +AliITSTriggerConditions* AliITSDetTypeRec::GetTriggerConditions() const { + //Get Pixel Trigger Conditions + if (fTriggerConditions==0) { + AliWarning("fTriggerConditions is 0!"); + } + return fTriggerConditions; +} //______________________________________________________________________ -void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){ +void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){ // Set branch address for the tree of digits. - const char *det[4] = {"SPD","SDD","SSD","ITS"}; - TBranch *branch; - Char_t* digclass; - Int_t i; - char branchname[30]; - - if(!treeD) return; - if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes); - for (i=0; iAt(i))) { - fDigits->AddAt(new TClonesArray(digclass,1000),i); - }else{ - ResetDigits(i); - } - if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]); - else sprintf(branchname,"%sDigits%d",det[3],i+1); - if (fDigits) { - branch = treeD->GetBranch(branchname); - if (branch) branch->SetAddress(&((*fDigits)[i])); - } + const char *det[4] = {"SPD","SDD","SSD","ITS"}; + TBranch *branch; + const Char_t* digclass; + Int_t i; + char branchname[30]; + + if(!treeD) return; + if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes); + for (i=0; iAt(i))) { + fDigits->AddAt(new TClonesArray(digclass,1000),i); + } + else{ + ResetDigits(i); } + if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]); + else sprintf(branchname,"%sDigits%d",det[3],i+1); + if (fDigits) { + branch = treeD->GetBranch(branchname); + if (branch) branch->SetAddress(&((*fDigits)[i])); + } + } + } //_______________________________________________________________________ -TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name, - const char *classname, - void* address,Int_t size, - Int_t splitlevel) +TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree* const tree, + const char* name, const char *classname, + void* address,Int_t size,Int_t splitlevel) { // // Makes branch in given tree and diverts them to a separate file @@ -350,23 +386,25 @@ void AliITSDetTypeRec::SetDefaults(){ seg = new AliITSsegmentationSPD(); SetSegmentationModel(dettype,seg); SetDigitClassName(dettype,"AliITSdigitSPD"); - SetClusterClassName(dettype,"AliITSRawClusterSPD"); - } - if(dettype==1){ - seg = new AliITSsegmentationSDD(); - SetSegmentationModel(dettype,seg); - SetDigitClassName(dettype,"AliITSdigitSDD"); - SetClusterClassName(dettype,"AliITSRawClusterSDD"); + if(fLoadOnlySPDCalib==kFALSE){ + if(dettype==1){ + seg = new AliITSsegmentationSDD(); + AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1); + if(cal->IsAMAt20MHz()){ + seg->SetPadSize(seg->Dpz(0),20.); + seg->SetNPads(seg->Npz()/2,128); + } + SetSegmentationModel(dettype,seg); + SetDigitClassName(dettype,"AliITSdigitSDD"); + } } if(dettype==2){ AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(); SetSegmentationModel(dettype,seg2); SetDigitClassName(dettype,"AliITSdigitSSD"); - SetClusterClassName(dettype,"AliITSRawClusterSSD"); } } - } //______________________________________________________________________ Bool_t AliITSDetTypeRec::GetCalibration() { @@ -375,8 +413,7 @@ Bool_t AliITSDetTypeRec::GetCalibration() { if(!fFirstcall){ AliITSCalibration* cal = GetCalibrationModel(0); if(cal)return kTRUE; - } - else { + }else { fFirstcall = kFALSE; } @@ -389,40 +426,89 @@ Bool_t AliITSDetTypeRec::GetCalibration() { fCalibration->SetOwner(!cacheStatus); fCalibration->Clear(); } + + Bool_t retCode=GetCalibrationSPD(cacheStatus); + if(retCode==kFALSE) return kFALSE; + + if(fLoadOnlySPDCalib==kFALSE){ + retCode=GetCalibrationSDD(cacheStatus); + if(retCode==kFALSE) return kFALSE; + retCode=GetCalibrationSSD(cacheStatus); + if(retCode==kFALSE) return kFALSE; + } + AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database", + fNMod[0], fNMod[1], fNMod[2])); + return kTRUE; +} +//______________________________________________________________________ +Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) { + // Get SPD calibration objects from OCDB // dead pixel are not used for local reconstruction - AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy"); - AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD"); + - // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD"); - AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD"); - AliCDBEntry *entryPedestalSSD = AliCDBManager::Instance()->Get("ITS/Calib/PedestalSSD"); - AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD"); - AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD"); - // Entry for the AliITSRecoParam object - AliCDBEntry *entryRP = AliCDBManager::Instance()->Get("ITS/Calib/RecoParam/"); - AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD"); + AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy"); + AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead"); + AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("ITS/Calib/PITConditions"); + if(!noisySPD || !deadSPD || !pitCond ){ + AliFatal("SPD Calibration object retrieval failed! "); + return kFALSE; + } + + TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject(); + if (!cacheStatus) noisySPD->SetObject(NULL); + noisySPD->SetOwner(kTRUE); + + TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject(); + if (!cacheStatus) deadSPD->SetObject(NULL); + deadSPD->SetOwner(kTRUE); + + AliITSTriggerConditions *calPitCond = (AliITSTriggerConditions*) pitCond->GetObject(); + if (!cacheStatus) pitCond->SetObject(NULL); + pitCond->SetOwner(kTRUE); + + if(!cacheStatus){ + delete noisySPD; + delete deadSPD; + delete pitCond; + } + if ((!calNoisySPD) || (!calDeadSPD) || (!calPitCond)){ + AliWarning("Can not get SPD calibration from calibration database !"); + return kFALSE; + } + + fNMod[0] = calNoisySPD->GetEntries(); + + AliITSCalibration* cal; + for (Int_t i=0; iAt(i); + SetCalibrationModel(i, cal); + cal = (AliITSCalibration*) calDeadSPD->At(i); + SetSPDDeadModel(i, cal); + } + fTriggerConditions = calPitCond; + + return kTRUE; +} + +//______________________________________________________________________ +Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) { + // Get SDD calibration objects from OCDB + + AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD"); AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD"); - AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD"); AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD"); AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD"); - AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD"); + AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD"); + // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD"); AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD"); - if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || - !entryPedestalSSD || !entryBadChannelsSSD || - !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD || !mapTSDD || !entryRP){ - AliFatal("Calibration object retrieval failed! "); + if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){ + AliFatal("SDD Calibration object retrieval failed! "); return kFALSE; } - TObjArray *calSPD = (TObjArray *)entrySPD->GetObject(); - if(!cacheStatus)entrySPD->SetObject(NULL); - entrySPD->SetOwner(kTRUE); - - AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject(); - if(!cacheStatus)entry2SPD->SetObject(NULL); - entry2SPD->SetOwner(kTRUE); + TObjArray *calSDD = (TObjArray *)entrySDD->GetObject(); if(!cacheStatus)entrySDD->SetObject(NULL); @@ -440,172 +526,158 @@ Bool_t AliITSDetTypeRec::GetCalibration() { if(!cacheStatus)ddlMapSDD->SetObject(NULL); ddlMapSDD->SetOwner(kTRUE); - TObjArray *mapAn = (TObjArray *)mapASDD->GetObject(); - if(!cacheStatus)mapASDD->SetObject(NULL); - mapASDD->SetOwner(kTRUE); + AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject(); + if(!cacheStatus)hltforSDD->SetObject(NULL); + hltforSDD->SetOwner(kTRUE); + +// TObjArray *mapAn = (TObjArray *)mapASDD->GetObject(); +// if(!cacheStatus)mapASDD->SetObject(NULL); +// mapASDD->SetOwner(kTRUE); TObjArray *mapT = (TObjArray *)mapTSDD->GetObject(); if(!cacheStatus)mapTSDD->SetObject(NULL); mapTSDD->SetOwner(kTRUE); - TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject(); - if(!cacheStatus)entryNoiseSSD->SetObject(NULL); - entryNoiseSSD->SetOwner(kTRUE); - - TObjArray *pedestalSSD = (TObjArray *)entryPedestalSSD->GetObject(); - if(!cacheStatus)entryPedestalSSD->SetObject(NULL); - entryPedestalSSD->SetOwner(kTRUE); - - TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject(); - if(!cacheStatus)entryGainSSD->SetObject(NULL); - entryGainSSD->SetOwner(kTRUE); - - TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject(); - if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL); - entryBadChannelsSSD->SetOwner(kTRUE); - - AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject(); - if(!cacheStatus)entry2SSD->SetObject(NULL); - entry2SSD->SetOwner(kTRUE); - - AliITSRecoParam *rp = (AliITSRecoParam*)entryRP->GetObject(); - if(!cacheStatus)entryRP->SetObject(NULL); - entryRP->SetOwner(kTRUE); - if(!AliITSReconstructor::GetRecoParam()){ - AliITSReconstructor::SetRecoParam(rp); - } - else { - AliWarning("AliITSRecoPAram object has been already set in AliITSReconstructor. The OCDB instance will not be used\n"); - } // DB entries are deleted. In this way metadeta objects are deleted as well if(!cacheStatus){ - delete entrySPD; delete entrySDD; - delete entryNoiseSSD; - delete entryPedestalSSD; - delete entryGainSSD; - delete entryBadChannelsSSD; - delete entry2SPD; delete entry2SDD; - delete entry2SSD; - delete mapASDD; + //delete mapASDD; + delete hltforSDD; delete mapTSDD; delete drSpSDD; delete ddlMapSDD; } - if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!calSDD) || (!drSp) || (!ddlsdd) - || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) { - AliWarning("Can not get calibration from calibration database !"); + if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) || (!mapT) ){ + AliWarning("Can not get SDD calibration from calibration database !"); return kFALSE; } - fNMod[0] = calSPD->GetEntries(); fNMod[1] = calSDD->GetEntries(); - fNMod[2] = noiseSSD->GetEntries(); - AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database", - fNMod[0], fNMod[1], fNMod[2])); + + fDDLMapSDD=ddlsdd; + fRespSDD=pSDD; + fIsHLTmodeC=hltsdd->IsHLTmodeC(); AliITSCalibration* cal; - for (Int_t i=0; iAt(i); - cal->SetResponse((AliITSresponse*)pSPD); - SetCalibrationModel(i, cal); + Float_t avegain=0.; + Float_t nGdAnodes=0; + Bool_t oldMapFormat=kFALSE; + TObject* objmap=(TObject*)mapT->At(0); + TString cname(objmap->ClassName()); + if(cname.CompareTo("AliITSMapSDD")==0){ + oldMapFormat=kTRUE; + AliInfo("SDD Maps converted to new format"); } - - fDDLMapSDD->SetDDLMap(ddlsdd); for(Int_t iddl=0; iddlGetModuleNumber(iddl,icar); if(iMod==-1) continue; Int_t i=iMod - fgkDefaultNModulesSPD; cal = (AliITSCalibration*) calSDD->At(i); - cal->SetResponse((AliITSresponse*)pSDD); Int_t i0=2*i; Int_t i1=1+2*i; + for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){ + if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue; + avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode); + nGdAnodes++; + } AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0); - AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0); - AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0); AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1); - AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1); - AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1); + + AliITSCorrMapSDD* mt0 = 0; + AliITSCorrMapSDD* mt1 = 0; + if(oldMapFormat){ + AliITSMapSDD* oldmap0=(AliITSMapSDD*)mapT->At(i0); + AliITSMapSDD* oldmap1=(AliITSMapSDD*)mapT->At(i1); + mt0=oldmap0->ConvertToNewFormat(); + mt1=oldmap1->ConvertToNewFormat(); + }else{ + mt0=(AliITSCorrMapSDD*)mapT->At(i0); + mt1=(AliITSCorrMapSDD*)mapT->At(i1); + } cal->SetDriftSpeed(0,arr0); cal->SetDriftSpeed(1,arr1); - cal->SetMapA(0,ma0); - cal->SetMapA(1,ma1); cal->SetMapT(0,mt0); cal->SetMapT(1,mt1); SetCalibrationModel(iMod, cal); } } - for (Int_t i=0; iSetResponse((AliITSresponse*)pSSD); - - AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i)); - calibSSD->SetNoise(noise); - AliITSPedestalSSD *pedestal = (AliITSPedestalSSD*) (pedestalSSD->At(i)); - calibSSD->SetPedestal(pedestal); - AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i)); - calibSSD->SetGain(gain); - AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i)); - calibSSD->SetBadChannels(bad); - - Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD; - SetCalibrationModel(iMod, calibSSD); - } - + if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes; return kTRUE; } -//________________________________________________________________ -void AliITSDetTypeRec::SetDefaultClusterFinders(){ - - //set defaults for standard cluster finder +//______________________________________________________________________ +Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) { + // Get SSD calibration objects from OCDB + // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD"); - if(!GetITSgeom()){ - Warning("SetDefaults","null pointer to AliITSgeom!"); - return; + AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD"); + AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD"); + AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD"); + + if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){ + AliFatal("SSD Calibration object retrieval failed! "); + return kFALSE; + } + + TObject *emptyssd = 0; TString ssdobjectname; + AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2(); + emptyssd = (TObject *)entryNoiseSSD->GetObject(); + ssdobjectname = emptyssd->GetName(); + if(ssdobjectname=="TObjArray") { + TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject(); + ReadOldSSDNoise(noiseSSDOld, noiseSSD); } + else if(ssdobjectname=="AliITSNoiseSSDv2") + noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject(); + if(!cacheStatus)entryNoiseSSD->SetObject(NULL); + entryNoiseSSD->SetOwner(kTRUE); - AliITSClusterFinder *clf; + AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2(); + emptyssd = (TObject *)entryGainSSD->GetObject(); + ssdobjectname = emptyssd->GetName(); + if(ssdobjectname=="Gain") { + TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject(); + ReadOldSSDGain(gainSSDOld, gainSSD); + } + else if(ssdobjectname=="AliITSGainSSDv2") + gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject(); + if(!cacheStatus)entryGainSSD->SetObject(NULL); + entryGainSSD->SetOwner(kTRUE); - for(Int_t dettype=0;dettypeGetObject(); + ssdobjectname = emptyssd->GetName(); + if(ssdobjectname=="TObjArray") { + TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject(); + ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD); + } + else if(ssdobjectname=="AliITSBadChannelsSSDv2") + badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject(); + if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL); + entryBadChannelsSSD->SetOwner(kTRUE); - } - } - - //SDD - if(dettype==1){ - if(!GetReconstructionModel(dettype)){ - TClonesArray *dig1 = DigitsAddress(1); - TClonesArray *rec1 = ClustersAddress(1); - clf = new AliITSClusterFinderSDD(this,dig1,rec1); - SetReconstructionModel(dettype,clf); - } + // DB entries are deleted. In this way metadeta objects are deleted as well + if(!cacheStatus){ + delete entryNoiseSSD; + delete entryGainSSD; + delete entryBadChannelsSSD; + } - } - //SSD - if(dettype==2){ - if(!GetReconstructionModel(dettype)){ - TClonesArray* dig2 = DigitsAddress(2); - clf = new AliITSClusterFinderSSD(this,dig2); - SetReconstructionModel(dettype,clf); - } - } + if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) { + AliWarning("Can not get SSD calibration from calibration database !"); + return kFALSE; + } - } - - + fSSDCalibration->SetNoise(noiseSSD); + fSSDCalibration->SetGain(gainSSD); + fSSDCalibration->SetBadChannels(badChannelsSSD); + //fSSDCalibration->FillBadChipMap(); + + return kTRUE; } //________________________________________________________________ @@ -669,23 +741,6 @@ void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){ } -//___________________________________________________________________ -void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){ - - // Adds a raw cluster to the list - TClonesArray &lc = *((TClonesArray*)fCtype->At(id)); - switch(id){ - case 0: - new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c)); - break; - case 1: - new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c)); - break; - case 2: - new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c)); - break; - } -} //___________________________________________________________________ void AliITSDetTypeRec::ResetDigits(){ // Reset number of digits and the digits array for the ITS detector. @@ -700,26 +755,7 @@ void AliITSDetTypeRec::ResetDigits(Int_t branch){ // Reset number of digits and the digits array for this branch. if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear(); - if(fNdtype) fNdtype[branch]=0; - -} - -//__________________________________________________________________ -void AliITSDetTypeRec::ResetClusters(){ - - //Resets number of clusters and the cluster array - for(Int_t i=0;iAt(i)) ((TClonesArray*)fCtype->At(i))->Clear(); - if (fNctype) fNctype[i]=0; } //__________________________________________________________________ void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){ @@ -750,7 +786,7 @@ void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){ MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99); } //______________________________________________________________________ -void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){ +void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){ // Set branch address for the Reconstructed points Trees. // Inputs: // TTree *treeR Tree containing the RecPoints. @@ -758,24 +794,24 @@ void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){ // none. // Return: - char branchname[30]; - Char_t namedet[10]="ITS"; + char branchname[30]; + Char_t namedet[10]="ITS"; - if(!treeR) return; - if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); - TBranch *branch; - sprintf(branchname,"%sRecPoints",namedet); - branch = treeR->GetBranch(branchname); - if (branch) { + if(!treeR) return; + if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); + TBranch *branch; + sprintf(branchname,"%sRecPoints",namedet); + branch = treeR->GetBranch(branchname); + if (branch) { branch->SetAddress(&fRecPoints); - }else { + } + else { sprintf(branchname,"%sRecPointsF",namedet); branch = treeR->GetBranch(branchname); if (branch) { branch->SetAddress(&fRecPoints); } - - } + } } //____________________________________________________________________ void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){ @@ -793,7 +829,7 @@ void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){ } //______________________________________________________________________ -void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){ +void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){ // cluster finding and reconstruction of space points // the condition below will disappear when the geom class will be // initialized for all versions - for the moment it is only for v5 ! @@ -810,15 +846,33 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent const char *all = strstr(opt,"All"); const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), strstr(opt,"SSD")}; - if(!v2) { - SetDefaultClusterFinders(); - AliInfo("Original cluster finder has been selected\n"); - } - else { + if(optCluFind==0){ SetDefaultClusterFindersV2(); AliInfo("V2 cluster finder has been selected \n"); + }else{ + SetDefaultClusterFindersV2(); + AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n"); } + + // Reset Fast-OR fired map + ResetFastOrFiredMap(); + + if (all || det[0]) { // SPD present + // Get the FO signals for this event + AliRunLoader* runLoader = AliRunLoader::Instance(); + AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader"); + if (!itsLoader) { + AliError("ITS loader is NULL."); + } + else { + fFOSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD"); + if(!fFOSignals) AliError("FO signals not retrieved"); + } + + } + + AliITSClusterFinder *rec = 0; Int_t id,module,first=0; for(module=0;moduleGetIndexMax();module++){ @@ -832,20 +886,25 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent ResetDigits(); // MvL: Not sure we neeed this when rereading anyways if (all) { treeD->GetEvent(lastentry+module); - }else { - treeD->GetEvent(lastentry+(module-first)); - } - Int_t ndigits = itsDigits->GetEntriesFast(); - if(ndigits>0){ - rec->SetDetTypeRec(this); - rec->SetDigits(DigitsAddress(id)); - // rec->SetClusters(ClustersAddress(id)); - rec->FindRawClusters(module); - } // end if - treeR->Fill(); - ResetRecPoints(); - ResetClusters(); - } + } + else { + treeD->GetEvent(lastentry+(module-first)); + } + Int_t ndigits = itsDigits->GetEntriesFast(); + if (ndigits>0 || id==0) { // for SPD we always want to call FindRawClusters (to process FO signals) + rec->SetDetTypeRec(this); + rec->SetDigits(DigitsAddress(id)); + // rec->SetClusters(ClustersAddress(id)); + rec->FindRawClusters(module); + } // end if + treeR->Fill(); + ResetRecPoints(); + } + + // Remove PIT in-active chips from Fast-OR fired map + if (all || det[0]) { // SPD present + RemoveFastOrFiredInActive(); + } } //______________________________________________________________________ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){ @@ -863,7 +922,11 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op const char *all = strstr(opt,"All"); const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), strstr(opt,"SSD")}; - AliITSClusterFinderV2 *rec = 0; + + // Reset Fast-OR fired map + ResetFastOrFiredMap(); + + AliITSClusterFinder *rec = 0; Int_t id=0; TClonesArray *array=new TClonesArray("AliITSRecPoint",1000); @@ -876,9 +939,9 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op } for(id=0;id<3;id++){ if (!all && !det[id]) continue; - rec = (AliITSClusterFinderV2*)GetReconstructionModel(id); + rec = (AliITSClusterFinder*)GetReconstructionModel(id); if (!rec) - AliFatal("The reconstruction class was not instanciated"); + AliFatal("The reconstruction class was not instantiated"); rec->SetDetTypeRec(this); rec->RawdataToClusters(rawReader,clusters); } @@ -907,6 +970,103 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n", nClusters); + // Remove PIT in-active chips from Fast-OR fired map + if (all || det[0]) { // SPD present + RemoveFastOrFiredInActive(); + } +} + +//______________________________________________________________________ +void AliITSDetTypeRec::ReadOldSSDNoise(const TObjArray *array, + AliITSNoiseSSDv2 *noiseSSD) { + //Reads the old SSD calibration object and converts it to the new format + const Int_t fgkSSDSTRIPSPERMODULE = 1536; + const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768; + + Int_t gNMod = array->GetEntries(); + cout<<"Converting old calibration object for noise..."<At(iModule)); + for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) { + noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip); + if(iStrip < fgkSSDPSIDESTRIPSPERMODULE) + noiseSSD->AddNoiseP(iModule,iStrip,noise); + if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE) + noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise); + }//loop over strips + }//loop over modules +} + +//______________________________________________________________________ +void AliITSDetTypeRec::ReadOldSSDBadChannels(const TObjArray *array, + AliITSBadChannelsSSDv2 *badChannelsSSD) { + //Reads the old SSD calibration object and converts it to the new format + Int_t gNMod = array->GetEntries(); + cout<<"Converting old calibration object for bad channels..."<At(iModule)); + TArrayI arrayPSide = bad->GetBadPChannelsList(); + for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) + badChannelsSSD->AddBadChannelP(iModule, + iPCounter, + (Char_t)arrayPSide.At(iPCounter)); + + TArrayI arrayNSide = bad->GetBadNChannelsList(); + for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) + badChannelsSSD->AddBadChannelN(iModule, + iNCounter, + (Char_t)arrayNSide.At(iNCounter)); + + }//loop over modules +} + +//______________________________________________________________________ +void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array, + AliITSGainSSDv2 *gainSSD) { + //Reads the old SSD calibration object and converts it to the new format + + Int_t gNMod = array->GetEntries(); + cout<<"Converting old calibration object for gain..."<At(iModule)); + TArrayF arrayPSide = gainModule->GetGainP(); + for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) + gainSSD->AddGainP(iModule, + iPCounter, + arrayPSide.At(iPCounter)); + TArrayF arrayNSide = gainModule->GetGainN(); + for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) + gainSSD->AddGainN(iModule, + iNCounter, + arrayNSide.At(iNCounter)); + }//loop over modules +} +//______________________________________________________________________ +void AliITSDetTypeRec::RemoveFastOrFiredInActive() { + // Removes the chips that were in-active in the pixel trigger (from fast-or fired map) + if (fTriggerConditions==NULL) { + AliError("Pixel trigger conditions are missing."); + return; + } + Int_t eq = -1; + Int_t hs = -1; + Int_t chip = -1; + while (fTriggerConditions->GetNextInActiveChip(eq,hs,chip)) { + UInt_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); + fFastOrFiredMap.SetBitNumber(chipKey,kFALSE); + } +} +//______________________________________________________________________ +void AliITSDetTypeRec::SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip) { + // Set fast-or fired map for this chip + Int_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip); + return SetFastOrFiredMap(chipKey); }