CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PatJPsiProducer Class Reference

#include <Analysis/PatJPsiProducer/src/PatJPsiProducer.cc>

Inheritance diagram for PatJPsiProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

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

Private Attributes

edm::InputTag muonSrc_

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 51 of file PatJPsiProducer.cc.


Constructor & Destructor Documentation

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

Definition at line 78 of file PatJPsiProducer.cc.

                                                               :
  muonSrc_ ( iConfig.getParameter<edm::InputTag>("muonSrc") )
{
  produces<std::vector<pat::CompositeCandidate> > ();
  
}
PatJPsiProducer::~PatJPsiProducer ( )

Definition at line 86 of file PatJPsiProducer.cc.

{
 
}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 140 of file PatJPsiProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 146 of file PatJPsiProducer.cc.

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

Implements edm::EDProducer.

Definition at line 98 of file PatJPsiProducer.cc.

References reco::CompositeCandidate::addDaughter(), pat::PATObject< ObjectType >::addUserFloat(), gather_cfg::cout, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, edm::Event::getByLabel(), edm::HandleBase::isValid(), jpsi, muonSrc_, edm::Event::put(), and AddFourMomenta::set().

{

  std::auto_ptr<std::vector<pat::CompositeCandidate> > jpsiCands( new std::vector<pat::CompositeCandidate> );
  edm::Handle<edm::View<pat::Muon> > h_muons;
  iEvent.getByLabel( muonSrc_, h_muons );
  std::cout<<"valid?"<< h_muons.isValid()<<" size?"<<  h_muons->size();
  if ( h_muons.isValid() && h_muons->size() > 1 ) {

      for ( edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
                muonsEnd = h_muons->end(), imuon = muonsBegin;
            imuon != muonsEnd - 1; ++imuon ) {
          
          for ( edm::View<pat::Muon>::const_iterator jmuon = imuon + 1;
                jmuon != muonsEnd; ++jmuon ) {
              if ( imuon->charge() * jmuon->charge() < 0 ) {
                  
                  //A composite Candidate is very useful to build event hypothesis and cut on combined object information.
                  pat::CompositeCandidate jpsi;
                  jpsi.addDaughter( *imuon, "mu1");
                  jpsi.addDaughter( *jmuon, "mu2");
                  
                  AddFourMomenta addp4;
                  addp4.set( jpsi );
                  
                  double dR = reco::deltaR<pat::Muon,pat::Muon>( *imuon, *jmuon );
                  
                  // Analogue to any other PAT object we can add our own information into the object via addUserFloat/Int/Data()
                  jpsi.addUserFloat("dR", dR );
                  
                  jpsiCands->push_back( jpsi );
                  
              }
          }
      }
  }
  iEvent.put( jpsiCands );
 
}

Member Data Documentation

Definition at line 63 of file PatJPsiProducer.cc.

Referenced by produce().