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.1 2012/02/01 16:24:02 arizzi 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 void beginJob() ;
57  virtual bool filter(edm::Event&, const edm::EventSetup&);
58  virtual void endJob() ;
59 
60  virtual bool beginRun(edm::Run&, edm::EventSetup const&);
61  virtual bool endRun(edm::Run&, edm::EventSetup const&);
64 
65  // ----------member data ---------------------------
69  bool m_doFilter;
70  double m_cutMinPt;
71  double m_cutMinPtRatio;
72  int32_t m_maxNjets;
73 
74 };
75 
76 //
77 // constants, enums and typedefs
78 //
79 
80 //
81 // static data member definitions
82 //
83 
84 //
85 // constructors and destructor
86 //
88 {
89  //now do what ever initialization is needed
90  m_beamSpot = iConfig.getParameter<edm::InputTag>("beamSpot");
91  m_associator = iConfig.getParameter<edm::InputTag>("jetTracks");
92  m_doFilter = iConfig.getParameter<bool>("doFilter");
93  m_cutMinPt = iConfig.getParameter<double>("minPt");
94  m_cutMinPtRatio = iConfig.getParameter<double>("minPtRatio");
95  m_maxNjets = iConfig.getParameter<int32_t>("maxNJetsToCheck");
96  produces<std::vector<reco::CaloJet> >();
97  produces<reco::VertexCollection >();
98 }
99 
100 
102 {
103 
104  // do anything here that needs to be done at desctruction time
105  // (e.g. close files, deallocate resources etc.)
106 
107 }
108 
109 
110 //
111 // member functions
112 //
113 
114 // ------------ method called on each new Event ------------
115 bool
117 {
118  using namespace edm;
120  iEvent.getByLabel(m_associator, jetTracksAssociation);
121  std::auto_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet> );
122 
123  bool result=true;
124  int i = 0;
125  //limit to first two jets
126  for(reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
127  it != jetTracksAssociation->end() && i < m_maxNjets; it++, i++) {
128  if(fabs(it->first->eta()) < 2.4)
129  {
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  {
135  trMomentum += (*itTrack)->momentum();
136  }
137  if(trMomentum.rho()/jetMomentum.rho() < m_cutMinPtRatio || trMomentum.rho() < m_cutMinPt)
138  {
139 // std::cout << "bad jet " << it->first->pt() << std::endl;
140  pOut->push_back(* dynamic_cast<const reco::CaloJet *>(&(*it->first)));
141  result=false;
142  }
143  }
144  }
145 
146  iEvent.put(pOut);
147 
150 
152  e(0, 0) = 0.0015 * 0.0015;
153  e(1, 1) = 0.0015 * 0.0015;
154  e(2, 2) = 1.5 * 1.5;
155  reco::Vertex::Point p(beamSpot->x0(), beamSpot->y0(), beamSpot->z0());
156  reco::Vertex thePV(p, e, 0, 0, 0);
157  std::auto_ptr<reco::VertexCollection> pOut2(new reco::VertexCollection);
158  pOut2->push_back(thePV);
159  iEvent.put(pOut2);
160 // std::cout << " filter " << result << std::endl;
161  if(m_doFilter) return result;
162  else
163  return true;
164 }
165 
166 // ------------ method called once each job just before starting event loop ------------
167 void
169 {
170 }
171 
172 // ------------ method called once each job just after ending the event loop ------------
173 void
175 }
176 
177 // ------------ method called when starting to processes a run ------------
178 bool
180 {
181  return true;
182 }
183 
184 // ------------ method called when ending the processing of a run ------------
185 bool
187 {
188  return true;
189 }
190 
191 // ------------ method called when starting to processes a luminosity block ------------
192 bool
194 {
195  return true;
196 }
197 
198 // ------------ method called when ending the processing of a luminosity block ------------
199 bool
201 {
202  return true;
203 }
204 
205 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
206 void
208  //The following says we do not know what parameters are allowed so do no validation
209  // Please change this to state exactly what you do use, even if it is no parameters
211  desc.setUnknown();
212  descriptions.addDefault(desc);
213 }
214 //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
virtual bool beginRun(edm::Run &, edm::EventSetup const &)
virtual void beginJob()
#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
virtual bool beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
virtual bool endLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
tuple result
Definition: query.py:137
edm::InputTag m_primaryVertexProducer
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void endJob()
virtual bool endRun(edm::Run &, edm::EventSetup const &)
edm::InputTag m_beamSpot
virtual bool filter(edm::Event &, const edm::EventSetup &)
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)
Definition: Run.h:33