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:
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EcalSeverityLevelAlgo(const edm::ParameterSet &p)
float timeThresh_
Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_.
std::vector< EcalRecHit >::const_iterator const_iterator
constexpr uint32_t mask
Definition: gpuClustering.h:26
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
bool checkFlagMask(uint32_t mask) const
apply a bitmask to our flags. Experts only
Definition: EcalRecHit.h:205
double f[11][100]
std::vector< uint32_t > flagMask_
Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.
const_iterator find(uint32_t rawId) const
const_iterator end() const
Definition: DetId.h:17
std::vector< Item >::const_iterator const_iterator
const EcalChannelStatus * chStatus_
iterator find(key_type k)
float energy() const
Definition: EcalRecHit.h:69
std::vector< uint32_t > dbstatusMask_
Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.
tmp
align.sh
Definition: createJobs.py:716
std::vector< std::string > getParameterNames() const
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:188
#define LogDebug(id)