CMS 3D CMS Logo

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

List of all members.

Public Member Functions

 MuonMETValueMapProducer (const edm::ParameterSet &)
 ~MuonMETValueMapProducer ()

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_

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_.

                                                                                 {

    using namespace edm;
  
    produces<ValueMap<reco::MuonMETCorrectionData> >   ("muCorrData");

    //get configuration parameters
    minPt_            = iConfig.getParameter<double>("minPt"               );
    maxEta_           = iConfig.getParameter<double>("maxEta"              );
    isAlsoTkMu_       = iConfig.getParameter<bool>  ("isAlsoTkMu"          );
    maxNormChi2_      = iConfig.getParameter<double>("maxNormChi2"         );
    maxd0_            = iConfig.getParameter<double>("maxd0"               );
    minnHits_         = iConfig.getParameter<int>   ("minnHits"            );
    minnValidStaHits_ = iConfig.getParameter<int>   ("minnValidStaHits"    );
  
    beamSpotInputTag_            = iConfig.getParameter<InputTag>("beamSpotInputTag"         );
    muonInputTag_   = iConfig.getParameter<InputTag>("muonInputTag");
  
    //Parameters from earlier
    useTrackAssociatorPositions_ = iConfig.getParameter<bool>("useTrackAssociatorPositions");
    useHO_                       = iConfig.getParameter<bool>("useHO"                      );
  
    ParameterSet trackAssociatorParams =
      iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
    trackAssociatorParameters_.loadParameters(trackAssociatorParams);
    trackAssociator_.useDefaultPropagator();
  
    towerEtThreshold_ = iConfig.getParameter<double>("towerEtThreshold");
    useRecHits_     = iConfig.getParameter<bool>("useRecHits");
  
  }
MuonMETValueMapProducer::~MuonMETValueMapProducer ( )

Definition at line 78 of file MuonMETValueMapProducer.cc.

  {
 
    // do anything here that needs to be done at desctruction time
    // (e.g. close files, deallocate resources etc.)

  }

Member Function Documentation

void MuonMETValueMapProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 209 of file MuonMETValueMapProducer.cc.

  {
  }
void MuonMETValueMapProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 214 of file MuonMETValueMapProducer.cc.

                                       {
  }
void MuonMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

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_, 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_.

                                                                                     {
  
    using namespace edm;
    using namespace reco;
  
    //get the Muon collection
    Handle<View<reco::Muon> > muons;
    iEvent.getByLabel(muonInputTag_,muons);

    //use the BeamSpot
    Handle<BeamSpot> beamSpotH;
    iEvent.getByLabel(beamSpotInputTag_, beamSpotH);
    bool haveBeamSpot = true;
    if(!beamSpotH.isValid() )
      haveBeamSpot = false;

    //get the Bfield
    edm::ESHandle<MagneticField> magneticField;
    iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
    //get the B-field at the origin
    double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();

    //make a ValueMap of ints => flags for 
    //met correction. The values and meanings of the flags are :
    // flag==0 --->    The muon is not used to correct the MET by default
    // flag==1 --->    The muon is used to correct the MET. The Global pt is used. For backward compatibility only
    // flag==2 --->    The muon is used to correct the MET. The tracker pt is used. For backward compatibility only
    // flag==3 --->    The muon is used to correct the MET. The standalone pt is used. For backward compatibility only
    // In general, the flag should never be 3. You do not want to correct the MET using
    // the pt measurement from the standalone system (unless you really know what you're 
    // doing
    //flag == 4 -->    The muon was treated as a Pion. This is used for the tcMET producer
    //flag == 5 -->    The default fit is used, i.e, we get the pt from muon->pt
    std::auto_ptr<ValueMap<MuonMETCorrectionData> > vm_muCorrData(new ValueMap<MuonMETCorrectionData>());
    
    unsigned int nMuons = muons->size();
    
    std::vector<MuonMETCorrectionData> v_muCorrData;
    for (unsigned int iMu=0; iMu<nMuons; iMu++) {

      const reco::Muon* mu = &(*muons)[iMu];
      double deltax = 0.0;
      double deltay = 0.0;
        
      TrackRef mu_track;
      if(mu->isGlobalMuon()) {
        mu_track = mu->globalTrack();
      } else if(mu->isTrackerMuon()) {
        mu_track = mu->innerTrack();
      } else 
        mu_track = mu->outerTrack();
    
      TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup,
                                                          trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track),
                                                          trackAssociatorParameters_);
      MuonMETAlgo alg;
      alg.GetMuDepDeltas(mu, info,
                          useTrackAssociatorPositions_, useRecHits_,
                          useHO_, towerEtThreshold_, 
                          deltax, deltay, bfield);

    
      //now we have to figure out the flags
      MuonMETCorrectionData muMETCorrData(MuonMETCorrectionData::NotUsed, deltax, deltay);
      //have to be a global muon!
      if(!mu->isGlobalMuon()) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }
    
      //if we require that the muon be both a global muon and tkmuon
      //but the muon fails the tkmuon requirement, we fail it
      if(!mu->isTrackerMuon() && isAlsoTkMu_) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }

      //if we have gotten here, we only have muons which are both global and tracker
        
      TrackRef globTk = mu->globalTrack();
      TrackRef siTk   = mu->innerTrack();
        
      if(mu->pt() < minPt_ || fabs(mu->eta()) > maxEta_) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }
      if(globTk->chi2()/globTk->ndof() > maxNormChi2_) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }
      if(fabs(globTk->dxy(beamSpotH->position())) > fabs(maxd0_) ) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }
      if(siTk->numberOfValidHits() < minnHits_) {
        v_muCorrData.push_back(muMETCorrData);
        continue;
      }

      if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) {
         v_muCorrData.push_back(muMETCorrData);
        continue;
      }   
      //if we've gotten here. the global muon has passed all the tests
      v_muCorrData.push_back(MuonMETCorrectionData(MuonMETCorrectionData::MuonCandidateValuesUsed, deltax, deltay));
    }
    
    ValueMap<MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
     
    dataFiller.insert(muons, v_muCorrData.begin(), v_muCorrData.end());
    dataFiller.fill();

    iEvent.put(vm_muCorrData, "muCorrData");
    
  }

Member Data Documentation

Definition at line 40 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 45 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 50 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 48 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 49 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 51 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 52 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 47 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 41 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 46 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 53 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 54 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 44 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 43 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

Definition at line 42 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().