File indexing completed on 2024-04-06 12:19:23
0001
0002 #include <memory>
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <string>
0006 #include <cmath>
0007 #include <vector>
0008
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "DataFormats/Common/interface/Ref.h"
0013 #include "DataFormats/JetReco/interface/Jet.h"
0014 #include "DataFormats/JetReco/interface/GenJet.h"
0015
0016 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0017 #include "DataFormats/JetReco/interface/BasicJet.h"
0018 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "DataFormats/Common/interface/Handle.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023
0024 #include "JetMETCorrections/JetVertexAssociation/test/AnalysisJV.h"
0025
0026 using namespace edm;
0027 using namespace std;
0028 using namespace reco;
0029
0030 AnalysisJV::AnalysisJV(const edm::ParameterSet& pset)
0031 : fOutputFileName(pset.getUntrackedParameter<string>("HistOutFile", std::string("jv_analysis.root"))),
0032 fResult1Token(consumes<ResultCollection1>(edm::InputTag("jetvertex", "Var"))),
0033 fResult2Token(consumes<ResultCollection2>(edm::InputTag("jetvertex", "JetType"))),
0034 fCaloJetsToken(consumes<CaloJetCollection>(edm::InputTag("iterativeCone5CaloJets"))) {}
0035
0036 AnalysisJV::~AnalysisJV() {}
0037
0038 void AnalysisJV::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0039 cout << "----------------------------" << endl;
0040
0041 Handle<ResultCollection1> JV_alpha;
0042 iEvent.getByToken(fResult1Token, JV_alpha);
0043
0044 Handle<ResultCollection2> JV_jet_type;
0045 iEvent.getByToken(fResult2Token, JV_jet_type);
0046
0047 Handle<CaloJetCollection> CaloIconeJetsHandle;
0048 iEvent.getByToken(fCaloJetsToken, CaloIconeJetsHandle);
0049
0050 if (CaloIconeJetsHandle->size()) {
0051 ResultCollection1::const_iterator it_jv1 = JV_alpha->begin();
0052 ResultCollection2::const_iterator it_jv2 = JV_jet_type->begin();
0053 for (CaloJetCollection::const_iterator it = CaloIconeJetsHandle->begin(); it != CaloIconeJetsHandle->end(); it++) {
0054 if (*it_jv2)
0055 cout << "Jet: Et = " << it->pt() << " - true jet" << endl;
0056 else
0057 cout << "Jet: Et = " << it->pt() << " - 'fake' jet" << endl;
0058
0059 fHistAlpha->Fill(*it_jv1);
0060 it_jv1++;
0061 it_jv2++;
0062 }
0063 }
0064 }
0065
0066 void AnalysisJV::beginJob() {
0067 fOutputFile = new TFile(fOutputFileName.c_str(), "RECREATE");
0068 fHistAlpha = new TH1D("HistAlpha", "", 30, 0., 1.5);
0069 }
0070
0071 void AnalysisJV::endJob() {
0072 fOutputFile->Write();
0073 fOutputFile->Close();
0074 delete fOutputFile;
0075
0076 return;
0077 }
0078
0079
0080 DEFINE_FWK_MODULE(AnalysisJV);