CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
MuonTrackCleanerBase Class Referenceabstract

#include <MuonTrackCleanerBase.h>

Inheritance diagram for MuonTrackCleanerBase:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper GlobalMuonTrackCleaner MuonTrackCleaner TeVMuonTrackCleaner

Classes

struct  muonMomentumType
 
struct  todoListEntryType
 

Public Member Functions

 MuonTrackCleanerBase (const edm::ParameterSet &)
 
 ~MuonTrackCleanerBase ()
 
- 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 ()
 

Protected Types

enum  { kInnerTrack, kOuterTrack, kLink, kTeV }
 

Protected Member Functions

muonMomentumType getMuonMomentum (const reco::Candidate &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
virtual void produceTrackExtras (edm::Event &, const edm::EventSetup &)=0
 
virtual void produceTracks (edm::Event &, const edm::EventSetup &)
 
- 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)
 

Protected Attributes

double dRmatch_
 
int maxWarnings_tooFew_
 
int maxWarnings_tooMany_
 
std::string moduleLabel_
 
int numWarnings_tooFew_
 
int numWarnings_tooMany_
 
bool removeDuplicates_
 
edm::InputTag srcSelectedMuons_
 
std::vector< todoListEntryTypetodoList_
 
int type_
 
int verbosity_
 

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)
 

Detailed Description

Base class for modules producing collections of reco::Tracks in Z –> mu+ mu- event from which the two muons are removed (later to be replaced by simulated tau decay products)

Authors
Christian Veelken, LLR
Version
Revision:
1.1
Id:
MuonTrackCleanerBase.h,v 1.1 2013/03/30 16:41:11 veelken Exp

Definition at line 30 of file MuonTrackCleanerBase.h.

Member Enumeration Documentation

anonymous enum
protected

Constructor & Destructor Documentation

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

Definition at line 14 of file MuonTrackCleanerBase.cc.

References edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::InputTag::instance(), kInnerTrack, kLink, kOuterTrack, kTeV, MuonTrackCleanerBase::todoListEntryType::srcTracks_, AlCaHLTBitMon_QueryRunRegistry::string, todoList_, type_, and verbosity_.

15  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
16  srcSelectedMuons_(cfg.getParameter<edm::InputTag>("selectedMuons")),
17  dRmatch_(cfg.getParameter<double>("dRmatch")),
18  removeDuplicates_(cfg.getParameter<bool>("removeDuplicates")),
23 {
24  std::string type_string = cfg.getParameter<std::string>("type");
25  // CV: types defined in RecoMuon/MuonIdentification/python/muons1stStep_cfi.py
26  if ( type_string == "inner tracks" ) type_ = kInnerTrack;
27  else if ( type_string == "outer tracks" ) type_ = kOuterTrack;
28  else if ( type_string == "links" ) type_ = kLink;
29  else if ( type_string.find("tev") == 0 ) type_ = kTeV;
30  else throw cms::Exception("Configuration")
31  << "Invalid Configuration Parameter 'type' = " << type_string << " !!\n";
32 
33  typedef std::vector<edm::InputTag> VInputTag;
34  VInputTag srcTracks = cfg.getParameter<VInputTag>("tracks");
35  for ( VInputTag::const_iterator srcTracks_i = srcTracks.begin();
36  srcTracks_i != srcTracks.end(); ++srcTracks_i ) {
37  todoListEntryType todoListEntry;
38  todoListEntry.srcTracks_ = (*srcTracks_i);
39 
40  todoList_.push_back(todoListEntry);
41 
42  produces<reco::TrackCollection>(todoListEntry.srcTracks_.instance());
43  }
44 
45  verbosity_ = ( cfg.exists("verbosity") ) ?
46  cfg.getParameter<int>("verbosity") : 0;
47 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag srcSelectedMuons_
std::vector< todoListEntryType > todoList_
MuonTrackCleanerBase::~MuonTrackCleanerBase ( )
inline

Definition at line 34 of file MuonTrackCleanerBase.h.

34 {}

Member Function Documentation

MuonTrackCleanerBase::muonMomentumType MuonTrackCleanerBase::getMuonMomentum ( const reco::Candidate muon_candidate)
protected

Definition at line 98 of file MuonTrackCleanerBase.cc.

References reco::Candidate::eta(), MuonTrackCleanerBase::muonMomentumType::eta_, reco::Muon::globalTrack(), reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), kInnerTrack, kLink, kOuterTrack, kTeV, trackingTruthProducerFastSim_cfi::muon, reco::Muon::outerTrack(), reco::Candidate::phi(), MuonTrackCleanerBase::muonMomentumType::phi_, reco::Candidate::pt(), MuonTrackCleanerBase::muonMomentumType::pt_, and type_.

Referenced by produceTracks().

99 {
100  muonMomentumType muonMomentum;
101  muonMomentum.pt_ = muon_candidate.pt();
102  muonMomentum.eta_ = muon_candidate.eta();
103  muonMomentum.phi_ = muon_candidate.phi();
104 
105  const reco::Muon* muon = dynamic_cast<const reco::Muon*>(&muon_candidate);
106  if ( muon ) {
107  if ( type_ == kInnerTrack && muon->innerTrack().isNonnull() ) {
108  muonMomentum.eta_ = muon->innerTrack()->eta();
109  muonMomentum.phi_ = muon->innerTrack()->phi();
110  } else if ( type_ == kOuterTrack && muon->outerTrack().isNonnull() ) {
111  muonMomentum.eta_ = muon->outerTrack()->eta();
112  muonMomentum.phi_ = muon->outerTrack()->phi();
113  } else if ( (type_ == kLink || type_ == kTeV) && muon->globalTrack().isNonnull() ) {
114  muonMomentum.eta_ = muon->globalTrack()->eta();
115  muonMomentum.phi_ = muon->globalTrack()->phi();
116  }
117  }
118 
119  return muonMomentum;
120 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual TrackRef innerTrack() const
Definition: Muon.h:48
virtual float eta() const =0
momentum pseudorapidity
virtual float phi() const =0
momentum azimuthal angle
virtual float pt() const =0
transverse momentum
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
void MuonTrackCleanerBase::produce ( edm::Event evt,
const edm::EventSetup es 
)
protectedvirtual

Implements edm::EDProducer.

Definition at line 92 of file MuonTrackCleanerBase.cc.

References produceTrackExtras(), and produceTracks().

93 {
94  produceTracks(evt, es);
95  produceTrackExtras(evt, es);
96 }
virtual void produceTrackExtras(edm::Event &, const edm::EventSetup &)=0
virtual void produceTracks(edm::Event &, const edm::EventSetup &)
virtual void MuonTrackCleanerBase::produceTrackExtras ( edm::Event ,
const edm::EventSetup  
)
protectedpure virtual
void MuonTrackCleanerBase::produceTracks ( edm::Event evt,
const edm::EventSetup es 
)
protectedvirtual

Definition at line 122 of file MuonTrackCleanerBase.cc.

References gather_cfg::cout, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRmatch_, reco::Candidate::eta(), edm::Event::getByLabel(), getMuonMomentum(), edm::Event::getRefBeforePut(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), customizeTrackingMonitorSeedNumber::idx, reco::isMuon(), edm::RefToBase< T >::isNonnull(), kInnerTrack, kLink, Max(), maxWarnings_tooFew_, maxWarnings_tooMany_, numWarnings_tooFew_, numWarnings_tooMany_, reco::Candidate::phi(), reco::Candidate::pt(), edm::Event::put(), removeDuplicates_, python.multivaluedict::sort(), srcSelectedMuons_, todoList_, testEve_cfg::tracks, type_, and verbosity_.

Referenced by produce().

123 {
124  if ( verbosity_ ) std::cout << "<MuonTrackCleanerBase::produceTracks>:" << std::endl;
125 
126  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
127  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
128  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
129 
130  std::vector<muonMomentumType> selMuonMomenta;
131  if ( muPlus.isNonnull() ) {
132  if ( verbosity_ ) std::cout << " muPlus: Pt = " << muPlus->pt() << ", eta = " << muPlus->eta() << ", phi = " << muPlus->phi() << std::endl;
133  selMuonMomenta.push_back(getMuonMomentum(*muPlus));
134  }
135  if ( muMinus.isNonnull() ) {
136  if ( verbosity_ ) std::cout << " muMinus: Pt = " << muMinus->pt() << ", eta = " << muMinus->eta() << ", phi = " << muMinus->phi() << std::endl;
137  selMuonMomenta.push_back(getMuonMomentum(*muMinus));
138  }
139 
140 //--- produce collection of reco::Tracks excluding muons
141  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
142  todoItem != todoList_.end(); ++todoItem ) {
143  if ( verbosity_ ) std::cout << "processing trackCollection = " << todoItem->srcTracks_ << std::endl;
144 
145  todoItem->trackRefMap_.clear();
146 
148  evt.getByLabel(todoItem->srcTracks_, tracks);
149 
150  std::auto_ptr<reco::TrackCollection> tracks_cleaned(new reco::TrackCollection());
151 
152  reco::TrackRefProd trackCollectionRefProd_cleaned = evt.getRefBeforePut<reco::TrackCollection>(todoItem->srcTracks_.instance());
153  size_t idxTrack_cleaned = 0;
154 
155  std::vector<muonToTrackMatchInfoType> selMuonToTrackMatches;
156  for ( std::vector<muonMomentumType>::const_iterator selMuonMomentum = selMuonMomenta.begin();
157  selMuonMomentum != selMuonMomenta.end(); ++selMuonMomentum ) {
158  std::vector<muonToTrackMatchInfoType> tmpMatches;
159  for ( reco::TrackCollection::const_iterator track = tracks->begin();
160  track != tracks->end(); ++track ) {
161  double dR = reco::deltaR(track->eta(), track->phi(), selMuonMomentum->eta_, selMuonMomentum->phi_);
162  if ( dR < dRmatch_ ) tmpMatches.push_back(muonToTrackMatchInfoType(selMuonMomentum->pt_, &(*track), dR));
163  }
164  // rank muon-to-track matches by quality
165  std::sort(tmpMatches.begin(), tmpMatches.end(), SortMuonToTrackMatchInfosDescendingMatchQuality());
166  if ( tmpMatches.size() > 0 ) selMuonToTrackMatches.push_back(tmpMatches.front());
167  if ( removeDuplicates_ ) {
168  // CV: remove all high Pt tracks very close to muon direction
169  // (duplicate tracks arise in case muon track in SiStrip + Pixel detector is reconstructed as 2 disjoint segments)
170  for ( std::vector<muonToTrackMatchInfoType>::const_iterator tmpMatch = tmpMatches.begin();
171  tmpMatch != tmpMatches.end(); ++tmpMatch ) {
172  if ( (tmpMatch->dR_ < 1.e-3 && tmpMatch->trackPt_ > (0.33*tmpMatch->muonPt_)) ||
173  (tmpMatch->dR_ < 1.e-1 && tmpMatch->trackPt_ > TMath::Max(0.66*tmpMatch->muonPt_, 10.)) ) selMuonToTrackMatches.push_back(*tmpMatch);
174  }
175  }
176  }
177 
178  std::vector<reco::TrackRef> removedTracks;
179  size_t numTracks = tracks->size();
180  for ( size_t trackIdx = 0; trackIdx < numTracks; ++trackIdx ) {
181  reco::TrackRef track(tracks, trackIdx);
182  bool isMuon = false;
183  for ( std::vector<muonToTrackMatchInfoType>::const_iterator muonMatchInfo = selMuonToTrackMatches.begin();
184  muonMatchInfo != selMuonToTrackMatches.end(); ++muonMatchInfo ) {
185  if ( muonMatchInfo->track_ == &(*track) ) isMuon = true;
186  }
187  if ( verbosity_ && track->pt() > 5. ) {
188  std::cout << "track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() << ", isMuon = " << isMuon << std::endl;
189  }
190  if ( isMuon ) {
191  removedTracks.push_back(track); // track belongs to a selected muon, do not copy
192  } else {
193  tracks_cleaned->push_back(*track);
194  todoItem->trackRefMap_[reco::TrackRef(trackCollectionRefProd_cleaned, idxTrack_cleaned)] = track;
195  ++idxTrack_cleaned;
196  }
197  }
198  if ( (type_ >= kInnerTrack && type_ <= kLink && removedTracks.size() > selMuons.size() && numWarnings_tooMany_ < maxWarnings_tooMany_) &&
199  (type_ >= kInnerTrack && type_ <= kInnerTrack && removedTracks.size() < selMuons.size() && numWarnings_tooFew_ < maxWarnings_tooFew_ ) ) {
200  edm::LogWarning("MuonTrackCleanerBase")
201  << " (" << runLumiEventNumbers_to_string(evt) << ")" << std::endl
202  << " Removed " << removedTracks.size() << " tracks from event containing " << selMuons.size() << " muons !!" << std::endl;
203  if ( muPlus.isNonnull() ) std::cout << " muPlus: Pt = " << muPlus->pt() << ", eta = " << muPlus->eta() << ", phi = " << muPlus->phi() << std::endl;
204  if ( muMinus.isNonnull() ) std::cout << " muMinus: Pt = " << muMinus->pt() << ", eta = " << muMinus->eta() << ", phi = " << muMinus->phi() << std::endl;
205  std::cout << "Removed tracks:" << std::endl;
206  int idx = 0;
207  for ( std::vector<reco::TrackRef>::const_iterator removedTrack = removedTracks.begin();
208  removedTrack != removedTracks.end(); ++removedTrack ) {
209  std::cout << "track #" << idx << ":"
210  << " Pt = " << (*removedTrack)->pt() << ", eta = " << (*removedTrack)->eta() << ", phi = " << (*removedTrack)->phi() << std::endl;
211  ++idx;
212  }
213  if ( removedTracks.size() > selMuons.size() ) ++numWarnings_tooMany_;
214  if ( removedTracks.size() < selMuons.size() ) ++numWarnings_tooFew_;
215  }
216 
217  evt.put(tracks_cleaned, todoItem->srcTracks_.instance());
218  }
219 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
bool isMuon(const Candidate &part)
Definition: pdgIdUtils.h:11
virtual float eta() const =0
momentum pseudorapidity
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
virtual float phi() const =0
momentum azimuthal angle
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:280
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
virtual float pt() const =0
transverse momentum
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
edm::InputTag srcSelectedMuons_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:133
muonMomentumType getMuonMomentum(const reco::Candidate &)
T Max(T a, T b)
Definition: MathUtil.h:44
tuple tracks
Definition: testEve_cfg.py:39
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
tuple cout
Definition: gather_cfg.py:121
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
std::vector< todoListEntryType > todoList_

Member Data Documentation

double MuonTrackCleanerBase::dRmatch_
protected

Definition at line 63 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

int MuonTrackCleanerBase::maxWarnings_tooFew_
protected

Definition at line 71 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

int MuonTrackCleanerBase::maxWarnings_tooMany_
protected

Definition at line 69 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

std::string MuonTrackCleanerBase::moduleLabel_
protected
int MuonTrackCleanerBase::numWarnings_tooFew_
protected

Definition at line 72 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

int MuonTrackCleanerBase::numWarnings_tooMany_
protected

Definition at line 70 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

bool MuonTrackCleanerBase::removeDuplicates_
protected

Definition at line 64 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

edm::InputTag MuonTrackCleanerBase::srcSelectedMuons_
protected

Definition at line 52 of file MuonTrackCleanerBase.h.

Referenced by produceTracks().

std::vector<todoListEntryType> MuonTrackCleanerBase::todoList_
protected
int MuonTrackCleanerBase::type_
protected
int MuonTrackCleanerBase::verbosity_
protected