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);
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
PileupJPTJetIdProducer::input_token_
edm::EDGetTokenT< edm::View< reco::JPTJet > > input_token_
Definition: PileupJPTJetIdProducer.cc:31
reco::JPTJet
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
mps_fire.i
i
Definition: mps_fire.py:428
EDProducer.h
ESHandle.h
PileupJPTJetIdProducer::verbosity
int verbosity
Definition: PileupJPTJetIdProducer.cc:33
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::PileupJPTJetIdAlgo::fillJPTBlock
float fillJPTBlock(const reco::JPTJet *jet)
Definition: PileupJPTJetIdAlgo.cc:104
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::PileupJPTJetIdAlgo::bookMVAReader
void bookMVAReader()
Definition: PileupJPTJetIdAlgo.cc:63
PileupJPTJetIdProducer::pualgo
cms::PileupJPTJetIdAlgo * pualgo
Definition: PileupJPTJetIdProducer.cc:34
Jet.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
beam_dqm_sourceclient-live_cfg.mva
mva
Definition: beam_dqm_sourceclient-live_cfg.py:122
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PileupJPTJetIdProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PileupJPTJetIdProducer.cc:53
PileupJPTJetIdProducer::jets_
edm::InputTag jets_
Definition: PileupJPTJetIdProducer.cc:30
PileupJPTJetIdProducer::PileupJPTJetIdProducer
PileupJPTJetIdProducer(const edm::ParameterSet &)
Definition: PileupJPTJetIdProducer.cc:38
b
double b
Definition: hdecay.h:118
cms::PileupJPTJetIdAlgo
Definition: PileupJPTJetIdAlgo.h:27
JPTJetCollection.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
PileupJPTJetIdProducer::~PileupJPTJetIdProducer
~PileupJPTJetIdProducer() override
Definition: PileupJPTJetIdProducer.cc:50
edm::EventSetup
Definition: EventSetup.h:57
PileupJPTJetIdProducer
Definition: PileupJPTJetIdProducer.cc:22
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
edm::ValueMap
Definition: ValueMap.h:107
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PileupJPTJetIdAlgo.h
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
PileupJPTJetIdProducer::allowMissingInputs_
bool allowMissingInputs_
Definition: PileupJPTJetIdProducer.cc:32
JPTJet.h