CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFCandidateDQMAnalyzer.cc
Go to the documentation of this file.
2 
4 
9 
12 
16 //
17 // -- Constructor
18 //
20 
21 {
22  pSet_ = parameterSet;
23  inputLabel_ = pSet_.getParameter<edm::InputTag>("InputCollection");
24  matchLabel_ = pSet_.getParameter<edm::InputTag>("MatchCollection");
25  benchmarkLabel_ = pSet_.getParameter<std::string>("BenchmarkLabel");
26 
27  pfCandidateMonitor_.setParameters(parameterSet);
28 
29 }
30 //
31 // -- BeginJob
32 //
34 
36  // part of the following could be put in the base class
37  std::string path = "ParticleFlow/" + benchmarkLabel_;
38  Benchmark::DQM_->setCurrentFolder(path.c_str());
39  edm::LogInfo("PFCandidateDQMAnalyzer") << " PFCandidateDQMAnalyzer::beginJob " << "Histogram Folder path set to "<< path;
41  nBadEvents_ = 0;
42 }
43 //
44 // -- Analyze
45 //
47  edm::EventSetup const& iSetup) {
49  iEvent.getByLabel( inputLabel_, candCollection);
50 
51  edm::Handle< edm::View<reco::Candidate> > matchedCandCollection;
52  iEvent.getByLabel( matchLabel_, matchedCandCollection);
53 
54  float maxRes = 0.0;
55  float minRes = 99.99;
56  if (candCollection.isValid() && matchedCandCollection.isValid()) {
57  pfCandidateMonitor_.fill( *candCollection, *matchedCandCollection, minRes, maxRes);
58  edm::ParameterSet skimPS = pSet_.getParameter<edm::ParameterSet>("SkimParameter");
59  if ( (skimPS.getParameter<bool>("switchOn")) &&
60  (nBadEvents_ <= skimPS.getParameter<int32_t>("maximumNumberToBeStored")) ) {
61  if ( minRes < skimPS.getParameter<double>("lowerCutOffOnResolution")) {
62  nBadEvents_++;
63  storeBadEvents(iEvent,minRes);
64  } else if (maxRes > skimPS.getParameter<double>("upperCutOffOnResolution")) {
65  nBadEvents_++;
66  storeBadEvents(iEvent,maxRes);
67  }
68  }
69  }
70 }
72  unsigned int runNb = iEvent.id().run();
73  unsigned int evtNb = iEvent.id().event();
74  unsigned int lumiNb = iEvent.id().luminosityBlock();
75 
76  std::string path = "ParticleFlow/" + benchmarkLabel_ + "/BadEvents";
77  Benchmark::DQM_->setCurrentFolder(path.c_str());
78  std::ostringstream eventid_str;
79  eventid_str << runNb << "_"<< evtNb << "_" << lumiNb;
80  MonitorElement* me = Benchmark::DQM_->get(path + "/" + eventid_str.str());
81  if (me) me->Reset();
82  else me = Benchmark::DQM_->bookFloat(eventid_str.str());
83  me->Fill(val);
84 }
85 //
86 // -- EndJob
87 //
89 }
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
void setup()
book histograms
PFCandidateDQMAnalyzer(const edm::ParameterSet &parameterSet)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:43
static DQMStore * DQM_
Definition: Benchmark.h:39
void setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool refHistoFlag)
set the parameters locally
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void Fill(long long x)
void analyze(edm::Event const &, edm::EventSetup const &)
list path
Definition: scaleCards.py:51
int iEvent
Definition: GenABIO.cc:243
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void fill(const T &candidateCollection, const C &matchedCandCollection, float &minVal, float &maxVal)
fill histograms with all particle
PFCandidateMonitor pfCandidateMonitor_
edm::EventID id() const
Definition: EventBase.h:56
void storeBadEvents(edm::Event const &, float &val)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429