CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/special/src/HLTHcalSimpleRecHitFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTHcalSimpleRecHitFilter
00004 // Class:      HLTHcalSimpleRecHitFilter
00005 // 
00013 //
00014 // Original Author:  Bryan DAHMES
00015 //         Created:  Wed Sep 19 16:21:29 CEST 2007
00016 // $Id: HLTHcalSimpleRecHitFilter.cc,v 1.4 2010/09/06 18:23:04 cer Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00034 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00035 
00036 //
00037 // class declaration
00038 //
00039 
00040 class HLTHcalSimpleRecHitFilter : public HLTFilter {
00041 public:
00042     explicit HLTHcalSimpleRecHitFilter(const edm::ParameterSet&);
00043     ~HLTHcalSimpleRecHitFilter();
00044     
00045 private:
00046     virtual bool filter(edm::Event&, const edm::EventSetup&);
00047     
00048     // ----------member data ---------------------------
00049     edm::InputTag HcalRecHitCollection_;
00050     double threshold_;
00051     int minNHitsNeg_;
00052     int minNHitsPos_;
00053     bool doCoincidence_;
00054     std::vector<int> maskedList_;
00055     
00056 };
00057 
00058 //
00059 // constructors and destructor
00060 //
00061 HLTHcalSimpleRecHitFilter::HLTHcalSimpleRecHitFilter(const edm::ParameterSet& iConfig)
00062 {
00063     //now do what ever initialization is needed
00064     threshold_     = iConfig.getParameter<double>("threshold");
00065     minNHitsNeg_     = iConfig.getParameter<int>("minNHitsNeg");
00066     minNHitsPos_     = iConfig.getParameter<int>("minNHitsPos");
00067     doCoincidence_     = iConfig.getParameter<bool>("doCoincidence");
00068     maskedList_    = iConfig.getParameter<std::vector<int> >("maskedChannels"); //this is using the hashed index
00069     HcalRecHitCollection_ = iConfig.getParameter<edm::InputTag>("HFRecHitCollection");
00070     
00071 }
00072 
00073 
00074 HLTHcalSimpleRecHitFilter::~HLTHcalSimpleRecHitFilter()
00075 {
00076  
00077    // do anything here that needs to be done at desctruction time
00078    // (e.g. close files, deallocate resources etc.)
00079 
00080 }
00081 
00082 
00083 //
00084 // member functions
00085 //
00086 
00087 // ------------ method called on each new Event  ------------
00088 bool
00089 HLTHcalSimpleRecHitFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00090     // using namespace edm;
00091 
00092     // getting very basic uncalRH
00093     edm::Handle<HFRecHitCollection> crudeHits;
00094     try {
00095         iEvent.getByLabel(HcalRecHitCollection_, crudeHits);
00096     } catch ( std::exception& ex) {
00097         edm::LogWarning("HLTHcalSimpleRecHitFilter") << HcalRecHitCollection_ << " not available";
00098     }
00099     
00100     bool accept = false ; 
00101 
00102     int nHitsNeg=0, nHitsPos=0;
00103     for ( HFRecHitCollection::const_iterator hitItr = crudeHits->begin(); hitItr != crudeHits->end(); ++hitItr ) {     
00104        HFRecHit hit = (*hitItr);
00105      
00106        // masking noisy channels
00107        std::vector<int>::iterator result;
00108        result = find( maskedList_.begin(), maskedList_.end(), HcalDetId(hit.id()).hashed_index() );    
00109        if  (result != maskedList_.end()) 
00110            continue; 
00111        
00112        // only count tower above threshold
00113        if ( hit.energy() < threshold_ ) continue;
00114 
00115        // count
00116        if (hit.id().zside()<0) ++nHitsNeg;
00117        else ++nHitsPos;
00118     }
00119 
00120     // Logic
00121     if (!doCoincidence_) accept = (nHitsNeg>=minNHitsNeg_) || (nHitsPos>=minNHitsPos_);
00122     else accept = (nHitsNeg>=minNHitsNeg_) && (nHitsPos>=minNHitsPos_);
00123 //  edm::LogInfo("HcalFilter")  << "at evet: " << iEvent.id().event() 
00124 //    << " and run: " << iEvent.id().run()
00125 //    << " Total HF hits: " << crudeHits->size() << " Above Threshold - nNeg: " << nHitsNeg << " nPos " << nHitsPos
00126 //    << " doCoinc: " << doCoincidence_ << " accept: " << accept << std::endl;
00127 
00128     // result
00129     return accept; 
00130 }
00131 
00132 //define this as a plug-in
00133 DEFINE_FWK_MODULE(HLTHcalSimpleRecHitFilter);