CMS 3D CMS Logo

Static Public Member Functions | Static Private Member Functions

EcalTools Class Reference

#include <EcalTools.h>

List of all members.

Static Public Member Functions

static bool deadNeighbour (const DetId &id, const EcalChannelStatus &chs, int chStatusThreshold, int dx, int dy)
 return true if the channel at offsets dx,dy is dead
static bool isNextToBoundary (const DetId &id)
 true if near a crack or ecal border
static bool isNextToDead (const DetId &id, const edm::EventSetup &es)
 true if the channel is near a dead one (in the 3x3)
static bool isNextToDeadFromNeighbours (const DetId &id, const EcalChannelStatus &chs, int chStatusThreshold)
 same as isNextToDead, but will use information from the neighbour
static float swissCross (const DetId &id, const EcalRecHitCollection &recHits, float recHitThreshold, bool avoidIeta85=true)
 the good old 1-e4/e1. Ignore hits below recHitThreshold

Static Private Member Functions

static float recHitApproxEt (const DetId id, const EcalRecHitCollection &recHits)
static float recHitE (const DetId id, const EcalRecHitCollection &recHits)
static float recHitE (const DetId id, const EcalRecHitCollection &recHits, int dEta, int dPhi)

Detailed Description

Definition at line 18 of file EcalTools.h.


Member Function Documentation

bool EcalTools::deadNeighbour ( const DetId id,
const EcalChannelStatus chs,
int  chStatusThreshold,
int  dx,
int  dy 
) [static]

return true if the channel at offsets dx,dy is dead

Definition at line 89 of file EcalTools.cc.

References EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EEDetId::offsetBy(), and EBDetId::offsetBy().

Referenced by isNextToDeadFromNeighbours().

                                             {

  
  DetId nid;
  if( id.subdetId() == EcalBarrel) nid = EBDetId::offsetBy( id, dx, dy );
  else if( id.subdetId() == EcalEndcap) nid = EEDetId::offsetBy( id, dx, dy );

  if (!nid) return false;

  EcalChannelStatus::const_iterator chIt = chs.find( nid );
  uint16_t dbStatus = 0;
  if ( chIt != chs.end() ) {
    // note that 
    dbStatus = chIt->getStatusCode() ;
  } else {
    edm::LogError("EcalDBError") 
      << "No channel status found for xtal " 
      << id.rawId() 
      << "! something wrong with EcalChannelStatus in your DB? ";
  }

  return (dbStatus>=chStatusThreshold );
  
}
static bool EcalTools::isNextToBoundary ( const DetId id) [static]

true if near a crack or ecal border

bool EcalTools::isNextToDead ( const DetId id,
const edm::EventSetup es 
) [static]

true if the channel is near a dead one (in the 3x3)

This function will use the ChannelStatus record to determine if the channel is next to a dead one, using bit 12 of the channel status word

Definition at line 53 of file EcalTools.cc.

References edm::EventSetup::get().

Referenced by InterestingDetIdCollectionProducer::produce().

                                                                     {
  
  edm::ESHandle<EcalNextToDeadChannel> dch;
  es.get<EcalNextToDeadChannelRcd>().get(dch);
  
  EcalNextToDeadChannel::const_iterator chIt = dch->find( id );

  if ( chIt != dch->end() ) {
    return *chIt;
  } else {
    edm::LogError("EcalDBError") 
      << "No NextToDead  status found for xtal " 
      << id.rawId() ;
  }

  return false;
  
}
bool EcalTools::isNextToDeadFromNeighbours ( const DetId id,
const EcalChannelStatus chs,
int  chStatusThreshold 
) [static]

same as isNextToDead, but will use information from the neighbour

Looks at neighbours in 3x3 and returns true if one of them has chStatus above chStatusThreshold. Use sparingly, slow. Normally isNextToDead() should be used instead.

Definition at line 72 of file EcalTools.cc.

References deadNeighbour().

Referenced by EcalNextToDeadChannelESProducer::findNextToDeadChannelsCallback().

                                                                   {
  
  if (deadNeighbour(id,chs, chStatusThreshold, 1, 0)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold,-1, 0)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold, 0, 1)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold, 0,-1)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold, 1,-1)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold, 1, 1)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold,-1, 1)) return true;
  if (deadNeighbour(id,chs, chStatusThreshold,-1,-1)) return true;

  return false;
}
float EcalTools::recHitApproxEt ( const DetId  id,
const EcalRecHitCollection recHits 
) [static, private]

Definition at line 143 of file EcalTools.cc.

References EBDetId::approxEta(), EcalBarrel, and recHitE().

Referenced by swissCross().

                                                                                    {
  // for the time being works only for the barrel
  if ( id.subdetId() == EcalBarrel ) {
    return recHitE( id, recHits ) / cosh( EBDetId::approxEta( id ) );
  }
  return 0;
}
float EcalTools::recHitE ( const DetId  id,
const EcalRecHitCollection recHits,
int  dEta,
int  dPhi 
) [static, private]

Definition at line 119 of file EcalTools.cc.

References EcalBarrel, EcalEndcap, EEDetId::offsetBy(), EBDetId::offsetBy(), and recHitE().

{
  // in the barrel:   di = dEta   dj = dPhi
  // in the endcap:   di = dX     dj = dY
  
  DetId nid;
  if( id.subdetId() == EcalBarrel) nid = EBDetId::offsetBy( id, di, dj );
  else if( id.subdetId() == EcalEndcap) nid = EEDetId::offsetBy( id, di, dj );
  
  return ( nid == DetId(0) ? 0 : recHitE( nid, recHits ) );
}
float EcalTools::recHitE ( const DetId  id,
const EcalRecHitCollection recHits 
) [static, private]

Definition at line 133 of file EcalTools.cc.

References edm::SortedCollection< T, SORT >::end(), and edm::SortedCollection< T, SORT >::find().

Referenced by recHitApproxEt(), recHitE(), and swissCross().

                                                                             {
  if ( id == DetId(0) ) {
    return 0;
  } else {
    EcalRecHitCollection::const_iterator it = recHits.find( id );
    if ( it != recHits.end() ) return (*it).energy();
  }
  return 0;
}
float EcalTools::swissCross ( const DetId id,
const EcalRecHitCollection recHits,
float  recHitThreshold,
bool  avoidIeta85 = true 
) [static]

the good old 1-e4/e1. Ignore hits below recHitThreshold

Definition at line 12 of file EcalTools.cc.

References abs, EcalBarrel, EcalEndcap, EBDetId::ieta(), recHitApproxEt(), and recHitE().

Referenced by EBRecoSummary::analyze(), ZeeCandidateFilter::filter(), and HiSpikeCleaner::produce().

                                              {
  // compute swissCross
  if ( id.subdetId() == EcalBarrel ) {
    EBDetId ebId( id );
    // avoid recHits at |eta|=85 where one side of the neighbours is missing
    // (may improve considering also eta module borders, but no
    // evidence for the time being that there the performance is
    // different)
    if ( abs(ebId.ieta())==85 && avoidIeta85) return 0;
    // select recHits with Et above recHitThreshold
    if ( recHitApproxEt( id, recHits ) < recHitThreshold ) return 0;
    float s4 = 0;
    float e1 = recHitE( id, recHits );
    // protect against nan (if 0 threshold is given above)
    if ( e1 == 0 ) return 0;
    s4 += recHitE( id, recHits,  1,  0 );
    s4 += recHitE( id, recHits, -1,  0 );
    s4 += recHitE( id, recHits,  0,  1 );
    s4 += recHitE( id, recHits,  0, -1 );
    return 1 - s4 / e1;
  } else if ( id.subdetId() == EcalEndcap ) {
    EEDetId eeId( id );
    // select recHits with E above recHitThreshold
    float e1 = recHitE( id, recHits );
    if ( e1 < recHitThreshold ) return 0;
    float s4 = 0;
    // protect against nan (if 0 threshold is given above)
    if ( e1 == 0 ) return 0;
    s4 += recHitE( id, recHits,  1,  0 );
    s4 += recHitE( id, recHits, -1,  0 );
    s4 += recHitE( id, recHits,  0,  1 );
    s4 += recHitE( id, recHits,  0, -1 );
    return 1 - s4 / e1;
  }
  return 0;
}