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::ProductRegistryHelper

Public Member Functions

 MuonsFromRefitTracksProducer (const edm::ParameterSet &)
 
 ~MuonsFromRefitTracksProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
reco::MuoncloneAndSwitchTrack (const reco::Muon &muon, const reco::TrackRef &newTrack) const
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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
 
std::string tevMuonTracks
 
double TMRcut
 
edm::Handle
< reco::TrackToTrackMap
trackMap
 
edm::Handle
< reco::TrackToTrackMap
trackMapDefault
 
edm::Handle
< reco::TrackToTrackMap
trackMapFirstHit
 
edm::Handle
< reco::TrackToTrackMap
trackMapPicky
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 67 of file MuonsFromRefitTracksProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 143 of file MuonsFromRefitTracksProducer.cc.

References fromTeVRefit, and tevMuonTracks.

144  : src(cfg.getParameter<edm::InputTag>("src")),
145  fromTrackerTrack(cfg.getParameter<bool>("fromTrackerTrack")),
146  fromGlobalTrack(cfg.getParameter<bool>("fromGlobalTrack")),
147  tevMuonTracks(cfg.getParameter<std::string>("tevMuonTracks")),
148  fromCocktail(cfg.getParameter<bool>("fromCocktail")),
149  fromTMR(cfg.getParameter<bool>("fromTMR")),
150  TMRcut(cfg.getParameter<double>("TMRcut")),
151  fromSigmaSwitch(cfg.getParameter<bool>("fromSigmaSwitch")),
152  nSigmaSwitch(cfg.getParameter<double>("nSigmaSwitch")),
153  ptThreshold(cfg.getParameter<double>("ptThreshold"))
154 {
155  fromTeVRefit = tevMuonTracks != "none";
156  produces<reco::MuonCollection>();
157 }
T getParameter(std::string const &) const
MuonsFromRefitTracksProducer::~MuonsFromRefitTracksProducer ( )
inline

Definition at line 70 of file MuonsFromRefitTracksProducer.cc.

70 {}

Member Function Documentation

virtual void MuonsFromRefitTracksProducer::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file MuonsFromRefitTracksProducer.cc.

73 {}
reco::Muon * MuonsFromRefitTracksProducer::cloneAndSwitchTrack ( const reco::Muon muon,
const reco::TrackRef newTrack 
) const
private

Definition at line 173 of file MuonsFromRefitTracksProducer.cc.

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

Referenced by produce().

174  {
175  // Muon mass to make a four-vector out of the new track.
176  static const double muMass = 0.10566;
177 
178  reco::TrackRef tkTrack = muon.innerTrack();
179  reco::TrackRef muTrack = muon.outerTrack();
180 
181  // Make up a real Muon from the tracker track.
182  reco::Particle::Point vtx(newTrack->vx(), newTrack->vy(), newTrack->vz());
184  double p = newTrack->p();
185  p4.SetXYZT(newTrack->px(), newTrack->py(), newTrack->pz(),
186  sqrt(p*p + muMass*muMass));
187 
188  reco::Muon* mu = muon.clone();
189  mu->setCharge(newTrack->charge());
190  mu->setP4(p4);
191  mu->setVertex(vtx);
192  mu->setGlobalTrack(newTrack);
193  mu->setInnerTrack(tkTrack);
194  mu->setOuterTrack(muTrack);
195  return mu;
196 }
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:719
virtual TrackRef innerTrack() const
Definition: Muon.h:38
virtual void setCharge(Charge q)
set electric charge
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:720
virtual void setP4(const LorentzVector &p4)
set 4-momentum
T sqrt(T t)
Definition: SSEVec.h:28
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:30
virtual void setVertex(const Point &vertex)
set vertex
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:41
Muon * clone() const
create a clone
Definition: Muon.cc:36
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:723
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
virtual void MuonsFromRefitTracksProducer::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 75 of file MuonsFromRefitTracksProducer.cc.

75 {}
void MuonsFromRefitTracksProducer::produce ( edm::Event event,
const edm::EventSetup eSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 198 of file MuonsFromRefitTracksProducer.cc.

References edm::ViewBase::clone(), cloneAndSwitchTrack(), edm::HandleBase::failedToGet(), fromCocktail, fromGlobalTrack, fromSigmaSwitch, fromTeVRefit, fromTMR, fromTrackerTrack, edm::Ref< C, T, F >::isNonnull(), prof2calltree::last, metsig::muon, patZpeak::muons, nSigmaSwitch, convertSQLiteXML::ok, ptThreshold, reco::Muon::setGlobalTrack(), reco::Muon::setInnerTrack(), reco::Muon::setOuterTrack(), sigmaSwitch(), src, storeMatchMaps(), tevMuonTracks, muon::tevOptimized(), tevOptimizedTMR(), TMRcut, trackMap, trackMapDefault, trackMapFirstHit, trackMapPicky, and edm::helpers::KeyVal< K, V >::val.

198  {
199  // Get the global muons from the event.
201  event.getByLabel(src, muons);
202 
203  // If we can't get the global muon collection, or below the
204  // track-to-track maps needed, still produce an empty collection of
205  // muons so consumers don't throw an exception.
206  bool ok = !muons.failedToGet();
207 
208  // If we're instructed to use the TeV refit tracks in some way, we
209  // need the track-to-track maps. If we're making a cocktail muon,
210  // get all three track maps (the cocktail ingredients); else just
211  // get the map which takes the above global tracks to the desired
212  // TeV-muon refitted tracks (firstHit or picky).
213  if (ok && fromTeVRefit)
214  ok = storeMatchMaps(event);
215 
216  // Make the output collection.
217  std::auto_ptr<reco::MuonCollection> cands(new reco::MuonCollection);
218 
219  if (ok) {
221  for (muon = muons->begin(); muon != muons->end(); muon++) {
222  // Filter out the so-called trackerMuons and stand-alone muons
223  // (and caloMuons, if they were ever to get into the input muons
224  // collection).
225  if (!muon->isGlobalMuon()) continue;
226 
227  if (fromTeVRefit || fromSigmaSwitch) {
228  // Start out with a null TrackRef.
229  reco::TrackRef tevTk;
230 
231  // If making a cocktail muon, use tevOptimized() to get the track
232  // desired. Otherwise, get the refit track from the desired track
233  // map.
234  if (fromTMR)
235  tevTk = tevOptimizedTMR(*muon, *trackMapFirstHit, TMRcut);
236  else if (fromCocktail)
238  *trackMapPicky);
239  else if (fromSigmaSwitch)
240  tevTk = sigmaSwitch(*muon, nSigmaSwitch, ptThreshold);
241  else {
243  trackMap->find(muon->combinedMuon());
244  if (tevTkRef != trackMap->end())
245  tevTk = tevTkRef->val;
246  }
247 
248  // If the TrackRef is valid, make a new Muon that has the same
249  // tracker and stand-alone tracks, but has the refit track as
250  // its global track.
251  if (tevTk.isNonnull())
252  cands->push_back(*cloneAndSwitchTrack(*muon, tevTk));
253  }
254  else if (fromTrackerTrack)
255  cands->push_back(*cloneAndSwitchTrack(*muon, muon->innerTrack()));
256  else if (fromGlobalTrack)
257  cands->push_back(*cloneAndSwitchTrack(*muon, muon->globalTrack()));
258  else {
259  cands->push_back(*muon->clone());
260 
261  // Just cloning does not work in the case of the source being
262  // a pat::Muon with embedded track references -- these do not
263  // get copied. Explicitly set them.
264  reco::Muon& last = cands->at(cands->size()-1);
265  if (muon->globalTrack().isTransient())
266  last.setGlobalTrack(muon->globalTrack());
267  if (muon->innerTrack().isTransient())
268  last.setInnerTrack(muon->innerTrack());
269  if (muon->outerTrack().isTransient())
270  last.setOuterTrack(muon->outerTrack());
271  }
272  }
273  }
274  else
275  edm::LogWarning("MuonsFromRefitTracksProducer")
276  << "either " << src << " or the track map(s) " << tevMuonTracks
277  << " not present in the event; producing empty collection";
278 
279  event.put(cands);
280 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:719
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:720
reco::TrackRef tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackToTrackMap tevMap1, const reco::TrackToTrackMap tevMap2, const reco::TrackToTrackMap tevMap3)
edm::Handle< reco::TrackToTrackMap > trackMapDefault
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
edm::Handle< reco::TrackToTrackMap > trackMap
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
bool storeMatchMaps(const edm::Event &event)
edm::Handle< reco::TrackToTrackMap > trackMapFirstHit
reco::TrackRef tevOptimizedTMR(const reco::Muon &muon, const reco::TrackToTrackMap &fmsMap, const double cut)
reco::Muon * cloneAndSwitchTrack(const reco::Muon &muon, const reco::TrackRef &newTrack) const
bool failedToGet() const
Definition: HandleBase.h:80
edm::Handle< reco::TrackToTrackMap > trackMapPicky
ViewBase * clone() const
Definition: View.cc:13
reco::TrackRef sigmaSwitch(const reco::Muon &muon, const double nSigma, const double ptThreshold)
tuple muons
Definition: patZpeak.py:38
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:723
bool MuonsFromRefitTracksProducer::storeMatchMaps ( const edm::Event event)
private

Definition at line 159 of file MuonsFromRefitTracksProducer.cc.

References edm::HandleBase::failedToGet(), fromCocktail, fromTMR, tevMuonTracks, trackMap, trackMapDefault, trackMapFirstHit, and trackMapPicky.

Referenced by produce().

159  {
160  if (fromCocktail || fromTMR) {
161  event.getByLabel(tevMuonTracks, "default", trackMapDefault);
162  event.getByLabel(tevMuonTracks, "firstHit", trackMapFirstHit);
163  event.getByLabel(tevMuonTracks, "picky", trackMapPicky);
164  return !trackMapDefault.failedToGet() &&
166  }
167  else {
168  event.getByLabel(edm::InputTag(tevMuonTracks), trackMap);
169  return !trackMap.failedToGet();
170  }
171 }
edm::Handle< reco::TrackToTrackMap > trackMapDefault
edm::Handle< reco::TrackToTrackMap > trackMap
edm::Handle< reco::TrackToTrackMap > trackMapFirstHit
bool failedToGet() const
Definition: HandleBase.h:80
edm::Handle< reco::TrackToTrackMap > trackMapPicky

Member Data Documentation

bool MuonsFromRefitTracksProducer::fromCocktail
private

Definition at line 113 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

bool MuonsFromRefitTracksProducer::fromGlobalTrack
private

Definition at line 99 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

bool MuonsFromRefitTracksProducer::fromSigmaSwitch
private

Definition at line 124 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

bool MuonsFromRefitTracksProducer::fromTeVRefit
private

Definition at line 103 of file MuonsFromRefitTracksProducer.cc.

Referenced by MuonsFromRefitTracksProducer(), and produce().

bool MuonsFromRefitTracksProducer::fromTMR
private

Definition at line 117 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

bool MuonsFromRefitTracksProducer::fromTrackerTrack
private

Definition at line 93 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

double MuonsFromRefitTracksProducer::nSigmaSwitch
private

Definition at line 127 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

double MuonsFromRefitTracksProducer::ptThreshold
private

Definition at line 130 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

edm::InputTag MuonsFromRefitTracksProducer::src
private

Definition at line 87 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

std::string MuonsFromRefitTracksProducer::tevMuonTracks
private
double MuonsFromRefitTracksProducer::TMRcut
private

Definition at line 120 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce().

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

Definition at line 135 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 138 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 139 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().

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

Definition at line 140 of file MuonsFromRefitTracksProducer.cc.

Referenced by produce(), and storeMatchMaps().