34 std::vector<edm::EDGetTokenT<reco::PFCandidateCollection>>
pf_;
35 std::vector<edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>>>
pf2pc_;
41 std::vector<edm::EDGetTokenT<edm::Association<reco::TrackExtraCollection>>>
trackExtraAssocs_;
48 linkToPackedPF_(iConfig.getParameter<bool>(
"linkToPackedPFCandidates")),
49 saveTeVMuons_(iConfig.getParameter<std::
string>(
"saveTeVMuons")),
50 dropDirectionalIso_(iConfig.getParameter<std::
string>(
"dropDirectionalIso")),
51 dropPfP4_(iConfig.getParameter<std::
string>(
"dropPfP4")),
52 slimCaloVars_(iConfig.getParameter<std::
string>(
"slimCaloVars")),
53 slimKinkVars_(iConfig.getParameter<std::
string>(
"slimKinkVars")),
54 slimCaloMETCorr_(iConfig.getParameter<std::
string>(
"slimCaloMETCorr")),
55 slimMatches_(iConfig.getParameter<std::
string>(
"slimMatches")),
56 segmentsMuonSelection_(iConfig.getParameter<std::
string>(
"segmentsMuonSelection")),
57 saveSegments_(iConfig.getParameter<bool>(
"saveSegments")),
58 modifyMuon_(iConfig.getParameter<bool>(
"modifyMuons")) {
60 const std::vector<edm::InputTag> &pf = iConfig.
getParameter<std::vector<edm::InputTag>>(
"pfCandidates");
61 const std::vector<edm::InputTag> &pf2pc = iConfig.
getParameter<std::vector<edm::InputTag>>(
"packedPFCandidates");
62 if (pf.size() != pf2pc.size())
63 throw cms::Exception(
"Configuration") <<
"Mismatching pfCandidates and packedPFCandidates\n";
65 pf_.push_back(consumes<reco::PFCandidateCollection>(
tag));
72 muonModifier_ = std::make_unique<pat::ObjectModifier<pat::Muon>>(mod_config, consumesCollector());
74 produces<std::vector<pat::Muon>>();
76 produces<DTRecSegment4DCollection>();
77 produces<CSCSegmentCollection>();
81 std::vector<edm::InputTag> trackExtraAssocTags = iConfig.
getParameter<std::vector<edm::InputTag>>(
"trackExtraAssocs");
92 muonModifier_->setEventContent(iSetup);
97 auto out = std::make_unique<std::vector<pat::Muon>>();
100 auto outDTSegments = std::make_unique<DTRecSegment4DCollection>();
101 std::set<DTRecSegment4DRef> dtSegmentsRefs;
102 auto outCSCSegments = std::make_unique<CSCSegmentCollection>();
103 std::set<CSCSegmentRef> cscSegmentsRefs;
106 muonModifier_->setEvent(iEvent);
109 std::map<reco::CandidatePtr, pat::PackedCandidateRef> mu2pc;
110 if (linkToPackedPF_) {
113 for (
unsigned int ipfh = 0, npfh = pf_.size(); ipfh < npfh; ++ipfh) {
116 const auto &pfcoll = (*pf);
117 const auto &pfmap = (*pf2pc);
118 for (
unsigned int i = 0,
n = pf->size();
i <
n; ++
i) {
126 std::vector<edm::Handle<edm::Association<reco::TrackExtraCollection>>>
trackExtraAssocs(trackExtraAssocs_.size());
127 for (
unsigned int i = 0;
i < trackExtraAssocs_.size(); ++
i) {
131 for (vector<pat::Muon>::const_iterator it =
src->begin(), ed =
src->end(); it != ed; ++it) {
136 muonModifier_->modify(mu);
139 if (saveTeVMuons_(mu)) {
144 if (linkToPackedPF_) {
147 if (dropDirectionalIso_(mu)) {
159 ene.
tower = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
tower);
161 ene.
towerS9 = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
towerS9);
163 ene.
had = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
had);
165 ene.
hadS9 = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
hadS9);
167 ene.
hadMax = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
hadMax);
169 ene.
em = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
em);
171 ene.
emS25 = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
emS25);
173 ene.
emMax = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
emMax);
183 MiniFloatConverter::reduceMantissaToNbitsRounding<14>(ene.
ecal_position.Y()),
184 MiniFloatConverter::reduceMantissaToNbitsRounding<14>(ene.
ecal_position.Z()));
186 MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
hcal_position.Y()),
187 MiniFloatConverter::reduceMantissaToNbitsRounding<12>(ene.
hcal_position.Z()));
194 MiniFloatConverter::reduceMantissaToNbitsRounding<12>(qual.
tkKink_position.Y()),
195 MiniFloatConverter::reduceMantissaToNbitsRounding<12>(qual.
tkKink_position.Z()));
201 MiniFloatConverter::reduceMantissaToNbitsRounding<10>(corrs.
corrX()),
202 MiniFloatConverter::reduceMantissaToNbitsRounding<10>(corrs.
corrY()));
207 cmatch.edgeX = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.edgeX);
208 cmatch.edgeY = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.edgeY);
209 cmatch.xErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.xErr);
210 cmatch.yErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.yErr);
211 cmatch.dXdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.dXdZErr);
212 cmatch.dYdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(cmatch.dYdZErr);
214 smatch.
xErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.
xErr);
215 smatch.
yErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.
yErr);
216 smatch.
dXdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.
dXdZErr);
217 smatch.
dYdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.
dYdZErr);
218 if (saveSegments_ && segmentsMuonSelection_(mu)) {
232 std::map<DTRecSegment4DRef, size_t> dtMap;
233 std::vector<DTRecSegment4D> outDTSegmentsTmp;
234 std::map<CSCSegmentRef, size_t> cscMap;
235 std::vector<CSCSegment> outCSCSegmentsTmp;
236 for (
auto &seg : dtSegmentsRefs) {
237 dtMap[seg] = outDTSegments->size();
238 outDTSegmentsTmp.push_back(*seg);
240 for (
auto &seg : cscSegmentsRefs) {
241 cscMap[seg] = outCSCSegments->size();
242 outCSCSegmentsTmp.push_back(*seg);
244 outDTSegments->put(
DTChamberId(), outDTSegmentsTmp.begin(), outDTSegmentsTmp.end());
245 outCSCSegments->put(
CSCDetId(), outCSCSegmentsTmp.begin(), outCSCSegmentsTmp.end());
248 for (
auto &
mu : *
out) {
249 if (
mu.isMatchesValid()) {
const edm::EDGetTokenT< pat::MuonCollection > src_
void embedDytMuon()
embed reference to the above dyt Track
DTRecSegment4DRef dtSegmentRef
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const StringCutObjectSelector< pat::Muon > dropDirectionalIso_
const StringCutObjectSelector< pat::Muon > slimKinkVars_
bool isNonnull() const
Checks for non-null.
void embedTpfmsMuon()
embed reference to the above tpfms Track
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
PATMuonSlimmer(const edm::ParameterSet &iConfig)
CSCSegmentRef cscSegmentRef
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
const bool linkToPackedPF_
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection > > pf_
bool isMatchesValid() const
const StringCutObjectSelector< pat::Muon > slimCaloVars_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
void setCalEnergy(const MuonEnergy &calEnergy)
set energy deposition information
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
float towerS9
total energy in 3x3 tower shape
float ecal_time
Calorimeter timing.
const StringCutObjectSelector< pat::Muon > segmentsMuonSelection_
float emS25
energy deposited in 5x5 ECAL crystal shape around central crystal
~PATMuonSlimmer() override
MuonQuality combinedQuality() const
get energy deposition information
void setPFIsolation(const std::string &label, const reco::MuonPFIsolation &deposit)
bool isQualityValid() const
math::XYZPointF hcal_position
bool isEnergyValid() const
reco::MuonRef muonRef() const
MuonEnergy calEnergy() const
get energy deposition information
float emMax
maximal energy of ECAL crystal in the 5x5 shape
const StringCutObjectSelector< pat::Muon > dropPfP4_
float hadMax
maximal energy of HCAL tower in the 3x3 shape
std::vector< edm::EDGetTokenT< edm::Association< reco::TrackExtraCollection > > > trackExtraAssocs_
void rekeyEmbeddedTracks(std::vector< edm::Handle< edm::Association< reco::TrackExtraCollection >>> const &assocs)
T getParameter(std::string const &) const
void setCombinedQuality(const MuonQuality &combinedQuality)
set energy deposition information
std::vector< MuonChamberMatch > & matches()
get muon matching information
const StringCutObjectSelector< pat::Muon > slimMatches_
math::XYZPoint tkKink_position
Kink position for the tracker stub and global track.
std::vector< Muon > MuonCollection
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Particle reconstructed by the particle flow algorithm.
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pc_
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
const StringCutObjectSelector< pat::Muon > saveTeVMuons_
const StringCutObjectSelector< pat::Muon > slimCaloMETCorr_
void embedPickyMuon()
embed reference to the above picky Track
math::XYZPointF ecal_position
Trajectory position at the calorimeter.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Analysis-level muon class.
edm::Ptr< reco::Candidate > refToOrig_
float hadS9
energy deposited in 3x3 HCAL tower shape around central tower
reco::MuonMETCorrectionData caloMETMuonCorrs() const
muon MET corrections for caloMET; returns the muon correction struct if embedded during pat tuple pro...