r2 - 12 Apr 2010 - 23:31:06 - SeoKonKangYou are here: KoreaCmsWiki >  Main Web > TWikiUsers > SeoKonKang > LogBooks > DailyLogBook > 2010 > 20100407 > CleanCaloJetFilter
// CleanCaloJetsFilter.cc
// Description:  Example of simple EDFilter for jets.
// Author: Seo Kon, Kang
// Mail to: seogoni@cern.ch
// Date:  21 Feb 2010
// 
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/JetReco/interface/JetID.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/InputTag.h"

#include "DataFormats/Common/interface/ValueMap.h"


using namespace edm;
using namespace reco;
using namespace std;

//
// class ceclaration
//

class CaloJetIDFilter: public edm::EDFilter{
        public:
                explicit CaloJetIDFilter(const edm::ParameterSet&);
                ~CaloJetIDFilter();

        private:
                virtual bool filter(edm::Event&, const edm::EventSetup&);
                edm::InputTag JetIDSrc;
                edm::InputTag CaloJetsSrc;
                double fhpd;
                double frbx;
                double n90hits;
                double emf;
};

CaloJetIDFilter::CaloJetIDFilter(const edm::ParameterSet& iConfig)
{
  CaloJetsSrc = iConfig.getParameter("CaloJetAlgorithm");
  JetIDSrc = iConfig.getParameter("CaloJetID");
  emf = iConfig.getParameter("EMF");
  fhpd = iConfig.getParameter("fHPD");
  frbx = iConfig.getParameter("fRBX");
  n90hits = iConfig.getParameter("n90Hits");
}

CaloJetIDFilter::~CaloJetIDFilter()
{}

bool CaloJetIDFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
 bool result = false;
 edm::Handle< edm::ValueMap > jetId;
 iEvent.getByLabel(JetIDSrc,jetId);
 jetId->begin();

 edm:: Handle Jets;
 iEvent.getByLabel(CaloJetsSrc, Jets);

 int jetInd =0;
 for(reco::CaloJetCollection::const_iterator cal = Jets->begin(); cal != Jets->end(); ++cal)
        {
          RefToBase jetRef(Ref (Jets, jetInd));

          double EMF_ = cal -> emEnergyFraction();
          double HPDfraction_ = (*jetId)[jetRef].fHPD;
          double RBXfraction_ = (*jetId)[jetRef].fRBX;
          double n90Hits_ = (*jetId)[jetRef].n90Hits;

          if( EMF_ > emf  && EMF_ < 0.98 && HPDfraction_ < fhpd && RBXfraction_ < frbx && n90Hits_ > n90hits  )
                result = true;

          jetInd++;
        }
 //if(result == true) cout << "baboo"<< endl;
 return result;
}

//define this as a plug-in
DEFINE_FWK_MODULE(CaloJetIDFilter);
                                                                                                          

-- SeoKonKang - 07 Apr 2010

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
KOREA-CMS
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding KoreaCmsWiki? Send feedback