CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DQMGenericClient Class Reference

#include <DQMGenericClient.h>

Inheritance diagram for DQMGenericClient:
DQMEDHarvester edm::one::EDProducer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources, edm::EndLuminosityBlockProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  CDOption
 
struct  EfficOption
 
struct  NormOption
 
struct  ProfileOption
 
struct  ResolOption
 

Public Types

enum  EfficType { EfficType::none = 0, EfficType::efficiency, EfficType::fakerate, EfficType::simpleratio }
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

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 EfficType type=EfficType::efficiency, 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 beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 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
 
void endLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) override final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void produce (edm::Event &, edm::EventSetup const &) override final
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources, edm::EndLuminosityBlockProducer >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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 & itemsToGetFrom (BranchType iType) 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 EfficType type=EfficType::efficiency)
 

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

- Static Public Member Functions inherited from edm::one::EDProducerBase
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.

Member Enumeration Documentation

Enumerator
none 
efficiency 
fakerate 
simpleratio 

Definition at line 36 of file DQMGenericClient.h.

36  {
37  none = 0,
38  efficiency,
39  fakerate,
40  simpleratio
41  };

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, PostProcessor_cff::efficiency, 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, none, 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 = EfficType::efficiency;
74  else if ( typeName == "fake" ) opt.type = EfficType::fakerate;
75  else if ( typeName == "simpleratio" ) opt.type = EfficType::simpleratio;
76  else opt.type = EfficType::none;
77 
78  efficOptions_.push_back(opt);
79  }
80 
81  VPSet efficSets = pset.getUntrackedParameter<VPSet>("efficiencySets", VPSet());
82  for ( VPSet::const_iterator efficSet = efficSets.begin();
83  efficSet != efficSets.end(); ++efficSet )
84  {
85  EfficOption opt;
86  opt.name = efficSet->getUntrackedParameter<string>("name");
87  opt.title = efficSet->getUntrackedParameter<string>("title");
88  opt.numerator = efficSet->getUntrackedParameter<string>("numerator");
89  opt.denominator = efficSet->getUntrackedParameter<string>("denominator");
90  opt.isProfile = false;
91 
92  const string typeName = efficSet->getUntrackedParameter<string>("typeName", "eff");
93  if ( typeName == "eff" ) opt.type = EfficType::efficiency;
94  else if ( typeName == "fake" ) opt.type = EfficType::fakerate;
95  else if ( typeName == "simpleratio" ) opt.type = EfficType::simpleratio;
96  else opt.type = EfficType::none;
97 
98  efficOptions_.push_back(opt);
99  }
100 
101  // Parse efficiency profiles
102  vstring effProfileCmds = pset.getUntrackedParameter<vstring>("efficiencyProfile", vstring());
103  for ( vstring::const_iterator effProfileCmd = effProfileCmds.begin();
104  effProfileCmd != effProfileCmds.end(); ++effProfileCmd )
105  {
106  if ( effProfileCmd->empty() ) continue;
107 
108  boost::tokenizer<elsc> tokens(*effProfileCmd, commonEscapes);
109 
110  vector<string> args;
111  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
112  iToken != tokens.end(); ++iToken) {
113  if ( iToken->empty() ) continue;
114  args.push_back(*iToken);
115  }
116 
117  if ( args.size() < 4 ) {
118  LogInfo("DQMGenericClient") << "Wrong input to effProfileCmds\n";
119  continue;
120  }
121 
122  EfficOption opt;
123  opt.name = args[0];
124  opt.title = args[1];
125  opt.numerator = args[2];
126  opt.denominator = args[3];
127  opt.isProfile = true;
128 
129  const string typeName = args.size() == 4 ? "eff" : args[4];
130  if ( typeName == "eff" ) opt.type = EfficType::efficiency;
131  else if ( typeName == "fake" ) opt.type = EfficType::fakerate;
132  else if ( typeName == "simpleratio" ) opt.type = EfficType::simpleratio;
133  else opt.type = EfficType::none;
134 
135  efficOptions_.push_back(opt);
136  }
137 
138  VPSet effProfileSets = pset.getUntrackedParameter<VPSet>("efficiencyProfileSets", VPSet());
139  for ( VPSet::const_iterator effProfileSet = effProfileSets.begin();
140  effProfileSet != effProfileSets.end(); ++effProfileSet )
141  {
142  EfficOption opt;
143  opt.name = effProfileSet->getUntrackedParameter<string>("name");
144  opt.title = effProfileSet->getUntrackedParameter<string>("title");
145  opt.numerator = effProfileSet->getUntrackedParameter<string>("numerator");
146  opt.denominator = effProfileSet->getUntrackedParameter<string>("denominator");
147  opt.isProfile = true;
148 
149  const string typeName = effProfileSet->getUntrackedParameter<string>("typeName", "eff");
150  if ( typeName == "eff" ) opt.type = EfficType::efficiency;
151  else if ( typeName == "fake" ) opt.type = EfficType::fakerate;
152  else if ( typeName == "simpleratio" ) opt.type = EfficType::simpleratio;
153  else opt.type = EfficType::none;
154 
155  efficOptions_.push_back(opt);
156  }
157 
158  // Parse resolution commands
159  vstring resCmds = pset.getParameter<vstring>("resolution");
160  for ( vstring::const_iterator resCmd = resCmds.begin();
161  resCmd != resCmds.end(); ++resCmd )
162  {
163  if ( resCmd->empty() ) continue;
164  boost::tokenizer<elsc> tokens(*resCmd, commonEscapes);
165 
166  vector<string> args;
167  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
168  iToken != tokens.end(); ++iToken) {
169  if ( iToken->empty() ) continue;
170  args.push_back(*iToken);
171  }
172 
173  if ( args.size() != 3 ) {
174  LogInfo("DQMGenericClient") << "Wrong input to resCmds\n";
175  continue;
176  }
177 
178  ResolOption opt;
179  opt.namePrefix = args[0];
180  opt.titlePrefix = args[1];
181  opt.srcName = args[2];
182 
183  resolOptions_.push_back(opt);
184  }
185 
186  VPSet resolSets = pset.getUntrackedParameter<VPSet>("resolutionSets", VPSet());
187  for ( VPSet::const_iterator resolSet = resolSets.begin();
188  resolSet != resolSets.end(); ++resolSet )
189  {
190  ResolOption opt;
191  opt.namePrefix = resolSet->getUntrackedParameter<string>("namePrefix");
192  opt.titlePrefix = resolSet->getUntrackedParameter<string>("titlePrefix");
193  opt.srcName = resolSet->getUntrackedParameter<string>("srcName");
194 
195  resolOptions_.push_back(opt);
196  }
197 
198  // Parse profiles
199  vstring profileCmds = pset.getUntrackedParameter<vstring>("profile", vstring());
200  for(const auto& profileCmd: profileCmds) {
201  boost::tokenizer<elsc> tokens(profileCmd, commonEscapes);
202 
203  vector<string> args;
204  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
205  iToken != tokens.end(); ++iToken) {
206  if ( iToken->empty() ) continue;
207  args.push_back(*iToken);
208  }
209 
210  if ( args.size() != 3 ) {
211  LogInfo("DQMGenericClient") << "Wrong input to profileCmds\n";
212  continue;
213  }
214 
215  ProfileOption opt;
216  opt.name = args[0];
217  opt.title = args[1];
218  opt.srcName = args[2];
219 
220  profileOptions_.push_back(opt);
221  }
222 
223  VPSet profileSets = pset.getUntrackedParameter<VPSet>("profileSets", VPSet());
224  for(const auto& profileSet: profileSets) {
225  ProfileOption opt;
226  opt.name = profileSet.getUntrackedParameter<string>("name");
227  opt.title = profileSet.getUntrackedParameter<string>("title");
228  opt.srcName = profileSet.getUntrackedParameter<string>("srcName");
229 
230  profileOptions_.push_back(opt);
231  }
232 
233  // Parse Normalization commands
234  vstring normCmds = pset.getUntrackedParameter<vstring>("normalization", vstring());
235  for ( vstring::const_iterator normCmd = normCmds.begin();
236  normCmd != normCmds.end(); ++normCmd )
237  {
238  if ( normCmd->empty() ) continue;
239  boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
240 
241  vector<string> args;
242  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
243  iToken != tokens.end(); ++iToken) {
244  if ( iToken->empty() ) continue;
245  args.push_back(*iToken);
246  }
247 
248  if ( args.empty() or args.size() > 2 ) {
249  LogInfo("DQMGenericClient") << "Wrong input to normCmds\n";
250  continue;
251  }
252 
253  NormOption opt;
254  opt.name = args[0];
255  opt.normHistName = args.size() == 2 ? args[1] : args[0];
256 
257  normOptions_.push_back(opt);
258  }
259 
260  VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationSets", VPSet());
261  for ( VPSet::const_iterator normSet = normSets.begin();
262  normSet != normSets.end(); ++normSet )
263  {
264  NormOption opt;
265  opt.name = normSet->getUntrackedParameter<string>("name");
266  opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name);
267 
268  normOptions_.push_back(opt);
269  }
270 
271  // Cumulative distributions
272  vstring cdCmds = pset.getUntrackedParameter<vstring>("cumulativeDists", vstring());
273  for ( vstring::const_iterator cdCmd = cdCmds.begin();
274  cdCmd != cdCmds.end(); ++cdCmd )
275  {
276  if ( cdCmd->empty() ) continue;
277  boost::tokenizer<elsc> tokens(*cdCmd, commonEscapes);
278 
279  vector<string> args;
280  for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
281  iToken != tokens.end(); ++iToken) {
282  if ( iToken->empty() ) continue;
283  args.push_back(*iToken);
284  }
285 
286  if ( args.size() == 0 || args.size() > 2) {
287  LogInfo("DQMGenericClient") << "Wrong input to cdCmds\n";
288  continue;
289  }
290 
291  CDOption opt;
292  opt.name = args[0];
293  opt.ascending = args.size() == 2 ? (args[1] != "descending") : true;
294 
295  cdOptions_.push_back(opt);
296  }
297 
298  VPSet cdSets = pset.getUntrackedParameter<VPSet>("cumulativeDistSets", VPSet());
299  for ( VPSet::const_iterator cdSet = cdSets.begin();
300  cdSet != cdSets.end(); ++cdSet )
301  {
302  CDOption opt;
303  opt.name = cdSet->getUntrackedParameter<string>("name");
304  opt.ascending = cdSet->getUntrackedParameter<bool>("ascending",true);
305 
306  cdOptions_.push_back(opt);
307  }
308 
309  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
310  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
311 
312  resLimitedFit_ = pset.getUntrackedParameter<bool>("resolutionLimitedFit",false);
313  isWildcardUsed_ = false;
314 }
std::vector< EfficOption > efficOptions_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ProfileOption > profileOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ResolOption > resolOptions_
std::vector< std::string > subDirs_
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::string outputFileName_
unsigned int verbose_
std::vector< CDOption > cdOptions_
def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff")
std::vector< NormOption > normOptions_
DQMGenericClient::~DQMGenericClient ( )
inline

Definition at line 32 of file DQMGenericClient.h.

References dqmEndJob().

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 EfficType  type = EfficType::efficiency,
const bool  makeProfile = false 
)

Definition at line 405 of file DQMGenericClient.cc.

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

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

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

699  {
700  if(!igetter.dirExists(startDir)) {
701  if(verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
702  LogInfo("DQMGenericClient") << "computeProfile() : "
703  << "Cannot find sub-directory " << startDir << endl;
704  }
705  return;
706  }
707 
708  ibooker.cd();
709 
710  ME* srcME = igetter.get(startDir+"/"+srcMEName);
711  if ( !srcME ) {
712  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
713  LogInfo("DQMGenericClient") << "computeProfile() : "
714  << "No source ME '" << srcMEName << "' found\n";
715  }
716  return;
717  }
718 
719  TH2F* hSrc = srcME->getTH2F();
720  if ( !hSrc ) {
721  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
722  LogInfo("DQMGenericClient") << "computeProfile() : "
723  << "Cannot create TH2F from source-ME\n";
724  }
725  return;
726  }
727 
728  string profileDir = startDir;
729  string newProfileMEName = profileMEName;
730  string::size_type shiftPos;
731  if ( string::npos != (shiftPos = profileMEName.rfind('/')) ) {
732  profileDir += "/"+profileMEName.substr(0, shiftPos);
733  newProfileMEName.erase(0, shiftPos+1);
734  }
735  ibooker.setCurrentFolder(profileDir);
736 
737  std::unique_ptr<TProfile> profile(hSrc->ProfileX()); // We own the pointer
738  profile->SetTitle(profileMETitle.c_str());
739  ibooker.bookProfile(profileMEName, profile.get()); // ibooker makes a copy
740 }
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 619 of file DQMGenericClient.cc.

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

621 {
622  if ( ! igetter.dirExists(startDir) ) {
623  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
624  LogInfo("DQMGenericClient") << "computeResolution() : "
625  << "Cannot find sub-directory " << startDir << endl;
626  }
627  return;
628  }
629 
630  ibooker.cd();
631 
632  ME* srcME = igetter.get(startDir+"/"+srcName);
633  if ( !srcME ) {
634  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
635  LogInfo("DQMGenericClient") << "computeResolution() : "
636  << "No source ME '" << srcName << "' found\n";
637  }
638  return;
639  }
640 
641  TH2F* hSrc = srcME->getTH2F();
642  if ( !hSrc ) {
643  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
644  LogInfo("DQMGenericClient") << "computeResolution() : "
645  << "Cannot create TH2F from source-ME\n";
646  }
647  return;
648  }
649 
650  const int nBin = hSrc->GetNbinsX();
651 
652  string newDir = startDir;
653  string newPrefix = namePrefix;
654  string::size_type shiftPos;
655  if ( string::npos != (shiftPos = namePrefix.rfind('/')) ) {
656  newDir += "/"+namePrefix.substr(0, shiftPos);
657  newPrefix.erase(0, shiftPos+1);
658  }
659 
660  ibooker.setCurrentFolder(newDir);
661 
662  float * lowedgesfloats = new float[nBin+1];
663  ME* meanME;
664  ME* sigmaME;
665  if (hSrc->GetXaxis()->GetXbins()->GetSize())
666  {
667  for (int j=0; j<nBin+1; ++j)
668  lowedgesfloats[j] = (float)hSrc->GetXaxis()->GetXbins()->GetAt(j);
669  meanME = ibooker.book1D(newPrefix+"_Mean", titlePrefix+" Mean", nBin, lowedgesfloats);
670  sigmaME = ibooker.book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin, lowedgesfloats);
671  }
672  else
673  {
674  meanME = ibooker.book1D(newPrefix+"_Mean", titlePrefix+" Mean", nBin,
675  hSrc->GetXaxis()->GetXmin(),
676  hSrc->GetXaxis()->GetXmax());
677  sigmaME = ibooker.book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin,
678  hSrc->GetXaxis()->GetXmin(),
679  hSrc->GetXaxis()->GetXmax());
680  }
681 
682  if (meanME && sigmaME)
683  {
684  meanME->setEfficiencyFlag();
685  sigmaME->setEfficiencyFlag();
686 
687  if (! resLimitedFit_ ) {
688  FitSlicesYTool fitTool(srcME);
689  fitTool.getFittedMeanWithError(meanME);
690  fitTool.getFittedSigmaWithError(sigmaME);
692  } else {
693  limitedFit(srcME,meanME,sigmaME);
694  }
695  }
696  delete[] lowedgesfloats;
697 }
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
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 316 of file DQMGenericClient.cc.

References TrackerOfflineValidation_Dqm_cff::dirName, metacharacters(), Utilities::operator, listBenchmarks::pattern, and muonValidation_cff::subDir.

Referenced by ~DQMGenericClient().

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

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

906  {
907  TString pattern = _pattern;
908  if (!igetter.dirExists(dir)) {
909  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
910  return;
911  }
912  if (pattern != "") {
913  if (pattern.Contains(nonPerlWildcard)) pattern.ReplaceAll("*",".*");
914  TPRegexp regexp(pattern);
915  ibooker.cd(dir);
916  vector <string> foundDirs = igetter.getSubdirs();
917  for(vector<string>::const_iterator iDir = foundDirs.begin();
918  iDir != foundDirs.end(); ++iDir) {
919  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
920  if (dirName.Contains(regexp))
921  findAllSubdirectories (ibooker, igetter, *iDir, myList);
922  }
923  }
924  //std::cout << "Looking for directory " << dir ;
925  else if (igetter.dirExists(dir)){
926  //std::cout << "... it exists! Inserting it into the list ";
927  myList->insert(dir);
928  //std::cout << "... now list has size " << myList->size() << std::endl;
929  ibooker.cd(dir);
930  findAllSubdirectories (ibooker, igetter, dir, myList, "*");
931  } else {
932  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
933 
934  LogInfo ("DQMGenericClient") << "Trying to find sub-directories of " << dir
935  << " failed because " << dir << " does not exist";
936 
937  }
938  return;
939 }
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 EfficType  type = EfficType::efficiency 
)
private

Definition at line 942 of file DQMGenericClient.cc.

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

942  {
943  for (int iBinX = 1; iBinX < denom->GetNbinsX()+1; iBinX++){
944  for (int iBinY = 1; iBinY < denom->GetNbinsY()+1; iBinY++){
945  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ()+1; iBinZ++){
946 
947  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
948 
949  float numerVal = numer->GetBinContent(globalBinNum);
950  float denomVal = denom->GetBinContent(globalBinNum);
951 
952  float effVal = 0;
953 
954  // fake eff is in use
955  if (type == EfficType::fakerate) {
956  effVal = denomVal ? (1 - numerVal / denomVal) : 0;
957  } else {
958  effVal = denomVal ? numerVal / denomVal : 0;
959  }
960 
961  float errVal = 0;
962  if (type == EfficType::simpleratio) {
963  errVal = denomVal ? 1.f/denomVal*effVal*(1+effVal) : 0;
964  } else {
965  errVal = (denomVal && (effVal <=1)) ? sqrt(effVal*(1-effVal)/denomVal) : 0;
966  }
967 
968  LogDebug ("DQMGenericClient") << "(iBinX, iBinY, iBinZ) = "
969  << iBinX << ", "
970  << iBinY << ", "
971  << iBinZ << "), global bin = " << globalBinNum
972  << "eff = " << numerVal << " / " << denomVal
973  << " = " << effVal
974  << " ... setting the error for that bin ... " << endl
975  << endl;
976 
977 
978  efficiencyHist->setBinContent(globalBinNum, effVal);
979  efficiencyHist->setBinError(globalBinNum, errVal);
980  efficiencyHist->setEfficiencyFlag();
981  }
982  }
983  }
984 
985  //efficiencyHist->setMinimum(0.0);
986  //efficiencyHist->setMaximum(1.0);
987 }
#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 853 of file DQMGenericClient.cc.

References MonitorElement::getTH2F(), trackerHits::histo, mps_fire::i, MonitorElement::setBinContent(), and MonitorElement::setBinError().

854 {
855  TH2F * histo = srcME->getTH2F();
856 
857  static int i = 0;
858  i++;
859 
860  // Fit slices projected along Y from bins in X
861  double cont_min = 100; //Minimum number of entries
862  Int_t binx = histo->GetXaxis()->GetNbins();
863 
864  for (int i = 1; i <= binx ; i++) {
865  TString iString(i);
866  TH1 *histoY = histo->ProjectionY(" ", i, i);
867  double cont = histoY->GetEntries();
868 
869  if (cont >= cont_min) {
870  float minfit = histoY->GetMean() - histoY->GetRMS();
871  float maxfit = histoY->GetMean() + histoY->GetRMS();
872 
873  TF1 *fitFcn = new TF1(TString("g")+histo->GetName()+iString,"gaus",minfit,maxfit);
874  double x1,x2;
875  fitFcn->GetRange(x1,x2);
876 
877  histoY->Fit(fitFcn,"QR0","",x1,x2);
878 
879 // histoY->Fit(fitFcn->GetName(),"RME");
880  double *par = fitFcn->GetParameters();
881  const double *err = fitFcn->GetParErrors();
882 
883  meanME->setBinContent(i, par[1]);
884  meanME->setBinError(i, err[1]);
885 // meanME->setBinEntries(i, 1.);
886 // meanME->setBinError(i,sqrt(err[1]*err[1]+par[1]*par[1]));
887 
888  sigmaME->setBinContent(i, par[2]);
889  sigmaME->setBinError(i, err[2]);
890 // sigmaME->setBinEntries(i, 1.);
891 // sigmaME->setBinError(i,sqrt(err[2]*err[2]+par[2]*par[2]));
892 
893  if(fitFcn) delete fitFcn;
894  if(histoY) delete histoY;
895  }
896  else {
897  if(histoY) delete histoY;
898  continue;
899  }
900  }
901 }
void setBinContent(int binx, double content)
set content of bin (1-D)
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 805 of file DQMGenericClient.cc.

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

806 {
807  if ( ! igetter.dirExists(startDir) ) {
808  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
809  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
810  << "Cannot find sub-directory " << startDir << endl;
811  }
812  return;
813  }
814 
815  ibooker.cd();
816 
817  ME* element_cd = igetter.get(startDir+"/"+cdName);
818 
819  if ( !element_cd ) {
820  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
821  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
822  << "No such element '" << cdName << "' found\n";
823  }
824  return;
825  }
826 
827  TH1F* cd = element_cd->getTH1F();
828 
829  if ( !cd ) {
830  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
831  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
832  << "Cannot create TH1F from ME\n";
833  }
834  return;
835  }
836 
837  int n_bins = cd->GetNbinsX() + 1;
838 
839  if(ascending) {
840  for (int i = 1; i <= n_bins; i++) {
841  cd->SetBinContent(i,cd->GetBinContent(i) + cd->GetBinContent(i-1));
842  }
843  }
844  else {
845  for (int i = n_bins-1; i >= 0; i--) { // n_bins points to the overflow bin
846  cd->SetBinContent(i,cd->GetBinContent(i) + cd->GetBinContent(i+1));
847  }
848  }
849 
850  return;
851 }
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 743 of file DQMGenericClient.cc.

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

745 {
746  if ( ! igetter.dirExists(startDir) ) {
747  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
748  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
749  << "Cannot find sub-directory " << startDir << endl;
750  }
751  return;
752  }
753 
754  ibooker.cd();
755 
756  ME* element = igetter.get(startDir+"/"+histName);
757  ME* normME = igetter.get(startDir+"/"+normHistName);
758 
759  if ( !element ) {
760  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
761  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
762  << "No such element '" << histName << "' found\n";
763  }
764  return;
765  }
766 
767  if ( !normME ) {
768  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
769  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
770  << "No such element '" << normHistName << "' found\n";
771  }
772  return;
773  }
774 
775  TH1F* hist = element->getTH1F();
776  if ( !hist) {
777  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
778  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
779  << "Cannot create TH1F from ME\n";
780  }
781  return;
782  }
783 
784  TH1F* normHist = normME->getTH1F();
785  if ( !normHist ) {
786  if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
787  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
788  << "Cannot create TH1F from ME\n";
789  }
790  return;
791  }
792 
793  const double entries = normHist->GetEntries();
794  if ( entries != 0 ) {
795  hist->Scale(1./entries);
796  }
797  else {
798  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
799  << "Zero entries in histogram\n";
800  }
801 
802  return;
803 }
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 120 of file DQMGenericClient.h.

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

Definition at line 116 of file DQMGenericClient.h.

bool DQMGenericClient::isWildcardUsed_
private

Definition at line 109 of file DQMGenericClient.h.

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

Definition at line 119 of file DQMGenericClient.h.

std::string DQMGenericClient::outputFileName_
private

Definition at line 114 of file DQMGenericClient.h.

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

Definition at line 118 of file DQMGenericClient.h.

bool DQMGenericClient::resLimitedFit_
private

Definition at line 110 of file DQMGenericClient.h.

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

Definition at line 117 of file DQMGenericClient.h.

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

Definition at line 113 of file DQMGenericClient.h.

DQMStore* DQMGenericClient::theDQM
private

Definition at line 112 of file DQMGenericClient.h.

unsigned int DQMGenericClient::verbose_
private

Definition at line 108 of file DQMGenericClient.h.