CMS 3D CMS Logo

Public Member Functions | Private Attributes

PFMCTruthTreeProducer Class Reference

#include <PFMCTruthTreeProducer.h>

Inheritance diagram for PFMCTruthTreeProducer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
virtual void beginJob ()
virtual void endJob ()
 PFMCTruthTreeProducer (edm::ParameterSet const &cfg)
 ~PFMCTruthTreeProducer ()

Private Attributes

float cemfJet_
float chfJet_
int cmultiJet_
float dR_
float etaGen_
float etaJet_
TFile * file_
std::string genjets_
std::string histogramFile_
std::string jets_
TTree * mcTruthTree_
float nemfJet_
float nhfJet_
int nmultiJet_
float phiGen_
float phiJet_
float ptGen_
float ptHat_
float ptJet_
int rank_

Detailed Description

Definition at line 10 of file PFMCTruthTreeProducer.h.


Constructor & Destructor Documentation

PFMCTruthTreeProducer::PFMCTruthTreeProducer ( edm::ParameterSet const &  cfg) [explicit]

Definition at line 29 of file PFMCTruthTreeProducer.cc.

References edm::ParameterSet::getParameter().

{
  jets_          = cfg.getParameter<std::string> ("jets");
  genjets_       = cfg.getParameter<std::string> ("genjets");
  histogramFile_ = cfg.getParameter<std::string> ("histogramFile");
}
PFMCTruthTreeProducer::~PFMCTruthTreeProducer ( )

Definition at line 115 of file PFMCTruthTreeProducer.cc.

{
  delete file_;
  delete mcTruthTree_;
}

Member Function Documentation

void PFMCTruthTreeProducer::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 68 of file PFMCTruthTreeProducer.cc.

References fwrapper::jets, njet, CosmicsPD_Skims::radius, and findQualityFiles::rr.

{ 
  edm::Handle<GenJetCollection> genjets;
  edm::Handle<PFJetCollection> jets;
  edm::Handle<GenEventInfoProduct> hEventInfo;
  PFJetCollection::const_iterator i_jet,i_matched;
  GenJetCollection::const_iterator i_genjet;
  event.getByLabel (genjets_,genjets);
  event.getByLabel (jets_,jets);
  event.getByLabel("generator",hEventInfo);
  ptHat_ = hEventInfo->binningValues()[0];
  float rr;  
  int njet(0);
  if (jets->size()>0 && genjets->size()>0)
    {
      for (i_genjet = genjets->begin(); i_genjet != genjets->end(); i_genjet++)
       {    
         float rmin(99);
         for(i_jet = jets->begin();i_jet != jets->end(); i_jet++)
           {
             rr=radius(i_genjet,i_jet);
             if (rr<rmin)
               {
                 rmin = rr;
                 i_matched = i_jet;
               }
           }
         ptGen_     = i_genjet->pt();
         etaGen_    = i_genjet->eta();
         phiGen_    = i_genjet->phi();
         ptJet_     = i_matched->pt();
         etaJet_    = i_matched->eta();
         phiJet_    = i_matched->phi();
         chfJet_    = i_matched->chargedHadronEnergyFraction();
         nhfJet_    = i_matched->neutralHadronEnergyFraction();
         cemfJet_   = i_matched->chargedEmEnergyFraction();
         nemfJet_   = i_matched->neutralEmEnergyFraction();
         cmultiJet_ = i_matched->chargedMultiplicity();
         nmultiJet_ = i_matched->neutralMultiplicity();
         dR_        = rmin;
         rank_      = njet;     
         mcTruthTree_->Fill();
         njet++;
       }  
    }      
}
void PFMCTruthTreeProducer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 36 of file PFMCTruthTreeProducer.cc.

{
  file_          = new TFile(histogramFile_.c_str(),"RECREATE");
  mcTruthTree_   = new TTree("mcTruthTree","mcTruthTree");

  mcTruthTree_->Branch("ptJet",      &ptJet_,      "ptJet_/F");
  mcTruthTree_->Branch("ptGen",      &ptGen_,      "ptGen_/F");
  mcTruthTree_->Branch("ptHat",      &ptHat_,      "ptHat_/F");
  mcTruthTree_->Branch("chfJet",     &chfJet_,     "chfJet_/F");
  mcTruthTree_->Branch("nhfJet",     &nhfJet_,     "nhfJet_/F");
  mcTruthTree_->Branch("cemfJet",    &cemfJet_,    "cemfJet_/F");
  mcTruthTree_->Branch("nemfJet",    &nemfJet_,    "nemfJet_/F");
  mcTruthTree_->Branch("cmultiJet",  &cmultiJet_,  "cmultiJet_/I");
  mcTruthTree_->Branch("nmultiJet",  &nmultiJet_,  "nmultiJet_/I");
  mcTruthTree_->Branch("etaJet",     &etaJet_,    "etaJet_/F");
  mcTruthTree_->Branch("etaGen",     &etaGen_,     "etaGen_/F");
  mcTruthTree_->Branch("phiJet",     &phiJet_,     "phiJet_/F");
  mcTruthTree_->Branch("phiGen",     &phiGen_,     "phiGen_/F");
  mcTruthTree_->Branch("dR",         &dR_,         "dR_/F");
  mcTruthTree_->Branch("rank",       &rank_,       "rank_/I");
}
void PFMCTruthTreeProducer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file PFMCTruthTreeProducer.cc.

{
  if (file_ !=0) 
    {
      file_->cd();
      mcTruthTree_->Write();
    }
  file_ = 0;
}

Member Data Documentation

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 26 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::dR_ [private]

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

TFile* PFMCTruthTreeProducer::file_ [private]

Definition at line 23 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::genjets_ [private]

Definition at line 22 of file PFMCTruthTreeProducer.h.

Definition at line 20 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::jets_ [private]

Definition at line 21 of file PFMCTruthTreeProducer.h.

Definition at line 24 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 26 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 25 of file PFMCTruthTreeProducer.h.

Definition at line 26 of file PFMCTruthTreeProducer.h.