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
QuarkoniaTrackSelector Class Reference

#include <QuarkoniaTrackSelector.h>

Inheritance diagram for QuarkoniaTrackSelector:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

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

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

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::RecoChargedCandidateCollection
muonToken_
 
edm::InputTag trackTag_
 tag for TrackCollection More...
 
edm::EDGetTokenT
< reco::TrackCollection
trackToken_
 

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

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_, i, LogDebug, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, muonTag_, muonToken_, edmStreamStallGrapher::stream, 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
int i
Definition: DBlmapReader.cc:9
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 ( )
inline

Definition at line 21 of file QuarkoniaTrackSelector.h.

21 {}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 71 of file QuarkoniaTrackSelector.cc.

References reco::TrackBase::charge(), reco::LeafCandidate::charge(), checkCharge_, reco::TrackBase::eta(), reco::LeafCandidate::eta(), spr::find(), edm::Event::getByToken(), i, edm::isDebugEnabled(), edm::HandleBase::isValid(), j, LogDebug, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, metsig::muon, muonToken_, reco::TrackBase::p(), reco::LeafCandidate::p(), reco::LeafCandidate::p4(), reco::TrackBase::pt(), reco::LeafCandidate::pt(), edm::Event::put(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), mathSSE::sqrt(), edmStreamStallGrapher::stream, and trackToken_.

72 {
73  //
74  // the product
75  //
76  std::auto_ptr<reco::TrackCollection> product(new 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(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(product);
178 }
#define LogDebug(id)
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
virtual double p() const GCC11_FINAL
magnitude of momentum vector
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< double > minMasses_
lower mass limits
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:131
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< double > maxMasses_
upper mass limits
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:129
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:76
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
edm::EDGetTokenT< reco::TrackCollection > trackToken_
double minTrackP_
track p cut
virtual int charge() const GCC11_FINAL
electric charge
int charge() const
track electric charge
Definition: TrackBase.h:111
virtual float pt() const GCC11_FINAL
transverse momentum
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
double minTrackPt_
track pt cut
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:133
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().