Go to the documentation of this file.00001
00002
00003 #include "MuScleFitGenFilter.h"
00004
00005
00006 #include "FWCore/Framework/interface/MakerMacros.h"
00007 #include "FWCore/Framework/interface/Frameworkfwd.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012 #include "DataFormats/MuonReco/interface/Muon.h"
00013 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00014 #include "DataFormats/Candidate/interface/Candidate.h"
00015 #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"
00016 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00017
00018 #include "MuonAnalysis/MomentumScaleCalibration/interface/MuScleFitUtils.h"
00019
00020 #include <CLHEP/Vector/LorentzVector.h>
00021
00022
00023
00024 MuScleFitGenFilter::MuScleFitGenFilter(const edm::ParameterSet& iConfig) :
00025 genParticlesName_( iConfig.getUntrackedParameter<std::string>("GenParticlesName", "genParticles") ),
00026 totalEvents_(0),
00027 eventsPassingTheFilter_(0)
00028 {
00029 MuScleFitUtils::resfind = iConfig.getParameter<std::vector<int> >("resfind");
00030 }
00031
00032
00033
00034 MuScleFitGenFilter::~MuScleFitGenFilter()
00035 {
00036 std::cout << "Total number of events = " << totalEvents_ << std::endl;
00037 std::cout << "Events passing the filter = " << eventsPassingTheFilter_ << std::endl;
00038 }
00039
00040
00041
00042 bool MuScleFitGenFilter::filter(edm::Event& event, const edm::EventSetup& iSetup)
00043 {
00044 ++totalEvents_;
00045
00046 bool ifHepMC = false;
00047 bool ifGenPart = false;
00048
00049 edm::Handle<edm::HepMCProduct> evtMC;
00050
00051 std::pair<lorentzVector,lorentzVector> genPair;
00052
00053 event.getByLabel( genParticlesName_, evtMC );
00054 if( evtMC.isValid() ) {
00055
00056 genPair = MuScleFitUtils::findGenMuFromRes(evtMC.product());
00057
00058 ifHepMC = true;
00059 }
00060 else {
00061 edm::Handle<reco::GenParticleCollection> genParticles;
00062 event.getByLabel( genParticlesName_, genParticles );
00063 if( genParticles.isValid() ) {
00064
00065 genPair = MuScleFitUtils::findGenMuFromRes(genParticles.product());
00066
00067 ifGenPart=true;
00068 }
00069 else {
00070 std::cout << "ERROR: no generator info found" << std::endl;
00071 return false;
00072 }
00073 }
00074 lorentzVector emptyVec(0.,0.,0.,0.);
00075 if( (genPair.first == emptyVec) || (genPair.second == emptyVec) ) {
00076 return false;
00077 }
00078
00079 ++eventsPassingTheFilter_;
00080
00081 return true;
00082 }