CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions | Static Private Member Functions
EcalTools Class Reference

#include <EcalTools.h>

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

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(), EBDetId::offsetBy(), and EEDetId::offsetBy().

Referenced by isNextToDeadFromNeighbours().

92  {
93 
94 
95  DetId nid;
96  if( id.subdetId() == EcalBarrel) nid = EBDetId::offsetBy( id, dx, dy );
97  else if( id.subdetId() == EcalEndcap) nid = EEDetId::offsetBy( id, dx, dy );
98 
99  if (!nid) return false;
100 
101  EcalChannelStatus::const_iterator chIt = chs.find( nid );
102  uint16_t dbStatus = 0;
103  if ( chIt != chs.end() ) {
104  // note that
105  dbStatus = chIt->getStatusCode() ;
106  } else {
107  edm::LogError("EcalDBError")
108  << "No channel status found for xtal "
109  << id.rawId()
110  << "! something wrong with EcalChannelStatus in your DB? ";
111  }
112 
113  return (dbStatus>=chStatusThreshold );
114 
115 }
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:490
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:111
Definition: DetId.h:20
std::vector< Item >::const_iterator const_iterator
const_iterator find(uint32_t rawId) const
const_iterator end() const
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().

53  {
54 
56  es.get<EcalNextToDeadChannelRcd>().get(dch);
57 
58  EcalNextToDeadChannel::const_iterator chIt = dch->find( id );
59 
60  if ( chIt != dch->end() ) {
61  return *chIt;
62  } else {
63  edm::LogError("EcalDBError")
64  << "No NextToDead status found for xtal "
65  << id.rawId() ;
66  }
67 
68  return false;
69 
70 }
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
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().

74  {
75 
76  if (deadNeighbour(id,chs, chStatusThreshold, 1, 0)) return true;
77  if (deadNeighbour(id,chs, chStatusThreshold,-1, 0)) return true;
78  if (deadNeighbour(id,chs, chStatusThreshold, 0, 1)) return true;
79  if (deadNeighbour(id,chs, chStatusThreshold, 0,-1)) return true;
80  if (deadNeighbour(id,chs, chStatusThreshold, 1,-1)) return true;
81  if (deadNeighbour(id,chs, chStatusThreshold, 1, 1)) return true;
82  if (deadNeighbour(id,chs, chStatusThreshold,-1, 1)) return true;
83  if (deadNeighbour(id,chs, chStatusThreshold,-1,-1)) return true;
84 
85  return false;
86 }
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
Definition: EcalTools.cc:89
float EcalTools::recHitApproxEt ( const DetId  id,
const EcalRecHitCollection recHits 
)
staticprivate

Definition at line 143 of file EcalTools.cc.

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

Referenced by swissCross().

143  {
144  // for the time being works only for the barrel
145  if ( id.subdetId() == EcalBarrel ) {
146  return recHitE( id, recHits ) / cosh( EBDetId::approxEta( id ) );
147  }
148  return 0;
149 }
float approxEta() const
Definition: EBDetId.h:93
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:133
float EcalTools::recHitE ( const DetId  id,
const EcalRecHitCollection recHits 
)
staticprivate

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().

133  {
134  if ( id == DetId(0) ) {
135  return 0;
136  } else {
137  EcalRecHitCollection::const_iterator it = recHits.find( id );
138  if ( it != recHits.end() ) return (*it).energy();
139  }
140  return 0;
141 }
std::vector< EcalRecHit >::const_iterator const_iterator
const_iterator end() const
Definition: DetId.h:20
iterator find(key_type k)
float EcalTools::recHitE ( const DetId  id,
const EcalRecHitCollection recHits,
int  dEta,
int  dPhi 
)
staticprivate

Definition at line 119 of file EcalTools.cc.

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

122 {
123  // in the barrel: di = dEta dj = dPhi
124  // in the endcap: di = dX dj = dY
125 
126  DetId nid;
127  if( id.subdetId() == EcalBarrel) nid = EBDetId::offsetBy( id, di, dj );
128  else if( id.subdetId() == EcalEndcap) nid = EEDetId::offsetBy( id, di, dj );
129 
130  return ( nid == DetId(0) ? 0 : recHitE( nid, recHits ) );
131 }
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:490
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:111
Definition: DetId.h:20
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:133
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().

15  {
16  // compute swissCross
17  if ( id.subdetId() == EcalBarrel ) {
18  EBDetId ebId( id );
19  // avoid recHits at |eta|=85 where one side of the neighbours is missing
20  // (may improve considering also eta module borders, but no
21  // evidence for the time being that there the performance is
22  // different)
23  if ( abs(ebId.ieta())==85 && avoidIeta85) return 0;
24  // select recHits with Et above recHitThreshold
25  if ( recHitApproxEt( id, recHits ) < recHitThreshold ) return 0;
26  float s4 = 0;
27  float e1 = recHitE( id, recHits );
28  // protect against nan (if 0 threshold is given above)
29  if ( e1 == 0 ) return 0;
30  s4 += recHitE( id, recHits, 1, 0 );
31  s4 += recHitE( id, recHits, -1, 0 );
32  s4 += recHitE( id, recHits, 0, 1 );
33  s4 += recHitE( id, recHits, 0, -1 );
34  return 1 - s4 / e1;
35  } else if ( id.subdetId() == EcalEndcap ) {
36  EEDetId eeId( id );
37  // select recHits with E above recHitThreshold
38  float e1 = recHitE( id, recHits );
39  if ( e1 < recHitThreshold ) return 0;
40  float s4 = 0;
41  // protect against nan (if 0 threshold is given above)
42  if ( e1 == 0 ) return 0;
43  s4 += recHitE( id, recHits, 1, 0 );
44  s4 += recHitE( id, recHits, -1, 0 );
45  s4 += recHitE( id, recHits, 0, 1 );
46  s4 += recHitE( id, recHits, 0, -1 );
47  return 1 - s4 / e1;
48  }
49  return 0;
50 }
#define abs(x)
Definition: mlp_lapack.h:159
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:133
static float recHitApproxEt(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:143