CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
QuarkoniaTrackSelector Class Reference

#include <QuarkoniaTrackSelector.h>

Inheritance diagram for QuarkoniaTrackSelector:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 QuarkoniaTrackSelector (const edm::ParameterSet &)
 
 ~QuarkoniaTrackSelector () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

bool checkCharge_
 check opposite charge? More...
 
std::vector< double > maxMasses_
 upper mass limits More...
 
double maxTrackEta_
 track |eta| cut More...
 
std::vector< double > minMasses_
 lower mass limits More...
 
double minTrackP_
 track p cut More...
 
double minTrackPt_
 track pt cut More...
 
edm::InputTag muonTag_
 tag for RecoChargedCandidateCollection More...
 
edm::EDGetTokenT< reco::RecoChargedCandidateCollectionmuonToken_
 
edm::InputTag trackTag_
 tag for TrackCollection More...
 
edm::EDGetTokenT< reco::TrackCollectiontrackToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Creates a filtered TrackCollection based on the mass of a combination of a track and a RecoChargedCandidate (typically a muon)

Definition at line 18 of file QuarkoniaTrackSelector.h.

Constructor & Destructor Documentation

QuarkoniaTrackSelector::QuarkoniaTrackSelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 19 of file QuarkoniaTrackSelector.cc.

References checkCharge_, mps_fire::i, LogDebug, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, muonTag_, muonToken_, trackTag_, and trackToken_.

19  :
20  muonTag_(iConfig.getParameter<edm::InputTag>("muonCandidates")),
21  trackTag_(iConfig.getParameter<edm::InputTag>("tracks")),
22  minMasses_(iConfig.getParameter< std::vector<double> >("MinMasses")),
23  maxMasses_(iConfig.getParameter< std::vector<double> >("MaxMasses")),
24  checkCharge_(iConfig.getParameter<bool>("checkCharge")),
25  minTrackPt_(iConfig.getParameter<double>("MinTrackPt")),
26  minTrackP_(iConfig.getParameter<double>("MinTrackP")),
27  maxTrackEta_(iConfig.getParameter<double>("MaxTrackEta"))
28 {
29 
30 
31  muonToken_ = consumes<reco::RecoChargedCandidateCollection>(muonTag_);
32  trackToken_ = consumes<reco::TrackCollection>(trackTag_);
33 
34 
35  //register your products
36  produces<reco::TrackCollection>();
37  //
38  // verify mass windows
39  //
40  bool massesValid = minMasses_.size()==maxMasses_.size();
41  if ( massesValid ) {
42  for ( size_t i=0; i<minMasses_.size(); ++i ) {
43  if ( minMasses_[i]<0 || maxMasses_[i]<0 ||
44  minMasses_[i]>maxMasses_[i] ) massesValid = false;
45  }
46  }
47  if ( !massesValid ) {
48  edm::LogError("QuarkoniaTrackSelector") << "Inconsistency in definition of mass windows, "
49  << "no track will be selected";
50  minMasses_.clear();
51  maxMasses_.clear();
52  }
53 
54  std::ostringstream stream;
55  stream << "instantiated with parameters\n"
56  << " muonTag = " << muonTag_ << "\n"
57  << " trackTag = " << trackTag_ << "\n";
58  stream << " mass windows =";
59  for ( size_t i=0; i<minMasses_.size(); ++i )
60  stream << " (" << minMasses_[i] << "," << maxMasses_[i] << ")";
61  stream << "\n";
62  stream << " checkCharge = " << checkCharge_ << "\n";
63  stream << " MinTrackPt = " << minTrackPt_ << "\n";
64  stream << " MinTrackP = " << minTrackP_ << "\n";
65  stream << " MaxTrackEta = " << maxTrackEta_;
66  LogDebug("QuarkoniaTrackSelector") << stream.str();
67 }
#define LogDebug(id)
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
T getParameter(std::string const &) const
std::vector< double > minMasses_
lower mass limits
std::vector< double > maxMasses_
upper mass limits
edm::EDGetTokenT< reco::TrackCollection > trackToken_
double minTrackP_
track p cut
edm::InputTag trackTag_
tag for TrackCollection
double minTrackPt_
track pt cut
edm::InputTag muonTag_
tag for RecoChargedCandidateCollection
bool checkCharge_
check opposite charge?
double maxTrackEta_
track |eta| cut
QuarkoniaTrackSelector::~QuarkoniaTrackSelector ( )
inlineoverride

Definition at line 21 of file QuarkoniaTrackSelector.h.

References produce().

21 {}

Member Function Documentation

void QuarkoniaTrackSelector::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 71 of file QuarkoniaTrackSelector.cc.

References reco::LeafCandidate::charge(), reco::TrackBase::charge(), checkCharge_, DEFINE_FWK_MODULE, reco::LeafCandidate::eta(), reco::TrackBase::eta(), spr::find(), edm::Event::getByToken(), mps_fire::i, edm::isDebugEnabled(), edm::HandleBase::isValid(), LogDebug, ResonanceBuilder::mass, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, eostools::move(), muonToken_, reco::LeafCandidate::p(), reco::TrackBase::p(), reco::LeafCandidate::p4(), reco::LeafCandidate::pt(), reco::TrackBase::pt(), edm::Event::put(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), mathSSE::sqrt(), HiIsolationCommonParameters_cff::track, and trackToken_.

Referenced by ~QuarkoniaTrackSelector().

72 {
73  //
74  // the product
75  //
76  auto product = std::make_unique<reco::TrackCollection>();
77  //
78  // Muons
79  //
81  iEvent.getByToken(muonToken_,muonHandle);
82  //
83  // Tracks
84  //
86  iEvent.getByToken(trackToken_,trackHandle);
87  //
88  // Verification
89  //
90  if ( !muonHandle.isValid() || !trackHandle.isValid() || minMasses_.empty() ) {
91  iEvent.put(std::move(product));
92  return;
93  }
94  //
95  // Debug output
96  //
97  if ( edm::isDebugEnabled() ) {
98  std::ostringstream stream;
99  stream << "\nInput muons: # / q / pt / p / eta\n";
100  for ( size_t im=0; im<muonHandle->size(); ++im ) {
101  const reco::RecoChargedCandidate& muon = (*muonHandle)[im];
102  stream << " " << im << " "
103  << muon.charge() << " " << muon.pt() << " "
104  << muon.p() << " " << muon.eta() << "\n";
105  }
106  stream << "Input tracks: # / q / pt / p / eta\n";
107  for ( size_t it=0; it<trackHandle->size(); ++it ) {
108  const reco::Track& track = (*trackHandle)[it];
109  stream << " " << it << " "
110  << track.charge() << " " << track.pt() << " "
111  << track.p() << " " << track.eta() << "\n";
112  }
113  LogDebug("QuarkoniaTrackSelector") << stream.str();
114  }
115  //
116  // combinations
117  //
118 // std::ostringstream stream;
119  unsigned int nQ(0);
120  unsigned int nComb(0);
121  std::vector<size_t> selectedTrackIndices;
122  selectedTrackIndices.reserve(muonHandle->size());
125  // muons
126  for ( size_t im=0; im<muonHandle->size(); ++im ) {
127  const reco::RecoChargedCandidate& muon = (*muonHandle)[im];
128  int qMuon = muon.charge();
129  p4Muon = muon.p4();
130  // tracks
131  for ( size_t it=0; it<trackHandle->size(); ++it ) {
132  const reco::Track& track = (*trackHandle)[it];
133  if ( track.pt()<minTrackPt_ || track.p()<minTrackP_ ||
134  fabs(track.eta())>maxTrackEta_ ) continue;
135  if ( checkCharge_ && track.charge()!=-qMuon ) continue;
136  ++nQ;
137  reco::Particle::LorentzVector p4Track(track.px(),track.py(),track.pz(),
138  sqrt(track.p()*track.p()+0.0111636));
139  // mass windows
140  double mass = (p4Muon+p4Track).mass();
141 // stream << "Combined mass = " << im << " " << it
142 // << " " << mass
143 // << " phi " << track.phi() << "\n";
144  for ( size_t j=0; j<minMasses_.size(); ++j ) {
145  if ( mass>minMasses_[j] && mass<maxMasses_[j] ) {
146  ++nComb;
147  if ( find(selectedTrackIndices.begin(),selectedTrackIndices.end(),it)==
148  selectedTrackIndices.end() ) selectedTrackIndices.push_back(it);
149 // stream << "... adding " << "\n";
150  break;
151  }
152  }
153  }
154  }
155 // LogDebug("QuarkoniaTrackSelector") << stream.str();
156  //
157  // filling of output collection
158  //
159  for ( size_t i=0; i<selectedTrackIndices.size(); ++i )
160  product->push_back((*trackHandle)[selectedTrackIndices[i]]);
161  //
162  // debug output
163  //
164  if ( edm::isDebugEnabled() ) {
165  std::ostringstream stream;
166  stream << "Total number of combinations = " << muonHandle->size()*trackHandle->size()
167  << " , after charge " << nQ << " , after mass " << nComb << std::endl;
168  stream << "Selected " << product->size() << " tracks with # / q / pt / eta\n";
169  for ( size_t i=0; i<product->size(); ++i ) {
170  const reco::Track& track = (*product)[i];
171  stream << " " << i << " " << track.charge() << " "
172  << track.pt() << " " << track.eta() << "\n";
173  }
174  LogDebug("QuarkoniaTrackSelector") << stream.str();
175  }
176  //
177  iEvent.put(std::move(product));
178 }
#define LogDebug(id)
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
bool isDebugEnabled()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< double > minMasses_
lower mass limits
double pt() const final
transverse momentum
int charge() const final
electric charge
Definition: LeafCandidate.h:91
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:627
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< double > maxMasses_
upper mass limits
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:621
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
bool isValid() const
Definition: HandleBase.h:74
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:639
double p() const final
magnitude of momentum vector
edm::EDGetTokenT< reco::TrackCollection > trackToken_
double minTrackP_
track p cut
int charge() const
track electric charge
Definition: TrackBase.h:567
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:510
double minTrackPt_
track pt cut
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:633
bool checkCharge_
check opposite charge?
double maxTrackEta_
track |eta| cut

Member Data Documentation

bool QuarkoniaTrackSelector::checkCharge_
private

check opposite charge?

Definition at line 34 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

std::vector<double> QuarkoniaTrackSelector::maxMasses_
private

upper mass limits

Definition at line 33 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::maxTrackEta_
private

track |eta| cut

Definition at line 37 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

std::vector<double> QuarkoniaTrackSelector::minMasses_
private

lower mass limits

Definition at line 32 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::minTrackP_
private

track p cut

Definition at line 36 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::minTrackPt_
private

track pt cut

Definition at line 35 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

edm::InputTag QuarkoniaTrackSelector::muonTag_
private

tag for RecoChargedCandidateCollection

Definition at line 27 of file QuarkoniaTrackSelector.h.

Referenced by QuarkoniaTrackSelector().

edm::EDGetTokenT<reco::RecoChargedCandidateCollection> QuarkoniaTrackSelector::muonToken_
private

Definition at line 29 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

edm::InputTag QuarkoniaTrackSelector::trackTag_
private

tag for TrackCollection

Definition at line 28 of file QuarkoniaTrackSelector.h.

Referenced by QuarkoniaTrackSelector().

edm::EDGetTokenT<reco::TrackCollection> QuarkoniaTrackSelector::trackToken_
private

Definition at line 30 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().