Skip to content

Commit

Permalink
Merge pull request #35216 from guitargeek/CommonTools_merging_1
Browse files Browse the repository at this point in the history
Merge .h and .cc files of plugins in some CommonTools packages
  • Loading branch information
cmsbuild authored Sep 16, 2021
2 parents 0967201 + f076690 commit f77b403
Show file tree
Hide file tree
Showing 27 changed files with 567 additions and 729 deletions.
17 changes: 4 additions & 13 deletions CommonTools/CandAlgos/interface/CandMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,8 @@
#include "DataFormats/Candidate/interface/Candidate.h"
#include "CommonTools/CandUtils/interface/CandMapTrait.h"

namespace reco {
namespace modules {
template <typename S, typename Collection = CandidateCollection, typename D = DeltaR<reco::Candidate> >
class CandMatcher
: public Matcher<Collection, Collection, S, D, typename reco::helper::CandMapTrait<Collection>::type> {
public:
CandMatcher(const edm::ParameterSet& cfg)
: Matcher<Collection, Collection, S, D, typename reco::helper::CandMapTrait<Collection>::type>(cfg) {}
~CandMatcher() override {}
};

} // namespace modules
} // namespace reco
namespace reco::modules {
template <typename S, typename Collection = CandidateCollection, typename D = DeltaR<reco::Candidate> >
using CandMatcher = Matcher<Collection, Collection, S, D, typename reco::helper::CandMapTrait<Collection>::type>;
} // namespace reco::modules
#endif
15 changes: 4 additions & 11 deletions CommonTools/CandAlgos/interface/NewCandMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
#include "CommonTools/UtilAlgos/interface/NewMatcher.h"
#include "DataFormats/Candidate/interface/Candidate.h"

namespace reco {
namespace modulesNew {
template <typename S, typename C1, typename C2, typename D = DeltaR<reco::Candidate> >
class CandMatcher : public Matcher<C1, C2, S, D> {
public:
CandMatcher(const edm::ParameterSet& cfg) : Matcher<C1, C2, S, D>(cfg) {}
~CandMatcher() override {}
};

} // namespace modulesNew
} // namespace reco
namespace reco::modulesNew {
template <typename S, typename C1, typename C2, typename D = DeltaR<reco::Candidate> >
using CandMatcher = Matcher<C1, C2, S, D>;
} // namespace reco::modulesNew
#endif
39 changes: 35 additions & 4 deletions CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
#include "CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h"
// Weight for neutral particles based on distance with charged
//
// Original Author: Michail Bachtis,40 1-B08,+41227678176,
// Created: Mon Dec 9 13:18:05 CET 2013
//
// edited by Pavel Jez
//

#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <memory>

class DeltaBetaWeights : public edm::EDProducer {
public:
explicit DeltaBetaWeights(const edm::ParameterSet&);
~DeltaBetaWeights() override;

private:
void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------
edm::InputTag src_;
edm::InputTag pfCharged_;
edm::InputTag pfPU_;

edm::EDGetTokenT<edm::View<reco::Candidate> > pfCharged_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > pfPU_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > src_token;
};

DeltaBetaWeights::DeltaBetaWeights(const edm::ParameterSet& iConfig)
: src_(iConfig.getParameter<edm::InputTag>("src")),
Expand All @@ -21,9 +53,8 @@ DeltaBetaWeights::~DeltaBetaWeights() {
// (e.g. close files, deallocate resources etc.)
}

//
// member functions
//
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(DeltaBetaWeights);

// ------------ method called to produce the data ------------
void DeltaBetaWeights::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
Expand Down
41 changes: 0 additions & 41 deletions CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h

This file was deleted.

71 changes: 58 additions & 13 deletions CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc
Original file line number Diff line number Diff line change
@@ -1,31 +1,76 @@
#include "CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h"

// Framework
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Framework/interface/ESHandle.h"

#include "CommonTools/Utils/interface/StringObjectFunction.h"
#include "DataFormats/Candidate/interface/CandAssociation.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <memory>
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "PhysicsTools/IsolationAlgos/interface/EventDependentAbsVeto.h"
#include "PhysicsTools/IsolationAlgos/interface/IsoDepositVetoFactory.h"

#include <memory>
#include <regex>
#include <string>

#include "PhysicsTools/IsolationAlgos/interface/IsoDepositVetoFactory.h"
class PFCandIsolatorFromDeposits : public edm::stream::EDProducer<> {
public:
typedef edm::ValueMap<double> CandDoubleMap;

enum Mode { Sum, SumRelative, Sum2, Sum2Relative, Max, MaxRelative, Count, NearestDR };
PFCandIsolatorFromDeposits(const edm::ParameterSet &);

~PFCandIsolatorFromDeposits() override;

void produce(edm::Event &, const edm::EventSetup &) override;

private:
class SingleDeposit {
public:
SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC);
void cleanup();
void open(const edm::Event &iEvent, const edm::EventSetup &iSetup);
double compute(const reco::CandidateBaseRef &cand);
const reco::IsoDepositMap &map() { return *hDeps_; }

private:
Mode mode_;
edm::EDGetTokenT<reco::IsoDepositMap> srcToken_;
double deltaR_;
bool usesFunction_;
double weight_;

StringObjectFunction<reco::Candidate> weightExpr_;
reco::isodeposit::AbsVetos barrelVetos_;
reco::isodeposit::AbsVetos endcapVetos_;
reco::isodeposit::EventDependentAbsVetos evdepVetos_; // note: these are a subset of the above. Don't delete twice!
bool skipDefaultVeto_;
bool usePivotForBarrelEndcaps_;
edm::Handle<reco::IsoDepositMap> hDeps_; // transient

bool isNumber(const std::string &str) const;
double toNumber(const std::string &str) const;
};
// datamembers
std::vector<SingleDeposit> sources_;
};

using namespace edm;
using namespace reco;
Expand Down
68 changes: 0 additions & 68 deletions CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#include "CommonTools/UtilAlgos/interface/ProductFromFwdPtrProducer.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "CommonTools/ParticleFlow/interface/PFCandidateWithSrcPtrFactory.h"

typedef edm::ProductFromFwdPtrProducer<reco::PFCandidate, reco::PFCandidateWithSrcPtrFactory>
PFCandidateFromFwdPtrProducer;
typedef edm::ProductFromFwdPtrProducer<reco::PFJet> PFJetFromFwdPtrProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PFCandidateFromFwdPtrProducer);
DEFINE_FWK_MODULE(PFJetFromFwdPtrProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ typedef edm::FwdPtrCollectionFilter<reco::PFCandidate,
PFCandidateFwdPtrCollectionStringFilter;
typedef edm::FwdPtrCollectionFilter<reco::PFCandidate, reco::PdgIdSelectorHandler, reco::PFCandidateWithSrcPtrFactory>
PFCandidateFwdPtrCollectionPdgIdFilter;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionStringFilter);
DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionPdgIdFilter);
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#include "DataFormats/JetReco/interface/PFJetCollection.h"

typedef edm::FwdPtrProducer<reco::PFJet> PFJetFwdPtrProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PFJetFwdPtrProducer);
42 changes: 37 additions & 5 deletions CommonTools/ParticleFlow/plugins/PFMET.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
#include "CommonTools/ParticleFlow/plugins/PFMET.h"
/**\class PFMET
\brief Computes the MET from a collection of PFCandidates. HF missing!
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
\todo Add HF energy to the MET calculation (access HF towers)
\author Colin Bernet
\date february 2008
*/

#include "CommonTools/ParticleFlow/interface/PFMETAlgo.h"
#include "DataFormats/METReco/interface/MET.h"
#include "DataFormats/METReco/interface/METFwd.h"
#include "DataFormats/Math/interface/LorentzVector.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include <memory>
#include <string>

class PFMET : public edm::EDProducer {
public:
explicit PFMET(const edm::ParameterSet&);

~PFMET() override;

void produce(edm::Event&, const edm::EventSetup&) override;

void beginJob() override;

private:
/// Input PFCandidates
edm::InputTag inputTagPFCandidates_;
edm::EDGetTokenT<reco::PFCandidateCollection> tokenPFCandidates_;

pf2pat::PFMETAlgo pfMETAlgo_;
};

using namespace std;
using namespace edm;
Expand All @@ -26,6 +55,9 @@ PFMET::PFMET(const edm::ParameterSet& iConfig) : pfMETAlgo_(iConfig) {
LogDebug("PFMET") << " input collection : " << inputTagPFCandidates_;
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PFMET);

PFMET::~PFMET() {}

void PFMET::beginJob() {}
Expand Down
Loading

0 comments on commit f77b403

Please sign in to comment.