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 
12 
14 
18 
19 // ------------------------------------------------------------------------------------------
21 public:
23  ~PileupJPTJetIdProducer() override;
24 
25 private:
26  void produce(edm::Event&, const edm::EventSetup&) override;
27 
31  int verbosity;
33 };
34 
35 // ------------------------------------------------------------------------------------------
37  jets_ = iConfig.getParameter<edm::InputTag>("jets");
38  input_token_ = consumes<edm::View<reco::JPTJet>>(jets_);
39  verbosity = iConfig.getParameter<int>("Verbosity");
40  allowMissingInputs_ = iConfig.getUntrackedParameter<bool>("AllowMissingInputs", false);
41  pualgo = new cms::PileupJPTJetIdAlgo(iConfig);
43  produces<edm::ValueMap<float>>("JPTPUDiscriminant");
44  produces<edm::ValueMap<int>>("JPTPUId");
45 }
46 
47 // ------------------------------------------------------------------------------------------
49 
50 // ------------------------------------------------------------------------------------------
52  using namespace edm;
53  using namespace std;
54  using namespace reco;
56  iEvent.getByToken(input_token_, jets);
57  vector<float> mva;
58  vector<int> idflag;
59  for (unsigned int i = 0; i < jets->size(); ++i) {
60  int b = -1;
61  const JPTJet& jet = jets->at(i);
62 
63  float mvapu = pualgo->fillJPTBlock(&jet);
64 
65  mva.push_back(mvapu);
66 
67  // Get PUid type
69  //WP 95% JPT PUID > 0.3
70  //WP 90% JPT PUID > 0.7
71  //WP 80% JPT PUID > 0.9
72 
73  //|eta|>=2.6
74  //WP 90% JPT PUID > -0.55
75  //WP 80% JPT PUID > -0.3
76  //WP 70% JPT PUID > -0.1
77 
78  if (fabs(jet.eta()) < 2.6) {
79  if (mvapu > 0.3)
80  b = 0;
81  if (mvapu > 0.7)
82  b = 1;
83  if (mvapu > 0.9)
84  b = 2;
85  } else {
86  if (mvapu > -0.55)
87  b = 0;
88  if (mvapu > -0.3)
89  b = 1;
90  if (mvapu > -0.1)
91  b = 2;
92  }
93 
94  idflag.push_back(b);
95 
96  if (verbosity > 0)
97  std::cout << " PUID producer::Corrected JPT Jet is " << jet.pt() << " " << jet.eta() << " " << jet.phi() << " "
98  << jet.getSpecific().Zch << std::endl;
99  }
100 
101  auto mvaout = std::make_unique<ValueMap<float>>();
102  ValueMap<float>::Filler mvafiller(*mvaout);
103  mvafiller.insert(jets, mva.begin(), mva.end());
104  mvafiller.fill();
105  iEvent.put(std::move(mvaout), "JPTPUDiscriminant");
106 
107  auto idflagout = std::make_unique<ValueMap<int>>();
108  ValueMap<int>::Filler idflagfiller(*idflagout);
109  idflagfiller.insert(jets, idflag.begin(), idflag.end());
110  idflagfiller.fill();
111  iEvent.put(std::move(idflagout), "JPTPUId");
112 }
113 
114 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:511