CMS 3D CMS Logo

Public Member Functions | Private Attributes

CaloMCTruthTreeProducer Class Reference

#include <CaloMCTruthTreeProducer.h>

Inheritance diagram for CaloMCTruthTreeProducer:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Attributes

float dR_
float emfJet_
float etaGen_
float etaJet_
TFile * file_
std::string genjets_
std::string histogramFile_
std::string jets_
TTree * mcTruthTree_
float phiGen_
float phiJet_
float ptGen_
float ptHat_
float ptJet_
int rank_

Detailed Description

Definition at line 10 of file CaloMCTruthTreeProducer.h.


Constructor & Destructor Documentation

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

Definition at line 29 of file CaloMCTruthTreeProducer.cc.

References edm::ParameterSet::getParameter().

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

Definition at line 105 of file CaloMCTruthTreeProducer.cc.

{
  delete file_;
  delete mcTruthTree_;
}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 63 of file CaloMCTruthTreeProducer.cc.

References analyzePatCleaning_cfg::jets, njet, and CosmicsPD_Skims::radius.

{ 
  edm::Handle<GenJetCollection> genjets;
  edm::Handle<CaloJetCollection> jets;
  edm::Handle<GenEventInfoProduct> hEventInfo;
  CaloJetCollection::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();
         emfJet_  = i_matched->emEnergyFraction();
         dR_      = rmin;
         rank_    = njet;       
         mcTruthTree_->Fill();
         njet++;
       }  
    }      
}
void CaloMCTruthTreeProducer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 36 of file CaloMCTruthTreeProducer.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("emfJet",     &emfJet_,     "emfJet_/F");
  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 CaloMCTruthTreeProducer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file CaloMCTruthTreeProducer.cc.

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

Member Data Documentation

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 23 of file CaloMCTruthTreeProducer.h.

std::string CaloMCTruthTreeProducer::genjets_ [private]

Definition at line 22 of file CaloMCTruthTreeProducer.h.

Definition at line 20 of file CaloMCTruthTreeProducer.h.

std::string CaloMCTruthTreeProducer::jets_ [private]

Definition at line 21 of file CaloMCTruthTreeProducer.h.

Definition at line 24 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 25 of file CaloMCTruthTreeProducer.h.

Definition at line 26 of file CaloMCTruthTreeProducer.h.