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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
34 
37 
40 
42 
43 //
44 // class declaration
45 //
46 
48  public:
49  explicit JetVertexChecker(const edm::ParameterSet&);
51 
52  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
53 
54  private:
55  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
56 
57  // ----------member data ---------------------------
61  bool m_doFilter;
62  double m_cutMinPt;
63  double m_cutMinPtRatio;
64  int32_t m_maxNjets;
65 
66 };
67 
68 //
69 // constants, enums and typedefs
70 //
71 
72 //
73 // static data member definitions
74 //
75 
76 //
77 // constructors and destructor
78 //
80 {
81  //now do what ever initialization is needed
82  m_beamSpot = iConfig.getParameter<edm::InputTag>("beamSpot");
83  m_associator = iConfig.getParameter<edm::InputTag>("jetTracks");
84  m_doFilter = iConfig.getParameter<bool>("doFilter");
85  m_cutMinPt = iConfig.getParameter<double>("minPt");
86  m_cutMinPtRatio = iConfig.getParameter<double>("minPtRatio");
87  m_maxNjets = iConfig.getParameter<int32_t>("maxNJetsToCheck");
88  produces<std::vector<reco::CaloJet> >();
89  produces<reco::VertexCollection >();
90 }
91 
92 
94 {
95 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 
99 }
100 
101 
102 //
103 // member functions
104 //
105 
106 // ------------ method called on each new Event ------------
107 bool
109 {
110  using namespace edm;
112  iEvent.getByLabel(m_associator, jetTracksAssociation);
113  std::auto_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet> );
114 
115  bool result=true;
116  int i = 0;
117  //limit to first two jets
118  for(reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
119  it != jetTracksAssociation->end() && i < m_maxNjets; it++, i++) {
120  if(fabs(it->first->eta()) < 2.4)
121  {
122  reco::TrackRefVector tracks = it->second;
123  math::XYZVector jetMomentum = it->first->momentum();
124  math::XYZVector trMomentum;
125  for(reco::TrackRefVector::const_iterator itTrack = tracks.begin(); itTrack != tracks.end(); ++itTrack)
126  {
127  trMomentum += (*itTrack)->momentum();
128  }
129  if(trMomentum.rho()/jetMomentum.rho() < m_cutMinPtRatio || trMomentum.rho() < m_cutMinPt)
130  {
131 // std::cout << "bad jet " << it->first->pt() << std::endl;
132  pOut->push_back(* dynamic_cast<const reco::CaloJet *>(&(*it->first)));
133  result=false;
134  }
135  }
136  }
137 
138  iEvent.put(pOut);
139 
142 
144  e(0, 0) = 0.0015 * 0.0015;
145  e(1, 1) = 0.0015 * 0.0015;
146  e(2, 2) = 1.5 * 1.5;
147  reco::Vertex::Point p(beamSpot->x0(), beamSpot->y0(), beamSpot->z0());
148  reco::Vertex thePV(p, e, 0, 0, 0);
149  std::auto_ptr<reco::VertexCollection> pOut2(new reco::VertexCollection);
150  pOut2->push_back(thePV);
151  iEvent.put(pOut2);
152 // std::cout << " filter " << result << std::endl;
153  if(m_doFilter) return result;
154  else
155  return true;
156 }
157 
158 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
159 void
161  //The following says we do not know what parameters are allowed so do no validation
162  // Please change this to state exactly what you do use, even if it is no parameters
164  desc.setUnknown();
165  descriptions.addDefault(desc);
166 }
167 //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:43
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:116
tuple result
Definition: query.py:137
edm::InputTag m_primaryVertexProducer
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
virtual bool filter(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag m_beamSpot
tuple tracks
Definition: testEve_cfg.py:39
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
JetVertexChecker(const edm::ParameterSet &)
edm::InputTag m_associator
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)