CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 
20 
22 
25 
26 #include <vector>
27 #include <ostream>
28 #include <fstream>
29 #include <iostream>
30 #include <algorithm>
31 #include <cmath>
32 #include <memory>
33 
34 using namespace reco;
35 using namespace edm;
36 using namespace std;
37 
39 {
40 
41  inputTruthLabel_ = iConfig.getParameter<edm::InputTag>("InputTruthLabel");
42  inputRecoLabel_ = iConfig.getParameter<edm::InputTag>("InputRecoLabel");
43  outputFile_ = iConfig.getUntrackedParameter<std::string>("OutputFile");
44  benchmarkLabel_ = iConfig.getParameter<std::string>("BenchmarkLabel");
45  startFromGen_ = iConfig.getParameter<bool>("StartFromGen");
46  plotAgainstRecoQuantities_ = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
47  onlyTwoJets_ = iConfig.getParameter<bool>("OnlyTwoJets");
48  recPt_cut = iConfig.getParameter<double>("recPt");
49  minEta_cut = iConfig.getParameter<double>("minEta");
50  maxEta_cut = iConfig.getParameter<double>("maxEta");
51  deltaR_cut = iConfig.getParameter<double>("deltaRMax");
52 
53  minDeltaEt_ = iConfig.getParameter<double>("minDeltaEt");
54  maxDeltaEt_ = iConfig.getParameter<double>("maxDeltaEt");
55  minDeltaPhi_ = iConfig.getParameter<double>("minDeltaPhi");
56  maxDeltaPhi_ = iConfig.getParameter<double>("maxDeltaPhi");
57  doMetPlots_ = iConfig.getParameter<bool>("doMetPlots");
58 
59  if (outputFile_.size() > 0)
60  edm::LogInfo("OutputInfo") << " ParticleFLow Task histograms will be saved to '" << outputFile_.c_str()<< "'";
61  else edm::LogInfo("OutputInfo") << " ParticleFlow Task histograms will NOT be saved";
62 
63 }
64 
66 
67 void
69 {
70 
71  // get ahold of back-end interface
73 
74  if (dbe_) {
75  //dbe_->setVerbose(1);
76  string path = "PFTask/Benchmarks/" + benchmarkLabel_ + "/";
77  if (plotAgainstRecoQuantities_) path += "Reco"; else path += "Gen";
78  dbe_->setCurrentFolder(path.c_str());
79  setup(dbe_, plotAgainstRecoQuantities_, minDeltaEt_, maxDeltaEt_, minDeltaPhi_, maxDeltaPhi_, doMetPlots_);
80 
81  }
82 
83 }
84 
85 void
87  const edm::EventSetup& iSetup)
88 {
89 
90  // Typedefs to use views
91  typedef edm::View<reco::Candidate> candidateCollection ;
92  typedef edm::View<reco::Candidate> candidateCollection ;
93 
94  const candidateCollection *truth_candidates;
95  const candidateCollection *reco_candidates;
96 
97  // ==========================================================
98  // Retrieve!
99  // ==========================================================
100 
101  {
102  // Get Truth Candidates (GenCandidates, GenJets, etc.)
103  Handle<candidateCollection> truth_hnd;
104  bool isGen = iEvent.getByLabel(inputTruthLabel_, truth_hnd);
105  if ( !isGen ) {
106  std::cout << "Warning : no Gen jets in input !" << std::endl;
107  return;
108  }
109 
110  truth_candidates = truth_hnd.product();
111 
112  // Get Reco Candidates (PFlow, CaloJet, etc.)
114  bool isReco = iEvent.getByLabel(inputRecoLabel_, reco_hnd);
115  if ( !isReco ) {
116  std::cout << "Warning : no Reco jets in input !" << std::endl;
117  return;
118  }
119  reco_candidates = reco_hnd.product();
120 
121  // no longer needed with template-ized Benchmark
122  //const PFCandidateCollection *pf_candidates = reco_hnd.product();
123  //static CandidateCollection reco_storage = algo_->makeCandidateCollection(pf_candidates);
124  //reco_candidates = &reco_storage;
125 
126  }
127  if (!truth_candidates || !reco_candidates) {
128 
129  edm::LogInfo("OutputInfo") << " failed to retrieve data required by ParticleFlow Task";
130  edm::LogInfo("OutputInfo") << " ParticleFlow Task cannot continue...!";
131  return;
132 
133  }
134 
135  // ==========================================================
136  // Analyze!
137  // ==========================================================
138 
139  fill(reco_candidates,truth_candidates,
140  startFromGen_, plotAgainstRecoQuantities_,
141  onlyTwoJets_, recPt_cut, minEta_cut, maxEta_cut, deltaR_cut);
142 }
143 
145 {
146 
147  // Store the DAQ Histograms
148  if (outputFile_.size() != 0)
149  dbe_->save(outputFile_);
150 }
GenericBenchmarkAnalyzer(const edm::ParameterSet &)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898
int path() const
Definition: HLTadd.h:3
int iEvent
Definition: GenABIO.cc:243
string benchmarkLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
DQMStore * dbe_
T const * product() const
Definition: Handle.h:74
tuple cout
Definition: gather_cfg.py:41
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232