CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoParticleFlow/PFProducer/plugins/EFilter.cc

Go to the documentation of this file.
00001 // system include files
00002 #include <memory>
00003 #include <iostream>
00004 
00005 // user include files
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 // #include "FWCore/Framework/interface/EDFilter.h"
00008 
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/Framework/interface/MakerMacros.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 
00014 // #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include "RecoParticleFlow/PFProducer/plugins/EFilter.h"
00017 
00018 
00019 // #include "FastSimulation/Event/interface/FSimEvent.h"
00020 // #include "FastSimulation/Event/interface/FSimTrack.h"
00021 // #include "FastSimulation/Event/interface/FSimVertex.h"
00022 
00023 // #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00024 // #include "FastSimulation/Particle/interface/ParticleTable.h"
00025 
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 // #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00028 
00029 #include "DataFormats/ParticleFlowReco/interface/PFSimParticle.h"
00030 
00031 using namespace edm;
00032 using namespace std;
00033 
00034 EFilter::EFilter(const edm::ParameterSet& iConfig) {
00035   //now do what ever initialization is needed
00036 
00037   inputTagParticles_ = iConfig.getParameter<InputTag>("particles");
00038 
00039   minE_ = iConfig.getUntrackedParameter<double>("minE",-1);
00040   maxE_ = iConfig.getUntrackedParameter<double>("maxE",999999);
00041   minEt_ = iConfig.getUntrackedParameter<double>("minEt",-1);
00042   maxEt_ = iConfig.getUntrackedParameter<double>("maxEt",999999);
00043 
00044   LogWarning("PFProducer")<<"EFilter : will filter particles with "
00045                           <<minE_<<" < E < "<<maxE_<<" and "<<minEt_<<" < Et <"<<maxEt_<<endl;
00046 
00047 }
00048 
00049 
00050 EFilter::~EFilter() {
00051  
00052   // do anything here that needs to be done at desctruction time
00053   // (e.g. close files, deallocate resources etc.)
00054   // delete mySimEvent;
00055 
00056 
00057 }
00058 
00059 
00060 bool
00061 EFilter::filter(edm::Event& iEvent, 
00062                 const edm::EventSetup& iSetup) {
00063 
00064 
00065 
00066   Handle<std::vector<reco::PFSimParticle> > particles;
00067   bool found = iEvent.getByLabel(inputTagParticles_, particles);
00068   //    cout<<"n particles = "<<particles->size()<<endl;
00069   
00070   if (! found) {
00071     LogError("PFSimParticle")<<"cannot find particles: "
00072                              <<inputTagParticles_<<endl;
00073     return false;
00074   }
00075   
00076 
00077   if( !particles->empty() ) {
00078     // take first trajectory point of first particle (the mother)
00079     const reco::PFTrajectoryPoint& tp = (*particles)[0].trajectoryPoint(0);
00080     
00081     const math::XYZTLorentzVector& mom = tp.momentum();
00082 
00083     double e = mom.E();
00084     double et = mom.Et(); 
00085 
00086     if( e >= minE_  && e<= maxE_ && 
00087         et>= minEt_ && et<= maxEt_ ) {
00088       cout<<"ok "<<e<<endl;
00089       return true;
00090     }
00091     else {
00092       cout<<"bad "<<e<<endl;    
00093       return false;
00094     }
00095   }
00096 
00097 
00098   
00099   return true;
00100 }
00101 
00102 bool
00103 EFilter::beginRun(edm::Run& run,
00104                   const edm::EventSetup& es) {
00105   // init Particle data table (from Pythia)
00106 //   edm::ESHandle < DefaultConfig::ParticleDataTable > pdt;
00107 //   es.getData(pdt);
00108 //   if ( !ParticleTable::instance() ) 
00109 //     ParticleTable::instance(&(*pdt));
00110 //   mySimEvent->initializePdt(&(*pdt));
00111   
00112   return true;
00113 
00114 }
00115 
00116 void EFilter::endRun() {
00117 }