CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CaloMuonMerger Class Reference

Merges reco::CaloMuons, reco::Muons and optionally reco::Tracks avoiding innerTrack duplications in a single reco::Muon collection. More...

#include "RecoMuon/MuonIdentification/plugins/CaloMuonMerger.cc"

Inheritance diagram for CaloMuonMerger:
edm::stream::EDProducer<>

Public Member Functions

 CaloMuonMerger (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~CaloMuonMerger () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::InputTag caloMuons_
 
StringCutObjectSelector< reco::CaloMuon, false > caloMuonsCut_
 
edm::EDGetTokenT< std::vector< reco::CaloMuon > > caloMuonToken_
 
bool mergeCaloMuons_
 
bool mergeTracks_
 
double minCaloCompatibility_
 
edm::InputTag muons_
 
StringCutObjectSelector< reco::Muon, false > muonsCut_
 
edm::EDGetTokenT< std::vector< reco::Muon > > muonToken_
 
edm::InputTag tracks_
 
StringCutObjectSelector< reco::TrackRef, false > tracksCut_
 
edm::EDGetTokenT< std::vector< reco::Track > > trackToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Merges reco::CaloMuons, reco::Muons and optionally reco::Tracks avoiding innerTrack duplications in a single reco::Muon collection.

Author
Giovanni Petrucciani

Definition at line 22 of file CaloMuonMerger.cc.

Constructor & Destructor Documentation

◆ CaloMuonMerger()

CaloMuonMerger::CaloMuonMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 45 of file CaloMuonMerger.cc.

46  : muons_(iConfig.getParameter<edm::InputTag>("muons")),
47  muonsCut_(iConfig.existsAs<std::string>("muonsCut") ? iConfig.getParameter<std::string>("muonsCut") : ""),
48  mergeCaloMuons_(iConfig.existsAs<bool>("mergeCaloMuons") ? iConfig.getParameter<bool>("mergeCaloMuons") : true),
49  caloMuons_(iConfig.getParameter<edm::InputTag>("caloMuons")),
50  caloMuonsCut_(iConfig.existsAs<std::string>("caloMuonsCut") ? iConfig.getParameter<std::string>("caloMuonsCut")
51  : ""),
52  minCaloCompatibility_(mergeCaloMuons_ ? iConfig.getParameter<double>("minCaloCompatibility") : 0),
53  mergeTracks_(iConfig.existsAs<bool>("mergeTracks") ? iConfig.getParameter<bool>("mergeTracks") : false),
55  tracksCut_(iConfig.existsAs<std::string>("tracksCut") ? iConfig.getParameter<std::string>("tracksCut") : "") {
56  muonToken_ = consumes<std::vector<reco::Muon>>(muons_);
57  caloMuonToken_ = consumes<std::vector<reco::CaloMuon>>(caloMuons_);
58  trackToken_ = consumes<std::vector<reco::Track>>(tracks_);
59  produces<std::vector<reco::Muon>>();
60 }

References caloMuons_, caloMuonToken_, muons_, muonToken_, tracks_, and trackToken_.

◆ ~CaloMuonMerger()

CaloMuonMerger::~CaloMuonMerger ( )
inlineoverride

Definition at line 25 of file CaloMuonMerger.cc.

25 {}

Member Function Documentation

◆ produce()

void CaloMuonMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 62 of file CaloMuonMerger.cc.

62  {
66 
67  iEvent.getByToken(muonToken_, muons);
68  if (mergeCaloMuons_)
69  iEvent.getByToken(caloMuonToken_, caloMuons);
70  if (mergeTracks_)
71  iEvent.getByToken(trackToken_, tracks);
72 
73  auto out = std::make_unique<std::vector<reco::Muon>>();
74  out->reserve(muons->size() + (mergeTracks_ ? tracks->size() : 0));
75 
76  // copy reco::Muons, turning on the CaloCompatibility flag if enabled and possible
77  for (std::vector<reco::Muon>::const_iterator it = muons->begin(), ed = muons->end(); it != ed; ++it) {
78  if (!muonsCut_(*it))
79  continue;
80  out->push_back(*it);
81  reco::Muon& mu = out->back();
82  if (mergeCaloMuons_ && mu.track().isNonnull()) {
83  if (mu.isCaloCompatibilityValid()) {
84  if (mu.caloCompatibility() >= minCaloCompatibility_) {
85  mu.setType(mu.type() | reco::Muon::CaloMuon);
86  }
87  } else
88  throw cms::Exception("Boh") << "Muon with track and no CaloCompatibility; pt = " << mu.pt()
89  << ", eta = " << mu.eta() << ", type = " << mu.type() << "\n";
90  }
91  }
92 
93  if (mergeCaloMuons_) {
94  // copy reco::CaloMuon
95  for (std::vector<reco::CaloMuon>::const_iterator it = caloMuons->begin(), ed = caloMuons->end(); it != ed; ++it) {
96  if (!caloMuonsCut_(*it))
97  continue;
98  // make a reco::Muon
99  reco::TrackRef track = it->track();
100  double energy = sqrt(track->p() * track->p() + 0.011163691);
101  math::XYZTLorentzVector p4(track->px(), track->py(), track->pz(), energy);
102  out->push_back(reco::Muon(track->charge(), p4, track->vertex()));
103  reco::Muon& mu = out->back();
104  // fill info
105  mu.setCalEnergy(it->calEnergy());
106  mu.setCaloCompatibility(it->caloCompatibility());
107  mu.setInnerTrack(track);
108  mu.setType(reco::Muon::CaloMuon);
109  }
110  }
111 
112  // merge reco::Track avoiding duplication of innerTracks
113  if (mergeTracks_) {
114  for (size_t i = 0; i < tracks->size(); i++) {
116  if (!tracksCut_(track))
117  continue;
118  // check if it is a muon or calomuon
119  bool isMuon = false;
120  for (std::vector<reco::Muon>::const_iterator muon = muons->begin(); muon < muons->end(); muon++) {
121  if (muon->innerTrack() == track) {
122  isMuon = true;
123  break;
124  }
125  }
126  if (isMuon)
127  continue;
128  if (mergeCaloMuons_) {
129  bool isCaloMuon = false;
130  for (std::vector<reco::CaloMuon>::const_iterator muon = caloMuons->begin(); muon < caloMuons->end(); muon++) {
131  if (muon->innerTrack() == track) {
132  isCaloMuon = true;
133  break;
134  }
135  }
136  if (isCaloMuon)
137  continue;
138  }
139  // make a reco::Muon
140  double energy = sqrt(track->p() * track->p() + 0.011163691);
141  math::XYZTLorentzVector p4(track->px(), track->py(), track->pz(), energy);
142  out->push_back(reco::Muon(track->charge(), p4, track->vertex()));
143  reco::Muon& mu = out->back();
144  // fill info
145  mu.setInnerTrack(track);
146  }
147  }
148 
149  iEvent.put(std::move(out));
150 }

References reco::Muon::CaloMuon, mergedMuons_cfi::caloMuons, caloMuonsCut_, caloMuonToken_, HCALHighEnergyHPDFilter_cfi::energy, Exception, mps_fire::i, iEvent, reco::isMuon(), mergeCaloMuons_, mergeTracks_, minCaloCompatibility_, eostools::move(), amptDefaultParameters_cff::mu, PDWG_BPHSkim_cff::muons, muonsCut_, muonToken_, MillePedeFileConverter_cfg::out, p4, mathSSE::sqrt(), HLT_2018_cff::track, PDWG_EXOHSCP_cff::tracks, tracksCut_, and trackToken_.

Member Data Documentation

◆ caloMuons_

edm::InputTag CaloMuonMerger::caloMuons_
private

Definition at line 33 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger().

◆ caloMuonsCut_

StringCutObjectSelector<reco::CaloMuon, false> CaloMuonMerger::caloMuonsCut_
private

Definition at line 34 of file CaloMuonMerger.cc.

Referenced by produce().

◆ caloMuonToken_

edm::EDGetTokenT<std::vector<reco::CaloMuon> > CaloMuonMerger::caloMuonToken_
private

Definition at line 41 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger(), and produce().

◆ mergeCaloMuons_

bool CaloMuonMerger::mergeCaloMuons_
private

Definition at line 32 of file CaloMuonMerger.cc.

Referenced by produce().

◆ mergeTracks_

bool CaloMuonMerger::mergeTracks_
private

Definition at line 36 of file CaloMuonMerger.cc.

Referenced by produce().

◆ minCaloCompatibility_

double CaloMuonMerger::minCaloCompatibility_
private

Definition at line 35 of file CaloMuonMerger.cc.

Referenced by produce().

◆ muons_

edm::InputTag CaloMuonMerger::muons_
private

Definition at line 30 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger().

◆ muonsCut_

StringCutObjectSelector<reco::Muon, false> CaloMuonMerger::muonsCut_
private

Definition at line 31 of file CaloMuonMerger.cc.

Referenced by produce().

◆ muonToken_

edm::EDGetTokenT<std::vector<reco::Muon> > CaloMuonMerger::muonToken_
private

Definition at line 40 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger(), and produce().

◆ tracks_

edm::InputTag CaloMuonMerger::tracks_
private

Definition at line 37 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger().

◆ tracksCut_

StringCutObjectSelector<reco::TrackRef, false> CaloMuonMerger::tracksCut_
private

Definition at line 38 of file CaloMuonMerger.cc.

Referenced by produce().

◆ trackToken_

edm::EDGetTokenT<std::vector<reco::Track> > CaloMuonMerger::trackToken_
private

Definition at line 42 of file CaloMuonMerger.cc.

Referenced by CaloMuonMerger(), and produce().

CaloMuonMerger::minCaloCompatibility_
double minCaloCompatibility_
Definition: CaloMuonMerger.cc:35
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
CaloMuonMerger::caloMuonsCut_
StringCutObjectSelector< reco::CaloMuon, false > caloMuonsCut_
Definition: CaloMuonMerger.cc:34
muon
Definition: MuonCocktails.h:17
CaloMuonMerger::trackToken_
edm::EDGetTokenT< std::vector< reco::Track > > trackToken_
Definition: CaloMuonMerger.cc:42
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
CaloMuonMerger::tracksCut_
StringCutObjectSelector< reco::TrackRef, false > tracksCut_
Definition: CaloMuonMerger.cc:38
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
CaloMuonMerger::muonToken_
edm::EDGetTokenT< std::vector< reco::Muon > > muonToken_
Definition: CaloMuonMerger.cc:40
edm::Handle
Definition: AssociativeIterator.h:50
reco::Muon
Definition: Muon.h:27
edm::Ref< TrackCollection >
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CaloMuonMerger::muonsCut_
StringCutObjectSelector< reco::Muon, false > muonsCut_
Definition: CaloMuonMerger.cc:31
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CaloMuonMerger::caloMuons_
edm::InputTag caloMuons_
Definition: CaloMuonMerger.cc:33
CaloMuonMerger::caloMuonToken_
edm::EDGetTokenT< std::vector< reco::CaloMuon > > caloMuonToken_
Definition: CaloMuonMerger.cc:41
iEvent
int iEvent
Definition: GenABIO.cc:224
mergedMuons_cfi.caloMuons
caloMuons
Definition: mergedMuons_cfi.py:7
reco::Muon::CaloMuon
static const unsigned int CaloMuon
Definition: Muon.h:288
p4
double p4[4]
Definition: TauolaWrapper.h:92
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
CaloMuonMerger::tracks_
edm::InputTag tracks_
Definition: CaloMuonMerger.cc:37
CaloMuonMerger::mergeCaloMuons_
bool mergeCaloMuons_
Definition: CaloMuonMerger.cc:32
CaloMuonMerger::mergeTracks_
bool mergeTracks_
Definition: CaloMuonMerger.cc:36
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
Exception
Definition: hltDiff.cc:246
CaloMuonMerger::muons_
edm::InputTag muons_
Definition: CaloMuonMerger.cc:30
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
edm::InputTag
Definition: InputTag.h:15
reco::isMuon
bool isMuon(const Candidate &part)
Definition: pdgIdUtils.h:9