Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <boost/foreach.hpp>
00015 #include <sstream>
00016
00017 #include "FWCore/Framework/interface/EDAnalyzer.h"
00018 #include "FWCore/Framework/interface/Event.h"
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020
00021 #include "DataFormats/TauReco/interface/PFTau.h"
00022 #include "DataFormats/Candidate/interface/Candidate.h"
00023
00024
00025 namespace {
00026
00027 void write(std::ostringstream& output, const reco::PFTau& tau) {
00028 output << " ------------------------------------" << std::endl;
00029 output << tau << std::endl;
00030 tau.dump(output);
00031 if (tau.pfTauTagInfoRef().isNonnull()) {
00032 output << " TTInfoJetRefID: "
00033 << tau.pfTauTagInfoRef()->pfjetRef().id() << ":"
00034 << tau.pfTauTagInfoRef()->pfjetRef().key() << std::endl;
00035 output << " TTInfoJetRef: " << *(tau.pfTauTagInfoRef()->pfjetRef());
00036 }
00037 if (tau.jetRef().isNonnull()) {
00038 output << " JetRefID: "
00039 << tau.jetRef().id() << ":"
00040 << tau.jetRef().key() << std::endl;
00041 output << " JetRef: " << *(tau.jetRef());
00042
00043 }
00044 output << std::endl;
00045 }
00046
00047 void write(std::ostringstream& output, const reco::PFJet& jet) {
00048 output << " ------------------------------------" << std::endl;
00049 output << jet << std::endl;
00050 BOOST_FOREACH(const reco::PFCandidatePtr& cand, jet.getPFConstituents()) {
00051 output << " --> " << *cand << std::endl;
00052 }
00053 output << std::endl;
00054 }
00055
00056 void write(std::ostringstream& output, const reco::Candidate& cand) {
00057 output << " ------------------------------------" << std::endl;
00058 output <<
00059 " candidate (pt/eta/phi): (" << cand.pt() << "/"
00060 << cand.eta() << "/"
00061 << cand.phi() << ")" << std::endl;
00062 output << std::endl;
00063 }
00064
00065 }
00066
00067 template<typename T>
00068 class CollectionDumper : public edm::EDAnalyzer {
00069 public:
00070 explicit CollectionDumper(const edm::ParameterSet& pset):
00071 src_(pset.getParameter<edm::InputTag>("src")),
00072 moduleName_(pset.getParameter<std::string>("@module_label")){}
00073 virtual ~CollectionDumper() {}
00074 virtual void analyze(const edm::Event& evt, const edm::EventSetup& es);
00075 private:
00076 edm::InputTag src_;
00077 std::string moduleName_;
00078 };
00079
00080 template<typename T> void
00081 CollectionDumper<T>::analyze(const edm::Event& evt, const edm::EventSetup& es) {
00082 typedef edm::View<T> TView;
00083 edm::Handle<TView> view;
00084 evt.getByLabel(src_, view);
00085
00086 std::ostringstream output;
00087 output << " * * * <" << moduleName_
00088 << "> Dump - source: [" << src_ << "]" << std::endl;
00089
00090 BOOST_FOREACH(const T& obj, *view) {
00091 write(output, obj);
00092 }
00093 std::cout << output.str();
00094 }
00095
00096 typedef CollectionDumper<reco::PFTau> RecoTauDumper;
00097 typedef CollectionDumper<reco::PFJet> PFJetDumper;
00098 typedef CollectionDumper<reco::Candidate> CandidateDumper;
00099
00100 #include "FWCore/Framework/interface/MakerMacros.h"
00101 DEFINE_FWK_MODULE(RecoTauDumper);
00102 DEFINE_FWK_MODULE(PFJetDumper);
00103 DEFINE_FWK_MODULE(CandidateDumper);