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::ProductRegistryHelper

Public Member Functions

 QuarkoniaTrackSelector (const edm::ParameterSet &)
 
 ~QuarkoniaTrackSelector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::InputTag trackTag_
 tag for TrackCollection More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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 13 of file QuarkoniaTrackSelector.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file QuarkoniaTrackSelector.cc.

References checkCharge_, i, LogDebug, maxMasses_, maxTrackEta_, minMasses_, minTrackP_, minTrackPt_, muonTag_, and trackTag_.

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

16 {}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 69 of file QuarkoniaTrackSelector.cc.

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

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

Member Data Documentation

bool QuarkoniaTrackSelector::checkCharge_
private

check opposite charge?

Definition at line 26 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

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

upper mass limits

Definition at line 25 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::maxTrackEta_
private

track |eta| cut

Definition at line 29 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

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

lower mass limits

Definition at line 24 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::minTrackP_
private

track p cut

Definition at line 28 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

double QuarkoniaTrackSelector::minTrackPt_
private

track pt cut

Definition at line 27 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

edm::InputTag QuarkoniaTrackSelector::muonTag_
private

tag for RecoChargedCandidateCollection

Definition at line 22 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().

edm::InputTag QuarkoniaTrackSelector::trackTag_
private

tag for TrackCollection

Definition at line 23 of file QuarkoniaTrackSelector.h.

Referenced by produce(), and QuarkoniaTrackSelector().