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