2 #include "TLorentzVector.h" 17 #include "TLorentzVector.h" 23 #include "Math/GenVector/VectorUtil.h" 33 PFTaus_ = consumes<reco::PFTauCollection>(pfTau.getUntrackedParameter<
InputTag>(
"PFTauProducer"));
34 auto discs = pfTau.getUntrackedParameter<vector<InputTag>>(
"PFTauDiscriminators");
35 auto discConts = pfTau.getUntrackedParameter<vector<InputTag>>(
"PFTauDiscriminatorContainers");
36 PFTauDisContWPs_ = pfTau.getUntrackedParameter<vector<std::string>>(
"PFTauDiscriminatorContainerWPs");
37 if (discConts.size() != PFTauDisContWPs_.size())
38 throw cms::Exception(
"Configuration") <<
"HLTTauRefProducer: Input parameters PFTauDiscriminatorContainers and " 39 "PFTauDiscriminatorContainerWPs must have the same number of entries!\n";
40 for (
auto const&
tag : discs) {
41 PFTauDis_.push_back(consumes<reco::PFTauDiscriminator>(
tag));
43 for (
auto const&
tag : discConts) {
44 PFTauDisCont_.push_back(consumes<reco::TauDiscriminatorContainer>(
tag));
46 doPFTaus_ = pfTau.getUntrackedParameter<
bool>(
"doPFTaus",
false);
47 ptMinPFTau_ = pfTau.getUntrackedParameter<
double>(
"ptMin", 15.);
48 etaMinPFTau_ = pfTau.getUntrackedParameter<
double>(
"etaMin", -2.5);
49 etaMaxPFTau_ = pfTau.getUntrackedParameter<
double>(
"etaMax", 2.5);
50 phiMinPFTau_ = pfTau.getUntrackedParameter<
double>(
"phiMin", -3.15);
51 phiMaxPFTau_ = pfTau.getUntrackedParameter<
double>(
"phiMax", 3.15);
56 Electrons_ = consumes<reco::GsfElectronCollection>(
electrons.getUntrackedParameter<
InputTag>(
"ElectronCollection"));
57 doElectrons_ =
electrons.getUntrackedParameter<
bool>(
"doElectrons",
false);
58 e_ctfTrackCollectionSrc_ =
electrons.getUntrackedParameter<
InputTag>(
"TrackCollection");
59 e_ctfTrackCollection_ = consumes<reco::TrackCollection>(e_ctfTrackCollectionSrc_);
60 ptMinElectron_ =
electrons.getUntrackedParameter<
double>(
"ptMin", 15.);
61 e_doTrackIso_ =
electrons.getUntrackedParameter<
bool>(
"doTrackIso",
false);
62 e_trackMinPt_ =
electrons.getUntrackedParameter<
double>(
"ptMinTrack", 1.5);
63 e_lipCut_ =
electrons.getUntrackedParameter<
double>(
"lipMinTrack", 1.5);
64 e_minIsoDR_ =
electrons.getUntrackedParameter<
double>(
"InnerConeDR", 0.02);
65 e_maxIsoDR_ =
electrons.getUntrackedParameter<
double>(
"OuterConeDR", 0.6);
66 e_isoMaxSumPt_ =
electrons.getUntrackedParameter<
double>(
"MaxIsoVar", 0.02);
71 Muons_ = consumes<reco::MuonCollection>(
muons.getUntrackedParameter<
InputTag>(
"MuonCollection"));
72 doMuons_ =
muons.getUntrackedParameter<
bool>(
"doMuons",
false);
73 ptMinMuon_ =
muons.getUntrackedParameter<
double>(
"ptMin", 15.);
78 Jets_ = consumes<reco::CaloJetCollection>(
jets.getUntrackedParameter<
InputTag>(
"JetCollection"));
79 doJets_ =
jets.getUntrackedParameter<
bool>(
"doJets");
80 ptMinJet_ =
jets.getUntrackedParameter<
double>(
"etMin");
85 Towers_ = consumes<CaloTowerCollection>(
towers.getUntrackedParameter<
InputTag>(
"TowerCollection"));
86 doTowers_ =
towers.getUntrackedParameter<
bool>(
"doTowers");
87 ptMinTower_ =
towers.getUntrackedParameter<
double>(
"etMin");
88 towerIsol_ =
towers.getUntrackedParameter<
double>(
"towerIsolation");
93 Photons_ = consumes<reco::PhotonCollection>(
photons.getUntrackedParameter<
InputTag>(
"PhotonCollection"));
94 doPhotons_ =
photons.getUntrackedParameter<
bool>(
"doPhotons");
95 ptMinPhoton_ =
photons.getUntrackedParameter<
double>(
"etMin");
96 photonEcalIso_ =
photons.getUntrackedParameter<
double>(
"ECALIso");
101 MET_ = consumes<reco::CaloMETCollection>(
met.getUntrackedParameter<
InputTag>(
"METCollection"));
102 doMET_ =
met.getUntrackedParameter<
bool>(
"doMET",
false);
103 ptMinMET_ =
met.getUntrackedParameter<
double>(
"ptMin", 15.);
112 produces<LorentzVectorCollection>(
"PFTaus");
113 produces<LorentzVectorCollection>(
"Electrons");
114 produces<LorentzVectorCollection>(
"Muons");
115 produces<LorentzVectorCollection>(
"Jets");
116 produces<LorentzVectorCollection>(
"Photons");
117 produces<LorentzVectorCollection>(
"Towers");
118 produces<LorentzVectorCollection>(
"MET");
139 auto product_PFTaus = make_unique<LorentzVectorCollection>();
142 if (
iEvent.getByToken(PFTaus_, pftaus)) {
144 if (streamCache(iID)->first !=
iEvent.processHistoryID()) {
145 streamCache(iID)->first =
iEvent.processHistoryID();
146 streamCache(iID)->second.resize(PFTauDisContWPs_.size());
147 for (
size_t i = 0;
i < PFTauDisCont_.size(); ++
i) {
148 auto const aHandle =
iEvent.getHandle(PFTauDisCont_[
i]);
149 auto const aProv = aHandle.provenance();
150 if (aProv ==
nullptr)
151 aHandle.whyFailed()->raise();
153 if (psetsFromProvenance.exists(
"workingPoints")) {
154 auto const idlist = psetsFromProvenance.
getParameter<std::vector<std::string>>(
"workingPoints");
156 for (
size_t j = 0;
j < idlist.size(); ++
j) {
157 if (PFTauDisContWPs_[
i] == idlist[
j]) {
159 streamCache(iID)->second[
i] =
j;
164 <<
"HLTTauRefProducer: Requested working point '" << PFTauDisContWPs_[
i] <<
"' not found!\n";
165 }
else if (psetsFromProvenance.exists(
"IDWPdefinitions")) {
166 auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
168 for (
size_t j = 0;
j < idlist.size(); ++
j) {
169 if (PFTauDisContWPs_[
i] == idlist[
j].getParameter<std::string>(
"IDname")) {
171 streamCache(iID)->second[
i] =
j;
176 <<
"HLTTauRefProducer: Requested working point '" << PFTauDisContWPs_[
i] <<
"' not found!\n";
179 <<
"HLTTauRefProducer: No suitable ID list found in provenace config!\n";
182 for (
unsigned int i = 0;
i < pftaus->size(); ++
i) {
183 auto const& pftau = (*pftaus)[
i];
184 if (pftau.pt() > ptMinPFTau_ && pftau.eta() > etaMinPFTau_ && pftau.eta() < etaMaxPFTau_ &&
185 pftau.phi() > phiMinPFTau_ && pftau.phi() < phiMaxPFTau_) {
189 for (
auto const&
token : PFTauDis_) {
192 if ((*pftaudis)[thePFTau] < 0.5) {
203 for (
auto const&
token : PFTauDisCont_) {
207 if ((*pftaudis)[thePFTau].workingPoints.empty() ||
208 !(*pftaudis)[thePFTau].workingPoints.at(streamCache(iID)->
second[
idx])) {
219 product_PFTaus->emplace_back(pftau.px(), pftau.py(), pftau.pz(), pftau.energy());
228 auto product_Electrons = make_unique<LorentzVectorCollection>();
231 if (!
iEvent.getByToken(e_ctfTrackCollection_, pCtfTracks)) {
232 edm::LogInfo(
"") <<
"Error! Can't get " << e_ctfTrackCollectionSrc_.label() <<
" by label. ";
233 iEvent.put(
move(product_Electrons),
"Electrons");
244 double sum_of_pt_ele{};
245 for (
auto const& tr : *pCtfTracks) {
246 double const lip{
electron.gsfTrack()->dz() - tr.dz()};
247 if (tr.pt() > e_trackMinPt_ && fabs(
lip) < e_lipCut_) {
248 double dphi{fabs(tr.phi() -
electron.trackMomentumAtVtx().phi())};
249 if (dphi > acos(-1.)) {
250 dphi = 2 * acos(-1.) - dphi;
252 double const deta{fabs(tr.eta() -
electron.trackMomentumAtVtx().eta())};
253 double const dr_ctf_ele{
sqrt(deta * deta + dphi * dphi)};
254 if ((dr_ctf_ele > e_minIsoDR_) && (dr_ctf_ele < e_maxIsoDR_)) {
255 double const cft_pt_2{tr.pt() * tr.pt()};
256 sum_of_pt_ele += cft_pt_2;
260 double const isolation_value_ele{sum_of_pt_ele /
261 (
electron.trackMomentumAtVtx().Rho() *
electron.trackMomentumAtVtx().Rho())};
262 if (isolation_value_ele < e_isoMaxSumPt_) {
271 iEvent.put(
move(product_Electrons),
"Electrons");
275 auto product_Muons = make_unique<LorentzVectorCollection>();
280 if (
muon.pt() > ptMinMuon_ &&
muon.eta() > etaMin_ &&
muon.eta() < etaMax_ &&
muon.phi() > phiMin_ &&
281 muon.phi() < phiMax_) {
282 product_Muons->emplace_back(
muon.px(),
muon.py(),
muon.pz(),
muon.energy());
290 auto product_Jets = make_unique<LorentzVectorCollection>();
294 for (
auto const&
jet : *
jets) {
295 if (
jet.et() > ptMinJet_ &&
jet.eta() > etaMin_ &&
jet.eta() < etaMax_ &&
jet.phi() > phiMin_ &&
296 jet.phi() < phiMax_) {
297 product_Jets->emplace_back(
jet.px(),
jet.py(),
jet.pz(),
jet.energy());
305 auto product_Towers = make_unique<LorentzVectorCollection>();
309 for (
auto const& tower1 : *
towers) {
310 if (tower1.pt() > ptMinTower_ && tower1.eta() > etaMin_ && tower1.eta() < etaMax_ && tower1.phi() > phiMin_ &&
311 tower1.phi() < phiMax_) {
314 for (
auto const& tower2 : *
towers) {
316 isolET += tower2.pt();
318 isolET -= tower1.pt();
320 if (isolET < towerIsol_) {
321 product_Towers->emplace_back(tower1.px(), tower1.py(), tower1.pz(), tower1.energy());
330 auto product_Gammas = make_unique<LorentzVectorCollection>();
335 if (
photon.ecalRecHitSumEtConeDR04() < photonEcalIso_ &&
photon.et() > ptMinPhoton_ &&
photon.eta() > etaMin_ &&
345 auto product_MET = make_unique<LorentzVectorCollection>();
349 auto const& metMom =
met->front().p4();
350 product_MET->emplace_back(metMom.Px(), metMom.Py(), 0, metMom.Pt());
T getParameter(std::string const &) const
void doPhotons(edm::Event &) const
void doTowers(edm::Event &) const
void doElectrons(edm::Event &) const
HLTTauRefProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
T getUntrackedParameter(std::string const &, T const &) const
U second(std::pair< T, U > const &p)
void doMuons(edm::Event &) const
Log< level::Info, false > LogInfo
void doMET(edm::Event &) const
void doPFTaus(edm::StreamID, edm::Event &) const
void doJets(edm::Event &) const