#ifndef UserCode_ICHiggsTauTau_ICJetProducer_h
#define UserCode_ICHiggsTauTau_ICJetProducer_h
#include <memory>
#include <typeinfo>
#include "boost/functional/hash.hpp"
#include "boost/format.hpp"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "DataFormats/JetReco/interface/JPTJet.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "DataFormats/JetReco/interface/JetID.h"
#include "DataFormats/BTauReco/interface/JetTag.h"
#include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
#include "JetMETCorrections/Objects/interface/JetCorrector.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
template <class T, class U>
public:
private:
virtual void beginJob();
virtual void produce(edm::Event &, const edm::EventSetup &);
virtual void endJob();
void constructSpecific(edm::Handle<edm::View<U> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup);
std::vector<T> *jets_;
edm::InputTag input_;
std::string branch_;
std::vector<unsigned> passed_;
};
template <class T, class U>
: input_(config.getParameter<
edm::InputTag>(
"input")),
branch_(config.getParameter<
std::string>(
"branch")),
consumes<edm::View<U>>(input_);
jets_ = new std::vector<T>();
src_.DoSetup(this);
dest_.DoSetup(this);
}
template <class T, class U>
template <class T, class U>
const edm::EventSetup& setup) {
edm::Handle<edm::View<U> > jets_handle;
event.getByLabel(input_, jets_handle);
jets_->clear();
passed_.clear();
jets_->reserve(jets_handle->size());
passed_.reserve(jets_handle->size());
src_.Produce(jets_handle, jets_, &passed_, event, setup);
constructSpecific(jets_handle, event, setup);
}
template <class T, class U>
edm::Handle<edm::View<U> > const& jets_handle, edm::Event& event,
const edm::EventSetup& setup) {}
template <>
edm::Handle<edm::View<reco::CaloJet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
edm::Handle<reco::JetIDValueMap> jet_id_handle;
if (dest_.do_jet_id) event.getByLabel(dest_.input_jet_id, jet_id_handle);
for (unsigned i = 0; i < passed_.size(); ++i) {
reco::CaloJet const& src = jets_handle->at(passed_[i]);
if (dest_.do_n_carrying) {
}
if (dest_.do_jet_id) {
reco::JetID const& jet_id =
(*jet_id_handle)[jets_handle->refAt(passed_[i])];
}
}
}
template <>
edm::Handle<edm::View<pat::Jet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
for (unsigned i = 0; i < passed_.size(); ++i) {
pat::Jet const& src = jets_handle->at(passed_[i]);
if (dest_.do_n_carrying) {
}
(src.jecSetsAvailable() ? src.jecFactor(0) : 1.) * src.energy());
if (dest_.do_jet_id) {
}
}
}
template <>
edm::Handle<edm::View<reco::JPTJet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
edm::Handle<reco::JetIDValueMap> jet_id_handle;
if (dest_.do_jet_id) event.getByLabel(dest_.input_jet_id, jet_id_handle);
edm::Handle<reco::TrackCollection> trk_handle;
edm::Handle<reco::VertexCollection> vtx_handle;
std::map<unsigned, unsigned> trk_vtx_map;
std::auto_ptr<reco::TrackRefVector> track_requests(
new reco::TrackRefVector());
if (dest_.do_trk_vars) {
event.getByLabel(dest_.input_trks, trk_handle);
event.getByLabel(dest_.input_vtxs, vtx_handle);
}
for (unsigned i = 0; i < passed_.size(); ++i) {
reco::JPTJet const& src = jets_handle->at(passed_[i]);
reco::CaloJetRef calo(src.getCaloJetRef().castTo<reco::CaloJetRef>());
if (dest_.do_n_carrying) {
}
if (dest_.do_jet_id) {
reco::JetID const& jet_id = (*jet_id_handle)[calo];
}
if (dest_.request_trks) {
src.getPionsInVertexInCalo(), track_requests.get()));
src.getPionsInVertexOutCalo(), track_requests.get()));
src.getPionsOutVertexInCalo(), track_requests.get()));
src.getMuonsInVertexInCalo(), track_requests.get()));
src.getMuonsInVertexOutCalo(), track_requests.get()));
src.getMuonsOutVertexInCalo(), track_requests.get()));
src.getElecsInVertexInCalo(), track_requests.get()));
src.getElecsInVertexOutCalo(), track_requests.get()));
src.getElecsOutVertexInCalo(), track_requests.get()));
}
if (dest_.do_trk_vars && trk_handle->size() > 0) {
std::vector<reco::Track const*> all_tracks;
dest_.AddTrackCollection(src.getPionsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.getPionsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.getPionsOutVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.getMuonsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.getMuonsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.getMuonsOutVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.getElecsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.getElecsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.getElecsOutVertexInCalo(), &all_tracks);
}
}
if (dest_.request_trks) {
event.put(track_requests, "requestedTracks");
}
}
template <>
edm::Handle<edm::View<pat::Jet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
edm::Handle<reco::TrackCollection> trk_handle;
edm::Handle<reco::VertexCollection> vtx_handle;
std::map<unsigned, unsigned> trk_vtx_map;
std::auto_ptr<reco::TrackRefVector> track_requests(
new reco::TrackRefVector());
if (dest_.do_trk_vars) {
event.getByLabel(dest_.input_trks, trk_handle);
event.getByLabel(dest_.input_vtxs, vtx_handle);
}
for (unsigned i = 0; i < passed_.size(); ++i) {
pat::Jet const& src = jets_handle->at(passed_[i]);
if (dest_.do_n_carrying) {
}
(src.jecSetsAvailable() ? src.jecFactor(0) : 1.) * src.energy());
if (dest_.do_jet_id) {
}
if (dest_.request_trks) {
src.pionsInVertexInCalo(), track_requests.get()));
src.pionsInVertexOutCalo(), track_requests.get()));
src.pionsOutVertexInCalo(), track_requests.get()));
src.muonsInVertexInCalo(), track_requests.get()));
src.muonsInVertexOutCalo(), track_requests.get()));
src.muonsOutVertexInCalo(), track_requests.get()));
src.elecsInVertexInCalo(), track_requests.get()));
src.elecsInVertexOutCalo(), track_requests.get()));
src.elecsOutVertexInCalo(), track_requests.get()));
}
if (dest_.do_trk_vars && trk_handle->size() > 0) {
std::vector<reco::Track const*> all_tracks;
dest_.AddTrackCollection(src.pionsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.pionsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.pionsOutVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.muonsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.muonsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.muonsOutVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.elecsInVertexInCalo(), &all_tracks);
dest_.AddTrackCollection(src.elecsInVertexOutCalo(), &all_tracks);
dest_.AddTrackCollection(src.elecsOutVertexInCalo(), &all_tracks);
}
}
if (dest_.request_trks) {
event.put(track_requests, "requestedTracks");
}
}
template <>
edm::Handle<edm::View<reco::PFJet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
edm::Handle<edm::ValueMap<float> > pu_id_handle;
if (dest_.do_pu_id) event.getByLabel(dest_.input_pu_id, pu_id_handle);
edm::Handle<reco::TrackCollection> trk_handle;
edm::Handle<reco::VertexCollection> vtx_handle;
std::map<unsigned, unsigned> trk_vtx_map;
std::auto_ptr<reco::TrackRefVector> track_requests(
new reco::TrackRefVector());
if (dest_.do_trk_vars) {
event.getByLabel(dest_.input_trks, trk_handle);
event.getByLabel(dest_.input_vtxs, vtx_handle);
}
for (unsigned i = 0; i < passed_.size(); ++i) {
reco::PFJet const& src = jets_handle->at(passed_[i]);
if (dest_.do_pu_id) {
}
if (dest_.request_trks) {
track_requests.get(), &(dest_.track_hasher));
}
if (dest_.do_trk_vars && trk_handle->size() > 0) {
if (dest_.do_trk_vars && trk_handle->size() > 0) {
trk_vtx_map);
}
}
}
if (dest_.request_trks) {
event.put(track_requests, "requestedTracks");
}
}
template <>
edm::Handle<edm::View<pat::Jet> > const& jets_handle,
edm::Event& event, const edm::EventSetup& setup) {
edm::Handle<edm::ValueMap<float> > pu_id_handle;
if (dest_.do_pu_id) event.getByLabel(dest_.input_pu_id, pu_id_handle);
edm::Handle<reco::TrackCollection> trk_handle;
edm::Handle<reco::VertexCollection> vtx_handle;
std::map<unsigned, unsigned> trk_vtx_map;
std::auto_ptr<reco::TrackRefVector> track_requests(
new reco::TrackRefVector());
if (dest_.do_trk_vars) {
event.getByLabel(dest_.input_trks, trk_handle);
event.getByLabel(dest_.input_vtxs, vtx_handle);
}
for (unsigned i = 0; i < passed_.size(); ++i) {
pat::Jet const& src = jets_handle->at(passed_[i]);
(src.jecSetsAvailable() ? src.jecFactor(0) : 1.) * src.energy());
if (dest_.do_pu_id) {
if (src_.is_slimmed) {
} else {
(*pu_id_handle)[jets_handle->refAt(passed_[i])->originalObjectRef()]);
}
}
if (dest_.request_trks) {
track_requests.get(), &(dest_.track_hasher));
}
if (dest_.do_trk_vars && trk_handle->size() > 0) {
trk_vtx_map);
}
}
if (dest_.request_trks) {
event.put(track_requests, "requestedTracks");
}
}
template <class T, class U>
}
template <class T, class U>
}
#endif