Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:59

0001 // -*- C++ -*-
0002 //
0003 // Package:    PythiaHLTSoupFilter
0004 // Class:      PythiaHLTSoupFilter
0005 //
0006 /**\class PythiaHLTSoupFilter PythiaHLTSoupFilter.cc IOMC/PythiaHLTSoupFilter/src/PythiaHLTSoupFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Filip Moortgat
0015 //         Created:  Mon Jan 23 14:57:54 CET 2006
0016 //
0017 //
0018 
0019 #include "DataFormats/Common/interface/Handle.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/global/EDFilter.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/Utilities/interface/EDGetToken.h"
0026 #include "FWCore/Utilities/interface/InputTag.h"
0027 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0028 
0029 #include <cmath>
0030 #include <cstdlib>
0031 #include <string>
0032 
0033 class PythiaHLTSoupFilter : public edm::global::EDFilter<> {
0034 public:
0035   explicit PythiaHLTSoupFilter(const edm::ParameterSet&);
0036 
0037   bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0038 
0039 private:
0040   const edm::EDGetTokenT<edm::HepMCProduct> token_;
0041 
0042   const double minptelectron;
0043   const double minptmuon;
0044   const double maxetaelectron;
0045   const double maxetamuon;
0046   const double minpttau;
0047   const double maxetatau;
0048 };
0049 
0050 using namespace std;
0051 
0052 PythiaHLTSoupFilter::PythiaHLTSoupFilter(const edm::ParameterSet& iConfig)
0053     : token_(consumes<edm::HepMCProduct>(
0054           edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))),
0055       minptelectron(iConfig.getUntrackedParameter("MinPtElectron", 0.)),
0056       minptmuon(iConfig.getUntrackedParameter("MinPtMuon", 0.)),
0057       maxetaelectron(iConfig.getUntrackedParameter("MaxEtaElectron", 10.)),
0058       maxetamuon(iConfig.getUntrackedParameter("MaxEtaMuon", 10.)),
0059       minpttau(iConfig.getUntrackedParameter("MinPtTau", 0.)),
0060       maxetatau(iConfig.getUntrackedParameter("MaxEtaTau", 10.)) {}
0061 
0062 bool PythiaHLTSoupFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
0063   bool accepted = false;
0064   edm::Handle<edm::HepMCProduct> evt;
0065   iEvent.getByToken(token_, evt);
0066 
0067   const HepMC::GenEvent* myGenEvent = evt->GetEvent();
0068 
0069   if (myGenEvent->signal_process_id() == 2) {
0070     for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
0071          ++p) {
0072       if (abs((*p)->pdg_id()) == 11 && (*p)->momentum().perp() > minptelectron &&
0073           abs((*p)->momentum().eta()) < maxetaelectron && (*p)->status() == 1) {
0074         accepted = true;
0075       }
0076 
0077       if (abs((*p)->pdg_id()) == 13 && (*p)->momentum().perp() > minptmuon &&
0078           abs((*p)->momentum().eta()) < maxetamuon && (*p)->status() == 1) {
0079         accepted = true;
0080       }
0081 
0082       if (abs((*p)->pdg_id()) == 15 && (*p)->momentum().perp() > minpttau && abs((*p)->momentum().eta()) < maxetatau &&
0083           (*p)->status() == 3) {
0084         accepted = true;
0085       }
0086     }
0087 
0088   } else {
0089     accepted = true;
0090   }
0091   return accepted;
0092 }
0093 
0094 DEFINE_FWK_MODULE(PythiaHLTSoupFilter);