CMS 3D CMS Logo

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