From 2ebdefe6c93ffbe736557098228dab83fcfe3a4a Mon Sep 17 00:00:00 2001 From: gconesab Date: Tue, 14 Sep 2010 17:00:11 +0000 Subject: [PATCH] AliEMCALRecPoint:Calculate distance to bad channel in cell units. Correct coverity reports. AliEMCALGeometry:Remove include of AliEMCALRecPoint, not needed anymore libEMCALrec.pkg: put AliEMCALTracker in include, for usage during analysis. --- EMCAL/AliEMCALGeometry.cxx | 2 +- EMCAL/AliEMCALRecPoint.cxx | 198 +++++++++++++++++++++++-------------- EMCAL/AliEMCALRecPoint.h | 2 +- EMCAL/libEMCALrec.pkg | 2 + 4 files changed, 126 insertions(+), 78 deletions(-) diff --git a/EMCAL/AliEMCALGeometry.cxx b/EMCAL/AliEMCALGeometry.cxx index bc6e5cdefb0..34b45f2f318 100644 --- a/EMCAL/AliEMCALGeometry.cxx +++ b/EMCAL/AliEMCALGeometry.cxx @@ -57,7 +57,7 @@ // // --- EMCAL headers #include "AliEMCALGeometry.h" #include "AliEMCALShishKebabTrd1Module.h" -#include "AliEMCALRecPoint.h" +//#include "AliEMCALRecPoint.h" //#include "AliEMCALHistoUtilities.h" ClassImp(AliEMCALGeometry) diff --git a/EMCAL/AliEMCALRecPoint.cxx b/EMCAL/AliEMCALRecPoint.cxx index 72786d8cb14..ec0b5094ad3 100644 --- a/EMCAL/AliEMCALRecPoint.cxx +++ b/EMCAL/AliEMCALRecPoint.cxx @@ -545,47 +545,62 @@ 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 + //It is done in cell units and not in global or local position as before (Sept 2010) if(!caloped->GetDeadTowerCount()) return; //Get channels map of the supermodule where the cluster is. TH2D* hMap = caloped->GetDeadMap(fSuperModuleNumber); - TVector3 dR; - TVector3 cellpos; - Float_t minDist = 100000; - Float_t dist = 0; - Int_t absId = -1; - - //Loop on tower status map + Int_t dRrow, dReta; + Float_t minDist = 10000.; + Float_t dist = 0.; + Int_t nSupMod, nModule; + Int_t nIphi, nIeta; + Int_t iphi, ieta; + fDigitIndMax = GetMaximalEnergyIndex(); + fGeomPtr->GetCellIndex(fAbsIdList[fDigitIndMax], nSupMod,nModule,nIphi,nIeta); + fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); + + // TVector3 dR; + // TVector3 cellpos; + // Float_t minDist = 100000; + // Float_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(fSuperModuleNumber, irow, icol); - - //Get the position of this tower. - - //Calculate the distance in local coordinates - //fGeomPtr->RelPosCellInSModule(absId,cellpos); - //Calculate distance between this tower and cluster, set if is smaller than previous. - //dR = cellpos-fLocPos; - - //Calculate the distance in global coordinates - fGeomPtr->GetGlobal(absId,cellpos); - //Calculate distance between this tower and cluster, set if it is smaller than previous. - dR = cellpos-fGlobPos; - - dist = dR.Mag(); + //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); + + dRrow=TMath::Abs(irow-iphi); + dReta=TMath::Abs(icol-ieta); + dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); if(dist < minDist) minDist = dist; + + // //Tower is bad, get the absId of the index. + // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(fSuperModuleNumber, irow, icol); + // + // //Get the position of this tower. + // + // //Calculate the distance in local coordinates + // //fGeomPtr->RelPosCellInSModule(absId,cellpos); + // //Calculate distance between this tower and cluster, set if is smaller than previous. + // //dR = cellpos-fLocPos; + // + // //Calculate the distance in global coordinates + // fGeomPtr->GetGlobal(absId,cellpos); + // //Calculate distance between this tower and cluster, set if it is smaller than previous. + // dR = cellpos-fGlobPos; + // + // dist = dR.Mag(); + // if(dist < minDist) minDist = dist; + } } - - + //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module if (fSharedCluster) { TH2D* hMap2 = 0; @@ -595,33 +610,44 @@ void AliEMCALRecPoint::EvalDistanceToBadChannels(AliCaloCalibPedestal* caloped) if(fSuperModuleNumber%2) nSupMod2 = fSuperModuleNumber-1; else nSupMod2 = fSuperModuleNumber+1; hMap2 = caloped->GetDeadMap(nSupMod2); - - + //Loop on tower status map of second super module for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ //Check if tower is bad. if(hMap2->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(nSupMod2, irow, icol); - - //Get the position of this tower. - - //Calculate the distance in global coordinates - fGeomPtr->GetGlobal(absId,cellpos); - //Calculate distance between this tower and cluster, set if it is smaller than previous. - dR = cellpos-fGlobPos; - - dist = dR.Mag(); - if(dist < minDist) minDist = dist; + + dRrow=TMath::Abs(irow-iphi); + + if(fSuperModuleNumber%2) { + dReta=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+ieta)); + } + else { + dReta=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-ieta); + } + + dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); + if(dist < minDist) minDist = dist; + +// +// //Tower is bad, get the absId of the index. +// absId = fGeomPtr->GetAbsCellIdFromCellIndexes(nSupMod2, irow, icol); +// +// //Get the position of this tower. +// +// //Calculate the distance in global coordinates +// fGeomPtr->GetGlobal(absId,cellpos); +// //Calculate distance between this tower and cluster, set if it is smaller than previous. +// dR = cellpos-fGlobPos; +// +// dist = dR.Mag(); +// if(dist < minDist) minDist = dist; } } }// shared cluster in 2 SuperModules - - + fDistToBadTower = minDist; //printf("AliEMCALRecPoint::EvalDistanceToBadChannel() - Distance to Bad is %f cm, shared cluster? %d \n",fDistToBadTower,fSharedCluster); } @@ -645,6 +671,11 @@ void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digit for(Int_t iDigit=0; iDigit(digits->At(fDigitsList[iDigit])) ; + if(!digit) { + AliError("No Digit!!"); + continue; + } + //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]); fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]); @@ -723,6 +754,11 @@ void AliEMCALRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digi for(Int_t iDigit=0; iDigit(digits->At(fDigitsList[iDigit])) ; + if(!digit) { + AliError("No Digit!!"); + continue; + } + //Get the local coordinates of the cell //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, lxyzi[0], lxyzi[1], lxyzi[2]); fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, lxyzi[0], lxyzi[1], lxyzi[2]); @@ -1075,38 +1111,43 @@ void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits) AliEMCALDigit * digit =0; Int_t * primArray = new Int_t[fMaxTrack] ; Float_t * dEPrimArray = new Float_t[fMaxTrack] ; - + Int_t index ; for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits digit = dynamic_cast(digits->At( fDigitsList[index] )) ; + if(!digit) { + AliError("No Digit!!"); + continue; + } + Int_t nprimaries = digit->GetNprimary() ; if ( nprimaries == 0 ) continue ; Int_t jndex ; for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit if ( fMulTrack > fMaxTrack ) { - fMulTrack = fMaxTrack ; - Error("EvalPrimaries", "increase fMaxTrack ") ; - break ; + fMulTrack = fMaxTrack ; + Error("EvalPrimaries", "increase fMaxTrack ") ; + break ; } Int_t newPrimary = digit->GetPrimary(jndex+1); Float_t dEPrimary = digit->GetDEPrimary(jndex+1); Int_t kndex ; Bool_t already = kFALSE ; for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored - if ( newPrimary == primArray[kndex] ){ - already = kTRUE ; - dEPrimArray[kndex] += dEPrimary; - break ; - } + if ( newPrimary == primArray[kndex] ){ + already = kTRUE ; + dEPrimArray[kndex] += dEPrimary; + break ; + } } // end of check if ( !already && (fMulTrack < fMaxTrack)) { // store it - primArray[fMulTrack] = newPrimary ; - dEPrimArray[fMulTrack] = dEPrimary ; - fMulTrack++ ; + primArray[fMulTrack] = newPrimary ; + dEPrimArray[fMulTrack] = dEPrimary ; + fMulTrack++ ; } // store it } // all primaries in digit } // all digits - + Int_t *sortIdx = new Int_t[fMulTrack]; TMath::Sort(fMulTrack,dEPrimArray,sortIdx); for(index = 0; index < fMulTrack; index++) { @@ -1116,52 +1157,57 @@ void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits) delete [] sortIdx; delete [] primArray ; delete [] dEPrimArray ; - + } //______________________________________________________________________________ void AliEMCALRecPoint::EvalParents(TClonesArray * digits) { // Constructs the list of parent particles (tracks) which have contributed to this RecPoint - + AliEMCALDigit * digit=0 ; Int_t * parentArray = new Int_t[fMaxTrack] ; Float_t * dEParentArray = new Float_t[fMaxTrack] ; - + Int_t index ; for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0) - AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index)); + AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index)); digit = dynamic_cast(digits->At( fDigitsList[index] )) ; + if(!digit) { + AliError("No Digit!!"); + continue; + } + Int_t nparents = digit->GetNiparent() ; if ( nparents == 0 ) continue ; - + Int_t jndex ; for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit if ( fMulParent > fMaxParent ) { - fMulTrack = - 1 ; - Error("EvalParents", "increase fMaxParent") ; - break ; + fMulTrack = - 1 ; + Error("EvalParents", "increase fMaxParent") ; + break ; } Int_t newParent = digit->GetIparent(jndex+1) ; Float_t newdEParent = digit->GetDEParent(jndex+1) ; Int_t kndex ; Bool_t already = kFALSE ; for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored - if ( newParent == parentArray[kndex] ){ - dEParentArray[kndex] += newdEParent; - already = kTRUE ; - break ; - } + if ( newParent == parentArray[kndex] ){ + dEParentArray[kndex] += newdEParent; + already = kTRUE ; + break ; + } } // end of check if ( !already && (fMulParent < fMaxParent)) { // store it - parentArray[fMulParent] = newParent ; - dEParentArray[fMulParent] = newdEParent ; - fMulParent++ ; + parentArray[fMulParent] = newParent ; + dEParentArray[fMulParent] = newdEParent ; + fMulParent++ ; } // store it } // all parents in digit } // all digits - + if (fMulParent>0) { Int_t *sortIdx = new Int_t[fMulParent]; TMath::Sort(fMulParent,dEParentArray,sortIdx); @@ -1171,7 +1217,7 @@ void AliEMCALRecPoint::EvalParents(TClonesArray * digits) } delete [] sortIdx; } - + delete [] parentArray; delete [] dEParentArray; } diff --git a/EMCAL/AliEMCALRecPoint.h b/EMCAL/AliEMCALRecPoint.h index 401db18963b..dc64d061b4b 100644 --- a/EMCAL/AliEMCALRecPoint.h +++ b/EMCAL/AliEMCALRecPoint.h @@ -122,7 +122,7 @@ class AliEMCALRecPoint : public AliCluster { Float_t GetTime(void) const { return fTime ; } Bool_t SharedCluster(void) const { return fSharedCluster ; } - void SetSharedCluster(Bool_t s){ s = fSharedCluster ; } + void SetSharedCluster(Bool_t s){ fSharedCluster = s ; } virtual Bool_t IsEmc(void) const { return kTRUE ; } virtual Bool_t IsSortable() const { diff --git a/EMCAL/libEMCALrec.pkg b/EMCAL/libEMCALrec.pkg index f1e92587971..ae76b125b32 100644 --- a/EMCAL/libEMCALrec.pkg +++ b/EMCAL/libEMCALrec.pkg @@ -21,6 +21,8 @@ DHDR:=EMCALrecLinkDef.h # have to tune EINCLUDE:=PYTHIA6 RAW EVGEN THijing VZERO +EXPORT:=AliEMCALTrack.h + ifeq (win32gcc,$(ALICE_TARGET)) PACKSOFLAGS:= $(SOFLAGS) -L$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET) \ -lEMCALUtils -lEMCALbase -lEMCALsim -lSTEER -lESD -lCDB -lSTEERBase \ -- 2.39.3