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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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 17 of file QuarkoniaTrackSelector.h.

Constructor & Destructor Documentation

◆ QuarkoniaTrackSelector()

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

Definition at line 18 of file QuarkoniaTrackSelector.cc.

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

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

◆ ~QuarkoniaTrackSelector()

QuarkoniaTrackSelector::~QuarkoniaTrackSelector ( )
inlineoverride

Definition at line 20 of file QuarkoniaTrackSelector.h.

20 {}

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 64 of file QuarkoniaTrackSelector.cc.

64  {
65  //
66  // the product
67  //
68  auto product = std::make_unique<reco::TrackCollection>();
69  //
70  // Muons
71  //
73  iEvent.getByToken(muonToken_, muonHandle);
74  //
75  // Tracks
76  //
78  iEvent.getByToken(trackToken_, trackHandle);
79  //
80  // Verification
81  //
82  if (!muonHandle.isValid() || !trackHandle.isValid() || minMasses_.empty()) {
83  iEvent.put(std::move(product));
84  return;
85  }
86  //
87  // Debug output
88  //
89  if (edm::isDebugEnabled()) {
90  std::ostringstream stream;
91  stream << "\nInput muons: # / q / pt / p / eta\n";
92  for (size_t im = 0; im < muonHandle->size(); ++im) {
93  const reco::RecoChargedCandidate& muon = (*muonHandle)[im];
94  stream << " " << im << " " << muon.charge() << " " << muon.pt() << " " << muon.p() << " " << muon.eta() << "\n";
95  }
96  stream << "Input tracks: # / q / pt / p / eta\n";
97  for (size_t it = 0; it < trackHandle->size(); ++it) {
98  const reco::Track& track = (*trackHandle)[it];
99  stream << " " << it << " " << track.charge() << " " << track.pt() << " " << track.p() << " " << track.eta()
100  << "\n";
101  }
102  LogDebug("QuarkoniaTrackSelector") << stream.str();
103  }
104  //
105  // combinations
106  //
107  // std::ostringstream stream;
108  unsigned int nQ(0);
109  unsigned int nComb(0);
110  std::vector<size_t> selectedTrackIndices;
111  selectedTrackIndices.reserve(muonHandle->size());
114  // muons
115  for (size_t im = 0; im < muonHandle->size(); ++im) {
116  const reco::RecoChargedCandidate& muon = (*muonHandle)[im];
117  int qMuon = muon.charge();
118  p4Muon = muon.p4();
119  // tracks
120  for (size_t it = 0; it < trackHandle->size(); ++it) {
121  const reco::Track& track = (*trackHandle)[it];
122  if (track.pt() < minTrackPt_ || track.p() < minTrackP_ || fabs(track.eta()) > maxTrackEta_)
123  continue;
124  if (checkCharge_ && track.charge() != -qMuon)
125  continue;
126  ++nQ;
128  track.px(), track.py(), track.pz(), sqrt(track.p() * track.p() + 0.0111636));
129  // mass windows
130  double mass = (p4Muon + p4Track).mass();
131  // stream << "Combined mass = " << im << " " << it
132  // << " " << mass
133  // << " phi " << track.phi() << "\n";
134  for (size_t j = 0; j < minMasses_.size(); ++j) {
135  if (mass > minMasses_[j] && mass < maxMasses_[j]) {
136  ++nComb;
137  if (find(selectedTrackIndices.begin(), selectedTrackIndices.end(), it) == selectedTrackIndices.end())
138  selectedTrackIndices.push_back(it);
139  // stream << "... adding " << "\n";
140  break;
141  }
142  }
143  }
144  }
145  // LogDebug("QuarkoniaTrackSelector") << stream.str();
146  //
147  // filling of output collection
148  //
149  for (size_t i = 0; i < selectedTrackIndices.size(); ++i)
150  product->push_back((*trackHandle)[selectedTrackIndices[i]]);
151  //
152  // debug output
153  //
154  if (edm::isDebugEnabled()) {
155  std::ostringstream stream;
156  stream << "Total number of combinations = " << muonHandle->size() * trackHandle->size() << " , after charge " << nQ
157  << " , after mass " << nComb << std::endl;
158  stream << "Selected " << product->size() << " tracks with # / q / pt / eta\n";
159  for (size_t i = 0; i < product->size(); ++i) {
160  const reco::Track& track = (*product)[i];
161  stream << " " << i << " " << track.charge() << " " << track.pt() << " " << track.eta() << "\n";
162  }
163  LogDebug("QuarkoniaTrackSelector") << stream.str();
164  }
165  //
166  iEvent.put(std::move(product));
167 }

References checkCharge_, spr::find(), mps_fire::i, iEvent, edm::isDebugEnabled(), edm::HandleBase::isValid(), dqmiolumiharvest::j, LogDebug, EgHLTOffHistBins_cfi::mass, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, eostools::move(), muonToken_, mathSSE::sqrt(), cms::cuda::stream, HLT_2018_cff::track, and trackToken_.

Member Data Documentation

◆ checkCharge_

bool QuarkoniaTrackSelector::checkCharge_
private

check opposite charge?

Definition at line 33 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ maxMasses_

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

upper mass limits

Definition at line 32 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ maxTrackEta_

double QuarkoniaTrackSelector::maxTrackEta_
private

track |eta| cut

Definition at line 36 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ minMasses_

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

lower mass limits

Definition at line 31 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ minTrackP_

double QuarkoniaTrackSelector::minTrackP_
private

track p cut

Definition at line 35 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ minTrackPt_

double QuarkoniaTrackSelector::minTrackPt_
private

track pt cut

Definition at line 34 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ muonTag_

edm::InputTag QuarkoniaTrackSelector::muonTag_
private

tag for RecoChargedCandidateCollection

Definition at line 26 of file QuarkoniaTrackSelector.h.

Referenced by QuarkoniaTrackSelector().

◆ muonToken_

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

Definition at line 28 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

◆ trackTag_

edm::InputTag QuarkoniaTrackSelector::trackTag_
private

tag for TrackCollection

Definition at line 27 of file QuarkoniaTrackSelector.h.

Referenced by QuarkoniaTrackSelector().

◆ trackToken_

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

Definition at line 29 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

mps_fire.i
i
Definition: mps_fire.py:355
muon
Definition: MuonCocktails.h:17
QuarkoniaTrackSelector::minTrackP_
double minTrackP_
track p cut
Definition: QuarkoniaTrackSelector.h:35
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
QuarkoniaTrackSelector::trackToken_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: QuarkoniaTrackSelector.h:29
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle< reco::RecoChargedCandidateCollection >
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
QuarkoniaTrackSelector::trackTag_
edm::InputTag trackTag_
tag for TrackCollection
Definition: QuarkoniaTrackSelector.h:27
reco::Track
Definition: Track.h:27
QuarkoniaTrackSelector::muonToken_
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
Definition: QuarkoniaTrackSelector.h:28
QuarkoniaTrackSelector::minTrackPt_
double minTrackPt_
track pt cut
Definition: QuarkoniaTrackSelector.h:34
QuarkoniaTrackSelector::muonTag_
edm::InputTag muonTag_
tag for RecoChargedCandidateCollection
Definition: QuarkoniaTrackSelector.h:26
QuarkoniaTrackSelector::checkCharge_
bool checkCharge_
check opposite charge?
Definition: QuarkoniaTrackSelector.h:33
QuarkoniaTrackSelector::maxTrackEta_
double maxTrackEta_
track |eta| cut
Definition: QuarkoniaTrackSelector.h:36
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::RecoChargedCandidate
Definition: RecoChargedCandidate.h:15
QuarkoniaTrackSelector::minMasses_
std::vector< double > minMasses_
lower mass limits
Definition: QuarkoniaTrackSelector.h:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
QuarkoniaTrackSelector::maxMasses_
std::vector< double > maxMasses_
upper mass limits
Definition: QuarkoniaTrackSelector.h:32
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:71
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15