CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoParticleFlow/PFSimProducer/plugins/TauHadronDecayFilter.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/PFSimProducer/plugins/TauHadronDecayFilter.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 
00028 
00029 using namespace edm;
00030 using namespace std;
00031 
00032 TauHadronDecayFilter::TauHadronDecayFilter(const edm::ParameterSet& iConfig) {
00033   //now do what ever initialization is needed
00034 
00035   vertexGenerator_ = iConfig.getParameter<edm::ParameterSet>
00036     ( "VertexGenerator" );   
00037   particleFilter_ = iConfig.getParameter<edm::ParameterSet>
00038     ( "ParticleFilter" );   
00039 
00040   // mySimEvent =  new FSimEvent(vertexGenerator_, particleFilter_);
00041   mySimEvent =  new FSimEvent( particleFilter_);
00042 }
00043 
00044 
00045 TauHadronDecayFilter::~TauHadronDecayFilter() {
00046  
00047   // do anything here that needs to be done at desctruction time
00048   // (e.g. close files, deallocate resources etc.)
00049   delete mySimEvent;
00050 
00051 }
00052 
00053 
00054 bool
00055 TauHadronDecayFilter::filter(edm::Event& iEvent, 
00056                              const edm::EventSetup& iSetup) {
00057 
00058   
00059   Handle<vector<SimTrack> > simTracks;
00060   iEvent.getByLabel("g4SimHits",simTracks);
00061   Handle<vector<SimVertex> > simVertices;
00062   iEvent.getByLabel("g4SimHits",simVertices);
00063    
00064   mySimEvent->fill( *simTracks, *simVertices );
00065  
00066   if( mySimEvent->nTracks() >= 2 ) {
00067     FSimTrack& gene = mySimEvent->track(0); 
00068     if( abs(gene.type()) != 15) { 
00069       // first particle is not a tau. 
00070       // -> do not filter
00071       return true;
00072     }
00073     
00074     FSimTrack& decayproduct = mySimEvent->track(1);
00075     switch( abs(decayproduct.type() ) ) {
00076     case 11: // electrons
00077     case 13: // muons 
00078       LogWarning("PFProducer")
00079         <<"TauHadronDecayFilter: selecting single tau events with hadronic decay."<<endl;
00080       // mySimEvent->print();
00081       return false;
00082     default:
00083       return true;
00084     }
00085   }
00086   
00087   // more than 2 particles
00088   return true;
00089 }
00090 
00091 bool 
00092 TauHadronDecayFilter::beginRun(edm::Run& run,
00093                                const edm::EventSetup& es) {
00094   // init Particle data table (from Pythia)
00095   edm::ESHandle < HepPDT::ParticleDataTable > pdt;
00096   // edm::ESHandle < DefaultConfig::ParticleDataTable > pdt;
00097 
00098   es.getData(pdt);
00099   if ( !ParticleTable::instance() ) 
00100     ParticleTable::instance(&(*pdt));
00101   mySimEvent->initializePdt(&(*pdt));
00102 
00103   return true;
00104 
00105 }
00106 
00107 void 
00108 TauHadronDecayFilter::endRun() {
00109 }