CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFClient Class Reference

#include <PFClient.h>

Inheritance diagram for PFClient:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 PFClient (const edm::ParameterSet &parameterSet)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
 
void beginJob ()
 
void createEfficiencyPlots (std::string &folder, std::string &name)
 
void createResolutionPlots (std::string &folder, std::string &name)
 
void doEfficiency ()
 
void doSummaries ()
 
void endJob ()
 
void endRun (edm::Run const &run, edm::EventSetup const &eSetup)
 
void getHistogramParameters (MonitorElement *me_slice, double &avarage, double &rms, double &mean, double &sigma)
 

Private Attributes

DQMStoredqmStore_
 
std::vector< std::string > effHistogramNames_
 
bool efficiencyFlag_
 
std::vector< std::string > folderNames_
 
std::vector< std::string > histogramNames_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 12 of file PFClient.h.

Constructor & Destructor Documentation

PFClient::PFClient ( const edm::ParameterSet parameterSet)

Definition at line 16 of file PFClient.cc.

References effHistogramNames_, efficiencyFlag_, folderNames_, edm::ParameterSet::getParameter(), and histogramNames_.

17 {
18  folderNames_ = parameterSet.getParameter< std::vector<std::string> >( "FolderNames" );
19  histogramNames_ = parameterSet.getParameter< std::vector<std::string> >( "HistogramNames" );
20  efficiencyFlag_ = parameterSet.getParameter< bool> ("CreateEfficiencyPlots" );
21  effHistogramNames_ = parameterSet.getParameter< std::vector<std::string> >( "HistogramNamesForEfficiencyPlots" );
22 }
T getParameter(std::string const &) const
std::vector< std::string > histogramNames_
Definition: PFClient.h:31
std::vector< std::string > folderNames_
Definition: PFClient.h:30
std::vector< std::string > effHistogramNames_
Definition: PFClient.h:32
bool efficiencyFlag_
Definition: PFClient.h:33

Member Function Documentation

void PFClient::analyze ( edm::Event const &  ,
edm::EventSetup const &   
)
inlineprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 19 of file PFClient.h.

19 {;}
void PFClient::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 26 of file PFClient.cc.

References dqmStore_, and cppFunctionSkipper::operator.

26  {
27 
29 }
DQMStore * dqmStore_
Definition: PFClient.h:35
void PFClient::createEfficiencyPlots ( std::string &  folder,
std::string &  name 
)
private

Definition at line 158 of file PFClient.cc.

References DQMStore::book1D(), MonitorElement::DQM_KIND_TH1F, dqmStore_, postValidation_cfi::efficiency, DQMStore::get(), MonitorElement::getAxisTitle(), MonitorElement::getBinContent(), MonitorElement::getNbinsX(), MonitorElement::getTH1F(), MonitorElement::kind(), MonitorElement::Reset(), MonitorElement::setBinContent(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::xmin.

Referenced by doEfficiency().

158  {
159  MonitorElement* me1 = dqmStore_->get(folder+"/"+name);
160  MonitorElement* me2 = dqmStore_->get(folder+"/"+name+"ref_");
161  if (!me1 || !me2) return;
162  MonitorElement* me_eff;
163  if ( (me1->kind() == MonitorElement::DQM_KIND_TH1F) &&
164  (me1->kind() == MonitorElement::DQM_KIND_TH1F) ) {
165  TH1* th1 = me1->getTH1F();
166  size_t nbinx = me1->getNbinsX();
167 
168  float xmin = th1->GetXaxis()->GetXmin();
169  float xmax = th1->GetXaxis()->GetXmax();
170  std::string xtit = me1->getAxisTitle(1);
171  std::string tit_new;
172  tit_new = ";"+xtit+";Efficiency";
173 
174  dqmStore_->setCurrentFolder(folder);
175  me_eff = dqmStore_->book1D("efficiency_"+name,tit_new, nbinx, xmin, xmax);
176 
177  double efficiency;
178  me_eff->Reset();
179  for (size_t ix = 1; ix < nbinx+1; ++ix) {
180  float val1 = me1->getBinContent(ix);
181  float val2 = me2->getBinContent(ix);
182  if (val2 > 0.0) efficiency = val1/val2;
183  else efficiency = 0;
184  me_eff->setBinContent(ix,efficiency);
185  }
186  }
187 }
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
TH1F * getTH1F(void) const
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
Definition: PFClient.h:35
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void PFClient::createResolutionPlots ( std::string &  folder,
std::string &  name 
)
private

Definition at line 77 of file PFClient.cc.

References PDRates::average, DQMStore::book1D(), MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, dqmStore_, DQMStore::get(), getHistogramParameters(), MonitorElement::getName(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), MonitorElement::getTH2F(), MonitorElement::kind(), timingPdfMaker::mean, DQMStore::removeElement(), MonitorElement::Reset(), plotscripts::rms(), MonitorElement::setBinContent(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, fw3dlego::xbins, SiStripMonitorClusterAlca_cfi::ymax, and SiStripMonitorClusterAlca_cfi::ymin.

Referenced by doSummaries().

77  {
78  MonitorElement* me = dqmStore_->get(folder+"/"+name);
79  if (!me) return;
80  MonitorElement* me_average;
81  MonitorElement* me_rms;
82  MonitorElement* me_mean;
83  MonitorElement* me_sigma;
84  if ( (me->kind() == MonitorElement::DQM_KIND_TH2F) ||
86  (me->kind() == MonitorElement::DQM_KIND_TH2D) ) {
87  TH2* th = me->getTH2F();
88  size_t nbinx = me->getNbinsX();
89  size_t nbiny = me->getNbinsY();
90 
91  float ymin = th->GetYaxis()->GetXmin();
92  float ymax = th->GetYaxis()->GetXmax();
93  std::string xtit = th->GetXaxis()->GetTitle();
94  std::string ytit = th->GetYaxis()->GetTitle();
95  float* xbins = new float[nbinx+1];
96  for (size_t ix = 1; ix < nbinx+1; ++ix) {
97  xbins[ix-1] = th->GetBinLowEdge(ix);
98  if (ix == nbinx) xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
99  }
100 
101  std::string tit_new;
102  dqmStore_->setCurrentFolder(folder);
103  MonitorElement* me_slice = dqmStore_->book1D("PFlowSlice","PFlowSlice",nbiny,ymin,ymax);
104 
105  tit_new = ";"+xtit+";Average_"+ytit;
106  me_average = dqmStore_->book1D("average_"+name,tit_new, nbinx, xbins);
107  tit_new = ";"+xtit+";RMS_"+ytit;
108  me_rms = dqmStore_->book1D("rms_"+name,tit_new, nbinx, xbins);
109  tit_new = ";"+xtit+";Mean_"+ytit;
110  me_mean = dqmStore_->book1D("mean_"+name,tit_new, nbinx, xbins);
111  tit_new = ";"+xtit+";Sigma_"+ytit;
112  me_sigma = dqmStore_->book1D("sigma_"+name,tit_new, nbinx, xbins);
113 
114  double average, rms, mean, sigma;
115  for (size_t ix = 1; ix < nbinx+1; ++ix) {
116  me_slice->Reset();
117  for (size_t iy = 1; iy < nbiny+1; ++iy) {
118  me_slice->setBinContent(iy,th->GetBinContent(ix,iy));
119  }
120  getHistogramParameters(me_slice, average, rms, mean, sigma);
121  me_average->setBinContent(ix,average);
122  me_rms->setBinContent(ix,rms);
123  me_mean->setBinContent(ix,mean);
124  me_sigma->setBinContent(ix,sigma);
125  }
126  if (me_slice) dqmStore_->removeElement(me_slice->getName());
127  delete [] xbins;
128  }
129 }
const std::string & getName(void) const
get name of ME
void setBinContent(int binx, double content)
set content of bin (1-D)
const double xbins[]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
int getNbinsY(void) const
get # of bins in Y-axis
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
int average
Definition: PDRates.py:137
int getNbinsX(void) const
get # of bins in X-axis
TH2F * getTH2F(void) const
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
Definition: PFClient.h:35
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void getHistogramParameters(MonitorElement *me_slice, double &avarage, double &rms, double &mean, double &sigma)
Definition: PFClient.cc:133
void PFClient::doEfficiency ( )
private

Definition at line 62 of file PFClient.cc.

References createEfficiencyPlots(), effHistogramNames_, folderNames_, getHLTPrescaleColumns::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endRun().

62  {
63  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin();
64  ifolder != folderNames_.end(); ifolder++) {
65  std::string path = "ParticleFlow/"+(*ifolder);
66 
67  for (std::vector<std::string>::const_iterator ihist = effHistogramNames_.begin();
68  ihist != effHistogramNames_.end(); ihist++) {
69  std::string hname = (*ihist);
70  createEfficiencyPlots(path, hname);
71  }
72  }
73 }
void createEfficiencyPlots(std::string &folder, std::string &name)
Definition: PFClient.cc:158
std::vector< std::string > folderNames_
Definition: PFClient.h:30
std::vector< std::string > effHistogramNames_
Definition: PFClient.h:32
void PFClient::doSummaries ( )
private

Definition at line 46 of file PFClient.cc.

References createResolutionPlots(), folderNames_, histogramNames_, getHLTPrescaleColumns::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endRun().

46  {
47 
48  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin();
49  ifolder != folderNames_.end(); ifolder++) {
50  std::string path = "ParticleFlow/"+(*ifolder);
51 
52  for (std::vector<std::string>::const_iterator ihist = histogramNames_.begin();
53  ihist != histogramNames_.end(); ihist++) {
54  std::string hname = (*ihist);
55  createResolutionPlots(path, hname);
56  }
57  }
58 }
std::vector< std::string > histogramNames_
Definition: PFClient.h:31
void createResolutionPlots(std::string &folder, std::string &name)
Definition: PFClient.cc:77
std::vector< std::string > folderNames_
Definition: PFClient.h:30
void PFClient::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file PFClient.cc.

40  {
41 
42 }
void PFClient::endRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file PFClient.cc.

References doEfficiency(), doSummaries(), and efficiencyFlag_.

33  {
34  doSummaries();
36 }
void doSummaries()
Definition: PFClient.cc:46
void doEfficiency()
Definition: PFClient.cc:62
bool efficiencyFlag_
Definition: PFClient.h:33
void PFClient::getHistogramParameters ( MonitorElement me_slice,
double &  avarage,
double &  rms,
double &  mean,
double &  sigma 
)
private

Definition at line 133 of file PFClient.cc.

References MonitorElement::DQM_KIND_TH1F, MonitorElement::getMean(), MonitorElement::getRMS(), MonitorElement::getTH1F(), and MonitorElement::kind().

Referenced by createResolutionPlots().

134  {
135  average = 0.0;
136  rms = 0.0;
137  mean = 0.0;
138  sigma = 0.0;
139 
140  if (!me_slice) return;
141  if (me_slice->kind() == MonitorElement::DQM_KIND_TH1F) {
142  average = me_slice->getMean();
143  rms = me_slice->getRMS();
144  TH1F* th_slice = me_slice->getTH1F();
145  if (th_slice && th_slice->GetEntries() > 0) {
146  th_slice->Fit( "gaus","Q0");
147  TF1* gaus = th_slice->GetFunction( "gaus" );
148  if (gaus) {
149  sigma = gaus->GetParameter(2);
150  mean = gaus->GetParameter(1);
151  }
152  }
153  }
154 }
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Kind kind(void) const
Get the type of the monitor element.
TH1F * getTH1F(void) const
int average
Definition: PDRates.py:137
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)

Member Data Documentation

DQMStore* PFClient::dqmStore_
private

Definition at line 35 of file PFClient.h.

Referenced by beginJob(), createEfficiencyPlots(), and createResolutionPlots().

std::vector<std::string> PFClient::effHistogramNames_
private

Definition at line 32 of file PFClient.h.

Referenced by doEfficiency(), and PFClient().

bool PFClient::efficiencyFlag_
private

Definition at line 33 of file PFClient.h.

Referenced by endRun(), and PFClient().

std::vector<std::string> PFClient::folderNames_
private

Definition at line 30 of file PFClient.h.

Referenced by doEfficiency(), doSummaries(), and PFClient().

std::vector<std::string> PFClient::histogramNames_
private

Definition at line 31 of file PFClient.h.

Referenced by doSummaries(), and PFClient().