CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PatMCMatchingExtended Class Reference

Inheritance diagram for PatMCMatchingExtended:
edm::EDAnalyzer

List of all members.

Public Member Functions

 PatMCMatchingExtended (const edm::ParameterSet &)
 default constructor
 ~PatMCMatchingExtended ()
 default destructor

Private Member Functions

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

Private Attributes

unsigned int decayInFlight
unsigned int diffCharge
std::map< std::string, TH1F * > histContainer_
edm::InputTag muonSrc_
unsigned int noMatch
unsigned int numberMuons

Detailed Description

Definition at line 15 of file PatMCMatchingExtended.cc.


Constructor & Destructor Documentation

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

default constructor

Definition at line 55 of file PatMCMatchingExtended.cc.

PatMCMatchingExtended::~PatMCMatchingExtended ( )

default destructor

Definition at line 61 of file PatMCMatchingExtended.cc.

{
}

Member Function Documentation

void PatMCMatchingExtended::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 66 of file PatMCMatchingExtended.cc.

References gather_cfg::cout, decayInFlight, diffCharge, edm::Event::getByLabel(), histContainer_, metsig::muon, patZpeak::muons, muonSrc_, noMatch, numberMuons, and p4.

{

  // get muon collection
  edm::Handle<edm::View<pat::Muon> > muons;
  iEvent.getByLabel(muonSrc_,muons);

  for(edm::View<pat::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
    if(muon->genParticleById(0,1).isNonnull() ){
      histContainer_["DR_status1Match"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , (muon->genParticleById(0,1) )->p4() ) ); 
      histContainer_["DPt_status1Match"]->Fill(muon->pt() - (muon->genParticleById(0,1) )->pt() );
    }
    if(muon->genParticleById(0,3).isNonnull() ){
      histContainer_["DR_status3Match"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , (muon->genParticleById(0,3) )->p4() ) );
      histContainer_["DPt_status3Match"]->Fill(muon->pt() - (muon->genParticleById(0,3) )->pt() );
    }
    if(muon->genParticleById(0,-1).isNonnull() ){
      histContainer_["DR_defaultMatch"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , (muon->genParticleById(0,-1) )->p4() ) );
      histContainer_["DPt_defaultMatch"]->Fill(muon->pt() - (muon->genParticleById(0,-1) )->pt() );
    }
    if(muon->genParticleById(0,1).isNull() && muon->genParticleById(0,3).isNull() && muon->genParticleById(0,-1).isNull()) noMatch++;
    if(muon->genParticleById(0,1).isNull() && muon->genParticleById(0,3).isNull() && muon->genParticleById(0,-1).isNonnull())decayInFlight++;
    
    
    
    if( muon->genParticleById(-13,0, 1).isNonnull() ){
      diffCharge++;
      std::cout<<" DIFF CHARGE!!! charge gen: "<< muon->genParticleById(-13,0, true)->charge()<< " charge reco: "<< muon->charge()<<std::endl;
    }
    numberMuons++;  
  }
  
}
void PatMCMatchingExtended::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 101 of file PatMCMatchingExtended.cc.

References decayInFlight, diffCharge, histContainer_, noMatch, and numberMuons.

{
  // register to the TFileService
  edm::Service<TFileService> fs;
  
  // book histograms:
  //DR
  histContainer_["DR_defaultMatch"  ]=fs->make<TH1F>("DR_defaultMatch",   "DR_defaultMatch",     100, 0,  0.02);
  histContainer_["DR_status1Match"  ]=fs->make<TH1F>("DR_status1Match",   "DR_status1Match",     100, 0,  0.02);
  histContainer_["DR_status3Match"  ]=fs->make<TH1F>("DR_status3Match",   "DR_status3Match",     100, 0,  0.02);
  //DPT
  histContainer_["DPt_defaultMatch"  ]=fs->make<TH1F>("DPt_defaultMatch",   "DPt_defaultMatch",     10, 0,  1.2);
  histContainer_["DPt_status1Match"  ]=fs->make<TH1F>("DPt_status1Match",   "DPt_status1Match",     10, 0,  1.2);
  histContainer_["DPt_status3Match"  ]=fs->make<TH1F>("DPt_status3Match",   "DPt_status3Match",     10, 0,  1.2);
  //some counters
  diffCharge=0;
  noMatch=0;
  decayInFlight=0;
  numberMuons=0;

}
void PatMCMatchingExtended::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 124 of file PatMCMatchingExtended.cc.

References gather_cfg::cout, decayInFlight, diffCharge, noMatch, and numberMuons.

{
    std::cout<<"diffcharge: "<< diffCharge <<std::endl;
    std::cout<<"noMatch: "<<  noMatch <<std::endl;
    std::cout<<"decayInFlight: "<< decayInFlight <<std::endl;
    std::cout<<"numberMuons: "<< numberMuons <<std::endl;
}

Member Data Documentation

unsigned int PatMCMatchingExtended::decayInFlight [private]

Definition at line 44 of file PatMCMatchingExtended.cc.

Referenced by analyze(), beginJob(), and endJob().

unsigned int PatMCMatchingExtended::diffCharge [private]

Definition at line 38 of file PatMCMatchingExtended.cc.

Referenced by analyze(), beginJob(), and endJob().

std::map<std::string,TH1F*> PatMCMatchingExtended::histContainer_ [private]

Definition at line 32 of file PatMCMatchingExtended.cc.

Referenced by analyze(), and beginJob().

Definition at line 35 of file PatMCMatchingExtended.cc.

Referenced by analyze().

unsigned int PatMCMatchingExtended::noMatch [private]

Definition at line 41 of file PatMCMatchingExtended.cc.

Referenced by analyze(), beginJob(), and endJob().

unsigned int PatMCMatchingExtended::numberMuons [private]

Definition at line 47 of file PatMCMatchingExtended.cc.

Referenced by analyze(), beginJob(), and endJob().