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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

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 }
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< double > minMasses_
lower mass limits
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
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
#define LogDebug(id)

◆ ~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.

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_2022v12_cff::track, and trackToken_.

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 }
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
bool isDebugEnabled()
std::vector< double > minMasses_
lower mass limits
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< double > maxMasses_
upper mass limits
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< reco::TrackCollection > trackToken_
double minTrackP_
track p cut
bool isValid() const
Definition: HandleBase.h:70
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:511
double minTrackPt_
track pt cut
bool checkCharge_
check opposite charge?
double maxTrackEta_
track |eta| cut
#define LogDebug(id)

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().