CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonsFromRefitTracksProducer Class Reference
Inheritance diagram for MuonsFromRefitTracksProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuonsFromRefitTracksProducer (const edm::ParameterSet &)
 
 ~MuonsFromRefitTracksProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

reco::MuoncloneAndSwitchTrack (const reco::Muon &muon, const reco::Muon::MuonTrackTypePair &newTrack) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 
bool storeMatchMaps (const edm::Event &event)
 

Private Attributes

bool fromCocktail
 
bool fromGlobalTrack
 
bool fromSigmaSwitch
 
bool fromTeVRefit
 
bool fromTMR
 
bool fromTrackerTrack
 
double nSigmaSwitch
 
double ptThreshold
 
edm::InputTag src
 
edm::EDGetTokenT< edm::View< reco::Muon > > srcToken_
 
std::string tevMuonTracks
 
double TMRcut
 
edm::Handle< reco::TrackToTrackMaptrackMap
 
edm::Handle< reco::TrackToTrackMaptrackMapDefault
 
edm::EDGetTokenT< reco::TrackToTrackMaptrackMapDefaultToken_
 
edm::Handle< reco::TrackToTrackMaptrackMapFirstHit
 
edm::EDGetTokenT< reco::TrackToTrackMaptrackMapFirstHitToken_
 
edm::Handle< reco::TrackToTrackMaptrackMapPicky
 
edm::EDGetTokenT< reco::TrackToTrackMaptrackMapPickyToken_
 
edm::EDGetTokenT< reco::TrackToTrackMaptrackMapToken_
 

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

Definition at line 67 of file MuonsFromRefitTracksProducer.cc.

Constructor & Destructor Documentation

◆ MuonsFromRefitTracksProducer()

MuonsFromRefitTracksProducer::MuonsFromRefitTracksProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 147 of file MuonsFromRefitTracksProducer.cc.

148  : src(cfg.getParameter<edm::InputTag>("src")),
149  fromTrackerTrack(cfg.getParameter<bool>("fromTrackerTrack")),
150  fromGlobalTrack(cfg.getParameter<bool>("fromGlobalTrack")),
151  tevMuonTracks(cfg.getParameter<std::string>("tevMuonTracks")),
152  fromCocktail(cfg.getParameter<bool>("fromCocktail")),
153  fromTMR(cfg.getParameter<bool>("fromTMR")),
154  TMRcut(cfg.getParameter<double>("TMRcut")),
155  fromSigmaSwitch(cfg.getParameter<bool>("fromSigmaSwitch")),
156  nSigmaSwitch(cfg.getParameter<double>("nSigmaSwitch")),
157  ptThreshold(cfg.getParameter<double>("ptThreshold")) {
158  fromTeVRefit = tevMuonTracks != "none";
159 
160  srcToken_ = consumes<edm::View<reco::Muon> >(src);
161  trackMapToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks, "default"));
162  trackMapDefaultToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks));
163  trackMapFirstHitToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks, "firstHit"));
164  trackMapPickyToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks, "picky"));
165 
166  produces<reco::MuonCollection>();
167 }

References fromTeVRefit, src, srcToken_, tevMuonTracks, trackMapDefaultToken_, trackMapFirstHitToken_, trackMapPickyToken_, and trackMapToken_.

◆ ~MuonsFromRefitTracksProducer()

MuonsFromRefitTracksProducer::~MuonsFromRefitTracksProducer ( )
inlineoverride

Definition at line 70 of file MuonsFromRefitTracksProducer.cc.

70 {}

Member Function Documentation

◆ cloneAndSwitchTrack()

reco::Muon * MuonsFromRefitTracksProducer::cloneAndSwitchTrack ( const reco::Muon muon,
const reco::Muon::MuonTrackTypePair newTrack 
) const
private

Definition at line 181 of file MuonsFromRefitTracksProducer.cc.

182  {
183  // Muon mass to make a four-vector out of the new track.
184  static const double muMass = 0.10566;
185 
186  reco::TrackRef tkTrack = muon.innerTrack();
187  reco::TrackRef muTrack = muon.outerTrack();
188 
189  // Make up a real Muon from the tracker track.
190  reco::Particle::Point vtx(newTrack.first->vx(), newTrack.first->vy(), newTrack.first->vz());
192  double p = newTrack.first->p();
193  p4.SetXYZT(newTrack.first->px(), newTrack.first->py(), newTrack.first->pz(), sqrt(p * p + muMass * muMass));
194 
195  reco::Muon* mu = muon.clone();
196  mu->setCharge(newTrack.first->charge());
197  mu->setP4(p4);
198  mu->setVertex(vtx);
199  mu->setGlobalTrack(newTrack.first);
200  mu->setInnerTrack(tkTrack);
201  mu->setOuterTrack(muTrack);
202  mu->setBestTrack(newTrack.second);
203  return mu;
204 }

References amptDefaultParameters_cff::mu, fastsim::Constants::muMass, AlCaHLTBitMon_ParallelJobs::p, p4, mathSSE::sqrt(), and extraflags_cff::vtx.

Referenced by produce().

◆ produce()

void MuonsFromRefitTracksProducer::produce ( edm::Event event,
const edm::EventSetup eSetup 
)
overrideprivate

Definition at line 206 of file MuonsFromRefitTracksProducer.cc.

206  {
207  // Get the global muons from the event.
209  event.getByToken(srcToken_, muons);
210 
211  // If we can't get the global muon collection, or below the
212  // track-to-track maps needed, still produce an empty collection of
213  // muons so consumers don't throw an exception.
214  bool ok = !muons.failedToGet();
215 
216  // If we're instructed to use the TeV refit tracks in some way, we
217  // need the track-to-track maps. If we're making a cocktail muon,
218  // get all three track maps (the cocktail ingredients); else just
219  // get the map which takes the above global tracks to the desired
220  // TeV-muon refitted tracks (firstHit or picky).
221  if (ok && fromTeVRefit)
223 
224  // Make the output collection.
225  auto cands = std::make_unique<reco::MuonCollection>();
226 
227  if (ok) {
229  for (muon = muons->begin(); muon != muons->end(); muon++) {
230  // Filter out the so-called trackerMuons and stand-alone muons
231  // (and caloMuons, if they were ever to get into the input muons
232  // collection).
233  if (!muon->isGlobalMuon())
234  continue;
235 
236  if (fromTeVRefit || fromSigmaSwitch) {
237  // Start out with a null TrackRef.
239 
240  // If making a cocktail muon, use tevOptimized() to get the track
241  // desired. Otherwise, get the refit track from the desired track
242  // map.
243  if (fromTMR)
245  else if (fromCocktail)
246  tevTk = muon::tevOptimized(*muon);
247  else if (fromSigmaSwitch)
249  else {
250  reco::TrackToTrackMap::const_iterator tevTkRef = trackMap->find(muon->combinedMuon());
251  if (tevTkRef != trackMap->end())
252  tevTk = make_pair(tevTkRef->val, reco::Muon::CombinedTrack);
253  }
254 
255  // If the TrackRef is valid, make a new Muon that has the same
256  // tracker and stand-alone tracks, but has the refit track as
257  // its global track.
258  if (tevTk.first.isNonnull())
259  cands->push_back(*cloneAndSwitchTrack(*muon, tevTk));
260  } else if (fromTrackerTrack)
261  cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->innerTrack(), reco::Muon::InnerTrack)));
262  else if (fromGlobalTrack)
263  cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->globalTrack(), reco::Muon::CombinedTrack)));
264  else {
265  cands->push_back(*muon->clone());
266 
267  // Just cloning does not work in the case of the source being
268  // a pat::Muon with embedded track references -- these do not
269  // get copied. Explicitly set them.
270  reco::Muon& last = cands->at(cands->size() - 1);
271  if (muon->globalTrack().isTransient())
272  last.setGlobalTrack(muon->globalTrack());
273  if (muon->innerTrack().isTransient())
274  last.setInnerTrack(muon->innerTrack());
275  if (muon->outerTrack().isTransient())
276  last.setOuterTrack(muon->outerTrack());
277  }
278  }
279  } else
280  edm::LogWarning("MuonsFromRefitTracksProducer") << "either " << src << " or the track map(s) " << tevMuonTracks
281  << " not present in the event; producing empty collection";
282 
283  event.put(std::move(cands));
284 }

References HLT_FULL_cff::cands, cloneAndSwitchTrack(), reco::Muon::CombinedTrack, fromCocktail, fromGlobalTrack, fromSigmaSwitch, fromTeVRefit, fromTMR, fromTrackerTrack, reco::Muon::InnerTrack, dqmdumpme::last, eostools::move(), HLT_FULL_cff::muon, PDWG_BPHSkim_cff::muons, nSigmaSwitch, convertSQLiteXML::ok, ptThreshold, sigmaSwitch(), src, srcToken_, storeMatchMaps(), tevMuonTracks, muon::tevOptimized(), tevOptimizedTMR(), TMRcut, trackMap, trackMapFirstHit, and edm::helpers::KeyVal< K, V >::val.

◆ storeMatchMaps()

bool MuonsFromRefitTracksProducer::storeMatchMaps ( const edm::Event event)
private

Definition at line 169 of file MuonsFromRefitTracksProducer.cc.

169  {
170  if (fromCocktail || fromTMR) {
171  event.getByToken(trackMapDefaultToken_, trackMapDefault);
172  event.getByToken(trackMapFirstHitToken_, trackMapFirstHit);
173  event.getByToken(trackMapPickyToken_, trackMapPicky);
174  return !trackMapDefault.failedToGet() && !trackMapFirstHit.failedToGet() && !trackMapPicky.failedToGet();
175  } else {
176  event.getByToken(trackMapToken_, trackMap);
177  return !trackMap.failedToGet();
178  }
179 }

References fromCocktail, fromTMR, trackMap, trackMapDefault, trackMapDefaultToken_, trackMapFirstHit, trackMapFirstHitToken_, trackMapPicky, trackMapPickyToken_, and trackMapToken_.

Referenced by produce().

Member Data Documentation

◆ fromCocktail

bool MuonsFromRefitTracksProducer::fromCocktail
private

Definition at line 110 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

◆ fromGlobalTrack

bool MuonsFromRefitTracksProducer::fromGlobalTrack
private

Definition at line 96 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ fromSigmaSwitch

bool MuonsFromRefitTracksProducer::fromSigmaSwitch
private

Definition at line 121 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ fromTeVRefit

bool MuonsFromRefitTracksProducer::fromTeVRefit
private

Definition at line 100 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

◆ fromTMR

bool MuonsFromRefitTracksProducer::fromTMR
private

Definition at line 114 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

◆ fromTrackerTrack

bool MuonsFromRefitTracksProducer::fromTrackerTrack
private

Definition at line 90 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ nSigmaSwitch

double MuonsFromRefitTracksProducer::nSigmaSwitch
private

Definition at line 124 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ ptThreshold

double MuonsFromRefitTracksProducer::ptThreshold
private

Definition at line 127 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ src

edm::InputTag MuonsFromRefitTracksProducer::src
private

Definition at line 84 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

◆ srcToken_

edm::EDGetTokenT<edm::View<reco::Muon> > MuonsFromRefitTracksProducer::srcToken_
private

Definition at line 140 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

◆ tevMuonTracks

std::string MuonsFromRefitTracksProducer::tevMuonTracks
private

Definition at line 105 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

◆ TMRcut

double MuonsFromRefitTracksProducer::TMRcut
private

Definition at line 117 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

◆ trackMap

edm::Handle<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMap
private

Definition at line 132 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

◆ trackMapDefault

edm::Handle<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapDefault
private

Definition at line 135 of file MuonsFromRefitTracksProducer.cc.

Referenced by storeMatchMaps().

◆ trackMapDefaultToken_

edm::EDGetTokenT<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapDefaultToken_
private

◆ trackMapFirstHit

edm::Handle<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapFirstHit
private

Definition at line 136 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

◆ trackMapFirstHitToken_

edm::EDGetTokenT<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapFirstHitToken_
private

◆ trackMapPicky

edm::Handle<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapPicky
private

Definition at line 137 of file MuonsFromRefitTracksProducer.cc.

Referenced by storeMatchMaps().

◆ trackMapPickyToken_

edm::EDGetTokenT<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapPickyToken_
private

◆ trackMapToken_

edm::EDGetTokenT<reco::TrackToTrackMap> MuonsFromRefitTracksProducer::trackMapToken_
private
reco::Muon::CombinedTrack
Definition: Muon.h:36
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
MuonsFromRefitTracksProducer::fromGlobalTrack
bool fromGlobalTrack
Definition: MuonsFromRefitTracksProducer.cc:96
reco::Muon::MuonTrackTypePair
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:38
muon::tevOptimized
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const reco::TrackRef &dytTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
Definition: MuonCocktails.cc:9
muon
Definition: MuonCocktails.h:17
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
MuonsFromRefitTracksProducer::fromSigmaSwitch
bool fromSigmaSwitch
Definition: MuonsFromRefitTracksProducer.cc:121
MuonsFromRefitTracksProducer::fromTeVRefit
bool fromTeVRefit
Definition: MuonsFromRefitTracksProducer.cc:100
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonsFromRefitTracksProducer::fromTrackerTrack
bool fromTrackerTrack
Definition: MuonsFromRefitTracksProducer.cc:90
MuonsFromRefitTracksProducer::fromTMR
bool fromTMR
Definition: MuonsFromRefitTracksProducer.cc:114
MuonsFromRefitTracksProducer::trackMapPickyToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapPickyToken_
Definition: MuonsFromRefitTracksProducer.cc:144
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
MuonsFromRefitTracksProducer::tevMuonTracks
std::string tevMuonTracks
Definition: MuonsFromRefitTracksProducer.cc:105
reco::Muon
Definition: Muon.h:27
edm::Ref< TrackCollection >
MuonsFromRefitTracksProducer::fromCocktail
bool fromCocktail
Definition: MuonsFromRefitTracksProducer.cc:110
MuonsFromRefitTracksProducer::trackMapToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapToken_
Definition: MuonsFromRefitTracksProducer.cc:141
dqmdumpme.last
last
Definition: dqmdumpme.py:56
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MuonsFromRefitTracksProducer::trackMapFirstHit
edm::Handle< reco::TrackToTrackMap > trackMapFirstHit
Definition: MuonsFromRefitTracksProducer.cc:136
MuonsFromRefitTracksProducer::src
edm::InputTag src
Definition: MuonsFromRefitTracksProducer.cc:84
MuonsFromRefitTracksProducer::trackMapDefault
edm::Handle< reco::TrackToTrackMap > trackMapDefault
Definition: MuonsFromRefitTracksProducer.cc:135
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonsFromRefitTracksProducer::ptThreshold
double ptThreshold
Definition: MuonsFromRefitTracksProducer.cc:127
MuonsFromRefitTracksProducer::trackMapDefaultToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapDefaultToken_
Definition: MuonsFromRefitTracksProducer.cc:142
edm::helpers::KeyVal::val
V val
Definition: AssociationMapHelpers.h:33
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15142
MuonsFromRefitTracksProducer::nSigmaSwitch
double nSigmaSwitch
Definition: MuonsFromRefitTracksProducer.cc:124
MuonsFromRefitTracksProducer::trackMap
edm::Handle< reco::TrackToTrackMap > trackMap
Definition: MuonsFromRefitTracksProducer.cc:132
sigmaSwitch
reco::Muon::MuonTrackTypePair sigmaSwitch(const reco::Muon &muon, const double nSigma, const double ptThreshold)
Definition: MuonsFromRefitTracksProducer.cc:53
MuonsFromRefitTracksProducer::storeMatchMaps
bool storeMatchMaps(const edm::Event &event)
Definition: MuonsFromRefitTracksProducer.cc:169
MuonsFromRefitTracksProducer::trackMapPicky
edm::Handle< reco::TrackToTrackMap > trackMapPicky
Definition: MuonsFromRefitTracksProducer.cc:137
p4
double p4[4]
Definition: TauolaWrapper.h:92
MuonsFromRefitTracksProducer::TMRcut
double TMRcut
Definition: MuonsFromRefitTracksProducer.cc:117
MuonsFromRefitTracksProducer::cloneAndSwitchTrack
reco::Muon * cloneAndSwitchTrack(const reco::Muon &muon, const reco::Muon::MuonTrackTypePair &newTrack) const
Definition: MuonsFromRefitTracksProducer.cc:181
reco::Muon::InnerTrack
Definition: Muon.h:36
fastsim::Constants::muMass
static constexpr double muMass
Muon mass [GeV].
Definition: Constants.h:14
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
MuonsFromRefitTracksProducer::srcToken_
edm::EDGetTokenT< edm::View< reco::Muon > > srcToken_
Definition: MuonsFromRefitTracksProducer.cc:140
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
MuonsFromRefitTracksProducer::trackMapFirstHitToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapFirstHitToken_
Definition: MuonsFromRefitTracksProducer.cc:143
tevOptimizedTMR
reco::Muon::MuonTrackTypePair tevOptimizedTMR(const reco::Muon &muon, const reco::TrackToTrackMap &fmsMap, const double cut)
Definition: MuonsFromRefitTracksProducer.cc:21
event
Definition: event.py:1
edm::AssociationMap::const_iterator
const iterator
Definition: AssociationMap.h:76
edm::InputTag
Definition: InputTag.h:15