CMS 3D CMS Logo

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 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
33 
36 
39 
41 
42 //
43 // class declaration
44 //
45 
47 public:
48  explicit JetVertexChecker(const edm::ParameterSet&);
49  ~JetVertexChecker() override;
50 
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  bool filter(edm::Event&, const edm::EventSetup&) override;
55 
56  // ----------member data ---------------------------
59  const bool m_doFilter;
60  const double m_cutMinPt;
61  const double m_cutMinPtRatio;
62  const double m_maxTrackPt;
63  const double m_maxChi2;
64  const int32_t m_maxNjets;
65  const int32_t m_maxNjetsOutput;
66 
67  const bool m_newMethod;
68 
69  const double m_maxETA;
70  const double m_pvErr_x;
71  const double m_pvErr_y;
72  const double m_pvErr_z;
73 };
74 
75 //
76 // constants, enums and typedefs
77 //
78 
79 //
80 // static data member definitions
81 //
82 
83 //
84 // constructors and destructor
85 //
87  : m_associator(consumes<reco::JetTracksAssociationCollection>(iConfig.getParameter<edm::InputTag>("jetTracks"))),
88  m_beamSpot(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
89  m_doFilter(iConfig.getParameter<bool>("doFilter")),
90  m_cutMinPt(iConfig.getParameter<double>("minPt")),
91  m_cutMinPtRatio(iConfig.getParameter<double>("minPtRatio")),
92  m_maxTrackPt(iConfig.getParameter<double>("maxTrackPt")),
93  m_maxChi2(iConfig.getParameter<double>("maxChi2")),
94  m_maxNjets(iConfig.getParameter<int32_t>("maxNJetsToCheck")),
95  m_maxNjetsOutput(iConfig.getParameter<int32_t>("maxNjetsOutput")),
96  m_newMethod(iConfig.getParameter<bool>("newMethod")),
97  m_maxETA(iConfig.getParameter<double>("maxETA")),
98  m_pvErr_x(iConfig.getParameter<double>("pvErr_x")),
99  m_pvErr_y(iConfig.getParameter<double>("pvErr_y")),
100  m_pvErr_z(iConfig.getParameter<double>("pvErr_z")) {
101  //now do what ever initialization is needed
102  produces<std::vector<reco::CaloJet>>();
103  produces<reco::VertexCollection>();
104 }
105 
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 }
110 
111 //
112 // member functions
113 // m_maxChi2 m_maxTrackPt
114 
115 // ------------ method called on each new Event ------------
117  using namespace edm;
119  iEvent.getByToken(m_associator, jetTracksAssociation);
120  auto pOut = std::make_unique<std::vector<reco::CaloJet>>();
121 
122  bool result = true;
123  int i = 0;
124  //limit to first two jets
125  for (reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin(),
126  et = jetTracksAssociation->end();
127  it != et && i < m_maxNjets;
128  it++, i++) {
129  if (std::abs(it->first->eta()) < m_maxETA) {
130  reco::TrackRefVector tracks = it->second;
131  math::XYZVector jetMomentum = it->first->momentum();
132  math::XYZVector trMomentum;
133  for (reco::TrackRefVector::const_iterator itTrack = tracks.begin(); itTrack != tracks.end(); ++itTrack) {
134  const reco::Track& iTrack = **itTrack;
135  if (m_newMethod && iTrack.chi2() > m_maxChi2)
136  continue;
137  trMomentum += iTrack.momentum();
138  }
139  if (trMomentum.rho() / jetMomentum.rho() < m_cutMinPtRatio || trMomentum.rho() < m_cutMinPt) {
140  pOut->push_back(*dynamic_cast<const reco::CaloJet*>(&(*it->first)));
141  }
142  }
143  }
144  iEvent.put(std::move(pOut));
145 
147  iEvent.getByToken(m_beamSpot, beamSpot);
148 
150  e(0, 0) = m_pvErr_x * m_pvErr_x;
151  e(1, 1) = m_pvErr_y * m_pvErr_y;
152  e(2, 2) = m_pvErr_z * m_pvErr_z;
153  reco::Vertex::Point p(beamSpot->x0(), beamSpot->y0(), beamSpot->z0());
154  reco::Vertex thePV(p, e, 0, 0, 0);
155  auto pOut2 = std::make_unique<reco::VertexCollection>();
156  pOut2->push_back(thePV);
157  iEvent.put(std::move(pOut2));
158 
159  if (m_doFilter)
160  return result;
161  else
162  return true;
163 }
164 
165 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
168  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
169  desc.add<edm::InputTag>("jetTracks", edm::InputTag("hltFastPVJetTracksAssociator"));
170  desc.add<double>("minPtRatio", 0.1);
171  desc.add<double>("minPt", 0.0);
172  desc.add<bool>("doFilter", false);
173  desc.add<int>("maxNJetsToCheck", 2);
174  desc.add<int>("maxNjetsOutput", 2);
175  desc.add<double>("maxChi2", 20.0);
176  desc.add<double>("maxTrackPt", 20.0);
177  desc.add<bool>("newMethod", false); // <---- newMethod
178  desc.add<double>("maxETA", 2.4);
179  desc.add<double>("pvErr_x", 0.0015);
180  desc.add<double>("pvErr_y", 0.0015);
181  desc.add<double>("pvErr_z", 1.5);
182  descriptions.add("jetVertexChecker", desc);
183 }
184 //define this as a plug-in
const double m_maxChi2
transient_vector_type::const_iterator const_iterator
JetTracksAssociation::Container JetTracksAssociationCollection
typedefs for backward compatibility
const double m_maxTrackPt
const bool m_newMethod
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
const double m_pvErr_z
const_iterator begin() const
const double m_pvErr_y
int iEvent
Definition: GenABIO.cc:224
const double m_cutMinPt
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int32_t m_maxNjets
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool filter(edm::Event &, const edm::EventSetup &) override
const double m_maxETA
const_iterator end() const
const edm::EDGetTokenT< reco::JetTracksAssociationCollection > m_associator
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:587
JetVertexChecker(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~JetVertexChecker() override
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
fixed size matrix
const double m_pvErr_x
HLT enums.
const edm::EDGetTokenT< reco::BeamSpot > m_beamSpot
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const int32_t m_maxNjetsOutput
def move(src, dest)
Definition: eostools.py:511
const double m_cutMinPtRatio