Go to the documentation of this file.00001
00002
00004 #include "FWCore/Framework/interface/EDProducer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/Utilities/interface/InputTag.h"
00008
00009 #include "DataFormats/Math/interface/deltaR.h"
00010
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012
00013 #include <memory>
00014 #include <vector>
00015 #include <sstream>
00016
00017
00019
00021 class IsoTracks : public edm::EDProducer
00022 {
00023 public:
00024
00025 IsoTracks(const edm::ParameterSet& iConfig);
00026 virtual ~IsoTracks();
00027
00028
00029 void produce(edm::Event& iEvent,const edm::EventSetup& iSetup);
00030 void endJob();
00031
00032 private:
00033
00034 edm::InputTag src_ ;
00035 double coneRadius_ ;
00036 double threshold_ ;
00037
00038 };
00039
00040
00042
00044
00045
00046 IsoTracks::IsoTracks(const edm::ParameterSet& iConfig)
00047 : src_ (iConfig.getParameter<edm::InputTag>("src"))
00048 , coneRadius_(iConfig.getParameter<double>("radius"))
00049 , threshold_ (iConfig.getParameter<double>("SumPtFraction"))
00050 {
00051 produces<std::vector<reco::Track> >();
00052 }
00053
00054
00055 IsoTracks::~IsoTracks(){}
00056
00058
00060
00061
00062 void IsoTracks::produce(edm::Event& iEvent,const edm::EventSetup& iSetup)
00063 {
00064
00065 std::auto_ptr<std::vector<reco::Track> > IsoTracks(new std::vector<reco::Track >);
00066
00067 edm::Handle< std::vector<reco::Track> > dirtyTracks;
00068 iEvent.getByLabel(src_,dirtyTracks);
00069
00070 if( dirtyTracks->size() == 0 )
00071 {
00072 iEvent.put(IsoTracks);
00073 return ;
00074 }
00075
00076 std::vector<reco::Track>::const_iterator dirtyTrackIt ;
00077 std::vector<reco::Track>::const_iterator dirtyTrackIt2 ;
00078
00079
00080 double sumPtInCone = 0 ;
00081
00082 for ( dirtyTrackIt = dirtyTracks->begin(); dirtyTrackIt != dirtyTracks->end(); ++dirtyTrackIt ) {
00083 for ( dirtyTrackIt2 = dirtyTracks->begin(); dirtyTrackIt2 != dirtyTracks->end(); ++dirtyTrackIt2 ) {
00084 if ( dirtyTrackIt == dirtyTrackIt2) continue ;
00085 if ( deltaR(dirtyTrackIt -> eta() ,
00086 dirtyTrackIt -> phi() ,
00087 dirtyTrackIt2 -> eta() ,
00088 dirtyTrackIt2 -> phi() ) < coneRadius_ ){
00089 sumPtInCone = sumPtInCone + dirtyTrackIt2 -> pt() ;
00090 }
00091 }
00092 if ( sumPtInCone <= threshold_*(dirtyTrackIt->pt()) ){
00093 IsoTracks -> push_back( *dirtyTrackIt ) ;
00094 }
00095 }
00096 iEvent.put(IsoTracks);
00097 }
00098
00099 void IsoTracks::endJob()
00100 {
00101 }
00102
00103 #include "FWCore/Framework/interface/MakerMacros.h"
00104 DEFINE_FWK_MODULE(IsoTracks);