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
cms::MuonMETValueMapProducer Class Reference

#include <MuonMETValueMapProducer.h>

Inheritance diagram for cms::MuonMETValueMapProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 MuonMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonMETValueMapProducer ()
 
- 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 beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag beamSpotInputTag_
 
bool isAlsoTkMu_
 
double maxd0_
 
double maxEta_
 
double maxNormChi2_
 
int minnHits_
 
int minnValidStaHits_
 
double minPt_
 
edm::InputTag muonInputTag_
 
double towerEtThreshold_
 
TrackDetectorAssociator trackAssociator_
 
TrackAssociatorParameters trackAssociatorParameters_
 
bool useHO_
 
bool useRecHits_
 
bool useTrackAssociatorPositions_
 

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)
 
static void prevalidate (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

Definition at line 28 of file MuonMETValueMapProducer.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file MuonMETValueMapProducer.cc.

References beamSpotInputTag_, edm::ParameterSet::getParameter(), isAlsoTkMu_, TrackAssociatorParameters::loadParameters(), maxd0_, maxEta_, maxNormChi2_, minnHits_, minnValidStaHits_, minPt_, muonInputTag_, towerEtThreshold_, trackAssociator_, trackAssociatorParameters_, TrackDetectorAssociator::useDefaultPropagator(), useHO_, useRecHits_, and useTrackAssociatorPositions_.

45  {
46 
47  using namespace edm;
48 
49  produces<ValueMap<reco::MuonMETCorrectionData> > ("muCorrData");
50 
51  //get configuration parameters
52  minPt_ = iConfig.getParameter<double>("minPt" );
53  maxEta_ = iConfig.getParameter<double>("maxEta" );
54  isAlsoTkMu_ = iConfig.getParameter<bool> ("isAlsoTkMu" );
55  maxNormChi2_ = iConfig.getParameter<double>("maxNormChi2" );
56  maxd0_ = iConfig.getParameter<double>("maxd0" );
57  minnHits_ = iConfig.getParameter<int> ("minnHits" );
58  minnValidStaHits_ = iConfig.getParameter<int> ("minnValidStaHits" );
59 
60  beamSpotInputTag_ = iConfig.getParameter<InputTag>("beamSpotInputTag" );
61  muonInputTag_ = iConfig.getParameter<InputTag>("muonInputTag");
62 
63  //Parameters from earlier
64  useTrackAssociatorPositions_ = iConfig.getParameter<bool>("useTrackAssociatorPositions");
65  useHO_ = iConfig.getParameter<bool>("useHO" );
66 
67  ParameterSet trackAssociatorParams =
68  iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
69  trackAssociatorParameters_.loadParameters(trackAssociatorParams);
71 
72  towerEtThreshold_ = iConfig.getParameter<double>("towerEtThreshold");
73  useRecHits_ = iConfig.getParameter<bool>("useRecHits");
74 
75  }
T getParameter(std::string const &) const
void useDefaultPropagator()
use the default propagator
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssociatorParameters_
void loadParameters(const edm::ParameterSet &)
MuonMETValueMapProducer::~MuonMETValueMapProducer ( )

Definition at line 78 of file MuonMETValueMapProducer.cc.

79  {
80 
81  // do anything here that needs to be done at desctruction time
82  // (e.g. close files, deallocate resources etc.)
83 
84  }

Member Function Documentation

void MuonMETValueMapProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 206 of file MuonMETValueMapProducer.cc.

207  {
208  }
void MuonMETValueMapProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 211 of file MuonMETValueMapProducer.cc.

211  {
212  }
void MuonMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 92 of file MuonMETValueMapProducer.cc.

References TrackDetectorAssociator::associate(), beamSpotInputTag_, reco::LeafCandidate::eta(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), TrackDetectorAssociator::getFreeTrajectoryState(), MuonMETAlgo::GetMuDepDeltas(), reco::Muon::globalTrack(), info, reco::Muon::innerTrack(), edm::helper::Filler< Map >::insert(), isAlsoTkMu_, reco::Muon::isGlobalMuon(), reco::Muon::isTrackerMuon(), maxd0_, maxEta_, maxNormChi2_, minnHits_, minnValidStaHits_, minPt_, RPCpg::mu, muonInputTag_, patZpeak::muons, reco::Muon::outerTrack(), reco::LeafCandidate::pt(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, towerEtThreshold_, trackAssociator_, trackAssociatorParameters_, useHO_, useRecHits_, and useTrackAssociatorPositions_.

92  {
93 
94  using namespace edm;
95  using namespace reco;
96 
97  //get the Muon collection
100 
101  //use the BeamSpot
102  Handle<BeamSpot> beamSpotH;
103  iEvent.getByLabel(beamSpotInputTag_, beamSpotH);
104 
105  //get the Bfield
106  edm::ESHandle<MagneticField> magneticField;
107  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
108  //get the B-field at the origin
109  double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
110 
111  //make a ValueMap of ints => flags for
112  //met correction. The values and meanings of the flags are :
113  // flag==0 ---> The muon is not used to correct the MET by default
114  // flag==1 ---> The muon is used to correct the MET. The Global pt is used. For backward compatibility only
115  // flag==2 ---> The muon is used to correct the MET. The tracker pt is used. For backward compatibility only
116  // flag==3 ---> The muon is used to correct the MET. The standalone pt is used. For backward compatibility only
117  // In general, the flag should never be 3. You do not want to correct the MET using
118  // the pt measurement from the standalone system (unless you really know what you're
119  // doing
120  //flag == 4 --> The muon was treated as a Pion. This is used for the tcMET producer
121  //flag == 5 --> The default fit is used, i.e, we get the pt from muon->pt
122  std::auto_ptr<ValueMap<MuonMETCorrectionData> > vm_muCorrData(new ValueMap<MuonMETCorrectionData>());
123 
124  unsigned int nMuons = muons->size();
125 
126  std::vector<MuonMETCorrectionData> v_muCorrData;
127  for (unsigned int iMu=0; iMu<nMuons; iMu++) {
128 
129  const reco::Muon* mu = &(*muons)[iMu];
130  double deltax = 0.0;
131  double deltay = 0.0;
132 
133  TrackRef mu_track;
134  if(mu->isGlobalMuon()) {
135  mu_track = mu->globalTrack();
136  } else if(mu->isTrackerMuon()) {
137  mu_track = mu->innerTrack();
138  } else
139  mu_track = mu->outerTrack();
140 
142  trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track),
144  MuonMETAlgo alg;
145  alg.GetMuDepDeltas(mu, info,
148  deltax, deltay, bfield);
149 
150 
151  //now we have to figure out the flags
152  MuonMETCorrectionData muMETCorrData(MuonMETCorrectionData::NotUsed, deltax, deltay);
153  //have to be a global muon!
154  if(!mu->isGlobalMuon()) {
155  v_muCorrData.push_back(muMETCorrData);
156  continue;
157  }
158 
159  //if we require that the muon be both a global muon and tkmuon
160  //but the muon fails the tkmuon requirement, we fail it
161  if(!mu->isTrackerMuon() && isAlsoTkMu_) {
162  v_muCorrData.push_back(muMETCorrData);
163  continue;
164  }
165 
166  //if we have gotten here, we only have muons which are both global and tracker
167 
168  TrackRef globTk = mu->globalTrack();
169  TrackRef siTk = mu->innerTrack();
170 
171  if(mu->pt() < minPt_ || fabs(mu->eta()) > maxEta_) {
172  v_muCorrData.push_back(muMETCorrData);
173  continue;
174  }
175  if(globTk->chi2()/globTk->ndof() > maxNormChi2_) {
176  v_muCorrData.push_back(muMETCorrData);
177  continue;
178  }
179  if(fabs(globTk->dxy(beamSpotH->position())) > fabs(maxd0_) ) {
180  v_muCorrData.push_back(muMETCorrData);
181  continue;
182  }
183  if(siTk->numberOfValidHits() < minnHits_) {
184  v_muCorrData.push_back(muMETCorrData);
185  continue;
186  }
187 
188  if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) {
189  v_muCorrData.push_back(muMETCorrData);
190  continue;
191  }
192  //if we've gotten here. the global muon has passed all the tests
193  v_muCorrData.push_back(MuonMETCorrectionData(MuonMETCorrectionData::MuonCandidateValuesUsed, deltax, deltay));
194  }
195 
196  ValueMap<MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
197 
198  dataFiller.insert(muons, v_muCorrData.begin(), v_muCorrData.end());
199  dataFiller.fill();
200 
201  iEvent.put(vm_muCorrData, "muCorrData");
202 
203  }
virtual TrackRef innerTrack() const
Definition: Muon.h:49
bool isTrackerMuon() const
Definition: Muon.h:212
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool isGlobalMuon() const
Definition: Muon.h:211
TrackDetectorAssociator trackAssociator_
virtual double eta() const
momentum pseudorapidity
void GetMuDepDeltas(const reco::Muon *inputMuon, TrackDetMatchInfo &info, bool useTrackAssociatorPositions, bool useRecHits, bool useHO, double towerEtThreshold, double &deltax, double &deltay, double Bfield)
Definition: MuonMETAlgo.cc:102
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
TrackAssociatorParameters trackAssociatorParameters_
const int mu
Definition: Constants.h:23
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
virtual double pt() const
transverse momentum
const T & get() const
Definition: EventSetup.h:55
tuple muons
Definition: patZpeak.py:38
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:55

Member Data Documentation

edm::InputTag cms::MuonMETValueMapProducer::beamSpotInputTag_
private

Definition at line 40 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::isAlsoTkMu_
private

Definition at line 45 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::maxd0_
private

Definition at line 50 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::maxEta_
private

Definition at line 48 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::maxNormChi2_
private

Definition at line 49 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

int cms::MuonMETValueMapProducer::minnHits_
private

Definition at line 51 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

int cms::MuonMETValueMapProducer::minnValidStaHits_
private

Definition at line 52 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::minPt_
private

Definition at line 47 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

edm::InputTag cms::MuonMETValueMapProducer::muonInputTag_
private

Definition at line 41 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::towerEtThreshold_
private

Definition at line 46 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

TrackDetectorAssociator cms::MuonMETValueMapProducer::trackAssociator_
private

Definition at line 53 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

TrackAssociatorParameters cms::MuonMETValueMapProducer::trackAssociatorParameters_
private

Definition at line 54 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::useHO_
private

Definition at line 44 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::useRecHits_
private

Definition at line 43 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::useTrackAssociatorPositions_
private

Definition at line 42 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().