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);
30  void endJob();
31 
32 private:
33  // member data
35  double coneRadius_ ;
36  double threshold_ ;
37 
38 };
39 
40 
42 // construction/destruction
44 
45 //______________________________________________________________________________
47  : src_ (iConfig.getParameter<edm::InputTag>("src"))
48  , coneRadius_(iConfig.getParameter<double>("radius"))
49  , threshold_ (iConfig.getParameter<double>("SumPtFraction"))
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.getByLabel(src_,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 
IsoTracks(const edm::ParameterSet &iConfig)
Definition: IsoTracks.cc:46
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: IsoTracks.cc:62
double coneRadius_
Definition: IsoTracks.cc:35
T eta() const
void endJob()
Definition: IsoTracks.cc:99
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual ~IsoTracks()
Definition: IsoTracks.cc:55
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
edm::InputTag src_
Definition: IsoTracks.cc:34
double threshold_
Definition: IsoTracks.cc:36
Definition: DDAxes.h:10