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 
15 
19 
21 
23 
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 }
80 
81 
84  const EcalRecHitCollection& rhs) const{
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 }
125 
126 
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 }
147 
148 
149 
150 
151 // Configure (x)emacs for this file ...
152 // Local Variables:
153 // mode:c++
154 // compile-command: "scram b -k"
155 // 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:102
float energy() const
Definition: CaloRecHit.h:19
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:20
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:105
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.