CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalCalo/EcalRecAlgos/src/EcalSeverityLevelAlgo.cc

Go to the documentation of this file.
00001 
00012 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00015 
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00019 
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 
00022 
00023 EcalSeverityLevelAlgo::EcalSeverityLevelAlgo(const edm::ParameterSet& p){
00024   flagMask_      = p.getParameter< std::vector<uint32_t> >("flagMask");
00025   dbstatusMask_  = p.getParameter< std::vector<uint32_t> >("dbstatusMask");
00026   timeThresh_    = p.getParameter< double> ("timeThresh");
00027   chStatus_ =0;     
00028 
00029 }
00030 
00031 
00032 EcalSeverityLevelAlgo::EcalSeverityLevel 
00033 EcalSeverityLevelAlgo::severityLevel(const DetId& id,      
00034                                      const EcalRecHitCollection& rhs) const{
00035   
00036 
00037   // if the detid is within our rechits, evaluate from flag
00038  EcalRecHitCollection::const_iterator rh= rhs.find(id);
00039   if ( rh != rhs.end()  )
00040     return severityLevel(*rh);
00041 
00042 
00043   // else evaluate from dbstatus
00044  
00045   if (!chStatus_)     
00046     edm::LogError("ObjectNotFound") << "Channel Status not set for EcalSeverityLevelAlgo"; 
00047         
00048 
00049   EcalChannelStatus::const_iterator chIt = chStatus_->find( id );
00050   uint16_t dbStatus = 0;
00051   if ( chIt != chStatus_->end() ) {
00052     dbStatus = chIt->getStatusCode();
00053   } else {
00054     edm::LogError("ObjectNotFound") << "No channel status found for xtal " 
00055          << id.rawId() 
00056          << "! something wrong with EcalChannelStatus in your DB? ";
00057   }
00058  
00059   // kGood==0 we know!
00060   if (0==dbStatus)  return kGood;
00061  
00062   // check if the bit corresponding to that dbStatus is set in the mask
00063   // This implementation implies that the statuses have a priority
00064   for (size_t i=0; i< dbstatusMask_.size();++i){
00065     uint32_t tmp = 0x1<<dbStatus;
00066     if (dbstatusMask_[i] & tmp) return EcalSeverityLevel(i);
00067   }
00068 
00069   // no matching
00070   LogDebug("EcalSeverityLevelAlgo")<< 
00071     "Unmatched DB status, returning kGood";
00072   return kGood;
00073 }
00074 
00075 
00076 EcalSeverityLevelAlgo::EcalSeverityLevel 
00077 EcalSeverityLevelAlgo::severityLevel(const EcalRecHit& rh) const{
00078 
00079   //if marked good, do not do any further test
00080   if (rh.checkFlag(kGood)) return kGood;
00081 
00082   // check if the bit corresponding to that flag is set in the mask
00083   // This implementation implies that  severities have a priority... 
00084   for (int sev=kBad;sev>=0;--sev){
00085     if(sev==kTime && rh.energy() < timeThresh_ ) continue;
00086     if (rh.checkFlagMask(flagMask_[sev])) return EcalSeverityLevel(sev);
00087   }
00088 
00089   // no matching
00090   LogDebug("EcalSeverityLevelAlgo")<< "Unmatched Flag , returning kGood";
00091   return kGood;
00092 
00093 }
00094 
00095 
00096 
00097 
00098 // Configure (x)emacs for this file ...
00099 // Local Variables:
00100 // mode:c++
00101 // compile-command: "scram b -k"
00102 // End: