CMS 3D CMS Logo

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

JetCorrectorOnTheFly< Jet > Class Template Reference

Inheritance diagram for JetCorrectorOnTheFly< Jet >:
edm::EDAnalyzer

List of all members.

Public Member Functions

 JetCorrectorOnTheFly (const edm::ParameterSet &)
 ~JetCorrectorOnTheFly ()

Private Types

typedef std::vector< JetJetCollection

Private Member Functions

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

Private Attributes

edm::Service< TFileServicefs
TH1F * mCorPt
bool mDebug
std::string mJetCorService
std::string mJetName
double mMinRawJetPt
TH1F * mRawPt

Detailed Description

template<class Jet>
class JetCorrectorOnTheFly< Jet >

Definition at line 29 of file JetCorrectorOnTheFly.cc.


Member Typedef Documentation

template<class Jet >
typedef std::vector<Jet> JetCorrectorOnTheFly< Jet >::JetCollection [private]

Definition at line 35 of file JetCorrectorOnTheFly.cc.


Constructor & Destructor Documentation

template<class Jet >
JetCorrectorOnTheFly< Jet >::JetCorrectorOnTheFly ( const edm::ParameterSet iConfig) [explicit]

Definition at line 52 of file JetCorrectorOnTheFly.cc.

References edm::ParameterSet::getParameter().

{
  mJetCorService = iConfig.getParameter<std::string> ("JetCorrectionService");
  mJetName       = iConfig.getParameter<std::string> ("JetCollectionName");
  mMinRawJetPt   = iConfig.getParameter<double> ("MinRawJetPt");
  mDebug         = iConfig.getParameter<bool> ("Debug");
}
template<class Jet >
JetCorrectorOnTheFly< Jet >::~JetCorrectorOnTheFly ( )

Definition at line 61 of file JetCorrectorOnTheFly.cc.

{
  
}

Member Function Documentation

template<class Jet >
void JetCorrectorOnTheFly< Jet >::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 67 of file JetCorrectorOnTheFly.cc.

References JetCorrector::correction(), gather_cfg::cout, edm::Event::getByLabel(), JetCorrector::getJetCorrector(), getHLTprescales::index, and analyzePatCleaning_cfg::jets.

{
  const JetCorrector* corrector = JetCorrector::getJetCorrector(mJetCorService,iSetup);
  Handle<JetCollection> jets;
  iEvent.getByLabel(mJetName,jets);

  edm::Handle<reco::VertexCollection> recVtxs;
  iEvent.getByLabel("offlinePrimaryVertices",recVtxs);
  int NPV(0);
  for(unsigned int ind=0;ind<recVtxs->size();ind++) {
    if (!((*recVtxs)[ind].isFake())) {
      NPV++;
    }
  } 
  typename JetCollection::const_iterator i_jet;
  for(i_jet = jets->begin(); i_jet != jets->end(); i_jet++) {
    int index = i_jet-jets->begin();
    edm::RefToBase<reco::Jet> jetRef(edm::Ref<JetCollection>(jets,index));
    if (i_jet->pt() < mMinRawJetPt) continue;
    //double scale = corrector->correction(i_jet->p4()); 
    double scale = corrector->correction(*i_jet,jetRef,iEvent,iSetup);
    if (mDebug) {
      std::cout<<"energy = "<<i_jet->energy()<<", "
               <<"eta = "<<i_jet->eta()<<", "
               <<"raw pt = "<<i_jet->pt()<<", "
               <<"NPV = "<<NPV<<", "
               <<"correction = "<<scale<<", "
               <<"cor pt = "<<scale*i_jet->pt()<<endl; 
    }
    mRawPt->Fill(i_jet->pt());
    mCorPt->Fill(scale*i_jet->pt());
  }


}
template<class Jet >
void JetCorrectorOnTheFly< Jet >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 105 of file JetCorrectorOnTheFly.cc.

{
  mRawPt = fs->make<TH1F>("RawJetPt","RawJetPt",1000,0,1000);
  mCorPt = fs->make<TH1F>("CorJetPt","CorJetPt",1000,0,1000);
}
template<class Jet >
void JetCorrectorOnTheFly< Jet >::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 112 of file JetCorrectorOnTheFly.cc.

{
  
}

Member Data Documentation

template<class Jet >
edm::Service<TFileService> JetCorrectorOnTheFly< Jet >::fs [private]

Definition at line 40 of file JetCorrectorOnTheFly.cc.

template<class Jet >
TH1F * JetCorrectorOnTheFly< Jet >::mCorPt [private]

Definition at line 45 of file JetCorrectorOnTheFly.cc.

template<class Jet >
bool JetCorrectorOnTheFly< Jet >::mDebug [private]

Definition at line 44 of file JetCorrectorOnTheFly.cc.

template<class Jet >
std::string JetCorrectorOnTheFly< Jet >::mJetCorService [private]

Definition at line 41 of file JetCorrectorOnTheFly.cc.

template<class Jet >
std::string JetCorrectorOnTheFly< Jet >::mJetName [private]

Definition at line 42 of file JetCorrectorOnTheFly.cc.

template<class Jet >
double JetCorrectorOnTheFly< Jet >::mMinRawJetPt [private]

Definition at line 43 of file JetCorrectorOnTheFly.cc.

template<class Jet >
TH1F* JetCorrectorOnTheFly< Jet >::mRawPt [private]

Definition at line 45 of file JetCorrectorOnTheFly.cc.