Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:35

0001 // system include files
0002 #include <memory>
0003 #include <string>
0004 #include <iostream>
0005 #include <vector>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0017 #include "DataFormats/Candidate/interface/CandMatchMap.h"
0018 
0019 using namespace std;
0020 using namespace reco;
0021 using namespace edm;
0022 
0023 class printTrackJet : public edm::EDAnalyzer {
0024 public:
0025   explicit printTrackJet(const edm::ParameterSet&);
0026   ~printTrackJet(){};
0027   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0028 
0029 private:
0030   edm::EDGetTokenT<reco::CandidateView> sourceToken_;
0031   edm::Handle<reco::CandidateView> trackJets;
0032 };
0033 
0034 printTrackJet::printTrackJet(const edm::ParameterSet& iConfig) {
0035   sourceToken_ = consumes<reco::CandidateView>(iConfig.getParameter<InputTag>("src"));
0036 }
0037 
0038 void printTrackJet::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0039   cout << "[printTrackJet] analysing event " << iEvent.id() << endl;
0040 
0041   try {
0042     iEvent.getByToken(sourceToken_, trackJets);
0043   } catch (std::exception& ce) {
0044     cerr << "[printTrackJet] caught std::exception " << ce.what() << endl;
0045     return;
0046   }
0047 
0048   cout << "************************" << endl;
0049   cout << "* TrackJetCollection  *" << endl;
0050   cout << "************************" << endl;
0051   for (CandidateView::const_iterator f = trackJets->begin(); f != trackJets->end(); f++) {
0052     printf("[printTrackJet] (pt,eta,phi) = %7.3f %6.3f %6.3f |\n", f->et(), f->eta(), f->phi());
0053 
0054     for (Candidate::const_iterator c = f->begin(); c != f->end(); c++) {
0055       printf("        [Constituents] (pt,eta,phi) = %6.2f %5.2f %5.2f|\n", c->et(), c->eta(), c->phi());
0056     }
0057   }
0058 }
0059 
0060 DEFINE_FWK_MODULE(printTrackJet);