CMS 3D CMS Logo

GenericBenchmarkAnalyzer.cc
Go to the documentation of this file.
1 // author: Mike Schmitt, University of Florida
2 // first version 11/7/2007
3 // extension: Leo Neuhaus & Joanna Weng 09.2008
4 // Performs matching and basic resolution plots of 2 candidate
5 // (or candidate based) collections
6 
22 
23 #include <algorithm>
24 #include <cmath>
25 #include <fstream>
26 #include <iostream>
27 #include <map>
28 #include <memory>
29 #include <ostream>
30 #include <vector>
31 
33 public:
35  ~GenericBenchmarkAnalyzer() override;
36 
37  void analyze(const edm::Event &, const edm::EventSetup &) override;
38  void beginJob() override;
39  void endJob() override;
40 
41 private:
42  // Inputs from Configuration File
52  double recPt_cut;
53  double minEta_cut;
54  double maxEta_cut;
55  double deltaR_cut;
56  float minDeltaEt_;
57  float maxDeltaEt_;
58  float minDeltaPhi_;
59  float maxDeltaPhi_;
61 };
62 
65 
66 using namespace reco;
67 using namespace edm;
68 using namespace std;
69 
71  inputTruthLabel_ = iConfig.getParameter<edm::InputTag>("InputTruthLabel");
72  inputRecoLabel_ = iConfig.getParameter<edm::InputTag>("InputRecoLabel");
73  outputFile_ = iConfig.getUntrackedParameter<std::string>("OutputFile");
74  benchmarkLabel_ = iConfig.getParameter<std::string>("BenchmarkLabel");
75  startFromGen_ = iConfig.getParameter<bool>("StartFromGen");
76  plotAgainstRecoQuantities_ = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
77  onlyTwoJets_ = iConfig.getParameter<bool>("OnlyTwoJets");
78  recPt_cut = iConfig.getParameter<double>("recPt");
79  minEta_cut = iConfig.getParameter<double>("minEta");
80  maxEta_cut = iConfig.getParameter<double>("maxEta");
81  deltaR_cut = iConfig.getParameter<double>("deltaRMax");
82 
83  minDeltaEt_ = iConfig.getParameter<double>("minDeltaEt");
84  maxDeltaEt_ = iConfig.getParameter<double>("maxDeltaEt");
85  minDeltaPhi_ = iConfig.getParameter<double>("minDeltaPhi");
86  maxDeltaPhi_ = iConfig.getParameter<double>("maxDeltaPhi");
87  doMetPlots_ = iConfig.getParameter<bool>("doMetPlots");
88 
89  if (!outputFile_.empty())
90  edm::LogInfo("OutputInfo") << " ParticleFLow Task histograms will be saved to '" << outputFile_.c_str() << "'";
91  else
92  edm::LogInfo("OutputInfo") << " ParticleFlow Task histograms will NOT be saved";
93 
94  myTruth_ = consumes<edm::View<reco::Candidate>>(inputTruthLabel_);
95  myReco_ = consumes<edm::View<reco::Candidate>>(inputRecoLabel_);
96 }
97 
99 
101  // get ahold of back-end interface
102  dbe_ = edm::Service<DQMStore>().operator->();
103 
104  if (dbe_) {
105  // dbe_->setVerbose(1);
106  // string path = "PFTask/Benchmarks/" + benchmarkLabel_ + "/";
107  std::string path = "ParticleFlow/" + benchmarkLabel_ + "/";
108  if (plotAgainstRecoQuantities_)
109  path += "Reco";
110  else
111  path += "Gen";
113  setup(dbe_, plotAgainstRecoQuantities_, minDeltaEt_, maxDeltaEt_, minDeltaPhi_, maxDeltaPhi_, doMetPlots_);
114  }
115 }
116 
118  // Typedefs to use views
119  typedef edm::View<reco::Candidate> candidateCollection;
120  typedef edm::View<reco::Candidate> candidateCollection;
121 
122  const candidateCollection *truth_candidates;
123  const candidateCollection *reco_candidates;
124 
125  // ==========================================================
126  // Retrieve!
127  // ==========================================================
128 
129  {
130  // Get Truth Candidates (GenCandidates, GenJets, etc.)
131  Handle<candidateCollection> truth_hnd;
132  bool isGen = iEvent.getByToken(myTruth_, truth_hnd);
133 
134  if (!isGen) {
135  std::cout << "Warning : no Gen jets in input !" << std::endl;
136  return;
137  }
138 
139  truth_candidates = truth_hnd.product();
140 
141  // Get Reco Candidates (PFlow, CaloJet, etc.)
143  bool isReco = iEvent.getByToken(myReco_, reco_hnd);
144  if (!isReco) {
145  std::cout << "Warning : no Reco jets in input !" << std::endl;
146  return;
147  }
148  reco_candidates = reco_hnd.product();
149 
150  // no longer needed with template-ized Benchmark
151  // const PFCandidateCollection *pf_candidates = reco_hnd.product();
152  // static CandidateCollection reco_storage =
153  // algo_->makeCandidateCollection(pf_candidates); reco_candidates =
154  // &reco_storage;
155  }
156  if (!truth_candidates || !reco_candidates) {
157  edm::LogInfo("OutputInfo") << " failed to retrieve data required by ParticleFlow Task";
158  edm::LogInfo("OutputInfo") << " ParticleFlow Task cannot continue...!";
159  return;
160  }
161 
162  // ==========================================================
163  // Analyze!
164  // ==========================================================
165 
166  fill(reco_candidates,
167  truth_candidates,
168  startFromGen_,
169  plotAgainstRecoQuantities_,
170  onlyTwoJets_,
171  recPt_cut,
172  minEta_cut,
173  maxEta_cut,
174  deltaR_cut);
175 }
176 
178  // Store the DAQ Histograms
179  if (!outputFile_.empty())
180  dbe_->save(outputFile_);
181 }
Handle.h
GenericBenchmarkAnalyzer::minEta_cut
double minEta_cut
Definition: GenericBenchmarkAnalyzer.cc:53
MessageLogger.h
GenericBenchmarkAnalyzer::endJob
void endJob() override
Definition: GenericBenchmarkAnalyzer.cc:177
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
PFCandidate.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GenericBenchmark
Definition: GenericBenchmark.h:21
GenericBenchmarkAnalyzer::maxDeltaEt_
float maxDeltaEt_
Definition: GenericBenchmarkAnalyzer.cc:57
GenericBenchmarkAnalyzer::startFromGen_
bool startFromGen_
Definition: GenericBenchmarkAnalyzer.cc:49
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
GenericBenchmarkAnalyzer::recPt_cut
double recPt_cut
Definition: GenericBenchmarkAnalyzer.cc:52
GenericBenchmarkAnalyzer::maxDeltaPhi_
float maxDeltaPhi_
Definition: GenericBenchmarkAnalyzer.cc:59
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
CandidateFwd.h
MakerMacros.h
GenericBenchmarkAnalyzer::benchmarkLabel_
std::string benchmarkLabel_
Definition: GenericBenchmarkAnalyzer.cc:48
GenericBenchmarkAnalyzer::myReco_
edm::EDGetTokenT< edm::View< reco::Candidate > > myReco_
Definition: GenericBenchmarkAnalyzer.cc:45
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
GenericBenchmarkAnalyzer::inputTruthLabel_
edm::InputTag inputTruthLabel_
Definition: GenericBenchmarkAnalyzer.cc:46
GenericBenchmarkAnalyzer::minDeltaPhi_
float minDeltaPhi_
Definition: GenericBenchmarkAnalyzer.cc:58
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:784
EDGetToken.h
GenericBenchmarkAnalyzer::maxEta_cut
double maxEta_cut
Definition: GenericBenchmarkAnalyzer.cc:54
edm::View
Definition: CaloClusterFwd.h:14
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
edm::ParameterSet
Definition: ParameterSet.h:47
GenericBenchmarkAnalyzer::GenericBenchmarkAnalyzer
GenericBenchmarkAnalyzer(const edm::ParameterSet &)
Definition: GenericBenchmarkAnalyzer.cc:70
Event.h
GenericBenchmarkAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GenericBenchmarkAnalyzer.cc:117
GenericBenchmarkAnalyzer::deltaR_cut
double deltaR_cut
Definition: GenericBenchmarkAnalyzer.cc:55
GenericBenchmarkAnalyzer::outputFile_
std::string outputFile_
Definition: GenericBenchmarkAnalyzer.cc:43
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
GenericBenchmarkAnalyzer::doMetPlots_
bool doMetPlots_
Definition: GenericBenchmarkAnalyzer.cc:60
edm::EventSetup
Definition: EventSetup.h:58
GenericBenchmarkAnalyzer::onlyTwoJets_
bool onlyTwoJets_
Definition: GenericBenchmarkAnalyzer.cc:51
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
GenericBenchmarkAnalyzer::myTruth_
edm::EDGetTokenT< edm::View< reco::Candidate > > myTruth_
Definition: GenericBenchmarkAnalyzer.cc:44
std
Definition: JetResolutionObject.h:76
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GenericBenchmarkAnalyzer
Definition: GenericBenchmarkAnalyzer.cc:32
GenericBenchmarkAnalyzer::inputRecoLabel_
edm::InputTag inputRecoLabel_
Definition: GenericBenchmarkAnalyzer.cc:47
GenericBenchmarkAnalyzer::beginJob
void beginJob() override
Definition: GenericBenchmarkAnalyzer.cc:100
Candidate.h
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
TauSpinner_cfi.isReco
isReco
Definition: TauSpinner_cfi.py:4
ParameterSet.h
GenericBenchmark.h
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
edm::InputTag
Definition: InputTag.h:15
GenericBenchmarkAnalyzer::minDeltaEt_
float minDeltaEt_
Definition: GenericBenchmarkAnalyzer.cc:56
PFCandidateFwd.h
GenericBenchmarkAnalyzer::plotAgainstRecoQuantities_
bool plotAgainstRecoQuantities_
Definition: GenericBenchmarkAnalyzer.cc:50
GenericBenchmarkAnalyzer::~GenericBenchmarkAnalyzer
~GenericBenchmarkAnalyzer() override
Definition: GenericBenchmarkAnalyzer.cc:98
benchmarkLabel_
string benchmarkLabel_
Definition: PFJetBenchmarkAnalyzer.cc:74