CMS 3D CMS Logo

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

#include <EcalSeverityLevelAlgo.h>

Public Member Functions

 EcalSeverityLevelAlgo (const edm::ParameterSet &p)
 
void setChannelStatus (const EcalChannelStatus &chs)
 Set the ChannelStatus record. More...
 
EcalSeverityLevel::SeverityLevel severityLevel (const DetId &id, const EcalRecHitCollection &rhs) const
 Evaluate status from id. More...
 
EcalSeverityLevel::SeverityLevel severityLevel (const EcalRecHit &rh) const
 Evaluate status from rechit, using its EcalRecHit::Flag. More...
 

Private Attributes

const EcalChannelStatuschStatus_
 
std::vector< uint32_t > dbstatusMask_
 Configure which DBStatus::Flag is mapped into which EcalSeverityLevel. More...
 
std::vector< uint32_t > flagMask_
 Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel. More...
 
float timeThresh_
 Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_. More...
 

Detailed Description

Definition at line 36 of file EcalSeverityLevelAlgo.h.

Constructor & Destructor Documentation

EcalSeverityLevelAlgo::EcalSeverityLevelAlgo ( const edm::ParameterSet p)
explicit

Definition at line 24 of file EcalSeverityLevelAlgo.cc.

References chStatus_, dbstatusMask_, f, flagMask_, flags, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), and timeThresh_.

24  {
25 
26 
27  timeThresh_ = p.getParameter< double> ("timeThresh");
28  chStatus_ =0;
29 
30  const edm::ParameterSet & ps=p.getParameter< edm::ParameterSet >("flagMask");
31  std::vector<std::string> severities = ps.getParameterNames();
32  std::vector<std::string> flags;
33 
34  flagMask_.resize(severities.size());
35 
36  // read configuration of severities
37 
38  for (unsigned int is=0;is!=severities.size();++is){
39 
41  (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
42  flags=ps.getParameter<std::vector<std::string> >(severities[is]);
43  uint32_t mask=0;
44  for (unsigned int ifi=0;ifi!=flags.size();++ifi){
46  (EcalRecHit::Flags)StringToEnumValue<EcalRecHit::Flags>(flags[ifi]);
47  //manipulate the mask
48  mask|=(0x1<<f);
49  }
50  flagMask_[snum]=mask;
51  }
52  // read configuration of dbstatus
53 
54  const edm::ParameterSet & dbps=
55  p.getParameter< edm::ParameterSet >("dbstatusMask");
56  std::vector<std::string> dbseverities = dbps.getParameterNames();
57  std::vector<uint32_t> dbflags;
58 
59  dbstatusMask_.resize(dbseverities.size());
60 
61  for (unsigned int is=0;is!=dbseverities.size();++is){
62 
64  (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
65 
66  dbflags=dbps.getParameter<std::vector<uint32_t> >(severities[is]);
67  uint32_t mask=0;
68  for (unsigned int ifi=0;ifi!=dbflags.size();++ifi){
69  int f= dbflags[ifi];
70 
71  //manipulate the mask
72  mask|=(0x1<<f);
73  }
74  dbstatusMask_[snum]=mask;
75  }
76 
77 
78 
79 }
T getParameter(std::string const &) const
float timeThresh_
Return kTime only if the rechit is flagged kOutOfTime and E&gt;timeThresh_.
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
double f[11][100]
std::vector< std::string > getParameterNames() const
std::vector< uint32_t > flagMask_
Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.
const EcalChannelStatus * chStatus_
std::vector< uint32_t > dbstatusMask_
Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.

Member Function Documentation

void EcalSeverityLevelAlgo::setChannelStatus ( const EcalChannelStatus chs)
inline

Set the ChannelStatus record.

Definition at line 58 of file EcalSeverityLevelAlgo.h.

References chStatus_.

58 {chStatus_=&chs;}
const EcalChannelStatus * chStatus_
EcalSeverityLevel::SeverityLevel EcalSeverityLevelAlgo::severityLevel ( const DetId id,
const EcalRecHitCollection rhs 
) const

Evaluate status from id.

If the id is in the collection, use the EcalRecHit::Flag else use the channelStatus from DB

Definition at line 83 of file EcalSeverityLevelAlgo.cc.

References chStatus_, dbstatusMask_, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), EcalCondObjectContainer< T >::find(), edm::SortedCollection< T, SORT >::find(), i, EcalSeverityLevel::kGood, LogDebug, and tmp.

Referenced by EcalClusterSeverityLevelAlgo::closestProblematic(), egammaisolation::EgammaRecHitExtractor::collect(), CaloTowersCreationAlgo::convert(), CaloTowersCreationAlgo::ecalChanStatusForCaloTower(), spr::eECALmatrix(), EgammaRecHitIsolation::getSum_(), EcalClusterSeverityLevelAlgo::goodFraction(), HybridClusterAlgo::makeClusters(), InterestingDetIdCollectionProducer::produce(), EcalClusterTools::recHitEnergy(), EcalSeverityLevelService::severityLevel(), and ObjectValidator::validHit().

84  {
85 
86  using namespace EcalSeverityLevel;
87 
88  // if the detid is within our rechits, evaluate from flag
90  if ( rh != rhs.end() )
91  return severityLevel(*rh);
92 
93 
94  // else evaluate from dbstatus
95 
96  if (!chStatus_)
97  edm::LogError("ObjectNotFound") << "Channel Status not set for EcalSeverityLevelAlgo";
98 
99 
101  uint16_t dbStatus = 0;
102  if ( chIt != chStatus_->end() ) {
103  dbStatus = chIt->getStatusCode() & 0x1F;
104  } else {
105  edm::LogError("ObjectNotFound") << "No channel status found for xtal "
106  << id.rawId()
107  << "! something wrong with EcalChannelStatus in your DB? ";
108  }
109 
110  // kGood==0 we know!
111  if (0==dbStatus) return kGood;
112 
113  // check if the bit corresponding to that dbStatus is set in the mask
114  // This implementation implies that the statuses have a priority
115  for (size_t i=0; i< dbstatusMask_.size();++i){
116  uint32_t tmp = 0x1<<dbStatus;
117  if (dbstatusMask_[i] & tmp) return SeverityLevel(i);
118  }
119 
120  // no matching
121  LogDebug("EcalSeverityLevelAlgo")<<
122  "Unmatched DB status, returning kGood";
123  return kGood;
124 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< EcalRecHit >::const_iterator const_iterator
const_iterator end() const
std::vector< Item >::const_iterator const_iterator
const EcalChannelStatus * chStatus_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
iterator find(key_type k)
const_iterator find(uint32_t rawId) const
const_iterator end() const
std::vector< uint32_t > dbstatusMask_
Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id, const EcalRecHitCollection &rhs) const
Evaluate status from id.
EcalSeverityLevel::SeverityLevel EcalSeverityLevelAlgo::severityLevel ( const EcalRecHit rh) const

Evaluate status from rechit, using its EcalRecHit::Flag.

Definition at line 128 of file EcalSeverityLevelAlgo.cc.

References EcalRecHit::checkFlag(), EcalRecHit::checkFlagMask(), CaloRecHit::energy(), flagMask_, EcalSeverityLevel::kBad, EcalSeverityLevel::kGood, EcalSeverityLevel::kTime, LogDebug, and timeThresh_.

128  {
129 
130  using namespace EcalSeverityLevel;
131 
132  //if marked good, do not do any further test
133  if (rh.checkFlag(kGood)) return kGood;
134 
135  // check if the bit corresponding to that flag is set in the mask
136  // This implementation implies that severities have a priority...
137  for (int sev=kBad;sev>=0;--sev){
138  if(sev==kTime && rh.energy() < timeThresh_ ) continue;
139  if (rh.checkFlagMask(flagMask_[sev])) return SeverityLevel(sev);
140  }
141 
142  // no matching
143  LogDebug("EcalSeverityLevelAlgo")<< "Unmatched Flag , returning kGood";
144  return kGood;
145 
146 }
#define LogDebug(id)
float timeThresh_
Return kTime only if the rechit is flagged kOutOfTime and E&gt;timeThresh_.
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:103
float energy() const
Definition: CaloRecHit.h:19
std::vector< uint32_t > flagMask_
Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.
bool checkFlagMask(uint32_t mask) const
apply a bitmask to our flags. Experts only
Definition: EcalRecHit.h:109

Member Data Documentation

const EcalChannelStatus* EcalSeverityLevelAlgo::chStatus_
private

Definition at line 80 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), setChannelStatus(), and severityLevel().

std::vector<uint32_t> EcalSeverityLevelAlgo::dbstatusMask_
private

Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.

The position in the vector is the EcalSeverityLevel The content defines which EcalRecHit::Flag should be mapped into that EcalSeverityLevel in a bit-wise way

Definition at line 74 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().

std::vector<uint32_t> EcalSeverityLevelAlgo::flagMask_
private

Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.

The position in the vector is the EcalSeverityLevel The content defines which EcalRecHit::Flag should be mapped into that EcalSeverityLevel in a bit-wise way

Definition at line 67 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().

float EcalSeverityLevelAlgo::timeThresh_
private

Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_.

Definition at line 78 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().