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::Muon::MuonTrackTypePair &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)
 
static void prevalidate (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::Muon::MuonTrackTypePair newTrack 
) const
private

Definition at line 173 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().

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.first->vx(), newTrack.first->vy(), newTrack.first->vz());
184  double p = newTrack.first->p();
185  p4.SetXYZT(newTrack.first->px(), newTrack.first->py(), newTrack.first->pz(),
186  sqrt(p*p + muMass*muMass));
187 
188  reco::Muon* mu = muon.clone();
189  mu->setCharge(newTrack.first->charge());
190  mu->setP4(p4);
191  mu->setVertex(vtx);
192  mu->setGlobalTrack(newTrack.first);
193  mu->setInnerTrack(tkTrack);
194  mu->setOuterTrack(muTrack);
195  mu->setBestTrack(newTrack.second);
196  return mu;
197 }
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:752
virtual TrackRef innerTrack() const
Definition: Muon.h:49
virtual void setCharge(Charge q)
set electric charge
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:753
virtual void setP4(const LorentzVector &p4)
set 4-momentum
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:29
const int mu
Definition: Constants.h:23
virtual void setVertex(const Point &vertex)
set vertex
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
Muon * clone() const
create a clone
Definition: Muon.cc:40
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:94
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:756
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
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 199 of file MuonsFromRefitTracksProducer.cc.

References edm::ViewBase::clone(), cloneAndSwitchTrack(), reco::Muon::CombinedTrack, 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, storeMatchMaps(), tevMuonTracks, muon::tevOptimized(), tevOptimizedTMR(), TMRcut, trackMap, trackMapDefault, trackMapFirstHit, trackMapPicky, and edm::helpers::KeyVal< K, V >::val.

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