CMS 3D CMS Logo

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 
34  int verbosity;
36 
37 };
38 
39 // ------------------------------------------------------------------------------------------
41 {
42  jets_ = iConfig.getParameter<edm::InputTag>("jets");
43  input_token_ = consumes<edm::View<reco::JPTJet> >(jets_);
44  verbosity = iConfig.getParameter<int>("Verbosity");
45  allowMissingInputs_=iConfig.getUntrackedParameter<bool>("AllowMissingInputs",false);
46  pualgo = new cms::PileupJPTJetIdAlgo(iConfig);
47  pualgo->bookMVAReader();
48  produces<edm::ValueMap<float> > ("JPTPUDiscriminant");
49  produces<edm::ValueMap<int> > ("JPTPUId");
50 }
51 
52 
53 
54 // ------------------------------------------------------------------------------------------
56 {
57 }
58 
59 
60 // ------------------------------------------------------------------------------------------
61 void
63 {
64  using namespace edm;
65  using namespace std;
66  using namespace reco;
68  iEvent.getByToken(input_token_, jets);
69  vector<float> mva;
70  vector<int> idflag;
71  for ( unsigned int i=0; i<jets->size(); ++i ) {
72  int b = -1;
73  const JPTJet & jet = jets->at(i);
74 
75  float mvapu = pualgo->fillJPTBlock(&jet);
76 
77  mva.push_back(mvapu);
78 
79  // Get PUid type
81 //WP 95% JPT PUID > 0.3
82 //WP 90% JPT PUID > 0.7
83 //WP 80% JPT PUID > 0.9
84 
85 //|eta|>=2.6
86 //WP 90% JPT PUID > -0.55
87 //WP 80% JPT PUID > -0.3
88 //WP 70% JPT PUID > -0.1
89 
90  if(fabs(jet.eta()) < 2.6 ) {
91  if( mvapu > 0.3 ) b = 0;
92  if( mvapu > 0.7 ) b = 1;
93  if( mvapu > 0.9 ) b = 2;
94  } else {
95  if( mvapu > -0.55 ) b = 0;
96  if( mvapu > -0.3 ) b = 1;
97  if( mvapu > -0.1 ) b = 2;
98  }
99 
100  idflag.push_back(b);
101 
102  if(verbosity > 0) std::cout<<" PUID producer::Corrected JPT Jet is "<<jet.pt()<<" "<<jet.eta()<<" "<<jet.phi()<<" "<<jet.getSpecific().Zch<<std::endl;
103 
104  }
105 
106  auto mvaout = std::make_unique<ValueMap<float>>();
107  ValueMap<float>::Filler mvafiller(*mvaout);
108  mvafiller.insert(jets,mva.begin(),mva.end());
109  mvafiller.fill();
110  iEvent.put(std::move(mvaout),"JPTPUDiscriminant");
111 
112  auto idflagout = std::make_unique<ValueMap<int>>();
113  ValueMap<int>::Filler idflagfiller(*idflagout);
114  idflagfiller.insert(jets,idflag.begin(),idflag.end());
115  idflagfiller.fill();
116  iEvent.put(std::move(idflagout),"JPTPUId");
117 
118 }
119 
120 //define this as a plug-in
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const Specific & getSpecific() const
block accessors
Definition: JPTJet.h:133
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual double phi() const final
momentum azimuthal angle
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
vector< PseudoJet > jets
edm::EDGetTokenT< edm::View< reco::JPTJet > > input_token_
cms::PileupJPTJetIdAlgo * pualgo
double b
Definition: hdecay.h:120
float fillJPTBlock(const reco::JPTJet *jet)
fixed size matrix
HLT enums.
PileupJPTJetIdProducer(const edm::ParameterSet &)
def move(src, dest)
Definition: eostools.py:510