CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MuScleFitMuonProducer Class Reference

#include <MuonAnalysis/MuScleFitMuonProducer/src/MuScleFitMuonProducer.cc>

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

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

Private Attributes

edm::InputTag theMuonLabel_

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 44 of file MuScleFitMuonProducer.cc.


Constructor & Destructor Documentation

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

Definition at line 59 of file MuScleFitMuonProducer.cc.

                                                                           :
  theMuonLabel_( iConfig.getParameter<edm::InputTag>( "MuonLabel" ) )
{
  produces<reco::MuonCollection>();
}
MuScleFitMuonProducer::~MuScleFitMuonProducer ( )

Definition at line 66 of file MuScleFitMuonProducer.cc.

{
}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 123 of file MuScleFitMuonProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 129 of file MuScleFitMuonProducer.cc.

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

Implements edm::EDProducer.

Definition at line 71 of file MuScleFitMuonProducer.cc.

References allMuons_cfi::allMuons, eta(), edm::Event::getByLabel(), metsig::muon, lumiNorm::norm, phi, Pi, ExpressReco_HICollisions_FallBack::pt, edm::Event::put(), reco::LeafCandidate::setP4(), ExpressReco_HICollisions_FallBack::sigma, mathSSE::sqrt(), and theMuonLabel_.

{
  edm::Handle<reco::MuonCollection> allMuons;
  iEvent.getByLabel (theMuonLabel_, allMuons);

  std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);

  // Apply any bias and/or smearing to the events
  for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {

    double pt = muon->pt();

    // Biasing the MC such that it reproduces the data + the residual error
    double a_0 = 1.0039;
    // double a_1 = 0.;
    // // The miscalibration can be applied only for pt < 626 GeV/c
    // if( pt < -a_0*a_0/(4*a_1) ) {
    // pt = (-a_0 + sqrt(a_0*a_0 + 4*a_1*pt))/(2*a_1);
    // }
    pt = a_0*pt;

    // Smearing
    // std::cout << "smearing muon" << std::endl;
    // std::vector<double> par;
    // double * y = 0;
    TF1 G("G", "[0]*exp(-0.5*pow(x,2)/[1])", -5., 5.);
    double sigma = 0.00014; // converted from TeV^-1 to GeV^-1
    double norm = 1/(sqrt(2*TMath::Pi()));
    G.SetParameter(0,norm);
    G.SetParameter(1,1);
    // std::cout << "old pt = " << pt;
    pt = 1/(1/pt + sigma*G.GetRandom());
    // pt' = pt + sigma pt^2
    // pt = pt*(1-G.GetRandom());
    double eta = muon->eta();
    double phi = muon->phi();
    // smearFunction.smear(pt, eta, phi, y, par);
    // std::cout << " new pt = " << pt << std::endl;

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

    pOut->push_back(*newMuon);
  }

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

Member Data Documentation

Definition at line 54 of file MuScleFitMuonProducer.cc.

Referenced by produce().