CMS 3D CMS Logo

EcalSeverityLevelAlgo.cc
Go to the documentation of this file.
1 
12 
16 
18 
20 
22  timeThresh_ = p.getParameter<double>("timeThresh");
23  chStatus_ = nullptr;
24 
25  const edm::ParameterSet& ps = p.getParameter<edm::ParameterSet>("flagMask");
26  std::vector<std::string> severities = ps.getParameterNames();
27  std::vector<std::string> flags;
28 
29  flagMask_.resize(severities.size());
30 
31  // read configuration of severities
32 
33  for (unsigned int is = 0; is != severities.size(); ++is) {
35  (EcalSeverityLevel::SeverityLevel)StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
36  flags = ps.getParameter<std::vector<std::string> >(severities[is]);
37  uint32_t mask = 0;
38  for (unsigned int ifi = 0; ifi != flags.size(); ++ifi) {
39  EcalRecHit::Flags f = (EcalRecHit::Flags)StringToEnumValue<EcalRecHit::Flags>(flags[ifi]);
40  //manipulate the mask
41  mask |= (0x1 << f);
42  }
43 
44  flagMask_[snum] = mask;
45  }
46  // read configuration of dbstatus
47 
48  const edm::ParameterSet& dbps = p.getParameter<edm::ParameterSet>("dbstatusMask");
49  std::vector<std::string> dbseverities = dbps.getParameterNames();
50  std::vector<std::string> dbflags;
51 
52  dbstatusMask_.resize(dbseverities.size());
53 
54  for (unsigned int is = 0; is != dbseverities.size(); ++is) {
56  (EcalSeverityLevel::SeverityLevel)StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
57 
58  dbflags = dbps.getParameter<std::vector<std::string> >(severities[is]);
59  uint32_t mask = 0;
60  for (unsigned int ifi = 0; ifi != dbflags.size(); ++ifi) {
62  (EcalChannelStatusCode::Code)StringToEnumValue<EcalChannelStatusCode::Code>(dbflags[ifi]);
63 
64  //manipulate the mask
65  mask |= (0x1 << f);
66  }
67 
68  dbstatusMask_[snum] = mask;
69  }
70 }
71 
73  const EcalRecHitCollection& rhs) const {
74  using namespace EcalSeverityLevel;
75 
76  // if the detid is within our rechits, evaluate from flag
78  if (rh != rhs.end())
79  return severityLevel(*rh);
80 
81  // else evaluate from dbstatus
82  return severityLevel(id);
83 }
84 
86  using namespace EcalSeverityLevel;
87 
89 
90  uint16_t dbStatus = chIt->getStatusCode();
91 
92  // kGood==0 we know!
93  if (0 == dbStatus)
94  return kGood;
95 
96  // check if the bit corresponding to that dbStatus is set in the mask
97  // This implementation implies that the statuses have a priority
98  for (size_t i = 0; i < dbstatusMask_.size(); ++i) {
99  uint32_t tmp = 0x1 << dbStatus;
100  if (dbstatusMask_[i] & tmp)
101  return SeverityLevel(i);
102  }
103 
104  // no matching
105  LogDebug("EcalSeverityLevelAlgo") << "Unmatched DB status, returning kGood";
106  return kGood;
107 }
108 
110  using namespace EcalSeverityLevel;
111 
112  //if marked good, do not do any further test
113  if (rh.checkFlag(kGood))
114  return kGood;
115 
116  // check if the bit corresponding to that flag is set in the mask
117  // This implementation implies that severities have a priority...
118  for (int sev = kBad; sev >= 0; --sev) {
119  if (sev == kTime && rh.energy() < timeThresh_)
120  continue;
121  if (rh.checkFlagMask(flagMask_[sev]))
122  return SeverityLevel(sev);
123  }
124 
125  // no matching
126  LogDebug("EcalSeverityLevelAlgo") << "Unmatched Flag , returning kGood";
127  return kGood;
128 }
129 
130 // Configure (x)emacs for this file ...
131 // Local Variables:
132 // mode:c++
133 // compile-command: "scram b -k"
134 // End:
EcalRecHit
Definition: EcalRecHit.h:15
mps_fire.i
i
Definition: mps_fire.py:428
EcalSeverityLevel::kGood
Definition: EcalSeverityLevel.h:19
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
EcalSeverityLevelAlgo::dbstatusMask_
std::vector< uint32_t > dbstatusMask_
Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.
Definition: EcalSeverityLevelAlgo.h:62
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
EcalRecHit::Flags
Flags
Definition: EcalRecHit.h:20
edm::SortedCollection< EcalRecHit >
EcalRecHit::energy
float energy() const
Definition: EcalRecHit.h:68
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
DetId
Definition: DetId.h:17
EcalRecHit::checkFlag
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:187
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
StringToEnumValue.h
EcalRecHit.h
EcalSeverityLevelAlgo.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalSeverityLevelAlgo::flagMask_
std::vector< uint32_t > flagMask_
Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.
Definition: EcalSeverityLevelAlgo.h:56
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
EcalSeverityLevelAlgo::timeThresh_
float timeThresh_
Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_.
Definition: EcalSeverityLevelAlgo.h:65
EcalSeverityLevel::SeverityLevel
SeverityLevel
Definition: EcalSeverityLevel.h:18
EcalSeverityLevel
Definition: EcalSeverityLevel.h:16
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
EcalChannelStatusCode::Code
Code
Definition: EcalChannelStatusCode.h:20
EcalSeverityLevelAlgo::EcalSeverityLevelAlgo
EcalSeverityLevelAlgo(const edm::ParameterSet &p)
Definition: EcalSeverityLevelAlgo.cc:21
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalSeverityLevelAlgo::chStatus_
const EcalChannelStatus * chStatus_
Definition: EcalSeverityLevelAlgo.h:67
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
EcalSeverityLevel::kBad
Definition: EcalSeverityLevel.h:24
ParameterSet.h
EcalRecHit::checkFlagMask
bool checkFlagMask(uint32_t mask) const
apply a bitmask to our flags. Experts only
Definition: EcalRecHit.h:204
HLT_FULL_cff.flags
flags
Definition: HLT_FULL_cff.py:13150
EcalChannelStatusRcd.h
EcalSeverityLevel::kTime
Definition: EcalSeverityLevel.h:22