CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MuScleFitMuonProducer Class Reference

Inheritance diagram for MuScleFitMuonProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

template<class T >
std::auto_ptr< TapplyCorrection (const edm::Handle< T > &allMuons)
virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

boost::shared_ptr
< MomentumScaleCorrector
corrector_
edm::ESHandle< MuScleFitDBobjectdbObject_
unsigned long long dbObjectCacheId_
std::string dbObjectLabel_
bool patMuons_
edm::InputTag theMuonLabel_

Detailed Description

Produce a new muon collection with corrected Pt.
It is also possible to apply a smearing to the muons Pt.

Definition at line 48 of file MuScleFitMuonProducer.cc.


Constructor & Destructor Documentation

MuScleFitMuonProducer::MuScleFitMuonProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 67 of file MuScleFitMuonProducer.cc.

References patMuons_.

                                                                           :
  theMuonLabel_( iConfig.getParameter<edm::InputTag>( "MuonLabel" ) ),
  patMuons_( iConfig.getParameter<bool>( "PatMuons" ) ),
  dbObjectLabel_( iConfig.getUntrackedParameter<std::string>("DbObjectLabel", "") ),
  dbObjectCacheId_(0)
{
  if ( patMuons_ == true ) {
    produces<pat::MuonCollection>();
  } else {
    produces<reco::MuonCollection>();
  }
}
MuScleFitMuonProducer::~MuScleFitMuonProducer ( )

Definition at line 81 of file MuScleFitMuonProducer.cc.

{
}

Member Function Documentation

template<class T >
std::auto_ptr< T > MuScleFitMuonProducer::applyCorrection ( const edm::Handle< T > &  allMuons) [private]

Definition at line 87 of file MuScleFitMuonProducer.cc.

References eta, metsig::muon, and phi.

Referenced by produce().

{
  std::auto_ptr<T> pOut(new T);

  // Apply the correction and produce the new muons
  for( typename T::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {

    //std::cout << "Pt before correction = " << muon->pt() << std::endl;
    double pt = (*corrector_)(*muon);
    //std::cout << "Pt after correction = " << pt << std::endl;
    double eta = muon->eta();
    double phi = muon->phi();

    typename T::value_type * newMuon = muon->clone();
    newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );

    pOut->push_back(*newMuon);
  }
  return pOut;
}
void MuScleFitMuonProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 161 of file MuScleFitMuonProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 167 of file MuScleFitMuonProducer.cc.

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

Implements edm::EDProducer.

Definition at line 109 of file MuScleFitMuonProducer.cc.

References allMuons_cfi::allMuons, applyCorrection(), corrector_, dbObject_, dbObjectCacheId_, dbObjectLabel_, edm::EventSetup::get(), edm::Event::getByLabel(), patMuons_, edm::ESHandle< T >::product(), edm::Event::put(), and theMuonLabel_.

{
  unsigned long long dbObjectCacheId = iSetup.get<MuScleFitDBobjectRcd>().cacheIdentifier();
  if ( dbObjectCacheId != dbObjectCacheId_ ) {
    if ( dbObjectLabel_ != "" ) {
      iSetup.get<MuScleFitDBobjectRcd>().get(dbObjectLabel_, dbObject_);
    } else {
      iSetup.get<MuScleFitDBobjectRcd>().get(dbObject_);
    }
  }

  //std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
  //std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;

  // Create the corrector and set the parameters
  corrector_.reset(new MomentumScaleCorrector( dbObject_.product() ) );

  if( patMuons_ == true ) {
    edm::Handle<pat::MuonCollection> allMuons;
    iEvent.getByLabel (theMuonLabel_, allMuons);
    iEvent.put(applyCorrection(allMuons));
  }
  else {
    edm::Handle<reco::MuonCollection> allMuons;
    iEvent.getByLabel (theMuonLabel_, allMuons);
    iEvent.put(applyCorrection(allMuons));
  }

  // put into the Event
  // iEvent.put(pOut);
  // iEvent.put(applyCorrection(allMuons));
  
/*  std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);

  // Apply the correction and produce the new muons
  for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {

    double pt = (*corrector_)(*muon);
    double eta = muon->eta();
    double phi = muon->phi();

    reco::Muon * newMuon = muon->clone();
    newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );

    pOut->push_back(*newMuon);
  }
*/

}

Member Data Documentation

Definition at line 64 of file MuScleFitMuonProducer.cc.

Referenced by produce().

Definition at line 61 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_ [private]

Definition at line 63 of file MuScleFitMuonProducer.cc.

Referenced by produce().

Definition at line 62 of file MuScleFitMuonProducer.cc.

Referenced by produce().

Definition at line 60 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

Definition at line 59 of file MuScleFitMuonProducer.cc.

Referenced by produce().