CMS 3D CMS Logo

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 
45 using namespace edm;
46 using namespace reco;
47 using namespace std;
48 
49 //
50 // class decleration
51 
53 public:
54  explicit PFMETBenchmarkAnalyzer(const edm::ParameterSet &);
55  ~PFMETBenchmarkAnalyzer() override;
56 
57 private:
58  void beginJob() override;
59  void analyze(const edm::Event &, const edm::EventSetup &) override;
60  void endJob() override;
61  // ----------member data ---------------------------
66 };
68 
69 // neuhaus - comment
76 //
77 // constants, enums and typedefs
78 //
79 
80 //
81 // static data member definitions
82 //
83 
84 //
85 // constructors and destructor
86 //
88 
89 {
90  // now do what ever initialization is needed
91  sInputTruthLabel_tok_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<InputTag>("InputTruthLabel"));
92  sInputRecoLabel_tok_ = consumes<reco::PFMETCollection>(iConfig.getParameter<InputTag>("InputRecoLabel"));
93  sInputCaloLabel_tok_ = consumes<reco::CaloMETCollection>(iConfig.getParameter<InputTag>("InputCaloLabel"));
94  sInputTCLabel_tok_ = consumes<reco::METCollection>(iConfig.getParameter<InputTag>("InputTCLabel"));
95  OutputFileName = iConfig.getUntrackedParameter<string>("OutputFile");
96  pfmBenchmarkDebug = iConfig.getParameter<bool>("pfjBenchmarkDebug");
97  xplotAgainstReco = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
98  xbenchmarkLabel_ = iConfig.getParameter<string>("BenchmarkLabel");
100 
101  PFMETBenchmark_.setup(OutputFileName, pfmBenchmarkDebug, xplotAgainstReco, xbenchmarkLabel_, xdbe_);
102 }
103 
105  // do anything here that needs to be done at desctruction time
106  // (e.g. close files, deallocate resources etc.)
107 }
108 
109 //
110 // member functions
111 //
112 
113 // ------------ method called to for each event ------------
115  // get gen jet collection
117  bool isGen = iEvent.getByToken(sInputTruthLabel_tok_, genparticles);
118  if (!isGen) {
119  std::cout << "Warning : no Gen Particles in input !" << std::endl;
120  return;
121  }
122 
123  // get rec PFMet collection
125  bool isReco = iEvent.getByToken(sInputRecoLabel_tok_, pfmets);
126  if (!isReco) {
127  std::cout << "Warning : no PF MET in input !" << std::endl;
128  return;
129  }
130 
131  // get rec TCMet collection
132  Handle<METCollection> tcmets;
133  bool isTC = iEvent.getByToken(sInputTCLabel_tok_, tcmets);
134  if (!isTC) {
135  std::cout << "Warning : no TC MET in input !" << std::endl;
136  return;
137  }
138 
139  Handle<CaloMETCollection> calomets;
140  bool isCalo = iEvent.getByToken(sInputCaloLabel_tok_, calomets);
141  if (!isCalo) {
142  std::cout << "Warning : no Calo MET in input !" << std::endl;
143  return;
144  }
145 
146  // Analyse (no "z" in "analyse" : we are in Europe, dammit!)
147  PFMETBenchmark_.process(*pfmets, *genparticles, *calomets, *tcmets);
148 }
149 
150 // ------------ method called once each job just before starting event loop
151 // ------------
153 
154 // ------------ method called once each job just after ending the event loop
155 // ------------
157  // PFMETBenchmark_.save();
158  PFMETBenchmark_.analyse();
159  PFMETBenchmark_.write();
160 }
161 
162 // define this as a plug-in
string OutputFileName
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void setup(std::string Filename, bool debug, bool plotAgainstReco=false, std::string benchmarkLabel_="ParticleFlow", DQMStore *dbe_store=0)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:14
PFMETBenchmark PFMETBenchmark_
PFJet Benchmark.
void process(const reco::PFMETCollection &, const reco::GenParticleCollection &, const reco::CaloMETCollection &, const reco::METCollection &)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::METCollection > sInputTCLabel_tok_
DQMStore * xdbe_
edm::EDGetTokenT< reco::PFMETCollection > sInputRecoLabel_tok_
edm::EDGetTokenT< reco::CaloMETCollection > sInputCaloLabel_tok_
edm::EDGetTokenT< reco::GenParticleCollection > sInputTruthLabel_tok_
fixed size matrix
HLT enums.
string xbenchmarkLabel_
bool xplotAgainstReco
bool pfmBenchmarkDebug
PFMETBenchmarkAnalyzer(const edm::ParameterSet &)