X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSDetTypeRec.cxx;h=0b46848ebf89d92169f0c7fe39edec5a4d3f49aa;hb=d643e2629193af8e0b2cd155063d5be731f642d4;hp=1c16babbac24b286ecb4ce95166345d3aa71d210;hpb=975f3564be14e908521f74ed4ac75b884154b957;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSDetTypeRec.cxx b/ITS/AliITSDetTypeRec.cxx index 1c16babbac2..0b46848ebf8 100644 --- a/ITS/AliITSDetTypeRec.cxx +++ b/ITS/AliITSDetTypeRec.cxx @@ -26,28 +26,32 @@ #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 "AliITSRawCluster.h" -#include "AliITSRawClusterSPD.h" -#include "AliITSRawClusterSDD.h" -#include "AliITSRawClusterSSD.h" +#include "AliITSDDLModuleMapSDD.h" #include "AliITSRecPoint.h" #include "AliITSCalibrationSDD.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 "AliITSresponseSDD.h" #include "AliITSsegmentationSPD.h" #include "AliITSsegmentationSDD.h" #include "AliITSsegmentationSSD.h" #include "AliLog.h" +class AliITSDriftSpeedArraySDD; +class AliITSMapSDD; +class AliITSRecoParam; const Int_t AliITSDetTypeRec::fgkNdettypes = 3; const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240; @@ -59,57 +63,23 @@ ClassImp(AliITSDetTypeRec) //________________________________________________________________ AliITSDetTypeRec::AliITSDetTypeRec(): TObject(), fNMod(0), +fITSgeom(0), fReconstruction(0), fSegmentation(0), fCalibration(0), -fPreProcess(0), -fPostProcess(0), +fSSDCalibration(0), +fSPDDead(0), +fSPDFastOr(0), fDigits(0), -fNdtype(0), -fCtype(0), -fNctype(0), +fDDLMapSDD(0), +fRespSDD(0), +fAveGainSDD(0), +fIsHLTmodeC(0), fRecPoints(0), fNRecPoints(0), -fSelectedVertexer(), -fLoader(0), -fRunNumber(0), -fFirstcall(kTRUE){ - // Default Constructor - // Inputs: - // none. - // Outputs: - // none. - // Return: - // A properly zero-ed AliITSDetTypeRec class. - - for(Int_t i=0; i<3; i++){ - fClusterClassName[i]=0; - fDigClassName[i]=0; - fRecPointClassName[i]=0; - } - - SelectVertexer(" "); - - -} -//________________________________________________________________ -AliITSDetTypeRec::AliITSDetTypeRec(AliITSLoader *loader): TObject(), -fNMod(0), -fReconstruction(0), -fSegmentation(0), -fCalibration(0), -fPreProcess(0), -fPostProcess(0), -fDigits(0), -fNdtype(0), -fCtype(0), -fNctype(0), -fRecPoints(0), -fNRecPoints(0), -fSelectedVertexer(), -fLoader(loader), -fRunNumber(0), -fFirstcall(kTRUE){ +fFirstcall(kTRUE), +fLoadOnlySPDCalib(0), +fFastOrFiredMap(1200){ // Standard Constructor // Inputs: // none. @@ -121,13 +91,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; + fkDigClassName[i]=0; } - fNdtype = new Int_t[fgkNdettypes]; - fCtype = new TObjArray(fgkNdettypes); - fNctype = new Int_t[fgkNdettypes]; + fSSDCalibration=new AliITSCalibrationSSD(); fNMod = new Int_t [fgkNdettypes]; fNMod[0] = fgkDefaultNModulesSPD; fNMod[1] = fgkDefaultNModulesSDD; @@ -135,34 +101,29 @@ fFirstcall(kTRUE){ fRecPoints = new TClonesArray("AliITSRecPoint",3000); fNRecPoints = 0; - for(Int_t i=0;iDelete(); delete fReconstruction; @@ -190,20 +151,23 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){ delete fSegmentation; fSegmentation = 0; } - if(fCalibration && fRunNumber<0){ - 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(fPreProcess) delete fPreProcess; - if(fPostProcess) delete fPostProcess; - + if(fCalibration){ + if(!(AliCDBManager::Instance()->GetCacheFlag())) { + fCalibration->Delete(); + delete fCalibration; + fCalibration = 0; + if(fRespSDD) delete fRespSDD; + if(fDDLMapSDD) delete fDDLMapSDD; + } + } + if(fSSDCalibration) delete fSSDCalibration; + if(fSPDDead){ + if(!(AliCDBManager::Instance()->GetCacheFlag())) { + fSPDDead->Delete(); + delete fSPDDead; + fSPDDead = 0; + } + } if(fDigits){ fDigits->Delete(); delete fDigits; @@ -214,16 +178,10 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){ delete fRecPoints; fRecPoints=0; } - if(fCtype) { - fCtype->Delete(); - delete fCtype; - fCtype = 0; - } - delete [] fNctype; - delete [] fNdtype; delete [] fNMod; - if(fLoader) delete fLoader; + if (fITSgeom) delete fITSgeom; + } //___________________________________________________________________ @@ -236,7 +194,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) { @@ -257,7 +215,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 @@ -284,7 +242,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 @@ -293,26 +265,35 @@ 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; + } -//______________________________________________________________________ -void AliITSDetTypeRec::SetTreeAddress(){ - // Set branch address for the Trees. - - TTree *treeR = fLoader->TreeR(); - TTree *treeD = fLoader->TreeD(); - - SetTreeAddressD(treeD); - SetTreeAddressR(treeR); + return (AliITSCalibration*)fSPDDead->At(iMod); } + //______________________________________________________________________ -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; + const Char_t* digclass; Int_t i; char branchname[30]; @@ -335,10 +316,9 @@ void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){ } //_______________________________________________________________________ -TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name, - const char *classname, - void* address,Int_t size, - Int_t splitlevel, const char */*file*/) +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 @@ -379,33 +359,28 @@ void AliITSDetTypeRec::SetDefaults(){ for(Int_t dettype=0;dettypeGetStartSDD()); - seg = new AliITSsegmentationSDD(GetITSgeom(),res); - SetSegmentationModel(dettype,seg); - const char *kopt = ((AliITSresponseSDD*)res->GetResponse())->ZeroSuppOption(); - if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) SetDigitClassName(dettype,"AliITSdigit"); - else 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(GetITSgeom()); - seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side. - seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side. - seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side. + AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(); SetSegmentationModel(dettype,seg2); SetDigitClassName(dettype,"AliITSdigitSSD"); - SetClusterClassName(dettype,"AliITSRawClusterSSD"); } } - } //______________________________________________________________________ Bool_t AliITSDetTypeRec::GetCalibration() { @@ -414,154 +389,257 @@ Bool_t AliITSDetTypeRec::GetCalibration() { if(!fFirstcall){ AliITSCalibration* cal = GetCalibrationModel(0); if(cal)return kTRUE; - } - else { + }else { fFirstcall = kFALSE; } - SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun()); - Int_t run=GetRunNumber(); + // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun()); + // Int_t run=GetRunNumber(); - Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag(); - Bool_t isCacheActive = kTRUE; - if(GetRunNumber()<0)isCacheActive=kFALSE; + Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag(); if (fCalibration==0) { fCalibration = new TObjArray(GetITSgeom()->GetIndexMax()); - fCalibration->SetOwner(isCacheActive); + fCalibration->SetOwner(!cacheStatus); fCalibration->Clear(); } + + Bool_t retCode=GetCalibrationSPD(cacheStatus); + if(retCode==kFALSE) return kFALSE; - AliCDBManager::Instance()->SetCacheFlag(isCacheActive); - - AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run); - AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run); - AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run); - AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run); - AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run); - AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run); + if(fLoadOnlySPDCalib==kFALSE){ + retCode=GetCalibrationSDD(cacheStatus); + if(retCode==kFALSE) return kFALSE; + retCode=GetCalibrationSSD(cacheStatus); + if(retCode==kFALSE) return kFALSE; + } - if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){ - AliFatal("Calibration object retrieval failed! "); + 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 *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead"); + AliCDBEntry *fastOrSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFastOr"); + if(!entrySPD || !deadSPD || !fastOrSPD ){ + AliFatal("SPD Calibration object retrieval failed! "); return kFALSE; } TObjArray *calSPD = (TObjArray *)entrySPD->GetObject(); - if(!isCacheActive)entrySPD->SetObject(NULL); + if(!cacheStatus)entrySPD->SetObject(NULL); entrySPD->SetOwner(kTRUE); - AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject(); - if(!isCacheActive)entry2SPD->SetObject(NULL); - entry2SPD->SetOwner(kTRUE); + TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject(); + if(!cacheStatus)deadSPD->SetObject(NULL); + deadSPD->SetOwner(kTRUE); + + AliITSFastOrCalibrationSPD *calfastOrSPD = (AliITSFastOrCalibrationSPD *)fastOrSPD->GetObject(); + if(!cacheStatus)fastOrSPD->SetObject(NULL); + fastOrSPD->SetOwner(kTRUE); + + if(!cacheStatus){ + delete entrySPD; + delete deadSPD; + delete fastOrSPD; + } + if ((!calSPD) || (!caldeadSPD) || (!calfastOrSPD)){ + AliWarning("Can not get SPD calibration from calibration database !"); + return kFALSE; + } + + fNMod[0] = calSPD->GetEntries(); + + AliITSCalibration* cal; + for (Int_t i=0; iAt(i); + SetCalibrationModel(i, cal); + cal = (AliITSCalibration*) caldeadSPD->At(i); + SetSPDDeadModel(i, cal); + } + fSPDFastOr = calfastOrSPD; + + 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 *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD"); + AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD"); + 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(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){ + AliFatal("SDD Calibration object retrieval failed! "); + return kFALSE; + } + + TObjArray *calSDD = (TObjArray *)entrySDD->GetObject(); - if(!isCacheActive)entrySDD->SetObject(NULL); + if(!cacheStatus)entrySDD->SetObject(NULL); entrySDD->SetOwner(kTRUE); AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject(); - if(!isCacheActive)entry2SDD->SetObject(NULL); + if(!cacheStatus)entry2SDD->SetObject(NULL); entry2SDD->SetOwner(kTRUE); - TObjArray *calSSD = (TObjArray *)entrySSD->GetObject(); - if(!isCacheActive)entrySSD->SetObject(NULL); - entrySSD->SetOwner(kTRUE); + TObjArray *drSp = (TObjArray *)drSpSDD->GetObject(); + if(!cacheStatus)drSpSDD->SetObject(NULL); + drSpSDD->SetOwner(kTRUE); + + AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject(); + if(!cacheStatus)ddlMapSDD->SetObject(NULL); + ddlMapSDD->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); - AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject(); - if(!isCacheActive)entry2SSD->SetObject(NULL); - entry2SSD->SetOwner(kTRUE); // DB entries are deleted. In this way metadeta objects are deleted as well - if(!isCacheActive){ - delete entrySPD; + if(!cacheStatus){ delete entrySDD; - delete entrySSD; - delete entry2SPD; delete entry2SDD; - delete entry2SSD; + //delete mapASDD; + delete hltforSDD; + delete mapTSDD; + delete drSpSDD; + delete ddlMapSDD; } - AliCDBManager::Instance()->SetCacheFlag(origCacheStatus); - - if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!calSDD) || (!calSSD)) { - 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] = calSSD->GetEntries(); - AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database", - fNMod[0], fNMod[1], fNMod[2])); - AliITSCalibration* cal; - for (Int_t i=0; iAt(i); - cal->SetResponse((AliITSresponse*)pSPD); - SetCalibrationModel(i, cal); - } - for (Int_t i=0; iAt(i); - cal->SetResponse((AliITSresponse*)pSDD); - Int_t iMod = i + fNMod[0]; - SetCalibrationModel(iMod, cal); - } - for (Int_t i=0; iAt(i); - cal->SetResponse((AliITSresponse*)pSSD); - Int_t iMod = i + fNMod[0] + fNMod[1]; - SetCalibrationModel(iMod, cal); - } + fDDLMapSDD=ddlsdd; + fRespSDD=pSDD; + fIsHLTmodeC=hltsdd->IsHLTmodeC(); + AliITSCalibration* cal; + Float_t avegain=0.; + Float_t nGdAnodes=0; + for(Int_t iddl=0; iddlGetModuleNumber(iddl,icar); + if(iMod==-1) continue; + Int_t i=iMod - fgkDefaultNModulesSPD; + cal = (AliITSCalibration*) calSDD->At(i); + 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); + 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); + } + } + 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"); - AliITSClusterFinder *clf; + if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){ + AliFatal("SSD Calibration object retrieval failed! "); + return kFALSE; + } - MakeTreeC(); - - for(Int_t dettype=0;dettypeGetObject(); + 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); + + 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); + + AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2(); + emptyssd = (TObject *)entryBadChannelsSSD->GetObject(); + 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; } //________________________________________________________________ @@ -576,7 +654,6 @@ void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){ AliITSClusterFinder *clf; - MakeTreeC(); for(Int_t dettype=0;dettypeTreeC()== 0x0) fLoader->MakeTree("C"); - MakeBranchC(); -} - -//______________________________________________________________ -void AliITSDetTypeRec::MakeBranchC(){ - - //Make branches in the tree of clusters - - if(!fLoader){ - Warning("MakeBranchC","ITS loader is null!"); - return; - } - TTree* lTC = fLoader->TreeC(); - if(lTC==0x0){ - Error("MakeTreeC","Can not get TreeC from loader"); - return; - } - - Int_t buffersize = 4000; - Char_t branchname[30]; - Char_t* cluclass; - const char *det[4]={"SPD","SDD","SSD","ITS"}; - - for(Int_t i=0;iAddAt(new TClonesArray(cluclass,1000),i); - } - if(fgkNdettypes==3) sprintf(branchname,"%sClusters%s",det[3],det[i]); - else sprintf(branchname,"%sClusters%d",det[3],i+1); - if(fCtype && lTC){ - if(lTC->GetBranch(branchname)){ - Warning("MakeBranchC","Branch %s already exists in TreeC",branchname); - } else{ - Info("MakeBranchC","Creating branch %s in TreeC",branchname); - lTC->Branch(branchname,&((*fCtype)[i]),buffersize); - } - } - - } - -} - -//_______________________________________________________________ -void AliITSDetTypeRec::GetTreeC(Int_t event){ - - //Get the clusters tree for this event and - //sets the branch address - - - if(!fLoader){ - Warning("GetTreeC","ITS loader is null!"); - return; - } - - Char_t branchname[30]; - const char *det[4] = {"SPD","SDD","SSD","ITS"}; - TTree* lTC = fLoader->TreeC(); - - ResetClusters(); - if(lTC) fLoader->CleanRawClusters(); - - TBranch* branch; - if(lTC){ - Char_t* cluclass; - for(Int_t i=0;iAt(i)) fCtype->AddAt(new TClonesArray(cluclass,1000),i); - if(fgkNdettypes==3) sprintf(branchname,"%sClusters%s",det[3],det[i]); - else sprintf(branchname,"%sClusters%d",det[3],i+1); - if(fCtype){ - branch = lTC->GetBranch(branchname); - if(branch) branch->SetAddress(&((*fCtype)[i])); - } - } - } else{ - Error("GetTreeC","cannot find clusters Tree for vent %d",event); - } + if(cR) MakeBranchR(tree); + if(cRF) MakeBranchRF(tree); } -//___________________________________________________________________ -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. @@ -749,29 +717,10 @@ 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(const char *file, Option_t *opt){ +void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){ //Creates tree branches for recpoints // Inputs: @@ -779,11 +728,6 @@ void AliITSDetTypeRec::MakeBranchR(const char *file, Option_t *opt){ // to. If blank it write the SDigits to the same // file in which the Hits were found. - if(!fLoader){ - Warning("MakeBranchR","ITS loader is null!"); - return; - } - Int_t buffsz = 4000; char branchname[30]; @@ -800,16 +744,11 @@ void AliITSDetTypeRec::MakeBranchR(const char *file, Option_t *opt){ } if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000); - if (fLoader->TreeR()) { - if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint", - 1000); - MakeBranchInTree(fLoader->TreeR(),branchname,0,&fRecPoints,buffsz,99,file); - } // end if - - + if (treeR) + 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. @@ -852,45 +791,31 @@ void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){ } //______________________________________________________________________ -void AliITSDetTypeRec::DigitsToRecPoints(Int_t evNumber,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 ! // 7 is the SDD beam test version // Inputs: - // Int_t evNumber Event number to be processed. + // TTree *treeD Digits tree + // TTree *treeR Clusters tree // Int_t lastentry Offset for module when not all of the modules // are processed. // Option_t *opt String indicating which ITS sub-detectors should // be processed. If ="All" then all of the ITS // sub detectors are processed. - if(!GetITSgeom()){ - Warning("DigitsToRecPoints","Null pointer to AliITSgeom !"); - return; - } - if(!fLoader){ - Warning("DigitsToRecPoints","ITS loader is null!"); - return; - } - 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"); } - TTree *treeC=fLoader->TreeC(); - if(!treeC){ - MakeTreeC(); - MakeBranchC(); - } AliITSClusterFinder *rec = 0; Int_t id,module,first=0; for(module=0;moduleGetIndexMax();module++){ @@ -899,69 +824,46 @@ void AliITSDetTypeRec::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t if(det[id]) first = GetITSgeom()->GetStartDet(id); rec = (AliITSClusterFinder*)GetReconstructionModel(id); TClonesArray *itsDigits = DigitsAddress(id); - if (!rec) { - Error("DigitsToRecPoints", - "The reconstruction class was not instanciated! event=%d", - evNumber); - exit(1); - } - ResetDigits(); - TTree *lTD = fLoader->TreeD(); + if (!rec) + AliFatal("The reconstruction class was not instanciated!"); + ResetDigits(); // MvL: Not sure we neeed this when rereading anyways if (all) { - lTD->GetEvent(lastentry+module); + treeD->GetEvent(lastentry+module); }else { - lTD->GetEvent(lastentry+(module-first)); + 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->SetClusters(ClustersAddress(id)); rec->FindRawClusters(module); } // end if - fLoader->TreeR()->Fill(); + treeR->Fill(); ResetRecPoints(); - treeC->Fill(); - ResetClusters(); } - - fLoader->WriteRecPoints("OVERWRITE"); - fLoader->WriteRawClusters("OVERWRITE"); } //______________________________________________________________________ -void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){ +void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){ // 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 ! // 7 is the SDD beam test version // Inputs: - // Int_t evNumber Event number to be processed. - // Int_t lastentry Offset for module when not all of the modules - // are processed. - // Option_t *opt String indicating which ITS sub-detectors should - // be processed. If ="All" then all of the ITS - // sub detectors are processed. + // AliRawReader *rawReader Pointer to the raw-data reader + // TTree *treeR Clusters tree // Outputs: // none. // Return: // none. - if(!GetITSgeom()){ - Warning("DigitsToRecPoints","Null pointer to AliITSgeom !"); - return; - } - if(!fLoader){ - Warning("DigitsToRecPoints","ITS loader is null!"); - return; - } - - - AliITSClusterFinderV2 *rec = 0; + const char *all = strstr(opt,"All"); + const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), + strstr(opt,"SSD")}; + AliITSClusterFinder *rec = 0; Int_t id=0; - if(!fLoader->TreeR()) fLoader->MakeTree("R"); - TTree* cTree = fLoader->TreeR(); TClonesArray *array=new TClonesArray("AliITSRecPoint",1000); - cTree->Branch("ITSRecPoints",&array); + TBranch *branch = treeR->Branch("ITSRecPoints",&array); delete array; TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()]; @@ -969,33 +871,110 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){ clusters[iModule] = NULL; } for(id=0;id<3;id++){ - rec = (AliITSClusterFinderV2*)GetReconstructionModel(id); - rec->SetDetTypeRec(this); + if (!all && !det[id]) continue; + 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); } Int_t nClusters =0; TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint"); for(Int_t iModule=0;iModuleGetIndexMax();iModule++){ + id = GetITSgeom()->GetModuleType(iModule); + if (!all && !det[id]) continue; array = clusters[iModule]; if(!array){ AliDebug(1,Form("data for module %d missing!",iModule)); array = emptyArray; } - cTree->SetBranchAddress("ITSRecPoints",&array); - cTree->Fill(); + branch->SetAddress(&array); + treeR->Fill(); nClusters+=array->GetEntriesFast(); + + if (array != emptyArray) { + array->Delete(); + delete array; + } } delete emptyArray; - fLoader->WriteRecPoints("OVERWRITE"); - delete[] clusters; Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n", nClusters); } +//______________________________________________________________________ +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 +} +