CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PileupJPTJetIdProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
8 
14 
16 
20 
21 
22 // ------------------------------------------------------------------------------------------
24 public:
27 
28 private:
29  virtual void produce(edm::Event&, const edm::EventSetup&);
30 
31  virtual void beginRun(edm::Run&, edm::EventSetup const&);
32  virtual void endRun(edm::Run&, edm::EventSetup const&);
35 
39  int verbosity;
41 
42 };
43 
44 // ------------------------------------------------------------------------------------------
46 {
47  jets_ = iConfig.getParameter<edm::InputTag>("jets");
48  input_token_ = consumes<edm::View<reco::JPTJet> >(jets_);
49  verbosity = iConfig.getParameter<int>("Verbosity");
50  allowMissingInputs_=iConfig.getUntrackedParameter<bool>("AllowMissingInputs",false);
51  pualgo = new cms::PileupJPTJetIdAlgo(iConfig);
52  pualgo->bookMVAReader();
53  produces<edm::ValueMap<float> > ("JPTPUDiscriminant");
54  produces<edm::ValueMap<int> > ("JPTPUId");
55 }
56 
57 
58 
59 // ------------------------------------------------------------------------------------------
61 {
62 }
63 
64 
65 // ------------------------------------------------------------------------------------------
66 void
68 {
69  using namespace edm;
70  using namespace std;
71  using namespace reco;
73  iEvent.getByToken(input_token_, jets);
74  vector<float> mva;
75  vector<int> idflag;
76  for ( unsigned int i=0; i<jets->size(); ++i ) {
77  int b = -1;
78  const JPTJet & jet = jets->at(i);
79 
80  float mvapu = pualgo->fillJPTBlock(&jet);
81 
82  mva.push_back(mvapu);
83 
84  // Get PUid type
86 //WP 95% JPT PUID > 0.3
87 //WP 90% JPT PUID > 0.7
88 //WP 80% JPT PUID > 0.9
89 
90 //|eta|>=2.6
91 //WP 90% JPT PUID > -0.55
92 //WP 80% JPT PUID > -0.3
93 //WP 70% JPT PUID > -0.1
94 
95  if(fabs(jet.eta()) < 2.6 ) {
96  if( mvapu > 0.3 ) b = 0;
97  if( mvapu > 0.7 ) b = 1;
98  if( mvapu > 0.9 ) b = 2;
99  } else {
100  if( mvapu > -0.55 ) b = 0;
101  if( mvapu > -0.3 ) b = 1;
102  if( mvapu > -0.1 ) b = 2;
103  }
104 
105  idflag.push_back(b);
106 
107  if(verbosity > 0) std::cout<<" PUID producer::Corrected JPT Jet is "<<jet.pt()<<" "<<jet.eta()<<" "<<jet.phi()<<" "<<jet.getSpecific().Zch<<std::endl;
108 
109  }
110 
111  auto_ptr<ValueMap<float> > mvaout(new ValueMap<float>());
112  ValueMap<float>::Filler mvafiller(*mvaout);
113  mvafiller.insert(jets,mva.begin(),mva.end());
114  mvafiller.fill();
115  iEvent.put(mvaout,"JPTPUDiscriminant");
116 
117  auto_ptr<ValueMap<int> > idflagout(new ValueMap<int>());
118  ValueMap<int>::Filler idflagfiller(*idflagout);
119  idflagfiller.insert(jets,idflag.begin(),idflag.end());
120  idflagfiller.fill();
121  iEvent.put(idflagout,"JPTPUId");
122 
123 }
124 
125 // ------------------------------------------------------------------------------------------
126 void
128 {
129 }
130 
131 // ------------------------------------------------------------------------------------------
132 void
134 {
135 }
136 
137 // ------------------------------------------------------------------------------------------
138 void
140 {
141 }
142 
143 // ------------------------------------------------------------------------------------------
144 void
146 {
147 }
148 
149 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
const Specific & getSpecific() const
block accessors
Definition: JPTJet.h:133
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endRun(edm::Run &, edm::EventSetup const &)
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual void beginRun(edm::Run &, edm::EventSetup const &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
vector< PseudoJet > jets
edm::EDGetTokenT< edm::View< reco::JPTJet > > input_token_
virtual void endLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
cms::PileupJPTJetIdAlgo * pualgo
double b
Definition: hdecay.h:120
float fillJPTBlock(const reco::JPTJet *jet)
tuple cout
Definition: gather_cfg.py:121
PileupJPTJetIdProducer(const edm::ParameterSet &)
virtual double phi() const
momentum azimuthal angle
Definition: Run.h:41