// GoniJetPlots.cc
// Description:  Example of simple EDAnalyzer for jets.
// Author: Robert M. Harris
// Date:  28 - August - 2006
// Modified by seogoni
// Date: 7 Mar 2010
// 
#include "RecoJets/JetAnalyzers/interface/GoniJetPlots.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/JetReco/interface/JetID.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include 
#include 
#include 
#include 
#include 
using namespace edm;
using namespace reco;
using namespace std;
  
// Get the algorithm of the jet collections we will read from the .cfg file 
// which defines the value of the strings CaloJetAlgorithm and GenJetAlgorithm.
GoniJetPlots::GoniJetPlots( const ParameterSet & cfg ) :
  //CaloJetAlgorithm( cfg.getParameter( "CaloJetAlgorithm" ) ), 
  CaloJetAlgorithm( cfg.getParameter( "CaloJetAlgorithm" ) )
  //GenJetAlgorithm( cfg.getParameter( "GenJetAlgorithm" ) )
  {
}

//void GoniJetPlots::beginJob( const EventSetup & ) {
void GoniJetPlots::beginJob() {

  // Open the histogram file and book some associated histograms
  m_file=new TFile("CaloJetPlots.root","RECREATE");
  const bool oldAddDir = TH1::AddDirectoryStatus();
  TH1::AddDirectory(true);
  jpe = new TH1F( "JetsPerEvent", "The number of jets per event",50,0,50);
  sjpe = new TH1F( "SJetsPerEvent", "The number of selected jets per event",10,0,10);
  nEvent = new TH1F( "nEvent","The number of events which satisfied cut",10,1,10);
  h_ptCal =  new TH1F( "ptCal",  "p_{T} of CaloJets", 100, 0, 100 );
  h_etaCal = new TH1F( "etaCal", "#eta of  CaloJets", 120, -6, 6 );
  h_phiCal = new TH1F( "phiCal", "#phi of  CaloJets", 100, -M_PI, M_PI );
  emfCal = new TH1F("emfCal","EMF of CaloJets", 100,-1.2, 1.2);
  fHPDCal = new TH1F("fHPD","energy fraction of HPD",100,0,1.2);
  fRBXCal = new TH1F("fRBX","energy fraction of RBX",100,0,1.2);
  n90HitsCal = new TH1F("n90Hits","Number of 90RecHit",25,0,25);
  TH1::AddDirectory(oldAddDir);

}

void GoniJetPlots::analyze( const Event& evt, const EventSetup& es ) {

  // JetID of CaloJet collection
  Handle > jetID;
  evt.getByLabel("ak5JetID",jetID);
  jetID->begin();

  //Get the CaloJet collection
  Handle CaloJets;
  evt.getByLabel( CaloJetAlgorithm, CaloJets );
  //  std::cout << CaloJets->size() << std::endl; 

  int jetInd = 0;
  int selected_njet =0;
  int NEvt=0;
  bool passed=false;

  //Loop over the two leading CaloJets and fill some histograms
  //for( CaloJetCollection::const_iterator cal = CaloJets->begin(); cal != CaloJets->end() && jetInd<2; ++ cal ) {

  // Loop over the all CaloJets and fill some histograms by seogoni
  for( CaloJetCollection::const_iterator cal = CaloJets->begin(); cal != CaloJets->end() ; ++ cal ) {
     //std::cout << "CALO JET #" << jetInd << std::endl << cal->print() << std::endl;
    RefToBase jetRef(Ref (CaloJets,jetInd));

    double fhpd    = (*jetID)[jetRef].fHPD;
    double frbx    = (*jetID)[jetRef].fRBX;
    double n90hits = (*jetID)[jetRef].n90Hits;
    double pt_     = cal->pt();
    double eta_    = cal ->eta();
    double emf_    = cal ->emEnergyFraction();
    //if(pt_>10) { 
    if(pt_ >10 && (eta_>-2.6 && eta_<2.6) ){
    //if(pt_ > 10 && (eta_ > -2.6 && eta_ < 2.6) && (emf_ > 0.01 && emf_ < 0.98)){ 
    //if(pt_ > 10 && (eta_ > -2.6 && eta_ < 2.6) && (emf_ > 0.01 && emf_ < 0.98) && fhpd < 0.98 && frbx < 0.98){ 
    //if(pt_ > 10 && (eta_ >= -2.6 && eta_ <= 2.6) && (emf_ > 0.01 && emf_ < 0.98) && fhpd < 0.98 && frbx < 0.98 && n90hits > 4 ){ 
      h_ptCal->Fill( cal->pt() );
      h_etaCal->Fill( cal->eta() );
      h_phiCal->Fill( cal->phi() );
      emfCal->Fill(cal->emEnergyFraction());
      fHPDCal->Fill(fhpd);
      fRBXCal->Fill(frbx);
      n90HitsCal->Fill(n90hits);
      selected_njet++;
      passed=true;
    }
    jetInd++;
  }

  if(passed == true){
    NEvt++;
    nEvent->Fill(NEvt);
    sjpe->Fill(selected_njet);
    int nJets = CaloJets->size();
    jpe->Fill(nJets);
  }

}

void GoniJetPlots::endJob() {

  //Write out the histogram file.
  m_file->Write();
  m_file->Close();


}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GoniJetPlots);

-- SeoKonKang - 07 Apr 2010

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2010-04-07 - SeoKonKang
 
KOREA-CMS
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding KoreaCmsWiki? Send feedback