CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalSeverityLevelAlgo.cc
Go to the documentation of this file.
1 
14 
18 
20 
22 
24 
25 
26  timeThresh_ = p.getParameter< double> ("timeThresh");
27  chStatus_ =0;
28 
29  const edm::ParameterSet & ps=p.getParameter< edm::ParameterSet >("flagMask");
30  std::vector<std::string> severities = ps.getParameterNames();
31  std::vector<std::string> flags;
32 
33  flagMask_.resize(severities.size());
34 
35  // read configuration of severities
36 
37  for (unsigned int is=0;is!=severities.size();++is){
38 
40  (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
41  flags=ps.getParameter<std::vector<std::string> >(severities[is]);
42  uint32_t mask=0;
43  for (unsigned int ifi=0;ifi!=flags.size();++ifi){
45  (EcalRecHit::Flags)StringToEnumValue<EcalRecHit::Flags>(flags[ifi]);
46  //manipulate the mask
47  mask|=(0x1<<f);
48  }
49  flagMask_[snum]=mask;
50  }
51  // read configuration of dbstatus
52 
53  const edm::ParameterSet & dbps=
54  p.getParameter< edm::ParameterSet >("dbstatusMask");
55  std::vector<std::string> dbseverities = dbps.getParameterNames();
56  std::vector<uint32_t> dbflags;
57 
58  dbstatusMask_.resize(dbseverities.size());
59 
60  for (unsigned int is=0;is!=dbseverities.size();++is){
61 
63  (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
64 
65  dbflags=dbps.getParameter<std::vector<uint32_t> >(severities[is]);
66  uint32_t mask=0;
67  for (unsigned int ifi=0;ifi!=dbflags.size();++ifi){
68  int f= dbflags[ifi];
69 
70  //manipulate the mask
71  mask|=(0x1<<f);
72  }
73  dbstatusMask_[snum]=mask;
74  }
75 
76 
77 
78 }
79 
80 
83  const EcalRecHitCollection& rhs) const{
84 
85  using namespace EcalSeverityLevel;
86 
87  // if the detid is within our rechits, evaluate from flag
89  if ( rh != rhs.end() )
90  return severityLevel(*rh);
91 
92 
93  // else evaluate from dbstatus
94 
95  if (!chStatus_)
96  edm::LogError("ObjectNotFound") << "Channel Status not set for EcalSeverityLevelAlgo";
97 
98 
100  uint16_t dbStatus = 0;
101  if ( chIt != chStatus_->end() ) {
102  dbStatus = chIt->getStatusCode() & 0x1F;
103  } else {
104  edm::LogError("ObjectNotFound") << "No channel status found for xtal "
105  << id.rawId()
106  << "! something wrong with EcalChannelStatus in your DB? ";
107  }
108 
109  // kGood==0 we know!
110  if (0==dbStatus) return kGood;
111 
112  // check if the bit corresponding to that dbStatus is set in the mask
113  // This implementation implies that the statuses have a priority
114  for (size_t i=0; i< dbstatusMask_.size();++i){
115  uint32_t tmp = 0x1<<dbStatus;
116  if (dbstatusMask_[i] & tmp) return SeverityLevel(i);
117  }
118 
119  // no matching
120  LogDebug("EcalSeverityLevelAlgo")<<
121  "Unmatched DB status, returning kGood";
122  return kGood;
123 }
124 
125 
128 
129  using namespace EcalSeverityLevel;
130 
131  //if marked good, do not do any further test
132  if (rh.checkFlag(kGood)) return kGood;
133 
134  // check if the bit corresponding to that flag is set in the mask
135  // This implementation implies that severities have a priority...
136  for (int sev=kBad;sev>=0;--sev){
137  if(sev==kTime && rh.energy() < timeThresh_ ) continue;
138  if (rh.checkFlagMask(flagMask_[sev])) return SeverityLevel(sev);
139  }
140 
141  // no matching
142  LogDebug("EcalSeverityLevelAlgo")<< "Unmatched Flag , returning kGood";
143  return kGood;
144 
145 }
146 
147 
148 
149 
150 // Configure (x)emacs for this file ...
151 // Local Variables:
152 // mode:c++
153 // compile-command: "scram b -k"
154 // End:
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
EcalSeverityLevelAlgo(const edm::ParameterSet &p)
float timeThresh_
Return kTime only if the rechit is flagged kOutOfTime and E&gt;timeThresh_.
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:106
float energy() const
Definition: CaloRecHit.h:17
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_iterator end() const
Definition: DetId.h:18
std::vector< Item >::const_iterator const_iterator
const EcalChannelStatus * chStatus_
bool checkFlagMask(uint32_t mask) const
apply a bitmask to our flags. Experts only
Definition: EcalRecHit.h:112
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
iterator find(key_type k)
SeverityLevel
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.