CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

ZMuMuUserDataOneTrack Class Reference

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

List of all members.

Public Types

typedef math::XYZVector Vector

Public Member Functions

 ZMuMuUserDataOneTrack (const edm::ParameterSet &)

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

double alpha_
InputTag beamSpot_
double beta_
int counter
string hltPath_
InputTag primaryVertices_
InputTag src_
InputTag zGenParticlesMatch_

Detailed Description

Definition at line 29 of file ZMuMuOneTrackUserData.cc.


Member Typedef Documentation

Definition at line 32 of file ZMuMuOneTrackUserData.cc.


Constructor & Destructor Documentation

ZMuMuUserDataOneTrack::ZMuMuUserDataOneTrack ( const edm::ParameterSet cfg)

Definition at line 46 of file ZMuMuOneTrackUserData.cc.

                                                                      :
  src_( cfg.getParameter<InputTag>( "src" ) ),
  beamSpot_(cfg.getParameter<InputTag>( "beamSpot" ) ),
  primaryVertices_(cfg.getParameter<InputTag>( "primaryVertices" ) ),
  zGenParticlesMatch_(cfg.getParameter<InputTag>( "zGenParticlesMatch" ) ),
  alpha_(cfg.getParameter<double>("alpha") ),
  beta_(cfg.getParameter<double>("beta") ), 
  hltPath_(cfg.getParameter<std::string >("hltPath") ){
  produces<vector<pat::CompositeCandidate> >();
}

Member Function Documentation

void ZMuMuUserDataOneTrack::produce ( edm::Event evt,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 57 of file ZMuMuOneTrackUserData.cc.

References pat::PATObject< ObjectType >::addUserFloat(), beamSpot_, gather_cfg::cout, WZMuSkim_cff::dimuons, reco::Candidate::eta(), edm::Event::getByLabel(), i, edm::Ref< C, T, F >::isNonnull(), reco::Candidate::mass(), reco::Candidate::phi(), primaryVertices_, reco::Candidate::pt(), edm::Event::put(), reco::Candidate::rapidity(), src_, z, and zGenParticlesMatch_.

                                                                     {
  Handle<std::vector<reco::CompositeCandidate> > dimuons;
  evt.getByLabel(src_,dimuons);

  Handle<BeamSpot> beamSpotHandle;
  if (!evt.getByLabel(beamSpot_, beamSpotHandle)) {
    std::cout << ">>> No beam spot found !!!"<<std::endl;
  }
  
  Handle<VertexCollection> primaryVertices;  // Collection of primary Vertices
  if (!evt.getByLabel(primaryVertices_, primaryVertices)){
    std::cout << ">>> No primary vertices  found !!!"<<std::endl;
  }
  
  bool isMCMatchTrue=false;
  
  Handle<GenParticleMatch> zGenParticlesMatch;
  if(evt.getByLabel( zGenParticlesMatch_, zGenParticlesMatch )){
    isMCMatchTrue=true;
  }
  
  //cout<<"isMCMatchTrue"<<isMCMatchTrue <<endl;
  auto_ptr<vector<pat::CompositeCandidate> > dimuonColl( new vector<pat::CompositeCandidate> () );


  for (unsigned int i = 0; i< dimuons->size();++i){
    const CompositeCandidate & z = (*dimuons)[i];
    //CandidateBaseRef zRef = dimuons ->refAt(i);
    edm::Ref<std::vector<reco::CompositeCandidate> > zRef(dimuons, i);
    pat::CompositeCandidate dimuon(z);
    
    float trueMass,truePt,trueEta,truePhi,trueY;
    if (isMCMatchTrue){
      GenParticleRef trueZRef  = (*zGenParticlesMatch)[zRef];
      //CandidateRef trueZRef = trueZIter->val;
      if( trueZRef.isNonnull() ) {
        const Candidate & z = * trueZRef;
        trueMass = z.mass();
        truePt   = z.pt();
        trueEta  = z.eta();
        truePhi  = z.phi();
        trueY    = z.rapidity();
      } else {
        trueMass = -100; 
        truePt   = -100;
        trueEta  = -100;
        truePhi  = -100;
        trueY    = -100;  
      }
      
      dimuon.addUserFloat("TrueMass",trueMass);
      dimuon.addUserFloat("TruePt",truePt);
      dimuon.addUserFloat("TrueEta",trueEta);
      dimuon.addUserFloat("TruePhi",truePhi);
      dimuon.addUserFloat("TrueY",trueY);
      
    }

    dimuonColl->push_back(dimuon);
  
  }
  
  evt.put( dimuonColl);
}

Member Data Documentation

Definition at line 37 of file ZMuMuOneTrackUserData.cc.

Definition at line 36 of file ZMuMuOneTrackUserData.cc.

Referenced by produce().

double ZMuMuUserDataOneTrack::beta_ [private]

Definition at line 37 of file ZMuMuOneTrackUserData.cc.

Definition at line 39 of file ZMuMuOneTrackUserData.cc.

Definition at line 38 of file ZMuMuOneTrackUserData.cc.

Definition at line 36 of file ZMuMuOneTrackUserData.cc.

Referenced by produce().

Definition at line 36 of file ZMuMuOneTrackUserData.cc.

Referenced by produce().

Definition at line 36 of file ZMuMuOneTrackUserData.cc.

Referenced by produce().