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 35 of file EcalSeverityLevelAlgo.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file EcalSeverityLevelAlgo.cc.

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

23  {
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 }
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 57 of file EcalSeverityLevelAlgo.h.

References chStatus_.

57 {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 82 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(), InterestingDetIdFromSuperClusterProducer::produce(), InterestingDetIdCollectionProducer::produce(), EcalClusterTools::recHitEnergy(), EcalSeverityLevelService::severityLevel(), and ObjectValidator::validHit().

83  {
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 }
#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)
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.
EcalSeverityLevel::SeverityLevel EcalSeverityLevelAlgo::severityLevel ( const EcalRecHit rh) const

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

Definition at line 127 of file EcalSeverityLevelAlgo.cc.

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

127  {
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 }
#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:106
float energy() const
Definition: CaloRecHit.h:17
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:112
SeverityLevel

Member Data Documentation

const EcalChannelStatus* EcalSeverityLevelAlgo::chStatus_
private

Definition at line 79 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 73 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 66 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 77 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().