test
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 
31 private:
32  // member data
33  double coneRadius_ ;
34  double threshold_ ;
36 
37 };
38 
39 
41 // construction/destruction
43 
44 //______________________________________________________________________________
46  : coneRadius_ ( iConfig.getParameter<double>( "radius" ) )
47  , threshold_ ( iConfig.getParameter<double>( "SumPtFraction" ) )
48  , v_recoTrackToken_( consumes< std::vector<reco::Track> >( iConfig.getParameter<edm::InputTag>( "src" ) ) )
49 {
50  produces<std::vector<reco::Track> >();
51 }
52 
53 //______________________________________________________________________________
55 
57 // implementation of member functions
59 
60 //______________________________________________________________________________
62 {
63 
64  std::auto_ptr<std::vector<reco::Track> > IsoTracks(new std::vector<reco::Track >);
65 
67  iEvent.getByToken( v_recoTrackToken_, dirtyTracks );
68 
69  if( dirtyTracks->size() == 0 )
70  {
71  iEvent.put(IsoTracks);
72  return ;
73  }
74 
75  std::vector<reco::Track>::const_iterator dirtyTrackIt ;
76  std::vector<reco::Track>::const_iterator dirtyTrackIt2 ;
77 // typename std::vector<reco::Track>::const_iterator dirtyTrackIt ;
78 // typename std::vector<reco::Track>::const_iterator dirtyTrackIt2 ;
79  double sumPtInCone = 0 ;
80 
81  for ( dirtyTrackIt = dirtyTracks->begin(); dirtyTrackIt != dirtyTracks->end(); ++dirtyTrackIt ) {
82  for ( dirtyTrackIt2 = dirtyTracks->begin(); dirtyTrackIt2 != dirtyTracks->end(); ++dirtyTrackIt2 ) {
83  if ( dirtyTrackIt == dirtyTrackIt2) continue ;
84  if ( deltaR(dirtyTrackIt -> eta() ,
85  dirtyTrackIt -> phi() ,
86  dirtyTrackIt2 -> eta() ,
87  dirtyTrackIt2 -> phi() ) < coneRadius_ ){
88  sumPtInCone = sumPtInCone + dirtyTrackIt2 -> pt() ;
89  }
90  }
91  if ( sumPtInCone <= threshold_*(dirtyTrackIt->pt()) ){
92  IsoTracks -> push_back( *dirtyTrackIt ) ;
93  }
94  }
95  iEvent.put(IsoTracks);
96 }
97 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
IsoTracks(const edm::ParameterSet &iConfig)
Definition: IsoTracks.cc:45
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double coneRadius_
Definition: IsoTracks.cc:33
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: IsoTracks.cc:61
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: IsoTracks.cc:35
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
virtual ~IsoTracks()
Definition: IsoTracks.cc:54
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:34