CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HcalHitSelection Class Reference

#include <RecoLocalCalo/HcalHitSelection/src/HcalHitSelection.cc>

Inheritance diagram for HcalHitSelection:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 HcalHitSelection (const edm::ParameterSet &)
 ~HcalHitSelection ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)
template<typename CollectionType >
void skim (const edm::Handle< CollectionType > &input, std::auto_ptr< CollectionType > &output, int severityThreshold=0)

Private Attributes

edm::InputTag hbheTag
edm::InputTag hfTag
int hoSeverityLevel
edm::InputTag hoTag
std::vector< edm::InputTaginterestingDetIdCollections
edm::ESHandle< HcalChannelQualitytheHcalChStatus
edm::ESHandle
< HcalSeverityLevelComputer
theHcalSevLvlComputer
std::set< DetIdtoBeKept

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 47 of file HcalHitSelection.cc.


Constructor & Destructor Documentation

HcalHitSelection::HcalHitSelection ( const edm::ParameterSet iConfig) [explicit]

Definition at line 107 of file HcalHitSelection.cc.

References edm::ParameterSet::getParameter(), hbheTag, hfTag, hoSeverityLevel, hoTag, interestingDetIdCollections, and edm::InputTag::label().

{
  hbheTag=iConfig.getParameter<edm::InputTag>("hbheTag");
  hfTag=iConfig.getParameter<edm::InputTag>("hfTag");
  hoTag=iConfig.getParameter<edm::InputTag>("hoTag");

  interestingDetIdCollections = iConfig.getParameter< std::vector<edm::InputTag> >("interestingDetIds");

  hoSeverityLevel=iConfig.getParameter<int>("hoSeverityLevel");

  produces<HBHERecHitCollection>(hbheTag.label());
  produces<HFRecHitCollection>(hfTag.label());
  produces<HORecHitCollection>(hoTag.label());
  
}
HcalHitSelection::~HcalHitSelection ( )

Definition at line 124 of file HcalHitSelection.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void HcalHitSelection::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 180 of file HcalHitSelection.cc.

{
}
void HcalHitSelection::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 186 of file HcalHitSelection.cc.

                         {
}
void HcalHitSelection::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 139 of file HcalHitSelection.cc.

References edm::EventSetup::get(), edm::Event::getByLabel(), hbheTag, hfTag, hoSeverityLevel, hoTag, interestingDetIdCollections, edm::HandleBase::isValid(), edm::InputTag::label(), edm::Event::put(), skim(), lumiQTWidget::t, theHcalChStatus, theHcalSevLvlComputer, and toBeKept.

{
  iSetup.get<HcalChannelQualityRcd>().get(theHcalChStatus);
  iSetup.get<HcalSeverityLevelComputerRcd>().get(theHcalSevLvlComputer);

  edm::Handle<HBHERecHitCollection> hbhe;
  edm::Handle<HFRecHitCollection> hf;
  edm::Handle<HORecHitCollection> ho;

  iEvent.getByLabel(hbheTag,hbhe);
  iEvent.getByLabel(hfTag,hf);
  iEvent.getByLabel(hoTag,ho);

  toBeKept.clear();
  edm::Handle<DetIdCollection > detId;
  for( unsigned int t = 0; t < interestingDetIdCollections.size(); ++t )
    {
      iEvent.getByLabel(interestingDetIdCollections[t],detId);
      if (!detId.isValid()){
        edm::LogError("MissingInput")<<"the collection of interesting detIds:"<<interestingDetIdCollections[t]<<" is not found.";
        continue;
      }
      toBeKept.insert(detId->begin(),detId->end());
    }

  std::auto_ptr<HBHERecHitCollection> hbhe_out(new HBHERecHitCollection());
  skim(hbhe,hbhe_out);
  iEvent.put(hbhe_out,hbheTag.label());

  std::auto_ptr<HFRecHitCollection> hf_out(new HFRecHitCollection());
  skim(hf,hf_out);
  iEvent.put(hf_out,hfTag.label());

  std::auto_ptr<HORecHitCollection> ho_out(new HORecHitCollection());
  skim(ho,ho_out,hoSeverityLevel);
  iEvent.put(ho_out,hoTag.label());
  
}
template<class CollectionType >
void HcalHitSelection::skim ( const edm::Handle< CollectionType > &  input,
std::auto_ptr< CollectionType > &  output,
int  severityThreshold = 0 
) [private]

Definition at line 70 of file HcalHitSelection.cc.

References begin, end, theHcalChStatus, theHcalSevLvlComputer, and toBeKept.

Referenced by produce().

                                                                                                                                                               {
  output->reserve(input->size());
  typename CollectionType::const_iterator begin=input->begin();
  typename CollectionType::const_iterator end=input->end();
  typename CollectionType::const_iterator hit=begin;

  for (;hit!=end;++hit){
    //    edm::LogError("HcalHitSelection")<<"the hit pointer is"<<&(*hit);
    const DetId & id = hit->detid();
    const uint32_t & recHitFlag = hit->flags();
    //    edm::LogError("HcalHitSelection")<<"the hit id and flag are "<<id.rawId()<<" "<<recHitFlag;
        
    const uint32_t & dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
    int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag); 
    //anything that is not "good" goes in
    if (severityLevel>severityThreshold){
      output->push_back(*hit);
    }else{
      //chek on the detid list
      if (toBeKept.find(id)!=toBeKept.end())
        output->push_back(*hit);
    }
  }
}

Member Data Documentation

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

Definition at line 59 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

Definition at line 62 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

Definition at line 63 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

std::set<DetId> HcalHitSelection::toBeKept [private]

Definition at line 64 of file HcalHitSelection.cc.

Referenced by produce(), and skim().