From: gconesab Date: Tue, 10 Nov 2009 18:13:34 +0000 (+0000) Subject: --- Access to bad channel map implemented in reconstruction chain. X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=40164976e6eea42a0e01a8207e005746885743cb --- Access to bad channel map implemented in reconstruction chain. -A first method to calculate the distance from a cluster to closest bad channel implemented. Output kept in AliESDCaloClusters::GetDistanceToBadChannel -Ideal map (no dead channels) committed to OCDB/EMCAL/Calib/Pedestals Example macro to create a bad channel map to be put in OCDB is in EMCAL/macros/PedestalDB --- diff --git a/EMCAL/AliCaloCalibPedestal.cxx b/EMCAL/AliCaloCalibPedestal.cxx index 1e2ac9dfb86..ed6c369aabd 100644 --- a/EMCAL/AliCaloCalibPedestal.cxx +++ b/EMCAL/AliCaloCalibPedestal.cxx @@ -311,7 +311,12 @@ void AliCaloCalibPedestal::Reset() // Parameter/cut handling //_____________________________________________________________________ void AliCaloCalibPedestal::SetParametersFromFile(const char *parameterFile) -{ +{ + // Note: this method is a bit more complicated than it really has to be + // - allowing for multiple entries per line, arbitrary order of the + // different variables etc. But I wanted to try and do this in as + // correct a C++ way as I could (as an exercise). + static const string delimitor("::"); // open, check input file @@ -321,10 +326,6 @@ void AliCaloCalibPedestal::SetParametersFromFile(const char *parameterFile) return; } - // Note: this method is a bit more complicated than it really has to be - // - allowing for multiple entries per line, arbitrary order of the - // different variables etc. But I wanted to try and do this in as - // correct a C++ way as I could (as an exercise). // read in char readline[1024]; @@ -390,6 +391,8 @@ void AliCaloCalibPedestal::SetParametersFromFile(const char *parameterFile) //_____________________________________________________________________ void AliCaloCalibPedestal::WriteParametersToFile(const char *parameterFile) { + //Write parameters in file. + static const string delimitor("::"); ofstream out( parameterFile ); out << "// " << parameterFile << endl; @@ -831,3 +834,24 @@ void AliCaloCalibPedestal::ComputeDeadTowers(int threshold, const char * deadMap fResurrectedTowers = countRes; } +//_____________________________________________________________________ +Bool_t AliCaloCalibPedestal::IsBadChannel(int imod, int icol, int irow) const +{ + //Check if channel is dead or hot. + + Int_t status = ((TH2D*)fDeadMap[imod])->GetBinContent(icol,irow); + if(status == kAlive) + return kFALSE; + else + return kTRUE; + +} + +//_____________________________________________________________________ +void AliCaloCalibPedestal::SetChannelStatus(int imod, int icol, int irow, int status) +{ + //Set status of channel dead, hot, alive ... + + ((TH2D*)fDeadMap[imod])->SetBinContent(icol,irow, status); + +} diff --git a/EMCAL/AliCaloCalibPedestal.h b/EMCAL/AliCaloCalibPedestal.h index 67fcb3eeb03..30302375c77 100644 --- a/EMCAL/AliCaloCalibPedestal.h +++ b/EMCAL/AliCaloCalibPedestal.h @@ -36,7 +36,7 @@ class AliCaloCalibPedestal : public TObject { public: enum kDetType {kPhos, kEmCal, kNone};//The detector types - enum kDeadMapEntry{kAlive = 0, kDead, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap + enum kDeadMapEntry{kAlive = 0, kDead, kHot, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap AliCaloCalibPedestal(kDetType detectorType = kPhos); virtual ~AliCaloCalibPedestal(); @@ -80,8 +80,15 @@ class AliCaloCalibPedestal : public TObject { TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain peak-pedestal profile ratio TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain peak-pedestal profile ratio - TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];}; - + TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];} + //void SetDeadMap(int i, TH2D *h) const {((TH2D*)fDeadMap[i])=h;} + + Bool_t IsBadChannel(int imod, int icol, int irow) const; + void SetChannelStatus(int imod, int icol, int irow, int status); + + TObjArray GetDeadMap() const {return fDeadMap;} + void SetDeadMap(TObjArray map) {fDeadMap = map;} + // Basic info: getters kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object @@ -112,6 +119,7 @@ class AliCaloCalibPedestal : public TObject { ///////////////////////////// //Analysis functions + void SetDeadTowerCount(Int_t dead) {fDeadTowers = dead;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference @@ -163,7 +171,7 @@ class AliCaloCalibPedestal : public TObject { int fNChanFills; //# total channel fills (NChan * NEvents if not zero-suppressed) //The dead tower counts - int fDeadTowers; //! + int fDeadTowers; // Number of towers found dead. int fNewDeadTowers; //! Towers that have died since the reference run int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference @@ -188,7 +196,7 @@ class AliCaloCalibPedestal : public TObject { static const int fgkPhosCols = 56; // number of columns per module for PHOS static const int fgkPhosModules = 5; // number of modules for PHOS - ClassDef(AliCaloCalibPedestal, 5) + ClassDef(AliCaloCalibPedestal, 6) }; diff --git a/EMCAL/AliEMCALClusterizerv1.cxx b/EMCAL/AliEMCALClusterizerv1.cxx index f2f6c3f5d65..ff25ebc72b2 100644 --- a/EMCAL/AliEMCALClusterizerv1.cxx +++ b/EMCAL/AliEMCALClusterizerv1.cxx @@ -76,6 +76,7 @@ class TSystem; #include "AliEMCALRecParam.h" #include "AliEMCALReconstructor.h" #include "AliCDBManager.h" +#include "AliCaloCalibPedestal.h" class AliCDBStorage; #include "AliCDBEntry.h" @@ -88,7 +89,7 @@ AliEMCALClusterizerv1::AliEMCALClusterizerv1() fGeom(0), fDefaultInit(kFALSE), fToUnfold(kFALSE), - fNumberOfECAClusters(0),fCalibData(0), + fNumberOfECAClusters(0),fCalibData(0),fCaloPed(0), fADCchannelECA(0.),fADCpedestalECA(0.),fECAClusteringThreshold(0.),fECALocMaxCut(0.), fECAW0(0.),fTimeCut(0.),fMinECut(0.) { @@ -103,7 +104,7 @@ AliEMCALClusterizerv1::AliEMCALClusterizerv1(AliEMCALGeometry* geometry) fGeom(geometry), fDefaultInit(kFALSE), fToUnfold(kFALSE), - fNumberOfECAClusters(0),fCalibData(0), + fNumberOfECAClusters(0),fCalibData(0), fCaloPed(0), fADCchannelECA(0.),fADCpedestalECA(0.),fECAClusteringThreshold(0.),fECALocMaxCut(0.), fECAW0(0.),fTimeCut(0.),fMinECut(0.) { @@ -127,12 +128,12 @@ AliEMCALClusterizerv1::AliEMCALClusterizerv1(AliEMCALGeometry* geometry) } //____________________________________________________________________________ -AliEMCALClusterizerv1::AliEMCALClusterizerv1(AliEMCALGeometry* geometry, AliEMCALCalibData * calib) +AliEMCALClusterizerv1::AliEMCALClusterizerv1(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped) : AliEMCALClusterizer(), fGeom(geometry), fDefaultInit(kFALSE), fToUnfold(kFALSE), -fNumberOfECAClusters(0),fCalibData(calib), +fNumberOfECAClusters(0),fCalibData(calib), fCaloPed(caloped), fADCchannelECA(0.),fADCpedestalECA(0.),fECAClusteringThreshold(0.),fECALocMaxCut(0.), fECAW0(0.),fTimeCut(0.),fMinECut(0.) { @@ -181,7 +182,13 @@ Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId) } fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta); - + + // Check if channel is bad (dead, hot ...), in this case return 0. + if(fCaloPed->IsBadChannel(iSupMod,ieta,iphi)) { + AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD!!!\n",iSupMod,ieta,iphi)); + return 0; + } + fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi); fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi); @@ -208,7 +215,9 @@ void AliEMCALClusterizerv1::Digits2Clusters(Option_t * option) //Get calibration parameters from file or digitizer default values. GetCalibrationParameters() ; - + //Get dead channel map from file or digitizer default values. + GetCaloCalibPedestal() ; + fNumberOfECAClusters = 0; MakeClusters() ; //only the real clusters @@ -221,6 +230,8 @@ void AliEMCALClusterizerv1::Digits2Clusters(Option_t * option) //Evaluate position, dispersion and other RecPoint properties for EC section for(index = 0; index < fRecPoints->GetEntries(); index++) { dynamic_cast(fRecPoints->At(index))->EvalAll(fECAW0,fDigitsArr) ; + //For each rec.point set the distance to the nearest bad crystal + dynamic_cast(fRecPoints->At(index))->EvalDistanceToBadChannels(fCaloPed); } fRecPoints->Sort() ; @@ -359,6 +370,32 @@ void AliEMCALClusterizerv1::GetCalibrationParameters() } +//____________________________________________________________________________ +void AliEMCALClusterizerv1::GetCaloCalibPedestal() +{ + // Set calibration parameters: + // if calibration database exists, they are read from database, + // otherwise, they are taken from digitizer. + // + // It is a user responsilibity to open CDB before reconstruction, + // for example: + // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB"); + + //Check if calibration is stored in data base + + if(!fCaloPed) + { + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); + if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject(); + } + + if(!fCaloPed) + AliFatal("Pedestal info not found in CDB!"); + +} + + //____________________________________________________________________________ void AliEMCALClusterizerv1::Init() { @@ -386,7 +423,8 @@ void AliEMCALClusterizerv1::InitParameters() fTimeCut = 300e-9 ; // 300 ns time cut (to be tuned) fCalibData = 0 ; - + fCaloPed = 0 ; + const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam(); if(!recParam) { AliFatal("Reconstruction parameters for EMCAL not set!"); diff --git a/EMCAL/AliEMCALClusterizerv1.h b/EMCAL/AliEMCALClusterizerv1.h index b02a181efd8..5c695dbae2e 100644 --- a/EMCAL/AliEMCALClusterizerv1.h +++ b/EMCAL/AliEMCALClusterizerv1.h @@ -30,6 +30,7 @@ class AliEMCALDigit ; class AliEMCALDigitizer ; class AliEMCALGeometry ; class AliEMCALCalibData ; +class AliCaloCalibPedestal ; class AliEMCALClusterizerv1 : public AliEMCALClusterizer { @@ -37,7 +38,7 @@ public: AliEMCALClusterizerv1() ; AliEMCALClusterizerv1(AliEMCALGeometry* geometry); - AliEMCALClusterizerv1(AliEMCALGeometry* geometry, AliEMCALCalibData * calib); + AliEMCALClusterizerv1(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * pedestal); virtual ~AliEMCALClusterizerv1() ; @@ -71,8 +72,9 @@ public: virtual const char * Version() const { return "clu-v1" ; } void PrintRecoInfo(); //*MENU* - void SetCalibrationParameters(AliEMCALCalibData * calib) { fCalibData = calib ; } - + void SetCalibrationParameters(AliEMCALCalibData * calib) { fCalibData = calib ; } + void SetCaloCalibPedestal(AliCaloCalibPedestal * caloped) { fCaloPed = caloped ; } + protected: virtual void MakeClusters(); @@ -82,7 +84,8 @@ private: AliEMCALClusterizerv1 & operator = (const AliEMCALClusterizerv1 &); void GetCalibrationParameters(void) ; - + void GetCaloCalibPedestal(void) ; + Bool_t FindFit(AliEMCALRecPoint * emcRP, AliEMCALDigit ** MaxAt, const Float_t * maxAtEnergy, Int_t NPar, Float_t * FitParametres) const; //Used in UnfoldClusters, calls TMinuit void Init() ; @@ -103,7 +106,9 @@ private: //Calibration parameters... to be replaced by database - AliEMCALCalibData * fCalibData ; //! Calibration database if aval + AliEMCALCalibData * fCalibData ; //! Calibration database if aval + AliCaloCalibPedestal * fCaloPed ; //! Tower status map if aval + Float_t fADCchannelECA ; // width of one ADC channel for EC section (GeV) Float_t fADCpedestalECA ; // pedestal of ADC for EC section (GeV) @@ -113,7 +118,7 @@ private: Float_t fTimeCut ; // Maximum time difference between the digits in ont EMC cluster Float_t fMinECut; // Minimum energy for a digit to be a member of a cluster - ClassDef(AliEMCALClusterizerv1,7) // Clusterizer implementation version 1 + ClassDef(AliEMCALClusterizerv1,8) // Clusterizer implementation version 1 }; diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index 2373496c921..21fa357c1ba 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -57,7 +57,8 @@ ClassImp(AliEMCALLoader) const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points -AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data +AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data +AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data //____________________________________________________________________________ AliEMCALLoader::AliEMCALLoader() @@ -141,6 +142,26 @@ AliEMCALCalibData* AliEMCALLoader::CalibData() } +//____________________________________________________________________________ +AliCaloCalibPedestal* AliEMCALLoader::PedestalData() +{ + // Check if the instance of AliCaloCalibPedestal exists, if not, create it if + // the OCDB is available, and finally return it. + + if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet())) + { + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); + if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject(); + } + + if(!fgCaloPed) + AliFatal("Pedestal info not found in CDB!"); + + return fgCaloPed; + +} + //____________________________________________________________________________ Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, diff --git a/EMCAL/AliEMCALLoader.h b/EMCAL/AliEMCALLoader.h index a923c84c37d..f9bd188073a 100644 --- a/EMCAL/AliEMCALLoader.h +++ b/EMCAL/AliEMCALLoader.h @@ -27,6 +27,7 @@ class TTask ; // --- AliRoot header files --- #include "AliLoader.h" #include "AliEMCALCalibData.h" +#include "AliCaloCalibPedestal.h" class AliLoader ; class AliEMCAL ; @@ -66,7 +67,7 @@ class AliEMCALLoader : public AliLoader { // ************ TClonesArrays Access functions - TClonesArray* Hits(void) { return fHits;} + TClonesArray* Hits(void) const { return fHits;} const AliEMCALHit* Hit(Int_t index) { if (fHits) @@ -74,21 +75,21 @@ class AliEMCALLoader : public AliLoader { return 0x0; } - TClonesArray* SDigits() { return fSDigits;} + TClonesArray* SDigits() const { return fSDigits;} const AliEMCALDigit* SDigit(Int_t index) { if (fSDigits) return (const AliEMCALDigit*) fSDigits->At(index); return 0x0; } - TClonesArray* Digits() { return fDigits;} + TClonesArray* Digits() const { return fDigits;} const AliEMCALDigit * Digit(Int_t index) { if (fDigits) return (const AliEMCALDigit*) fDigits->At(index); return 0x0; } - TObjArray * RecPoints() { return fRecPoints;} + TObjArray * RecPoints() const { return fRecPoints;} const AliEMCALRecPoint * RecPoint(Int_t index) { if (fRecPoints) return (const AliEMCALRecPoint*) fRecPoints->At(index); @@ -104,6 +105,10 @@ class AliEMCALLoader : public AliLoader { void SetCalibData(AliEMCALCalibData* calibda) { fgCalibData = calibda; } AliEMCALCalibData * CalibData(); // to get the calibration CDB object + void SetPedestalData(AliCaloCalibPedestal* caloped) { fgCaloPed = caloped; } + AliCaloCalibPedestal* PedestalData(); // to get the pedestal CDB object + + private: // assignement operator requested by coding convention, but not needed @@ -122,9 +127,10 @@ private: TClonesArray *fSDigits; //! TClonesArray of sdigits (for tree reading) TObjArray *fRecPoints; //! TClonesArray of recpoints (for tree reading) - static AliEMCALCalibData * fgCalibData; // calibration data + static AliEMCALCalibData * fgCalibData; // calibration data + static AliCaloCalibPedestal * fgCaloPed; // dead map - ClassDef(AliEMCALLoader,2) // Algorithm class that provides methods to retrieve objects from a list knowing the index + ClassDef(AliEMCALLoader,3) // Algorithm class that provides methods to retrieve objects from a list knowing the index }; diff --git a/EMCAL/AliEMCALRecPoint.cxx b/EMCAL/AliEMCALRecPoint.cxx index b4d94fc38d8..408f5e9956f 100644 --- a/EMCAL/AliEMCALRecPoint.cxx +++ b/EMCAL/AliEMCALRecPoint.cxx @@ -16,6 +16,8 @@ //_________________________________________________________________________ // Reconstructed Points for the EMCAL // A RecPoint is a cluster of digits +// +// //*-- Author: Yves Schutz (SUBATECH) //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH) //*-- Author: Heather Gray (LBL) merged AliEMCALRecPoint and AliEMCALTowerRecPoint 02/04 @@ -43,6 +45,8 @@ class AliEMCAL; #include "AliEMCALHit.h" #include "AliEMCALDigit.h" #include "AliEMCALRecPoint.h" +#include "AliCaloCalibPedestal.h" +#include "AliEMCALGeoParams.h" ClassImp(AliEMCALRecPoint) @@ -58,7 +62,7 @@ AliEMCALRecPoint::AliEMCALRecPoint() fTime(0.), fNExMax(0), fCoreRadius(10), //HG check this fDETracksList(0), fMulParent(0), fMaxParent(0), fParentsList(0), fDEParentsList(0), fSuperModuleNumber(0), - fDigitIndMax(-1) + fDigitIndMax(-1), fDistToBadTower(-1) { // ctor fGeomPtr = AliEMCALGeometry::GetInstance(); @@ -80,7 +84,7 @@ AliEMCALRecPoint::AliEMCALRecPoint(const char *) fAbsIdList(new Int_t[fMaxDigit]), fTime(-1.), fNExMax(0), fCoreRadius(10), fDETracksList(new Float_t[fMaxTrack]), fMulParent(0), fMaxParent(1000), fParentsList(new Int_t[fMaxParent]), fDEParentsList(new Float_t[fMaxParent]), - fSuperModuleNumber(0), fDigitIndMax(-1) + fSuperModuleNumber(0), fDigitIndMax(-1), fDistToBadTower(-1) { // ctor for (Int_t i = 0; i < fMaxTrack; i++) @@ -110,7 +114,8 @@ AliEMCALRecPoint::AliEMCALRecPoint(const AliEMCALRecPoint & rp) fDETracksList(new Float_t[rp.fMaxTrack]), fMulParent(rp.fMulParent), fMaxParent(rp.fMaxParent), fParentsList(new Int_t[rp.fMaxParent]), fDEParentsList(new Float_t[rp.fMaxParent]), - fSuperModuleNumber(rp.fSuperModuleNumber), fDigitIndMax(rp.fDigitIndMax) + fSuperModuleNumber(rp.fSuperModuleNumber), fDigitIndMax(rp.fDigitIndMax), + fDistToBadTower(rp.fDistToBadTower) { //copy ctor fLambda[0] = rp.fLambda[0]; @@ -193,7 +198,9 @@ AliEMCALRecPoint& AliEMCALRecPoint::operator= (const AliEMCALRecPoint &rp) fLambda[0] = rp.fLambda[0]; fLambda[1] = rp.fLambda[1]; - + + fDistToBadTower = rp.fDistToBadTower; + return *this; } @@ -430,7 +437,7 @@ void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) EvalTime(digits) ; EvalPrimaries(digits) ; EvalParents(digits); - + //Called last because it sets the global position of the cluster? EvalLocal2TrackingCSTransform(); @@ -497,6 +504,49 @@ void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits) fDispersion = TMath::Sqrt(d) ; } +//____________________________________________________________________________ +void AliEMCALRecPoint::EvalDistanceToBadChannels(AliCaloCalibPedestal* caloped) +{ + //For each EMC rec. point set the distance to the nearest bad channel. + //AliInfo(Form("%d bad channel(s) found.\n", caloped->GetDeadTowerCount())); + //Needs to be carefully checked!!! Gustavo 10-11-2009 + + if(!caloped->GetDeadTowerCount()) return; + + //Number of supermodule this cluster belongs. + Int_t iSM = GetSuperModuleNumber(); + + //Get channels map of the supermodule where the cluster is + TH2D* hMap = caloped->GetDeadMap(iSM); + + TVector3 dR; + TVector3 cellpos; + + Int_t minDist = 100000; + Int_t dist = 0; + Int_t absId = -1; + + //Loop on tower status map + for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ + for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ + //Check if tower is bad. + if(hMap->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue; + //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); + //Tower is bad, get the absId of the index. + absId = fGeomPtr->GetAbsCellIdFromCellIndexes(iSM, irow, icol); + //Get the position of this tower. + fGeomPtr->RelPosCellInSModule(absId,cellpos); + //Calculate distance between this tower and cluster, set if is smaller than previous. + dR = cellpos-fLocPos; + dist = dR.Mag(); + if(distGet("EMCAL/Calib/Pedestals"); + if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); + } + + if(!fPedestalData) + AliFatal("Dead map not found in CDB!"); + + //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. - fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData); + fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); if(!fGeom) AliFatal(Form("Could not get geometry!")); @@ -294,8 +306,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig); if(dig->GetAmp() > 0 ){ energy = (static_cast (fgClusterizer))->Calibrate(dig->GetAmp(),dig->GetId()); - emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime()); - idignew++; + if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them + emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime()); + idignew++; + } } } emcCells.SetNumberOfCells(idignew); @@ -383,6 +397,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1); ec->SetPosition(xyz); ec->SetE(clust->GetEnergy()); + + //Distance to the nearest bad crystal + ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); + ec->SetNCells(newCellMult); //Change type of list from short to ushort UShort_t *newAbsIdList = new UShort_t[newCellMult]; diff --git a/EMCAL/AliEMCALReconstructor.h b/EMCAL/AliEMCALReconstructor.h index 4fd2b6424a9..8b491f9294b 100644 --- a/EMCAL/AliEMCALReconstructor.h +++ b/EMCAL/AliEMCALReconstructor.h @@ -10,6 +10,12 @@ //*-- //*-- Author: Yves Schutz (SUBATECH) //*-- Dmitri Peressounko (SUBATECH & Kurchatov Institute) +// Reconstruction class. Redesigned from the old AliReconstructionner class and +// derived from STEER/AliReconstructor. +// +//-- Aleksei Pavlinov : added staf for EMCAL jet trigger 9Apr 25, 2008) +// : fgDigitsArr should read just once at event + // --- ROOT system --- class TList; @@ -32,6 +38,7 @@ class AliRawReader ; class AliEMCALRawUtils; class AliEMCALGeometry; class AliEMCALCalibData ; +class AliCaloCalibPedestal ; // --- Standard library --- @@ -63,7 +70,7 @@ public: void ReadDigitsArrayFromTree(TTree *digitsTree) const; - TList *GetList() {return fList;} + TList *GetList() const {return fList;} static const AliEMCALRecParam* GetRecParam() { return dynamic_cast(AliReconstructor::GetRecoParam(6)); } @@ -88,9 +95,10 @@ private: static AliEMCALRawUtils* fgRawUtils; // raw utilities class - // only need one per reco static TClonesArray* fgDigitsArr; // Array with EMCAL digits - AliEMCALCalibData * fCalibData ; //! Calibration database if aval + AliEMCALCalibData * fCalibData ; //! Calibration database if aval + AliCaloCalibPedestal * fPedestalData ; //! Tower status database if aval - ClassDef(AliEMCALReconstructor,7) // Reconstruction algorithm class (Base Class) + ClassDef(AliEMCALReconstructor,8) // Reconstruction algorithm class (Base Class) }; diff --git a/EMCAL/macros/PedestalDB/AliEMCALPedestalCDB.C b/EMCAL/macros/PedestalDB/AliEMCALPedestalCDB.C new file mode 100644 index 00000000000..b9821072be1 --- /dev/null +++ b/EMCAL/macros/PedestalDB/AliEMCALPedestalCDB.C @@ -0,0 +1,151 @@ +// Script to create dead channel map and store them into CDB +// - 4 sets of maps parameters can be created, with now dead channels +// and 5%, 10%, 20% and 30% of dead channels +// - it reads the stored map in a given file. +// Author: Gustavo Conesa + +//.x $ALICE_ROOT/EMCAL/macros/CalibrationDB/AliEMCALSetTowerStatusCDB.C + +#if !defined(__CINT__) +#include +#include +#include +#include +#include +#include +#include + +#include "AliRun.h" +#include "AliCaloCalibPedestal.h" +#include "AliEMCALGeoParams.h" +#include "AliCDBMetaData.h" +#include "AliCDBId.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" +#endif + + +void AliEMCALPedestalCDB() +{ + TControlBar *menu = new TControlBar("vertical","EMCAL CDB"); + menu->AddButton("Help to run EMCAL CDB","Help()", + "Explains how to use EMCAL CDS menus"); + menu->AddButton("Equal Tower Status Map, all Alive","SetTowerStatusMap(0)", + "Set all channels to alive"); + menu->AddButton("Create Random Status Map, 5% dead","SetTowerStatusMap(5)", + "Set randomly 5% of the channels dead"); + menu->AddButton("Create Random Status Map, 10% dead","SetTowerStatusMap(10)", + "Set randomly 10% of the channels dead"); + menu->AddButton("Create Random Status Map, 20% dead","SetTowerStatusMap(20)", + "Set randomly 20% of the channels dead"); + menu->AddButton("Create Random Status Map, 30% dead","SetTowerStatusMap(30)", + "Set randomly 30% of the channels dead"); + menu->AddButton("Read Tower Status Map","GetTowerStatusMap()", + "Read initial equal calibration coefficients"); + menu->Show(); +} + +//------------------------------------------------------------------------ +void Help() +{ + char *string = + "\nSet tower status map (dead, hot, alive) and write them into ALICE CDB. Press button \"Equal kAlive\" to set all channels alive. Press button \"Random, 5% dead\" to create random dead channel map at 5%\n"; + printf(string); +} + +//------------------------------------------------------------------------ +void SetTowerStatusMap(Int_t percent=0) +{ + // Writing status of all the channels in the OCDB with equal value + // except a percent to be not alive. Right now only "alive" or "dead", + // we need to implement the other cases like "hot" + + TString sDBFolder ="local://PedestalsDB"; + Int_t firstRun = 0; + Int_t lastRun = 999999999; + Int_t beamPeriod = 1; + char* objFormat = Form("%d percent decalibrated channels", percent); + + AliCaloCalibPedestal *caloped=new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); + TObjArray map = caloped->GetDeadMap(); + printf("MAP entries %d\n",map.GetEntries()); + TRandom rn; + //for(Int_t iSM = 0; iSM < AliEMCALGeoParams::fgkEMCALModules; iSM ++){ + for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){ + Int_t ndead = 0; + printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY()); + for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){ + for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){ + //printf("Bin (%d-%d) Content, before: %d ",i,j,((TH2D*)map[iSM])->GetBinContent(i, j)); + + if(rn.Uniform(0,100) > percent) + ((TH2D*)map[iSM])->SetBinContent(i, j, AliCaloCalibPedestal::kAlive); + else{ + ((TH2D*)map[iSM])->SetBinContent(i, j, AliCaloCalibPedestal::kDead); + ndead++; + } + //printf("; after: %d \n",((TH2D*)map[iSM])->GetBinContent(i, j)); + } + } + caloped->SetDeadTowerCount(caloped->GetDeadTowerCount()+ndead); + printf("--- dead %d\n",ndead); + } + + printf("--- total dead %d\n",caloped->GetDeadTowerCount()); + + caloped->SetDeadMap(map); + + //Store map into database + + AliCDBMetaData md; + md.SetComment(objFormat); + md.SetBeamPeriod(beamPeriod); + md.SetResponsible("Gustavo Conesa"); + + AliCDBId id("EMCAL/Calib/Pedestals",firstRun,lastRun); // create in EMCAL/Calib/Pedestal sDBFolder + + AliCDBManager* man = AliCDBManager::Instance(); + AliCDBStorage* loc = man->GetStorage(sDBFolder.Data()); + loc->Put(caloped, id, &md); + +} + +//------------------------------------------------------------------------ +void GetTowerStatusMap() +{ + // Read status map + + TString sDBFolder ="local://PedestalsDB"; + Int_t runNumber = 0; + + AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*) + (AliCDBManager::Instance() + ->GetStorage(sDBFolder.Data()) + ->Get("EMCAL/Calib/Pedestals", + runNumber)->GetObject()); + + cout<GetDeadMap(); + printf("MAP entries %d\n",map.GetEntries()); + for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){ + TCanvas *cMap = new TCanvas(Form("cMap%d",iSM),Form("SM %d dead map",iSM), 12,12,400,400); + cMap->Divide(1,1); + Int_t ndead = 0; + printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY()); + for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){ + for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){ + //printf("Bin (%d-%d) Content: %d \n",i,j,((TH2D*)map[iSM])->GetBinContent(i, j)); + + if(((TH2D*)map[iSM])->GetBinContent(i, j)==AliCaloCalibPedestal::kDead) + ndead++; + } + } + printf("--- dead %d\n",ndead); + cMap->cd(iSM); + (TH2D*)map[iSM])->Draw("lego2"); + } + + printf("Total DEAD %d\n", caloped->GetDeadTowerCount()); + +} diff --git a/OCDB/EMCAL/Calib/Pedestals/Run0_999999999_v0_s0.root b/OCDB/EMCAL/Calib/Pedestals/Run0_999999999_v0_s0.root new file mode 100644 index 00000000000..ab758d7f032 Binary files /dev/null and b/OCDB/EMCAL/Calib/Pedestals/Run0_999999999_v0_s0.root differ