CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsoTracks.cc
Go to the documentation of this file.
1 // Includes
8 
10 
12 
13 #include <memory>
14 #include <vector>
15 #include <sstream>
16 
17 
19 // class definition
21 class IsoTracks : public edm::EDProducer
22 {
23 public:
24  // construction/destruction
25  IsoTracks(const edm::ParameterSet& iConfig);
26  virtual ~IsoTracks();
27 
28  // member functions
29  void produce(edm::Event& iEvent,const edm::EventSetup& iSetup) override;
30  void endJob() override;
31 
32 private:
33  // member data
34  double coneRadius_ ;
35  double threshold_ ;
37 
38 };
39 
40 
42 // construction/destruction
44 
45 //______________________________________________________________________________
47  : coneRadius_ ( iConfig.getParameter<double>( "radius" ) )
48  , threshold_ ( iConfig.getParameter<double>( "SumPtFraction" ) )
49  , v_recoTrackToken_( consumes< std::vector<reco::Track> >( iConfig.getParameter<edm::InputTag>( "src" ) ) )
50 {
51  produces<std::vector<reco::Track> >();
52 }
53 
54 //______________________________________________________________________________
56 
58 // implementation of member functions
60 
61 //______________________________________________________________________________
63 {
64 
65  std::auto_ptr<std::vector<reco::Track> > IsoTracks(new std::vector<reco::Track >);
66 
68  iEvent.getByToken( v_recoTrackToken_, dirtyTracks );
69 
70  if( dirtyTracks->size() == 0 )
71  {
72  iEvent.put(IsoTracks);
73  return ;
74  }
75 
76  std::vector<reco::Track>::const_iterator dirtyTrackIt ;
77  std::vector<reco::Track>::const_iterator dirtyTrackIt2 ;
78 // typename std::vector<reco::Track>::const_iterator dirtyTrackIt ;
79 // typename std::vector<reco::Track>::const_iterator dirtyTrackIt2 ;
80  double sumPtInCone = 0 ;
81 
82  for ( dirtyTrackIt = dirtyTracks->begin(); dirtyTrackIt != dirtyTracks->end(); ++dirtyTrackIt ) {
83  for ( dirtyTrackIt2 = dirtyTracks->begin(); dirtyTrackIt2 != dirtyTracks->end(); ++dirtyTrackIt2 ) {
84  if ( dirtyTrackIt == dirtyTrackIt2) continue ;
85  if ( deltaR(dirtyTrackIt -> eta() ,
86  dirtyTrackIt -> phi() ,
87  dirtyTrackIt2 -> eta() ,
88  dirtyTrackIt2 -> phi() ) < coneRadius_ ){
89  sumPtInCone = sumPtInCone + dirtyTrackIt2 -> pt() ;
90  }
91  }
92  if ( sumPtInCone <= threshold_*(dirtyTrackIt->pt()) ){
93  IsoTracks -> push_back( *dirtyTrackIt ) ;
94  }
95  }
96  iEvent.put(IsoTracks);
97 }
98 
100 {
101 }
102 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
IsoTracks(const edm::ParameterSet &iConfig)
Definition: IsoTracks.cc:46
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double coneRadius_
Definition: IsoTracks.cc:34
void endJob() override
Definition: IsoTracks.cc:99
T eta() const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: IsoTracks.cc:62
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: IsoTracks.cc:36
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual ~IsoTracks()
Definition: IsoTracks.cc:55
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
return(e1-e2)*(e1-e2)+dp *dp
double threshold_
Definition: IsoTracks.cc:35
Definition: DDAxes.h:10