CMS 3D CMS Logo

RecoTauDumper.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: RecoTauDumper.cc
5  *
6  * Description: Dump information about reco::PFTaus
7  *
8  * Author: Evan K. Friis, UC Davis
9  *
10  *
11  * =====================================================================================
12  */
13 #include <sstream>
14 
18 
21 
22 // Methods to write the different types
23 namespace {
24 
25 void write(std::ostringstream& output, const reco::PFTau& tau) {
26  output << " ------------------------------------" << std::endl;
27  output << tau << std::endl;
28  tau.dump(output);
29  if (tau.pfTauTagInfoRef().isNonnull()) {
30  output << " TTInfoJetRefID: "
31  << tau.pfTauTagInfoRef()->pfjetRef().id() << ":"
32  << tau.pfTauTagInfoRef()->pfjetRef().key() << std::endl;
33  output << " TTInfoJetRef: " << *(tau.pfTauTagInfoRef()->pfjetRef());
34  }
35  if (tau.jetRef().isNonnull()) {
36  output << " JetRefID: "
37  << tau.jetRef().id() << ":"
38  << tau.jetRef().key() << std::endl;
39  output << " JetRef: " << *(tau.jetRef());
40 
41  }
42  output << std::endl;
43 }
44 
45 void write(std::ostringstream& output, const reco::PFJet& jet) {
46  output << " ------------------------------------" << std::endl;
47  output << jet << std::endl;
48  for(auto const& cand : jet.getPFConstituents()) {
49  output << " --> " << *cand << std::endl;
50  }
51  output << std::endl;
52 }
53 
54 void write(std::ostringstream& output, const reco::Candidate& cand) {
55  output << " ------------------------------------" << std::endl;
56  output <<
57  " candidate (pt/eta/phi): (" << cand.pt() << "/"
58  << cand.eta() << "/"
59  << cand.phi() << ")" << std::endl;
60  output << std::endl;
61 }
62 
63 }
64 
65 template<typename T>
67  public:
69  src_(pset.getParameter<edm::InputTag>("src")),
70  moduleName_(pset.getParameter<std::string>("@module_label")){}
71  ~CollectionDumper() override {}
72  void analyze(const edm::Event& evt, const edm::EventSetup& es) override;
73  private:
76 };
77 
78 template<typename T> void
80  typedef edm::View<T> TView;
81  edm::Handle<TView> view;
82  evt.getByLabel(src_, view);
83 
84  std::ostringstream output;
85  output << " * * * <" << moduleName_
86  << "> Dump - source: [" << src_ << "]" << std::endl;
87 
88  for(auto const& obj : *view) {
89  write(output, obj);
90  }
91  std::cout << output.str();
92 }
93 
97 
99 DEFINE_FWK_MODULE(RecoTauDumper);
100 DEFINE_FWK_MODULE(PFJetDumper);
101 DEFINE_FWK_MODULE(CandidateDumper);
std::string moduleName_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
const PFJetRef & jetRef() const
Definition: PFTau.cc:58
void analyze(const edm::Event &evt, const edm::EventSetup &es) override
CollectionDumper(const edm::ParameterSet &pset)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CollectionDumper< reco::Candidate > CandidateDumper
~CollectionDumper() override
key_type key() const
Accessor for product key.
Definition: Ref.h:265
Jets made from PFObjects.
Definition: PFJet.h:21
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
edm::InputTag src_
void dump(std::ostream &out=std::cout) const
prints information on this PFTau
Definition: PFTau.cc:276
CollectionDumper< reco::PFTau > RecoTauDumper
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
const PFTauTagInfoRef & pfTauTagInfoRef() const
Definition: PFTau.cc:61
CollectionDumper< reco::PFJet > PFJetDumper
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
HLT enums.
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:52
def write(self, setup)
virtual double phi() const =0
momentum azimuthal angle