CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonsFromRefitTracksProducer Class Reference
Inheritance diagram for MuonsFromRefitTracksProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonsFromRefitTracksProducer (const edm::ParameterSet &)
 
 ~MuonsFromRefitTracksProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob () override
 
reco::MuoncloneAndSwitchTrack (const reco::Muon &muon, const reco::Muon::MuonTrackTypePair &newTrack) const
 
virtual void endJob () override
 
virtual 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::TrackToTrackMap
trackMap
 
edm::Handle
< reco::TrackToTrackMap
trackMapDefault
 
edm::EDGetTokenT
< reco::TrackToTrackMap
trackMapDefaultToken_
 
edm::Handle
< reco::TrackToTrackMap
trackMapFirstHit
 
edm::EDGetTokenT
< reco::TrackToTrackMap
trackMapFirstHitToken_
 
edm::Handle
< reco::TrackToTrackMap
trackMapPicky
 
edm::EDGetTokenT
< reco::TrackToTrackMap
trackMapPickyToken_
 
edm::EDGetTokenT
< reco::TrackToTrackMap
trackMapToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 66 of file MuonsFromRefitTracksProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 154 of file MuonsFromRefitTracksProducer.cc.

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

155  : src(cfg.getParameter<edm::InputTag>("src")),
156  fromTrackerTrack(cfg.getParameter<bool>("fromTrackerTrack")),
157  fromGlobalTrack(cfg.getParameter<bool>("fromGlobalTrack")),
158  tevMuonTracks(cfg.getParameter<std::string>("tevMuonTracks")),
159  fromCocktail(cfg.getParameter<bool>("fromCocktail")),
160  fromTMR(cfg.getParameter<bool>("fromTMR")),
161  TMRcut(cfg.getParameter<double>("TMRcut")),
162  fromSigmaSwitch(cfg.getParameter<bool>("fromSigmaSwitch")),
163  nSigmaSwitch(cfg.getParameter<double>("nSigmaSwitch")),
164  ptThreshold(cfg.getParameter<double>("ptThreshold"))
165 {
166  fromTeVRefit = tevMuonTracks != "none";
167 
168 
169  srcToken_ = consumes<edm::View<reco::Muon> >(src) ;
170  trackMapToken_ = consumes<reco::TrackToTrackMap> (edm::InputTag(tevMuonTracks, "default"));
171  trackMapDefaultToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks)) ;
172  trackMapFirstHitToken_ = consumes<reco::TrackToTrackMap>(edm::InputTag(tevMuonTracks, "firstHit"));
173  trackMapPickyToken_ = consumes<reco::TrackToTrackMap> (edm::InputTag(tevMuonTracks, "picky"));
174 
175 
176 
177 
178  produces<reco::MuonCollection>();
179 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapPickyToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapDefaultToken_
edm::EDGetTokenT< edm::View< reco::Muon > > srcToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapFirstHitToken_
MuonsFromRefitTracksProducer::~MuonsFromRefitTracksProducer ( )
inline

Definition at line 69 of file MuonsFromRefitTracksProducer.cc.

69 {}

Member Function Documentation

virtual void MuonsFromRefitTracksProducer::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 72 of file MuonsFromRefitTracksProducer.cc.

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

Definition at line 195 of file MuonsFromRefitTracksProducer.cc.

References reco::Muon::clone(), reco::Muon::innerTrack(), RPCpg::mu, reco::Muon::outerTrack(), AlCaHLTBitMon_ParallelJobs::p, p4, reco::Muon::setBestTrack(), reco::LeafCandidate::setCharge(), reco::Muon::setGlobalTrack(), reco::Muon::setInnerTrack(), reco::Muon::setOuterTrack(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setVertex(), and mathSSE::sqrt().

Referenced by produce().

196  {
197  // Muon mass to make a four-vector out of the new track.
198  static const double muMass = 0.10566;
199 
200  reco::TrackRef tkTrack = muon.innerTrack();
201  reco::TrackRef muTrack = muon.outerTrack();
202 
203  // Make up a real Muon from the tracker track.
204  reco::Particle::Point vtx(newTrack.first->vx(), newTrack.first->vy(), newTrack.first->vz());
206  double p = newTrack.first->p();
207  p4.SetXYZT(newTrack.first->px(), newTrack.first->py(), newTrack.first->pz(),
208  sqrt(p*p + muMass*muMass));
209 
210  reco::Muon* mu = muon.clone();
211  mu->setCharge(newTrack.first->charge());
212  mu->setP4(p4);
213  mu->setVertex(vtx);
214  mu->setGlobalTrack(newTrack.first);
215  mu->setInnerTrack(tkTrack);
216  mu->setOuterTrack(muTrack);
217  mu->setBestTrack(newTrack.second);
218  return mu;
219 }
virtual void setCharge(Charge q) GCC11_FINAL
set electric charge
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:845
virtual TrackRef innerTrack() const
Definition: Muon.h:48
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:846
T sqrt(T t)
Definition: SSEVec.h:48
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:31
const int mu
Definition: Constants.h:22
virtual void setVertex(const Point &vertex)
set vertex
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
Muon * clone() const
create a clone
Definition: Muon.cc:44
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:91
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:849
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
virtual void MuonsFromRefitTracksProducer::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 74 of file MuonsFromRefitTracksProducer.cc.

74 {}
void MuonsFromRefitTracksProducer::produce ( edm::Event event,
const edm::EventSetup eSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 221 of file MuonsFromRefitTracksProducer.cc.

References edm::ViewBase::clone(), cloneAndSwitchTrack(), reco::Muon::CombinedTrack, edm::AssociationMap< edm::OneToOne< reco::TrackCollection, reco::TrackCollection > >::const_iterator, edm::HandleBase::failedToGet(), fromCocktail, fromGlobalTrack, fromSigmaSwitch, fromTeVRefit, fromTMR, fromTrackerTrack, reco::Muon::InnerTrack, prof2calltree::last, metsig::muon, patZpeak::muons, nSigmaSwitch, convertSQLiteXML::ok, ptThreshold, reco::Muon::setGlobalTrack(), reco::Muon::setInnerTrack(), reco::Muon::setOuterTrack(), sigmaSwitch(), src, srcToken_, storeMatchMaps(), tevMuonTracks, muon::tevOptimized(), tevOptimizedTMR(), TMRcut, trackMap, trackMapDefault, trackMapFirstHit, and trackMapPicky.

221  {
222  // Get the global muons from the event.
224  event.getByToken(srcToken_, muons);
225 
226  // If we can't get the global muon collection, or below the
227  // track-to-track maps needed, still produce an empty collection of
228  // muons so consumers don't throw an exception.
229  bool ok = !muons.failedToGet();
230 
231  // If we're instructed to use the TeV refit tracks in some way, we
232  // need the track-to-track maps. If we're making a cocktail muon,
233  // get all three track maps (the cocktail ingredients); else just
234  // get the map which takes the above global tracks to the desired
235  // TeV-muon refitted tracks (firstHit or picky).
236  if (ok && fromTeVRefit)
237  ok = storeMatchMaps(event);
238 
239  // Make the output collection.
240  std::auto_ptr<reco::MuonCollection> cands(new reco::MuonCollection);
241 
242  if (ok) {
244  for (muon = muons->begin(); muon != muons->end(); muon++) {
245  // Filter out the so-called trackerMuons and stand-alone muons
246  // (and caloMuons, if they were ever to get into the input muons
247  // collection).
248  if (!muon->isGlobalMuon()) continue;
249 
250  if (fromTeVRefit || fromSigmaSwitch) {
251  // Start out with a null TrackRef.
253 
254  // If making a cocktail muon, use tevOptimized() to get the track
255  // desired. Otherwise, get the refit track from the desired track
256  // map.
257  if (fromTMR)
258  tevTk = tevOptimizedTMR(*muon, *trackMapFirstHit, TMRcut);
259  else if (fromCocktail)
261  *trackMapPicky);
262  else if (fromSigmaSwitch)
263  tevTk = sigmaSwitch(*muon, nSigmaSwitch, ptThreshold);
264  else {
266  trackMap->find(muon->combinedMuon());
267  if (tevTkRef != trackMap->end())
268  tevTk = make_pair(tevTkRef->val,reco::Muon::CombinedTrack);
269  }
270 
271  // If the TrackRef is valid, make a new Muon that has the same
272  // tracker and stand-alone tracks, but has the refit track as
273  // its global track.
274  if (tevTk.first.isNonnull())
275  cands->push_back(*cloneAndSwitchTrack(*muon, tevTk));
276  }
277  else if (fromTrackerTrack)
278  cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->innerTrack(),reco::Muon::InnerTrack)));
279  else if (fromGlobalTrack)
280  cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->globalTrack(),reco::Muon::CombinedTrack)));
281  else {
282  cands->push_back(*muon->clone());
283 
284  // Just cloning does not work in the case of the source being
285  // a pat::Muon with embedded track references -- these do not
286  // get copied. Explicitly set them.
287  reco::Muon& last = cands->at(cands->size()-1);
288  if (muon->globalTrack().isTransient())
289  last.setGlobalTrack(muon->globalTrack());
290  if (muon->innerTrack().isTransient())
291  last.setInnerTrack(muon->innerTrack());
292  if (muon->outerTrack().isTransient())
293  last.setOuterTrack(muon->outerTrack());
294  }
295  }
296  }
297  else
298  edm::LogWarning("MuonsFromRefitTracksProducer")
299  << "either " << src << " or the track map(s) " << tevMuonTracks
300  << " not present in the event; producing empty collection";
301 
302  event.put(cands);
303 }
reco::Muon::MuonTrackTypePair sigmaSwitch(const reco::Muon &muon, const double nSigma, const double ptThreshold)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:845
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:846
reco::Muon * cloneAndSwitchTrack(const reco::Muon &muon, const reco::Muon::MuonTrackTypePair &newTrack) const
edm::Handle< reco::TrackToTrackMap > trackMapDefault
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
edm::Handle< reco::TrackToTrackMap > trackMap
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
Definition: MuonCocktails.cc:9
bool storeMatchMaps(const edm::Event &event)
edm::Handle< reco::TrackToTrackMap > trackMapFirstHit
reco::Muon::MuonTrackTypePair tevOptimizedTMR(const reco::Muon &muon, const reco::TrackToTrackMap &fmsMap, const double cut)
bool failedToGet() const
Definition: HandleBase.h:80
edm::Handle< reco::TrackToTrackMap > trackMapPicky
ViewBase * clone() const
Definition: View.cc:13
edm::EDGetTokenT< edm::View< reco::Muon > > srcToken_
tuple muons
Definition: patZpeak.py:38
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:849
bool MuonsFromRefitTracksProducer::storeMatchMaps ( const edm::Event event)
private

Definition at line 181 of file MuonsFromRefitTracksProducer.cc.

References edm::HandleBase::failedToGet(), fromCocktail, fromTMR, trackMap, trackMapDefault, trackMapDefaultToken_, trackMapFirstHit, trackMapFirstHitToken_, trackMapPicky, trackMapPickyToken_, and trackMapToken_.

Referenced by produce().

181  {
182  if (fromCocktail || fromTMR) {
183  event.getByToken(trackMapDefaultToken_,trackMapDefault);
184  event.getByToken(trackMapFirstHitToken_, trackMapFirstHit);
185  event.getByToken(trackMapPickyToken_, trackMapPicky);
186  return !trackMapDefault.failedToGet() &&
188  }
189  else {
190  event.getByToken(trackMapToken_, trackMap);
191  return !trackMap.failedToGet();
192  }
193 }
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapPickyToken_
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapToken_
edm::Handle< reco::TrackToTrackMap > trackMapDefault
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapDefaultToken_
edm::Handle< reco::TrackToTrackMap > trackMap
edm::Handle< reco::TrackToTrackMap > trackMapFirstHit
bool failedToGet() const
Definition: HandleBase.h:80
edm::Handle< reco::TrackToTrackMap > trackMapPicky
edm::EDGetTokenT< reco::TrackToTrackMap > trackMapFirstHitToken_

Member Data Documentation

bool MuonsFromRefitTracksProducer::fromCocktail
private

Definition at line 112 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

bool MuonsFromRefitTracksProducer::fromGlobalTrack
private

Definition at line 98 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

bool MuonsFromRefitTracksProducer::fromSigmaSwitch
private

Definition at line 123 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

bool MuonsFromRefitTracksProducer::fromTeVRefit
private

Definition at line 102 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

bool MuonsFromRefitTracksProducer::fromTMR
private

Definition at line 116 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

bool MuonsFromRefitTracksProducer::fromTrackerTrack
private

Definition at line 92 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

double MuonsFromRefitTracksProducer::nSigmaSwitch
private

Definition at line 126 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

double MuonsFromRefitTracksProducer::ptThreshold
private

Definition at line 129 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

edm::InputTag MuonsFromRefitTracksProducer::src
private

Definition at line 86 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

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

Definition at line 144 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

std::string MuonsFromRefitTracksProducer::tevMuonTracks
private

Definition at line 107 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

double MuonsFromRefitTracksProducer::TMRcut
private

Definition at line 119 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

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

Definition at line 134 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 137 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 138 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 139 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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