CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetVertexChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: JetVertexChecker
4 // Class: JetVertexChecker
5 //
13 //
14 // Original Author: Andrea RIZZI
15 // Created: Mon Jan 16 11:19:48 CET 2012
16 // $Id: JetVertexChecker.cc,v 1.2 2013/02/26 21:19:31 chrjones Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
35 
38 
41 
43 
44 //
45 // class declaration
46 //
47 
49  public:
50  explicit JetVertexChecker(const edm::ParameterSet&);
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55  private:
56  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
57 
58  // ----------member data ---------------------------
62  bool m_doFilter;
63  double m_cutMinPt;
64  double m_cutMinPtRatio;
65  int32_t m_maxNjets;
66 
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81 {
82  //now do what ever initialization is needed
83  m_beamSpot = iConfig.getParameter<edm::InputTag>("beamSpot");
84  m_associator = iConfig.getParameter<edm::InputTag>("jetTracks");
85  m_doFilter = iConfig.getParameter<bool>("doFilter");
86  m_cutMinPt = iConfig.getParameter<double>("minPt");
87  m_cutMinPtRatio = iConfig.getParameter<double>("minPtRatio");
88  m_maxNjets = iConfig.getParameter<int32_t>("maxNJetsToCheck");
89  produces<std::vector<reco::CaloJet> >();
90  produces<reco::VertexCollection >();
91 }
92 
93 
95 {
96 
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99 
100 }
101 
102 
103 //
104 // member functions
105 //
106 
107 // ------------ method called on each new Event ------------
108 bool
110 {
111  using namespace edm;
113  iEvent.getByLabel(m_associator, jetTracksAssociation);
114  std::auto_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet> );
115 
116  bool result=true;
117  int i = 0;
118  //limit to first two jets
119  for(reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
120  it != jetTracksAssociation->end() && i < m_maxNjets; it++, i++) {
121  if(fabs(it->first->eta()) < 2.4)
122  {
123  reco::TrackRefVector tracks = it->second;
124  math::XYZVector jetMomentum = it->first->momentum();
125  math::XYZVector trMomentum;
126  for(reco::TrackRefVector::const_iterator itTrack = tracks.begin(); itTrack != tracks.end(); ++itTrack)
127  {
128  trMomentum += (*itTrack)->momentum();
129  }
130  if(trMomentum.rho()/jetMomentum.rho() < m_cutMinPtRatio || trMomentum.rho() < m_cutMinPt)
131  {
132 // std::cout << "bad jet " << it->first->pt() << std::endl;
133  pOut->push_back(* dynamic_cast<const reco::CaloJet *>(&(*it->first)));
134  result=false;
135  }
136  }
137  }
138 
139  iEvent.put(pOut);
140 
143 
145  e(0, 0) = 0.0015 * 0.0015;
146  e(1, 1) = 0.0015 * 0.0015;
147  e(2, 2) = 1.5 * 1.5;
148  reco::Vertex::Point p(beamSpot->x0(), beamSpot->y0(), beamSpot->z0());
149  reco::Vertex thePV(p, e, 0, 0, 0);
150  std::auto_ptr<reco::VertexCollection> pOut2(new reco::VertexCollection);
151  pOut2->push_back(thePV);
152  iEvent.put(pOut2);
153 // std::cout << " filter " << result << std::endl;
154  if(m_doFilter) return result;
155  else
156  return true;
157 }
158 
159 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
160 void
162  //The following says we do not know what parameters are allowed so do no validation
163  // Please change this to state exactly what you do use, even if it is no parameters
165  desc.setUnknown();
166  descriptions.addDefault(desc);
167 }
168 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
transient_vector_type::const_iterator const_iterator
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
tuple result
Definition: query.py:137
edm::InputTag m_primaryVertexProducer
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
virtual bool filter(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag m_beamSpot
tuple tracks
Definition: testEve_cfg.py:39
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
JetVertexChecker(const edm::ParameterSet &)
edm::InputTag m_associator
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)