CMS 3D CMS Logo

JPTJetSlimmer.cc
Go to the documentation of this file.
1 
6 
11 
18 #include <vector>
19 
21 public:
23  : srcToken_(consumes<edm::View<reco::JPTJet> >(params.getParameter<edm::InputTag>("src"))),
24  srcCaloToken_(consumes<edm::View<reco::CaloJet> >(params.getParameter<edm::InputTag>("srcCalo"))),
25  cut_(params.getParameter<std::string>("cut")),
26  selector_(cut_) {
27  produces<reco::JPTJetCollection>();
28  produces<reco::CaloJetCollection>();
29  }
30 
31  ~JPTJetSlimmer() override {}
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34 
35  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {
36  auto jptJets = std::make_unique<reco::JPTJetCollection>();
37  auto caloJets = std::make_unique<reco::CaloJetCollection>();
38 
41 
42  auto const& h_calojets = iEvent.get(srcCaloToken_);
43  auto const& h_jets = iEvent.get(srcToken_);
44 
45  for (auto const& ijet : h_jets) {
46  if (selector_(ijet)) {
47  // Add specific : only reference to CaloJet collection. It is necessary for
48  // recalibration JPTJet at MiniAod.
49  const edm::RefToBase<reco::Jet>& rawcalojet = ijet.getCaloJetRef();
50  int icalo = -1;
51  int i = 0;
52  for (auto const& icjet : h_calojets) {
53  double dr2 = deltaR2(icjet, *rawcalojet);
54  if (dr2 <= 0.001) {
55  icalo = i;
56  }
57  i++;
58  }
59  reco::JPTJet::Specific tmp_specific;
60  if (icalo < 0) {
61  // Add reference to the created CaloJet collection
62  reco::CaloJetRef myjet(pOut1RefProd, idxCaloJet++);
63  tmp_specific.theCaloJetRef = edm::RefToBase<reco::Jet>(myjet);
64  reco::CaloJet const* rawcalojetc = dynamic_cast<reco::CaloJet const*>(&*rawcalojet);
65  caloJets->push_back(*rawcalojetc);
66  const reco::Candidate::Point& orivtx = ijet.vertex();
67  reco::JPTJet newJPTJet(ijet.p4(), orivtx, tmp_specific, ijet.getJetConstituents());
68  float jetArea = ijet.jetArea();
69  newJPTJet.setJetArea(fabs(jetArea));
70  jptJets->push_back(newJPTJet);
71  }
72  }
73  }
75  iEvent.put(std::move(jptJets));
76  }
77 
78 protected:
83 };
85  // slimmedJPTJets
87  desc.add<edm::InputTag>("src", edm::InputTag("JetPlusTrackZSPCorJetAntiKt4"));
88  desc.add<edm::InputTag>("srcCalo", edm::InputTag("slimmedCaloJets"));
89  desc.add<std::string>("cut", "pt>20");
90  descriptions.add("slimmedJPTJets", desc);
91 }
92 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
Jets made from CaloTowers.
Definition: CaloJet.h:27
const edm::EDGetTokenT< edm::View< reco::JPTJet > > srcToken_
JPTJetSlimmer(edm::ParameterSet const &params)
const edm::EDGetTokenT< edm::View< reco::CaloJet > > srcCaloToken_
int iEvent
Definition: GenABIO.cc:224
const std::string cut_
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const StringCutObjectSelector< reco::Jet > selector_
edm::RefToBase< reco::Jet > theCaloJetRef
Definition: JPTJet.h:46
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
def move(src, dest)
Definition: eostools.py:511
~JPTJetSlimmer() override
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects