CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFMETBenchmarkAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package:
4 // Class: PFMETBenchmarkAnalyzer.cc
5 //
14 //
15 // Original Author: Michel Della Negra
16 // Created: Wed Jan 23 10:11:13 CET 2008
17 // Extensions by Joanna Weng
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
44 using namespace edm;
45 using namespace reco;
46 using namespace std;
47 
48 //
49 // class decleration
50 
52 public:
55 
56  explicit PFMETBenchmarkAnalyzer(const edm::ParameterSet &);
57  ~PFMETBenchmarkAnalyzer() override;
58 
59 private:
60  void beginJob() override;
61  void analyze(const edm::Event &, const edm::EventSetup &) override;
62  void endJob() override;
63  // ----------member data ---------------------------
68 };
70 
71 // neuhaus - comment
78 //
79 // constants, enums and typedefs
80 //
81 
82 //
83 // static data member definitions
84 //
85 
86 //
87 // constructors and destructor
88 //
90 
91 {
92  // now do what ever initialization is needed
93  sInputTruthLabel_tok_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<InputTag>("InputTruthLabel"));
94  sInputRecoLabel_tok_ = consumes<reco::PFMETCollection>(iConfig.getParameter<InputTag>("InputRecoLabel"));
95  sInputCaloLabel_tok_ = consumes<reco::CaloMETCollection>(iConfig.getParameter<InputTag>("InputCaloLabel"));
96  sInputTCLabel_tok_ = consumes<reco::METCollection>(iConfig.getParameter<InputTag>("InputTCLabel"));
97  OutputFileName = iConfig.getUntrackedParameter<string>("OutputFile");
98  pfmBenchmarkDebug = iConfig.getParameter<bool>("pfjBenchmarkDebug");
99  xplotAgainstReco = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
100  xbenchmarkLabel_ = iConfig.getParameter<string>("BenchmarkLabel");
102 
103  PFMETBenchmark_.setup(OutputFileName, pfmBenchmarkDebug, xplotAgainstReco, xbenchmarkLabel_, xdbe_);
104 }
105 
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 }
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to for each event ------------
117  // get gen jet collection
118  Handle<GenParticleCollection> genparticles;
119  bool isGen = iEvent.getByToken(sInputTruthLabel_tok_, genparticles);
120  if (!isGen) {
121  std::cout << "Warning : no Gen Particles in input !" << std::endl;
122  return;
123  }
124 
125  // get rec PFMet collection
127  bool isReco = iEvent.getByToken(sInputRecoLabel_tok_, pfmets);
128  if (!isReco) {
129  std::cout << "Warning : no PF MET in input !" << std::endl;
130  return;
131  }
132 
133  // get rec TCMet collection
134  Handle<METCollection> tcmets;
135  bool isTC = iEvent.getByToken(sInputTCLabel_tok_, tcmets);
136  if (!isTC) {
137  std::cout << "Warning : no TC MET in input !" << std::endl;
138  return;
139  }
140 
141  Handle<CaloMETCollection> calomets;
142  bool isCalo = iEvent.getByToken(sInputCaloLabel_tok_, calomets);
143  if (!isCalo) {
144  std::cout << "Warning : no Calo MET in input !" << std::endl;
145  return;
146  }
147 
148  // Analyse (no "z" in "analyse" : we are in Europe, dammit!)
149  PFMETBenchmark_.process(*pfmets, *genparticles, *calomets, *tcmets);
150 }
151 
152 // ------------ method called once each job just before starting event loop
153 // ------------
155 
156 // ------------ method called once each job just after ending the event loop
157 // ------------
159  // PFMETBenchmark_.save();
162 }
163 
164 // define this as a plug-in
string OutputFileName
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &, const edm::EventSetup &) override
dqm::legacy::DQMStore DQMStore
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:14
dqm::legacy::MonitorElement MonitorElement
PFMETBenchmark PFMETBenchmark_
PFJet Benchmark.
void process(const reco::PFMETCollection &, const reco::GenParticleCollection &, const reco::CaloMETCollection &, const reco::METCollection &)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::METCollection > sInputTCLabel_tok_
edm::EDGetTokenT< reco::PFMETCollection > sInputRecoLabel_tok_
edm::EDGetTokenT< reco::CaloMETCollection > sInputCaloLabel_tok_
edm::EDGetTokenT< reco::GenParticleCollection > sInputTruthLabel_tok_
dqm::legacy::DQMStore * xdbe_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setup(std::string Filename, bool debug, bool plotAgainstReco=false, std::string benchmarkLabel_="ParticleFlow", DQMStore *dbe_store=nullptr)
string xbenchmarkLabel_
bool xplotAgainstReco
bool pfmBenchmarkDebug
tuple cout
Definition: gather_cfg.py:144
PFMETBenchmarkAnalyzer(const edm::ParameterSet &)