CMS 3D CMS Logo

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

#include <DQMGenericClient.h>

Inheritance diagram for DQMGenericClient:
DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  CDOption
 
struct  EfficOption
 
struct  NormOption
 
struct  ProfileOption
 
struct  ResolOption
 

Public Member Functions

void computeEfficiency (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &efficMEName, const std::string &efficMETitle, const std::string &recoMEName, const std::string &simMEName, const int type=1, const bool makeProfile=false)
 
void computeProfile (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
 
void computeResolution (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &fitMEPrefix, const std::string &fitMETitlePrefix, const std::string &srcMEName)
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
 DQMGenericClient (const edm::ParameterSet &pset)
 
void limitedFit (MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
 
void makeCumulativeDist (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
 
void normalizeToEntries (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
 
 ~DQMGenericClient ()
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDHarvester (void)
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void findAllSubdirectories (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
 
void generic_eff (TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const int type=1)
 

Private Attributes

std::vector< CDOptioncdOptions_
 
std::vector< EfficOptionefficOptions_
 
bool isWildcardUsed_
 
std::vector< NormOptionnormOptions_
 
std::string outputFileName_
 
std::vector< ProfileOptionprofileOptions_
 
bool resLimitedFit_
 
std::vector< ResolOptionresolOptions_
 
std::vector< std::string > subDirs_
 
DQMStoretheDQM
 
unsigned int verbose_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 28 of file DQMGenericClient.h.

Constructor & Destructor Documentation

DQMGenericClient::DQMGenericClient ( const edm::ParameterSet pset)

Definition at line 34 of file DQMGenericClient.cc.

References createfilelist::args, DQMGenericClient::CDOption::ascending, DQMGenericClient::EfficOption::denominator, genericClientPSetHelper_cff::efficSet(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), DQMGenericClient::EfficOption::isProfile, DQMGenericClient::EfficOption::name, DQMGenericClient::ProfileOption::name, DQMGenericClient::NormOption::name, DQMGenericClient::CDOption::name, DQMGenericClient::ResolOption::namePrefix, DQMGenericClient::NormOption::normHistName, DQMGenericClient::EfficOption::numerator, or, DQMGenericClient::ResolOption::srcName, DQMGenericClient::ProfileOption::srcName, DQMGenericClient::EfficOption::title, DQMGenericClient::ProfileOption::title, DQMGenericClient::ResolOption::titlePrefix, DQMGenericClient::EfficOption::type, and HistogramManager_cfi::VPSet().

35 {
36  typedef std::vector<edm::ParameterSet> VPSet;
37  typedef std::vector<std::string> vstring;
38  typedef boost::escaped_list_separator<char> elsc;
39 
40  elsc commonEscapes("\\", " \t", "\'");
41 
42  verbose_ = pset.getUntrackedParameter<unsigned int>("verbose", 0);
43 
44  // Parse efficiency commands
45  vstring effCmds = pset.getParameter<vstring>("efficiency");
46  for ( vstring::const_iterator effCmd = effCmds.begin();
47  effCmd != effCmds.end(); ++effCmd )
48  {
49  if ( effCmd->empty() ) continue;
50 
51  boost::tokenizer<elsc> tokens(*effCmd, commonEscapes);
52 
53  vector<string> args;
54  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
55  iToken != tokens.end(); ++iToken) {
56  if ( iToken->empty() ) continue;
57  args.push_back(*iToken);
58  }
59 
60  if ( args.size() < 4 ) {
61  LogInfo("DQMGenericClient") << "Wrong input to effCmds\n";
62  continue;
63  }
64 
65  EfficOption opt;
66  opt.name = args[0];
67  opt.title = args[1];
68  opt.numerator = args[2];
69  opt.denominator = args[3];
70  opt.isProfile = false;
71 
72  const string typeName = args.size() == 4 ? "eff" : args[4];
73  if ( typeName == "eff" ) opt.type = 1;
74  else if ( typeName == "fake" ) opt.type = 2;
75  else opt.type = 0;
76 
77  efficOptions_.push_back(opt);
78  }
79 
80  VPSet efficSets = pset.getUntrackedParameter<VPSet>("efficiencySets", VPSet());
81  for ( VPSet::const_iterator efficSet = efficSets.begin();
82  efficSet != efficSets.end(); ++efficSet )
83  {
84  EfficOption opt;
85  opt.name = efficSet->getUntrackedParameter<string>("name");
86  opt.title = efficSet->getUntrackedParameter<string>("title");
87  opt.numerator = efficSet->getUntrackedParameter<string>("numerator");
88  opt.denominator = efficSet->getUntrackedParameter<string>("denominator");
89  opt.isProfile = false;
90 
91  const string typeName = efficSet->getUntrackedParameter<string>("typeName", "eff");
92  if ( typeName == "eff" ) opt.type = 1;
93  else if ( typeName == "fake" ) opt.type = 2;
94  else opt.type = 0;
95 
96  efficOptions_.push_back(opt);
97  }
98 
99  // Parse efficiency profiles
100  vstring effProfileCmds = pset.getUntrackedParameter<vstring>("efficiencyProfile", vstring());
101  for ( vstring::const_iterator effProfileCmd = effProfileCmds.begin();
102  effProfileCmd != effProfileCmds.end(); ++effProfileCmd )
103  {
104  if ( effProfileCmd->empty() ) continue;
105 
106  boost::tokenizer<elsc> tokens(*effProfileCmd, commonEscapes);
107 
108  vector<string> args;
109  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
110  iToken != tokens.end(); ++iToken) {
111  if ( iToken->empty() ) continue;
112  args.push_back(*iToken);
113  }
114 
115  if ( args.size() < 4 ) {
116  LogInfo("DQMGenericClient") << "Wrong input to effProfileCmds\n";
117  continue;
118  }
119 
120  EfficOption opt;
121  opt.name = args[0];
122  opt.title = args[1];
123  opt.numerator = args[2];
124  opt.denominator = args[3];
125  opt.isProfile = true;
126 
127  const string typeName = args.size() == 4 ? "eff" : args[4];
128  if ( typeName == "eff" ) opt.type = 1;
129  else if ( typeName == "fake" ) opt.type = 2;
130  else opt.type = 0;
131 
132  efficOptions_.push_back(opt);
133  }
134 
135  VPSet effProfileSets = pset.getUntrackedParameter<VPSet>("efficiencyProfileSets", VPSet());
136  for ( VPSet::const_iterator effProfileSet = effProfileSets.begin();
137  effProfileSet != effProfileSets.end(); ++effProfileSet )
138  {
139  EfficOption opt;
140  opt.name = effProfileSet->getUntrackedParameter<string>("name");
141  opt.title = effProfileSet->getUntrackedParameter<string>("title");
142  opt.numerator = effProfileSet->getUntrackedParameter<string>("numerator");
143  opt.denominator = effProfileSet->getUntrackedParameter<string>("denominator");
144  opt.isProfile = true;
145 
146  const string typeName = effProfileSet->getUntrackedParameter<string>("typeName", "eff");
147  if ( typeName == "eff" ) opt.type = 1;
148  else if ( typeName == "fake" ) opt.type = 2;
149  else opt.type = 0;
150 
151  efficOptions_.push_back(opt);
152  }
153 
154  // Parse resolution commands
155  vstring resCmds = pset.getParameter<vstring>("resolution");
156  for ( vstring::const_iterator resCmd = resCmds.begin();
157  resCmd != resCmds.end(); ++resCmd )
158  {
159  if ( resCmd->empty() ) continue;
160  boost::tokenizer<elsc> tokens(*resCmd, commonEscapes);
161 
162  vector<string> args;
163  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
164  iToken != tokens.end(); ++iToken) {
165  if ( iToken->empty() ) continue;
166  args.push_back(*iToken);
167  }
168 
169  if ( args.size() != 3 ) {
170  LogInfo("DQMGenericClient") << "Wrong input to resCmds\n";
171  continue;
172  }
173 
174  ResolOption opt;
175  opt.namePrefix = args[0];
176  opt.titlePrefix = args[1];
177  opt.srcName = args[2];
178 
179  resolOptions_.push_back(opt);
180  }
181 
182  VPSet resolSets = pset.getUntrackedParameter<VPSet>("resolutionSets", VPSet());
183  for ( VPSet::const_iterator resolSet = resolSets.begin();
184  resolSet != resolSets.end(); ++resolSet )
185  {
186  ResolOption opt;
187  opt.namePrefix = resolSet->getUntrackedParameter<string>("namePrefix");
188  opt.titlePrefix = resolSet->getUntrackedParameter<string>("titlePrefix");
189  opt.srcName = resolSet->getUntrackedParameter<string>("srcName");
190 
191  resolOptions_.push_back(opt);
192  }
193 
194  // Parse profiles
195  vstring profileCmds = pset.getUntrackedParameter<vstring>("profile", vstring());
196  for(const auto& profileCmd: profileCmds) {
197  boost::tokenizer<elsc> tokens(profileCmd, commonEscapes);
198 
199  vector<string> args;
200  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
201  iToken != tokens.end(); ++iToken) {
202  if ( iToken->empty() ) continue;
203  args.push_back(*iToken);
204  }
205 
206  if ( args.size() != 3 ) {
207  LogInfo("DQMGenericClient") << "Wrong input to profileCmds\n";
208  continue;
209  }
210 
211  ProfileOption opt;
212  opt.name = args[0];
213  opt.title = args[1];
214  opt.srcName = args[2];
215 
216  profileOptions_.push_back(opt);
217  }
218 
219  VPSet profileSets = pset.getUntrackedParameter<VPSet>("profileSets", VPSet());
220  for(const auto& profileSet: profileSets) {
221  ProfileOption opt;
222  opt.name = profileSet.getUntrackedParameter<string>("name");
223  opt.title = profileSet.getUntrackedParameter<string>("title");
224  opt.srcName = profileSet.getUntrackedParameter<string>("srcName");
225 
226  profileOptions_.push_back(opt);
227  }
228 
229  // Parse Normalization commands
230  vstring normCmds = pset.getUntrackedParameter<vstring>("normalization", vstring());
231  for ( vstring::const_iterator normCmd = normCmds.begin();
232  normCmd != normCmds.end(); ++normCmd )
233  {
234  if ( normCmd->empty() ) continue;
235  boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
236 
237  vector<string> args;
238  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
239  iToken != tokens.end(); ++iToken) {
240  if ( iToken->empty() ) continue;
241  args.push_back(*iToken);
242  }
243 
244  if ( args.empty() or args.size() > 2 ) {
245  LogInfo("DQMGenericClient") << "Wrong input to normCmds\n";
246  continue;
247  }
248 
249  NormOption opt;
250  opt.name = args[0];
251  opt.normHistName = args.size() == 2 ? args[1] : args[0];
252 
253  normOptions_.push_back(opt);
254  }
255 
256  VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationSets", VPSet());
257  for ( VPSet::const_iterator normSet = normSets.begin();
258  normSet != normSets.end(); ++normSet )
259  {
260  NormOption opt;
261  opt.name = normSet->getUntrackedParameter<string>("name");
262  opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name);
263 
264  normOptions_.push_back(opt);
265  }
266 
267  // Cumulative distributions
268  vstring cdCmds = pset.getUntrackedParameter<vstring>("cumulativeDists", vstring());
269  for ( vstring::const_iterator cdCmd = cdCmds.begin();
270  cdCmd != cdCmds.end(); ++cdCmd )
271  {
272  if ( cdCmd->empty() ) continue;
273  boost::tokenizer<elsc> tokens(*cdCmd, commonEscapes);
274 
275  vector<string> args;
276  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
277  iToken != tokens.end(); ++iToken) {
278  if ( iToken->empty() ) continue;
279  args.push_back(*iToken);
280  }
281 
282  if ( args.size() == 0 || args.size() > 2) {
283  LogInfo("DQMGenericClient") << "Wrong input to cdCmds\n";
284  continue;
285  }
286 
287  CDOption opt;
288  opt.name = args[0];
289  opt.ascending = args.size() == 2 ? (args[1] != "descending") : true;
290 
291  cdOptions_.push_back(opt);
292  }
293 
294  VPSet cdSets = pset.getUntrackedParameter<VPSet>("cumulativeDistSets", VPSet());
295  for ( VPSet::const_iterator cdSet = cdSets.begin();
296  cdSet != cdSets.end(); ++cdSet )
297  {
298  CDOption opt;
299  opt.name = cdSet->getUntrackedParameter<string>("name");
300  opt.ascending = cdSet->getUntrackedParameter<bool>("ascending",true);
301 
302  cdOptions_.push_back(opt);
303  }
304 
305  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
306  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
307 
308  resLimitedFit_ = pset.getUntrackedParameter<bool>("resolutionLimitedFit",false);
309  isWildcardUsed_ = false;
310 }
std::vector< EfficOption > efficOptions_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ProfileOption > profileOptions_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ResolOption > resolOptions_
std::vector< std::string > subDirs_
std::string outputFileName_
unsigned int verbose_
std::vector< CDOption > cdOptions_
std::vector< NormOption > normOptions_
DQMGenericClient::~DQMGenericClient ( )
inline

Definition at line 32 of file DQMGenericClient.h.

32 {};

Member Function Documentation

void DQMGenericClient::computeEfficiency ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  efficMEName,
const std::string &  efficMETitle,
const std::string &  recoMEName,
const std::string &  simMEName,
const int  type = 1,
const bool  makeProfile = false 
)

Definition at line 401 of file DQMGenericClient.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::book2D(), DQMStore::IBooker::book3D(), DQMStore::IBooker::bookProfile(), DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), DQMStore::IGetter::get(), i, DQMStore::IBooker::setCurrentFolder(), mathSSE::sqrt(), and AlCaHLTBitMon_QueryRunRegistry::string.

403 {
404  if ( ! igetter.dirExists(startDir) ) {
405  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
406  LogInfo("DQMGenericClient") << "computeEfficiency() : "
407  << "Cannot find sub-directory " << startDir << endl;
408  }
409  return;
410  }
411 
412  ibooker.cd();
413 
414  ME* simME = igetter.get(startDir+"/"+simMEName);
415  ME* recoME = igetter.get(startDir+"/"+recoMEName);
416 
417  if ( !simME ) {
418  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
419  LogInfo("DQMGenericClient") << "computeEfficiency() : "
420  << "No sim-ME '" << simMEName << "' found\n";
421  }
422  return;
423  }
424 
425  if ( !recoME ) {
426  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
427  LogInfo("DQMGenericClient") << "computeEfficiency() : "
428  << "No reco-ME '" << recoMEName << "' found\n";
429  }
430  return;
431  }
432 
433  // Treat everything as the base class, TH1
434 
435  TH1* hSim = simME ->getTH1();
436  TH1* hReco = recoME->getTH1();
437 
438  if ( !hSim || !hReco ) {
439  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
440  LogInfo("DQMGenericClient") << "computeEfficiency() : "
441  << "Cannot create TH1 from ME\n";
442  }
443  return;
444  }
445 
446  string efficDir = startDir;
447  string newEfficMEName = efficMEName;
448  string::size_type shiftPos;
449  if ( string::npos != (shiftPos = efficMEName.rfind('/')) ) {
450  efficDir += "/"+efficMEName.substr(0, shiftPos);
451  newEfficMEName.erase(0, shiftPos+1);
452  }
453  ibooker.setCurrentFolder(efficDir);
454 
455  if (makeProfile) {
456  TProfile * efficHist = (hReco->GetXaxis()->GetXbins()->GetSize()==0) ?
457  new TProfile(newEfficMEName.c_str(), efficMETitle.c_str(),
458  hReco->GetXaxis()->GetNbins(),
459  hReco->GetXaxis()->GetXmin(),
460  hReco->GetXaxis()->GetXmax()) :
461  new TProfile(newEfficMEName.c_str(), efficMETitle.c_str(),
462  hReco->GetXaxis()->GetNbins(),
463  hReco->GetXaxis()->GetXbins()->GetArray());
464 
465  efficHist->GetXaxis()->SetTitle(hSim->GetXaxis()->GetTitle());
466  efficHist->GetYaxis()->SetTitle(hSim->GetYaxis()->GetTitle());
467 
468 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,27,0)
469  for (int i=1; i <= hReco->GetNbinsX(); i++) {
470 
471  const double nReco = hReco->GetBinContent(i);
472  const double nSim = hSim->GetBinContent(i);
473  if(nSim > INT_MAX || nSim < INT_MIN || nReco > INT_MAX || nReco < INT_MIN)
474  {
475  LogError("DQMGenericClient") << "computeEfficiency() : "
476  << "Overflow: bin content either too large or too small to be casted to int";
477  return;
478  }
479 
480  if(std::string(hSim->GetXaxis()->GetBinLabel(i)) != "")
481  efficHist->GetXaxis()->SetBinLabel(i, hSim->GetXaxis()->GetBinLabel(i));
482 
483  if ( nSim == 0 || nReco > nSim ) continue;
484  const double effVal = nReco/nSim;
485 
486  const double errLo = TEfficiency::ClopperPearson((int)nSim,
487  (int)nReco,
488  0.683,false);
489  const double errUp = TEfficiency::ClopperPearson((int)nSim,
490  (int)nReco,
491  0.683,true);
492  const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
493  efficHist->SetBinContent(i, effVal);
494  efficHist->SetBinEntries(i, 1);
495  efficHist->SetBinError(i, sqrt(effVal * effVal + errVal * errVal));
496  }
497 #else
498  for (int i=1; i <= hReco->GetNbinsX(); i++) {
499 
500  const double nReco = hReco->GetBinContent(i);
501  const double nSim = hSim->GetBinContent(i);
502  if(nSim > INT_MAX || nSim < INT_MIN || nReco > INT_MAX || nReco < INT_MIN)
503  {
504  LogError("DQMGenericClient") << "computeEfficiency() : "
505  << "Overflow: bin content either too large or too small to be casted to int";
506  return;
507  }
508 
509  TGraphAsymmErrorsWrapper asymm;
510  std::pair<double, double> efficiencyWithError;
511  efficiencyWithError = asymm.efficiency((int)nReco,
512  (int)nSim);
513  double effVal = efficiencyWithError.first;
514  double errVal = efficiencyWithError.second;
515  if ((int)nSim > 0) {
516  efficHist->SetBinContent(i, effVal);
517  efficHist->SetBinEntries(i, 1);
518  efficHist->SetBinError(i, sqrt(effVal * effVal + errVal * errVal));
519  }
520  if(std::string(hSim->GetXaxis()->GetBinLabel(i)) != "")
521  efficHist->GetXaxis()->SetBinLabel(i, hSim->GetXaxis()->GetBinLabel(i));
522  }
523 #endif
524  ibooker.bookProfile(newEfficMEName.c_str(),efficHist);
525  delete efficHist;
526  }
527 
528  else {
529 
530  TH1* efficHist = (TH1*)hSim->Clone(newEfficMEName.c_str());
531  efficHist->SetTitle(efficMETitle.c_str());
532 
533  // Here is where you have trouble --- you need
534  // to understand what type of hist you have.
535 
536  ME* efficME = 0;
537 
538  // Parse the class name
539  // This works, but there might be a better way
540  TClass * myHistClass = efficHist->IsA();
541  TString histClassName = myHistClass->GetName();
542 
543  if (histClassName == "TH1F"){
544  efficME = ibooker.book1D(newEfficMEName, (TH1F*)efficHist);
545  } else if (histClassName == "TH2F"){
546  efficME = ibooker.book2D(newEfficMEName, (TH2F*)efficHist);
547  } else if (histClassName == "TH3F"){
548  efficME = ibooker.book3D(newEfficMEName, (TH3F*)efficHist);
549  }
550 
551 
552  if ( !efficME ) {
553  LogInfo("DQMGenericClient") << "computeEfficiency() : "
554  << "Cannot book effic-ME from the DQM\n";
555  return;
556  }
557 
558  // Update: 2009-9-16 slaunwhj
559  // call the most generic efficiency function
560  // works up to 3-d histograms
561 
562  generic_eff (hSim, hReco, efficME, type);
563 
564  // const int nBin = efficME->getNbinsX();
565  // for(int bin = 0; bin <= nBin; ++bin) {
566  // const float nSim = simME ->getBinContent(bin);
567  // const float nReco = recoME->getBinContent(bin);
568  // float eff =0;
569  // if (type=="fake")eff = nSim ? 1-nReco/nSim : 0.;
570  // else eff= nSim ? nReco/nSim : 0.;
571  // const float err = nSim && eff <= 1 ? sqrt(eff*(1-eff)/nSim) : 0.;
572  // efficME->setBinContent(bin, eff);
573  // efficME->setBinError(bin, err);
574  // }
575  efficME->setEntries(simME->getEntries());
576 
577  }
578 
579  // Global efficiency
580  ME* globalEfficME = igetter.get(efficDir+"/globalEfficiencies");
581  if ( !globalEfficME ) globalEfficME = ibooker.book1D("globalEfficiencies", "Global efficiencies", 1, 0, 1);
582  if ( !globalEfficME ) {
583  LogInfo("DQMGenericClient") << "computeEfficiency() : "
584  << "Cannot book globalEffic-ME from the DQM\n";
585  return;
586  }
587  globalEfficME->setEfficiencyFlag();
588  TH1F* hGlobalEffic = globalEfficME->getTH1F();
589  if ( !hGlobalEffic ) {
590  LogInfo("DQMGenericClient") << "computeEfficiency() : "
591  << "Cannot create TH1F from ME, globalEfficME\n";
592  return;
593  }
594 
595  const float nSimAll = hSim->GetEntries();
596  const float nRecoAll = hReco->GetEntries();
597  float efficAll=0;
598  if ( type == 1 ) efficAll = nSimAll ? nRecoAll/nSimAll : 0;
599  else if ( type == 2 ) efficAll = nSimAll ? 1-nRecoAll/nSimAll : 0;
600  const float errorAll = nSimAll && efficAll < 1 ? sqrt(efficAll*(1-efficAll)/nSimAll) : 0;
601 
602  const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
603  hGlobalEffic->SetBinContent(iBin, efficAll);
604  hGlobalEffic->SetBinError(iBin, errorAll);
605 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
uint16_t size_type
Definition: ME.h:11
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
unsigned int verbose_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * book3D(Args &&...args)
Definition: DQMStore.h:151
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const int type=1)
void DQMGenericClient::computeProfile ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  profileMEName,
const std::string &  profileMETitle,
const std::string &  srcMEName 
)

Definition at line 687 of file DQMGenericClient.cc.

References DQMStore::IBooker::bookProfile(), DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), DQMStore::IGetter::get(), and DQMStore::IBooker::setCurrentFolder().

687  {
688  if(!igetter.dirExists(startDir)) {
689  if(verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
690  LogInfo("DQMGenericClient") << "computeProfile() : "
691  << "Cannot find sub-directory " << startDir << endl;
692  }
693  return;
694  }
695 
696  ibooker.cd();
697 
698  ME* srcME = igetter.get(startDir+"/"+srcMEName);
699  if ( !srcME ) {
700  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
701  LogInfo("DQMGenericClient") << "computeProfile() : "
702  << "No source ME '" << srcMEName << "' found\n";
703  }
704  return;
705  }
706 
707  TH2F* hSrc = srcME->getTH2F();
708  if ( !hSrc ) {
709  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
710  LogInfo("DQMGenericClient") << "computeProfile() : "
711  << "Cannot create TH2F from source-ME\n";
712  }
713  return;
714  }
715 
716  string profileDir = startDir;
717  string newProfileMEName = profileMEName;
718  string::size_type shiftPos;
719  if ( string::npos != (shiftPos = profileMEName.rfind('/')) ) {
720  profileDir += "/"+profileMEName.substr(0, shiftPos);
721  newProfileMEName.erase(0, shiftPos+1);
722  }
723  ibooker.setCurrentFolder(profileDir);
724 
725  std::unique_ptr<TProfile> profile(hSrc->ProfileX()); // We own the pointer
726  profile->SetTitle(profileMETitle.c_str());
727  ibooker.bookProfile(profileMEName, profile.get()); // ibooker makes a copy
728 }
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
uint16_t size_type
Definition: ME.h:11
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
unsigned int verbose_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
void DQMGenericClient::computeResolution ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  fitMEPrefix,
const std::string &  fitMETitlePrefix,
const std::string &  srcMEName 
)

Definition at line 607 of file DQMGenericClient.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), DQMStore::IGetter::get(), FitSlicesYTool::getFittedMeanWithError(), FitSlicesYTool::getFittedSigmaWithError(), j, and DQMStore::IBooker::setCurrentFolder().

609 {
610  if ( ! igetter.dirExists(startDir) ) {
611  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
612  LogInfo("DQMGenericClient") << "computeResolution() : "
613  << "Cannot find sub-directory " << startDir << endl;
614  }
615  return;
616  }
617 
618  ibooker.cd();
619 
620  ME* srcME = igetter.get(startDir+"/"+srcName);
621  if ( !srcME ) {
622  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
623  LogInfo("DQMGenericClient") << "computeResolution() : "
624  << "No source ME '" << srcName << "' found\n";
625  }
626  return;
627  }
628 
629  TH2F* hSrc = srcME->getTH2F();
630  if ( !hSrc ) {
631  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
632  LogInfo("DQMGenericClient") << "computeResolution() : "
633  << "Cannot create TH2F from source-ME\n";
634  }
635  return;
636  }
637 
638  const int nBin = hSrc->GetNbinsX();
639 
640  string newDir = startDir;
641  string newPrefix = namePrefix;
642  string::size_type shiftPos;
643  if ( string::npos != (shiftPos = namePrefix.rfind('/')) ) {
644  newDir += "/"+namePrefix.substr(0, shiftPos);
645  newPrefix.erase(0, shiftPos+1);
646  }
647 
648  ibooker.setCurrentFolder(newDir);
649 
650  float * lowedgesfloats = new float[nBin+1];
651  ME* meanME;
652  ME* sigmaME;
653  if (hSrc->GetXaxis()->GetXbins()->GetSize())
654  {
655  for (int j=0; j<nBin+1; ++j)
656  lowedgesfloats[j] = (float)hSrc->GetXaxis()->GetXbins()->GetAt(j);
657  meanME = ibooker.book1D(newPrefix+"_Mean", titlePrefix+" Mean", nBin, lowedgesfloats);
658  sigmaME = ibooker.book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin, lowedgesfloats);
659  }
660  else
661  {
662  meanME = ibooker.book1D(newPrefix+"_Mean", titlePrefix+" Mean", nBin,
663  hSrc->GetXaxis()->GetXmin(),
664  hSrc->GetXaxis()->GetXmax());
665  sigmaME = ibooker.book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin,
666  hSrc->GetXaxis()->GetXmin(),
667  hSrc->GetXaxis()->GetXmax());
668  }
669 
670  if (meanME && sigmaME)
671  {
672  meanME->setEfficiencyFlag();
673  sigmaME->setEfficiencyFlag();
674 
675  if (! resLimitedFit_ ) {
676  FitSlicesYTool fitTool(srcME);
677  fitTool.getFittedMeanWithError(meanME);
678  fitTool.getFittedSigmaWithError(sigmaME);
680  } else {
681  limitedFit(srcME,meanME,sigmaME);
682  }
683  }
684  delete[] lowedgesfloats;
685 }
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
uint16_t size_type
Definition: ME.h:11
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
unsigned int verbose_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
void limitedFit(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
void DQMGenericClient::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
overridevirtual

Implements DQMEDHarvester.

Definition at line 312 of file DQMGenericClient.cc.

References TrackerOfflineValidation_Dqm_cff::dirName, metacharacters(), cppFunctionSkipper::operator, and listBenchmarks::pattern.

312  {
313 
314  typedef vector<string> vstring;
315 
316  // Update 2014-04-02
317  // Migrated back to the endJob. the DQMFileSaver logic has
318  // to be reviewed to guarantee that the endJob is properly
319  // considered. The splitting per run is done centrally when
320  // running the harvesting in production
321 
322  // Update 2009-09-23
323  // Migrated all code from endJob to this function
324  // endJob is not necessarily called in the proper sequence
325  // and does not necessarily book histograms produced in
326  // that step.
327  // It more robust to do the histogram manipulation in
328  // this endRun function
329 
330  // needed to access the DQMStore::save method
331  theDQM = 0;
333 
334  // Process wildcard in the sub-directory
335  set<string> subDirSet;
336 
337  for(vstring::const_iterator iSubDir = subDirs_.begin();
338  iSubDir != subDirs_.end(); ++iSubDir) {
339  string subDir = *iSubDir;
340 
341  if ( subDir[subDir.size()-1] == '/' ) subDir.erase(subDir.size()-1);
342 
343  if ( TString(subDir).Contains(metacharacters) ) {
344  isWildcardUsed_ = true;
345 
346  const string::size_type shiftPos = subDir.rfind('/');
347  const string searchPath = subDir.substr(0, shiftPos);
348  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
349  //std::cout << "\n\n\n\nLooking for all subdirs of " << subDir << std::endl;
350 
351  findAllSubdirectories (ibooker, igetter, searchPath, &subDirSet, pattern);
352 
353  }
354  else {
355  subDirSet.insert(subDir);
356  }
357  }
358 
359  for(set<string>::const_iterator iSubDir = subDirSet.begin();
360  iSubDir != subDirSet.end(); ++iSubDir) {
361  const string& dirName = *iSubDir;
362 
363  // First normalize, then make cumulative, and only then efficiency
364  // This allows to use the cumulative distributions for efficiency calculation
365  for ( vector<NormOption>::const_iterator normOption = normOptions_.begin();
366  normOption != normOptions_.end(); ++normOption )
367  {
368  normalizeToEntries(ibooker, igetter, dirName, normOption->name, normOption->normHistName);
369  }
370 
371  for ( vector<CDOption>::const_iterator cdOption = cdOptions_.begin();
372  cdOption != cdOptions_.end(); ++cdOption )
373  {
374  makeCumulativeDist(ibooker, igetter, dirName, cdOption->name, cdOption->ascending);
375  }
376 
377  for ( vector<EfficOption>::const_iterator efficOption = efficOptions_.begin();
378  efficOption != efficOptions_.end(); ++efficOption )
379  {
380  computeEfficiency(ibooker, igetter, dirName, efficOption->name, efficOption->title,
381  efficOption->numerator, efficOption->denominator,
382  efficOption->type, efficOption->isProfile);
383  }
384 
385  for ( vector<ResolOption>::const_iterator resolOption = resolOptions_.begin();
386  resolOption != resolOptions_.end(); ++resolOption )
387  {
388  computeResolution(ibooker, igetter, dirName, resolOption->namePrefix, resolOption->titlePrefix, resolOption->srcName);
389  }
390 
391  for(const auto& profileOption: profileOptions_) {
392  computeProfile(ibooker, igetter, dirName, profileOption.name, profileOption.title, profileOption.srcName);
393  }
394 
395  }
396 
397  if ( ! outputFileName_.empty() ) theDQM->save(outputFileName_);
398 
399 }
std::vector< EfficOption > efficOptions_
std::vector< ProfileOption > profileOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
void makeCumulativeDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
uint16_t size_type
std::vector< ResolOption > resolOptions_
std::vector< std::string > subDirs_
void normalizeToEntries(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
void computeResolution(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &fitMEPrefix, const std::string &fitMETitlePrefix, const std::string &srcMEName)
std::string outputFileName_
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
std::vector< CDOption > cdOptions_
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &efficMEName, const std::string &efficMETitle, const std::string &recoMEName, const std::string &simMEName, const int type=1, const bool makeProfile=false)
void computeProfile(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
std::vector< NormOption > normOptions_
void DQMGenericClient::findAllSubdirectories ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
std::string  dir,
std::set< std::string > *  myList,
const TString &  pattern = TString("") 
)
private

Definition at line 893 of file DQMGenericClient.cc.

References DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, DQMStore::IGetter::getSubdirs(), nonPerlWildcard(), and listBenchmarks::pattern.

894  {
895  TString pattern = _pattern;
896  if (!igetter.dirExists(dir)) {
897  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
898  return;
899  }
900  if (pattern != "") {
901  if (pattern.Contains(nonPerlWildcard)) pattern.ReplaceAll("*",".*");
902  TPRegexp regexp(pattern);
903  ibooker.cd(dir);
904  vector <string> foundDirs = igetter.getSubdirs();
905  for(vector<string>::const_iterator iDir = foundDirs.begin();
906  iDir != foundDirs.end(); ++iDir) {
907  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
908  if (dirName.Contains(regexp))
909  findAllSubdirectories (ibooker, igetter, *iDir, myList);
910  }
911  }
912  //std::cout << "Looking for directory " << dir ;
913  else if (igetter.dirExists(dir)){
914  //std::cout << "... it exists! Inserting it into the list ";
915  myList->insert(dir);
916  //std::cout << "... now list has size " << myList->size() << std::endl;
917  ibooker.cd(dir);
918  findAllSubdirectories (ibooker, igetter, dir, myList, "*");
919  } else {
920  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
921 
922  LogInfo ("DQMGenericClient") << "Trying to find sub-directories of " << dir
923  << " failed because " << dir << " does not exist";
924 
925  }
926  return;
927 }
void cd(void)
Definition: DQMStore.cc:269
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
TPRegexp nonPerlWildcard("\\w\\*|^\\*")
dbl *** dir
Definition: mlp_gen.cc:35
void DQMGenericClient::generic_eff ( TH1 *  denom,
TH1 *  numer,
MonitorElement efficiencyHist,
const int  type = 1 
)
private

Definition at line 930 of file DQMGenericClient.cc.

References LogDebug, MonitorElement::setBinContent(), MonitorElement::setBinError(), MonitorElement::setEfficiencyFlag(), and mathSSE::sqrt().

930  {
931  for (int iBinX = 1; iBinX < denom->GetNbinsX()+1; iBinX++){
932  for (int iBinY = 1; iBinY < denom->GetNbinsY()+1; iBinY++){
933  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ()+1; iBinZ++){
934 
935  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
936 
937  float numerVal = numer->GetBinContent(globalBinNum);
938  float denomVal = denom->GetBinContent(globalBinNum);
939 
940  float effVal = 0;
941 
942  // fake eff is in use
943  if (type == 2 ) {
944  effVal = denomVal ? (1 - numerVal / denomVal) : 0;
945  } else {
946  effVal = denomVal ? numerVal / denomVal : 0;
947  }
948 
949  float errVal = (denomVal && (effVal <=1)) ? sqrt(effVal*(1-effVal)/denomVal) : 0;
950 
951  LogDebug ("DQMGenericClient") << "(iBinX, iBinY, iBinZ) = "
952  << iBinX << ", "
953  << iBinY << ", "
954  << iBinZ << "), global bin = " << globalBinNum
955  << "eff = " << numerVal << " / " << denomVal
956  << " = " << effVal
957  << " ... setting the error for that bin ... " << endl
958  << endl;
959 
960 
961  efficiencyHist->setBinContent(globalBinNum, effVal);
962  efficiencyHist->setBinError(globalBinNum, errVal);
963  efficiencyHist->setEfficiencyFlag();
964  }
965  }
966  }
967 
968  //efficiencyHist->setMinimum(0.0);
969  //efficiencyHist->setMaximum(1.0);
970 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
void setBinContent(int binx, double content)
set content of bin (1-D)
T sqrt(T t)
Definition: SSEVec.h:18
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void setEfficiencyFlag(void)
void DQMGenericClient::limitedFit ( MonitorElement srcME,
MonitorElement meanME,
MonitorElement sigmaME 
)

Definition at line 841 of file DQMGenericClient.cc.

References generateEDF::cont, MonitorElement::getTH2F(), timingPdfMaker::histo, i, MonitorElement::setBinContent(), and MonitorElement::setBinError().

842 {
843  TH2F * histo = srcME->getTH2F();
844 
845  static int i = 0;
846  i++;
847 
848  // Fit slices projected along Y from bins in X
849  double cont_min = 100; //Minimum number of entries
850  Int_t binx = histo->GetXaxis()->GetNbins();
851 
852  for (int i = 1; i <= binx ; i++) {
853  TString iString(i);
854  TH1 *histoY = histo->ProjectionY(" ", i, i);
855  double cont = histoY->GetEntries();
856 
857  if (cont >= cont_min) {
858  float minfit = histoY->GetMean() - histoY->GetRMS();
859  float maxfit = histoY->GetMean() + histoY->GetRMS();
860 
861  TF1 *fitFcn = new TF1(TString("g")+histo->GetName()+iString,"gaus",minfit,maxfit);
862  double x1,x2;
863  fitFcn->GetRange(x1,x2);
864 
865  histoY->Fit(fitFcn,"QR0","",x1,x2);
866 
867 // histoY->Fit(fitFcn->GetName(),"RME");
868  double *par = fitFcn->GetParameters();
869  const double *err = fitFcn->GetParErrors();
870 
871  meanME->setBinContent(i, par[1]);
872  meanME->setBinError(i, err[1]);
873 // meanME->setBinEntries(i, 1.);
874 // meanME->setBinError(i,sqrt(err[1]*err[1]+par[1]*par[1]));
875 
876  sigmaME->setBinContent(i, par[2]);
877  sigmaME->setBinError(i, err[2]);
878 // sigmaME->setBinEntries(i, 1.);
879 // sigmaME->setBinError(i,sqrt(err[2]*err[2]+par[2]*par[2]));
880 
881  if(fitFcn) delete fitFcn;
882  if(histoY) delete histoY;
883  }
884  else {
885  if(histoY) delete histoY;
886  continue;
887  }
888  }
889 }
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
TH2F * getTH2F(void) const
void DQMGenericClient::makeCumulativeDist ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  cdName,
bool  ascending = true 
)

Definition at line 793 of file DQMGenericClient.cc.

References DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), DQMStore::IGetter::get(), and i.

794 {
795  if ( ! igetter.dirExists(startDir) ) {
796  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
797  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
798  << "Cannot find sub-directory " << startDir << endl;
799  }
800  return;
801  }
802 
803  ibooker.cd();
804 
805  ME* element_cd = igetter.get(startDir+"/"+cdName);
806 
807  if ( !element_cd ) {
808  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
809  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
810  << "No such element '" << cdName << "' found\n";
811  }
812  return;
813  }
814 
815  TH1F* cd = element_cd->getTH1F();
816 
817  if ( !cd ) {
818  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
819  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
820  << "Cannot create TH1F from ME\n";
821  }
822  return;
823  }
824 
825  int n_bins = cd->GetNbinsX() + 1;
826 
827  if(ascending) {
828  for (int i = 1; i <= n_bins; i++) {
829  cd->SetBinContent(i,cd->GetBinContent(i) + cd->GetBinContent(i-1));
830  }
831  }
832  else {
833  for (int i = n_bins-1; i >= 0; i--) { // n_bins points to the overflow bin
834  cd->SetBinContent(i,cd->GetBinContent(i) + cd->GetBinContent(i+1));
835  }
836  }
837 
838  return;
839 }
int i
Definition: DBlmapReader.cc:9
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
Definition: ME.h:11
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
unsigned int verbose_
void DQMGenericClient::normalizeToEntries ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName 
)

Definition at line 731 of file DQMGenericClient.cc.

References DQMStore::IBooker::cd(), DQMStore::IGetter::dirExists(), DQMStore::IGetter::get(), and estimatePileup::hist.

733 {
734  if ( ! igetter.dirExists(startDir) ) {
735  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
736  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
737  << "Cannot find sub-directory " << startDir << endl;
738  }
739  return;
740  }
741 
742  ibooker.cd();
743 
744  ME* element = igetter.get(startDir+"/"+histName);
745  ME* normME = igetter.get(startDir+"/"+normHistName);
746 
747  if ( !element ) {
748  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
749  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
750  << "No such element '" << histName << "' found\n";
751  }
752  return;
753  }
754 
755  if ( !normME ) {
756  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
757  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
758  << "No such element '" << normHistName << "' found\n";
759  }
760  return;
761  }
762 
763  TH1F* hist = element->getTH1F();
764  if ( !hist) {
765  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
766  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
767  << "Cannot create TH1F from ME\n";
768  }
769  return;
770  }
771 
772  TH1F* normHist = normME->getTH1F();
773  if ( !normHist ) {
774  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
775  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
776  << "Cannot create TH1F from ME\n";
777  }
778  return;
779  }
780 
781  const double entries = normHist->GetEntries();
782  if ( entries != 0 ) {
783  hist->Scale(1./entries);
784  }
785  else {
786  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
787  << "Zero entries in histogram\n";
788  }
789 
790  return;
791 }
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
Definition: ME.h:11
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
unsigned int verbose_

Member Data Documentation

std::vector<CDOption> DQMGenericClient::cdOptions_
private

Definition at line 113 of file DQMGenericClient.h.

std::vector<EfficOption> DQMGenericClient::efficOptions_
private

Definition at line 109 of file DQMGenericClient.h.

bool DQMGenericClient::isWildcardUsed_
private

Definition at line 102 of file DQMGenericClient.h.

std::vector<NormOption> DQMGenericClient::normOptions_
private

Definition at line 112 of file DQMGenericClient.h.

std::string DQMGenericClient::outputFileName_
private

Definition at line 107 of file DQMGenericClient.h.

std::vector<ProfileOption> DQMGenericClient::profileOptions_
private

Definition at line 111 of file DQMGenericClient.h.

bool DQMGenericClient::resLimitedFit_
private

Definition at line 103 of file DQMGenericClient.h.

std::vector<ResolOption> DQMGenericClient::resolOptions_
private

Definition at line 110 of file DQMGenericClient.h.

std::vector<std::string> DQMGenericClient::subDirs_
private

Definition at line 106 of file DQMGenericClient.h.

DQMStore* DQMGenericClient::theDQM
private

Definition at line 105 of file DQMGenericClient.h.

unsigned int DQMGenericClient::verbose_
private

Definition at line 101 of file DQMGenericClient.h.