CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

WMuNuProducer Class Reference

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

List of all members.

Classes

struct  ComparePt

Public Member Functions

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

Private Member Functions

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

Private Attributes

edm::InputTag metTag_
edm::InputTag muonTag_
unsigned int nall
ComparePt ptComparator
const std::string WMuNuCollectionTag_

Detailed Description

Definition at line 31 of file WMuNuProducer.cc.


Constructor & Destructor Documentation

WMuNuProducer::WMuNuProducer ( const edm::ParameterSet cfg)

Definition at line 88 of file WMuNuProducer.cc.

                                                       :
      // Input collections
      muonTag_(cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons"))),
      metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met")))
{
  produces< WMuNuCandidateCollection >();
}
WMuNuProducer::~WMuNuProducer ( )

Definition at line 104 of file WMuNuProducer.cc.

{

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

}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 96 of file WMuNuProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 99 of file WMuNuProducer.cc.

References LogTrace.

                           {
   LogTrace("")<<"WMuNuCandidateCollection Stored in the Event";
}
void WMuNuProducer::produce ( edm::Event ev,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 113 of file WMuNuProducer.cc.

References reco::WMuNuCandidate::acop(), reco::WMuNuCandidate::eT(), edm::Event::getByLabel(), reco::WMuNuCandidate::getMuon(), reco::WMuNuCandidate::getNeutrino(), edm::Ptr< T >::isNull(), LogTrace, reco::WMuNuCandidate::massT(), CaloMET_cfi::met, metTag_, metsig::muon, muonTag_, reco::LeafCandidate::pt(), ptComparator, edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), and python::multivaluedict::sort().

                                                           {

      // Muon collection
      Handle<View<Muon> > muonCollection;
      if (!ev.getByLabel(muonTag_, muonCollection)) {
            LogError("") << ">>> Muon collection does not exist !!!";
            return;
      }
      int muonCollectionSize = muonCollection->size();

      // MET
      Handle<View<MET> > metCollection;
      if (!ev.getByLabel(metTag_, metCollection)) {
            LogError("") << ">>> MET collection does not exist !!!";
            return;
      }
      //const MET& Met = metCollection->at(0);
      edm::Ptr<reco::MET> met(metCollection,0);


      if (muonCollectionSize<1) return;
     
      auto_ptr< WMuNuCandidateCollection > WMuNuCandidates(new WMuNuCandidateCollection );


     // Fill Collection with n muons --> n W Candidates ordered by pt
 
     for (int indx=0; indx<muonCollectionSize; indx++){ 
            edm::Ptr<reco::Muon> muon(muonCollection,indx);
            if (!muon->isGlobalMuon()) continue;
            if (muon->globalTrack().isNull()) continue;
            if (muon->innerTrack().isNull()) continue;
 
      // Build WMuNuCandidate
      LogTrace("")<<"Building WMuNu Candidate!"; 
      WMuNuCandidate* WCand = new WMuNuCandidate(muon,met); 
      LogTrace("") << "\t... W mass, W_et: "<<WCand->massT()<<", "<<WCand->eT()<<"[GeV]";
      LogTrace("") << "\t... W_px, W_py: "<<WCand->px()<<", "<< WCand->py() <<"[GeV]";
      LogTrace("") << "\t... acop:  " << WCand->acop();
      LogTrace("") << "\t... Muon pt, px, py, pz: "<<WCand->getMuon().pt()<<", "<<WCand->getMuon().px()<<", "<<WCand->getMuon().py()<<", "<< WCand->getMuon().pz()<<" [GeV]";
      LogTrace("") << "\t... Met  met_et, met_px, met_py : "<<WCand->getNeutrino().pt()<<", "<<WCand->getNeutrino().px()<<", "<<WCand->getNeutrino().py()<<" [GeV]";
        WMuNuCandidates->push_back(*WCand);
       } 

      std::sort(WMuNuCandidates->begin(),WMuNuCandidates->end(),ptComparator);      

      ev.put(WMuNuCandidates);

}

Member Data Documentation

Definition at line 44 of file WMuNuProducer.cc.

Referenced by produce().

Definition at line 43 of file WMuNuProducer.cc.

Referenced by produce().

unsigned int WMuNuProducer::nall [private]

Definition at line 56 of file WMuNuProducer.cc.

Definition at line 54 of file WMuNuProducer.cc.

Referenced by produce().

const std::string WMuNuProducer::WMuNuCollectionTag_ [private]

Definition at line 45 of file WMuNuProducer.cc.