CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalSeverityLevelAlgo Class Reference

#include <EcalSeverityLevelAlgo.h>

List of all members.

Public Member Functions

 EcalSeverityLevelAlgo (const edm::ParameterSet &p)
void setChannelStatus (const EcalChannelStatus &chs)
 Set the ChannelStatus record.
EcalSeverityLevel::SeverityLevel severityLevel (const EcalRecHit &rh) const
 Evaluate status from rechit, using its EcalRecHit::Flag.
EcalSeverityLevel::SeverityLevel severityLevel (const DetId &id, const EcalRecHitCollection &rhs) const
 Evaluate status from id.

Private Attributes

const EcalChannelStatuschStatus_
std::vector< uint32_t > dbstatusMask_
 Configure which DBStatus::Flag is mapped into which EcalSeverityLevel.
std::vector< uint32_t > flagMask_
 Configure which EcalRecHit::Flag is mapped into which EcalSeverityLevel.
float timeThresh_
 Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_.

Detailed Description

Definition at line 36 of file EcalSeverityLevelAlgo.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file EcalSeverityLevelAlgo.cc.

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

                                                                    {
  
  
  timeThresh_    = p.getParameter< double> ("timeThresh");
  chStatus_ =0;     

  const edm::ParameterSet & ps=p.getParameter< edm::ParameterSet >("flagMask");
  std::vector<std::string> severities = ps.getParameterNames();
  std::vector<std::string> flags;
 
  flagMask_.resize(severities.size());

  // read configuration of severities

  for (unsigned int is=0;is!=severities.size();++is){

    EcalSeverityLevel::SeverityLevel snum=
      (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
    flags=ps.getParameter<std::vector<std::string> >(severities[is]);
    uint32_t mask=0;
    for (unsigned int ifi=0;ifi!=flags.size();++ifi){
      EcalRecHit::Flags f=
        (EcalRecHit::Flags)StringToEnumValue<EcalRecHit::Flags>(flags[ifi]);
      //manipulate the mask
      mask|=(0x1<<f);
    }
    flagMask_[snum]=mask;
  }
  // read configuration of dbstatus

  const edm::ParameterSet & dbps=
    p.getParameter< edm::ParameterSet >("dbstatusMask");
  std::vector<std::string> dbseverities = dbps.getParameterNames();
  std::vector<uint32_t>    dbflags;
 
  dbstatusMask_.resize(dbseverities.size());

  for (unsigned int is=0;is!=dbseverities.size();++is){

    EcalSeverityLevel::SeverityLevel snum=
      (EcalSeverityLevel::SeverityLevel) StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severities[is]);
    
    dbflags=dbps.getParameter<std::vector<uint32_t> >(severities[is]);
    uint32_t mask=0;
    for (unsigned int ifi=0;ifi!=dbflags.size();++ifi){
      int f= dbflags[ifi];
      
      //manipulate the mask
      mask|=(0x1<<f);
    }
    dbstatusMask_[snum]=mask;
  }

  

}

Member Function Documentation

void EcalSeverityLevelAlgo::setChannelStatus ( const EcalChannelStatus chs) [inline]

Set the ChannelStatus record.

Definition at line 58 of file EcalSeverityLevelAlgo.h.

References chStatus_.

{chStatus_=&chs;}
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 83 of file EcalSeverityLevelAlgo.cc.

References chStatus_, dbstatusMask_, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), EcalCondObjectContainer< T >::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(), InterestingDetIdCollectionProducer::produce(), EcalClusterTools::recHitEnergy(), EcalSeverityLevelService::severityLevel(), and ObjectValidator::validHit().

                                                                           {
  
  using namespace EcalSeverityLevel;

  // if the detid is within our rechits, evaluate from flag
 EcalRecHitCollection::const_iterator rh= rhs.find(id);
  if ( rh != rhs.end()  )
    return severityLevel(*rh);


  // else evaluate from dbstatus
 
  if (!chStatus_)     
    edm::LogError("ObjectNotFound") << "Channel Status not set for EcalSeverityLevelAlgo"; 
        

  EcalChannelStatus::const_iterator chIt = chStatus_->find( id );
  uint16_t dbStatus = 0;
  if ( chIt != chStatus_->end() ) {
    dbStatus = chIt->getStatusCode() & 0x1F;
  } else {
    edm::LogError("ObjectNotFound") << "No channel status found for xtal " 
         << id.rawId() 
         << "! something wrong with EcalChannelStatus in your DB? ";
  }
 
  // kGood==0 we know!
  if (0==dbStatus)  return kGood;
 
  // check if the bit corresponding to that dbStatus is set in the mask
  // This implementation implies that the statuses have a priority
  for (size_t i=0; i< dbstatusMask_.size();++i){
    uint32_t tmp = 0x1<<dbStatus;
    if (dbstatusMask_[i] & tmp) return SeverityLevel(i);
  }

  // no matching
  LogDebug("EcalSeverityLevelAlgo")<< 
    "Unmatched DB status, returning kGood";
  return kGood;
}
EcalSeverityLevel::SeverityLevel EcalSeverityLevelAlgo::severityLevel ( const EcalRecHit rh) const

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

Definition at line 128 of file EcalSeverityLevelAlgo.cc.

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

                                                              {

  using namespace EcalSeverityLevel;

  //if marked good, do not do any further test
  if (rh.checkFlag(kGood)) return kGood;

  // check if the bit corresponding to that flag is set in the mask
  // This implementation implies that  severities have a priority... 
  for (int sev=kBad;sev>=0;--sev){
    if(sev==kTime && rh.energy() < timeThresh_ ) continue;
    if (rh.checkFlagMask(flagMask_[sev])) return SeverityLevel(sev);
  }

  // no matching
  LogDebug("EcalSeverityLevelAlgo")<< "Unmatched Flag , returning kGood";
  return kGood;

}

Member Data Documentation

Definition at line 80 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 74 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 67 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().

Return kTime only if the rechit is flagged kOutOfTime and E>timeThresh_.

Definition at line 78 of file EcalSeverityLevelAlgo.h.

Referenced by EcalSeverityLevelAlgo(), and severityLevel().