CMS 3D CMS Logo

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

#include <DQMOffline/MEtoMEComparitor/src/MEtoMEComparitor.cc>

Inheritance diagram for MEtoMEComparitor:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 MEtoMEComparitor (const edm::ParameterSet &)
 
 ~MEtoMEComparitor ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup)
 
template<class T >
void book (const std::string &directory, const std::string &type, const T *h)
 
template<class W , class T >
void compare (const W &where, const std::string &instance)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
 
virtual void endRun (const edm::Run &iRun, const edm::EventSetup &iSetup)
 
template<class T >
void keepBadHistograms (const std::string &directory, const T *h_new, const T *h_ref)
 

Private Attributes

bool _autoProcess
 
DQMStore_dbe
 
double _diffgoodness
 
unsigned int _dirDepth
 
double _KSgoodness
 
std::string _lumiInstance
 
std::string _moduleLabel
 
double _overallgoodness
 
std::string _process_new
 
std::string _process_ref
 
std::string _runInstance
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 51 of file MEtoMEComparitor.h.

Constructor & Destructor Documentation

MEtoMEComparitor::MEtoMEComparitor ( const edm::ParameterSet iConfig)
explicit

Definition at line 26 of file MEtoMEComparitor.cc.

References _autoProcess, _dbe, _diffgoodness, _dirDepth, _KSgoodness, _lumiInstance, _moduleLabel, _overallgoodness, _process_new, _process_ref, _runInstance, edm::ParameterSet::getParameter(), cppFunctionSkipper::operator, and AlCaHLTBitMon_QueryRunRegistry::string.

28 {
29  _moduleLabel = iConfig.getParameter<std::string>("MEtoEDMLabel");
30 
31  _lumiInstance = iConfig.getParameter<std::string>("lumiInstance");
32  _runInstance = iConfig.getParameter<std::string>("runInstance");
33 
34  _process_ref = iConfig.getParameter<std::string>("processRef");
35  _process_new = iConfig.getParameter<std::string>("processNew");
36 
37  _autoProcess=iConfig.getParameter<bool>("autoProcess");
38 
39  _KSgoodness = iConfig.getParameter<double>("KSgoodness");
40  _diffgoodness = iConfig.getParameter<double>("Diffgoodness");
41  _dirDepth = iConfig.getParameter<unsigned int>("dirDepth");
42  _overallgoodness = iConfig.getParameter<double>("OverAllgoodness");
43 
45 
46 
47 }
T getParameter(std::string const &) const
std::string _lumiInstance
std::string _process_ref
std::string _process_new
unsigned int _dirDepth
std::string _runInstance
std::string _moduleLabel
MEtoMEComparitor::~MEtoMEComparitor ( )

Definition at line 50 of file MEtoMEComparitor.cc.

51 {
52 
53 }

Member Function Documentation

virtual void MEtoMEComparitor::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 59 of file MEtoMEComparitor.h.

59 {}
void MEtoMEComparitor::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 288 of file MEtoMEComparitor.cc.

289 {
290 }
void MEtoMEComparitor::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 65 of file MEtoMEComparitor.cc.

References _autoProcess, _process_new, _process_ref, gather_cfg::cout, edm::Run::processHistory(), and edm::ProcessHistory::rbegin().

66 {
67  if (_autoProcess)
68  {
69  const edm::ProcessHistory& iHistory=iRun.processHistory();
70 
72  _process_new=hi->processName();
73  hi++;
74  _process_ref=hi->processName();
75  std::cout<<_process_ref<<" vs "<<_process_new<<std::endl;
76  }
77 }
const_reverse_iterator rbegin() const
collection_type::const_reverse_iterator const_reverse_iterator
std::string _process_ref
ProcessHistory const & processHistory() const
Definition: Run.cc:108
std::string _process_new
tuple cout
Definition: gather_cfg.py:121
template<class T >
void MEtoMEComparitor::book ( const std::string &  directory,
const std::string &  type,
const T h 
)
private

Definition at line 91 of file MEtoMEComparitor.cc.

References _dbe, DQMStore::book1D(), DQMStore::book1DD(), DQMStore::book1S(), h, and DQMStore::setCurrentFolder().

Referenced by keepBadHistograms().

91  {
93  std::type_info const & tp = typeid(*h);
94  if (tp == typeid(TH1S))
95  _dbe->book1S(h->GetName(),dynamic_cast<TH1S*>(const_cast<T*>(h)));
96  else if (tp == typeid(TH1F))
97  _dbe->book1D(h->GetName(),dynamic_cast<TH1F*>(const_cast<T*>(h)));
98  else if (tp == typeid(TH1D))
99  _dbe->book1DD(h->GetName(),dynamic_cast<TH1D*>(const_cast<T*>(h)));
100 }
type
Definition: HCALResponse.h:21
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:928
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:960
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:944
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:639
template<class W , class T >
void MEtoMEComparitor::compare ( const W &  where,
const std::string &  instance 
)
private

Definition at line 127 of file MEtoMEComparitor.cc.

References _diffgoodness, _dirDepth, _KSgoodness, _moduleLabel, _overallgoodness, _process_new, _process_ref, funct::abs(), dir, cppFunctionSkipper::exception, edm::HandleBase::failedToGet(), keepBadHistograms(), LogDebug, timingPdfMaker::pathname, split, AlCaHLTBitMon_QueryRunRegistry::string, hcal_dqm_sourceclient-file_cfg::subsystem, and edmLumisInFiles::summary.

127  {
128 
129  edm::Handle<MEtoEDM<T> > metoedm_ref;
130  edm::Handle<MEtoEDM<T> > metoedm_new;
131  where.getByLabel(edm::InputTag(_moduleLabel,
132  instance,
133  _process_ref),
134  metoedm_ref);
135  where.getByLabel(edm::InputTag(_moduleLabel,
136  instance,
137  _process_new),
138  metoedm_new);
139 
140  if (metoedm_ref.failedToGet() || metoedm_new.failedToGet()){
141  edm::LogError("ProductNotFound")<<"MEtoMEComparitor did not find his products.";
142  return;
143  }
144 
145  typedef typename MEtoEDM<T>::MEtoEDMObject MEtoEDMObject;
146 
147  const std::vector<MEtoEDMObject> & metoedmobject_ref = metoedm_ref->getMEtoEdmObject();
148  const std::vector<MEtoEDMObject> & metoedmobject_new = metoedm_new->getMEtoEdmObject();
149 
150  typedef std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> > Mapping;
151  typedef typename std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> >::iterator Mapping_iterator;
152 
153  Mapping mapping;
154 
155  LogDebug("MEtoMEComparitor")<<"going to do the mapping from "<<metoedmobject_ref.size()<<" x "<<metoedmobject_new.size();
156  unsigned int countMe=0;
157  for (unsigned int i_new=0; i_new!= metoedmobject_new.size(); ++i_new){
158  const std::string & pathname = metoedmobject_new[i_new].name;
159  if (metoedmobject_new[i_new].object.GetEntries()==0 ||
160  metoedmobject_new[i_new].object.Integral()==0){
161  countMe--;
162  continue;
163  }
164  mapping[pathname]=std::make_pair(&metoedmobject_new[i_new],(const MEtoEDMObject*)0);
165  }
166  for (unsigned int i_ref=0; i_ref!= metoedmobject_ref.size() ; ++i_ref){
167  const std::string & pathname = metoedmobject_ref[i_ref].name;
168  Mapping_iterator there = mapping.find(pathname);
169  if (there != mapping.end()){
170  there->second.second = &metoedmobject_ref[i_ref];
171  }
172  }
173 
174  LogDebug("MEtoMEComparitor")<<"found "<<mapping.size()<<" pairs of plots";
175  countMe=0;
176 
177  unsigned int nNoMatch=0;
178  unsigned int nEmpty=0;
179  unsigned int nHollow=0;
180  unsigned int nGoodKS=0;
181  unsigned int nBadKS=0;
182  unsigned int nBadDiff=0;
183  unsigned int nGoodDiff=0;
184 
185  typedef std::map<std::string, std::pair<unsigned int,unsigned int> > Subs;
186  Subs subSystems;
187 
188  for (Mapping_iterator it = mapping.begin();
189  it!=mapping.end();
190  ++it){
191  if (!it->second.second){
192  //this is expected by how the map was created
193  nNoMatch++;
194  continue;
195  }
196  const T * h_ref = &it->second.second->object;
197  const T * h_new = &it->second.first->object;
198 
199  lat::StringList dir = lat::StringOps::split(it->second.second->name,"/");
200  std::string subsystem = dir[0];
201  if (dir.size()>=_dirDepth)
202  for (unsigned int iD=1;iD!=_dirDepth;++iD) subsystem+="/"+dir[iD];
203  subSystems[subsystem].first++;
204 
205  if (h_ref->GetEntries()!=0 && h_ref->Integral()!=0){
206  double KS=0;
207  bool cannotComputeKS=false;
208  try {
209  KS = h_new->KolmogorovTest(h_ref);
210  }
211  catch( cms::Exception& exception ){
212  cannotComputeKS=true;
213  }
214  if (KS<_KSgoodness){
215 
216  unsigned int total_ref=0;
217  unsigned int absdiff=0;
218  for (unsigned int iBin=0;
219  iBin!=(unsigned int)h_new->GetNbinsX()+1 ;
220  ++iBin){
221  total_ref+=h_ref->GetBinContent(iBin);
222  absdiff=std::abs(h_new->GetBinContent(iBin) - h_ref->GetBinContent(iBin));
223  }
224  double relativediff=1;
225  if (total_ref!=0){
226  relativediff=absdiff / (double) total_ref;
227  }
228  if (relativediff > _diffgoodness ){
229  edm::LogWarning("MEtoMEComparitor")<<"for "<<h_new->GetName()
230  <<" in "<<it->first
231  <<" the KS is "<<KS*100.<<" %"
232  <<" and the relative diff is: "<<relativediff*100.<<" %"
233  <<" KS"<<((cannotComputeKS)?" not valid":" is valid");
234  //std::string(" KolmogorovTest is not happy on : ")+h_new->GetName() : "";
235  //there you want to output the plots somewhere
236  keepBadHistograms(subsystem,h_new,h_ref);
237 
238  nBadDiff++;
239  subSystems[subsystem].second++;
240  }else{
241  nGoodDiff++;
242  }
243  nBadKS++;
244  }
245  else
246  nGoodKS++;
247  }
248  else{
249  if (h_ref->GetEntries()==0)
250  nEmpty++;
251  else
252  nHollow++;
253  LogDebug("MEtoMEComparitor")<<h_new->GetName() <<" in "<<it->first <<" is empty";
254  countMe--;
255  }
256 
257  }
258 
259  if (mapping.size()!=0){
260  std::stringstream summary;
261  summary<<" Summary :"
262  <<"\n not matched : "<<nNoMatch
263  <<"\n empty : "<<nEmpty
264  <<"\n integral zero : "<<nHollow
265  <<"\n good KS : "<<nGoodKS
266  <<"\n bad KS : "<<nBadKS
267  <<"\n bad diff : "<<nBadDiff
268  <<"\n godd diff : "<<nGoodDiff;
269  bool tell=false;
270  for (Subs::iterator iSub=subSystems.begin();
271  iSub!=subSystems.end();++iSub){
272  double fraction = 1-(iSub->second.second / (double)iSub->second.first);
273  summary<<std::endl<<"Subsytem: "<<iSub->first<<" has "<< fraction*100<<" % goodness";
274  if (fraction < _overallgoodness)
275  tell=true;
276  }
277  if (tell)
278  edm::LogWarning("MEtoMEComparitor")<<summary.str();
279  else
280  edm::LogInfo("MEtoMEComparitor")<<summary.str();
281  }
282 
283 }
#define LogDebug(id)
static PFTauRenderPlugin instance
std::string _process_ref
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string _process_new
bool failedToGet() const
Definition: HandleBase.h:80
void keepBadHistograms(const std::string &directory, const T *h_new, const T *h_ref)
unsigned int _dirDepth
dbl *** dir
Definition: mlp_gen.cc:35
long double T
double split
Definition: MVATrainer.cc:139
std::string _moduleLabel
void MEtoMEComparitor::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 294 of file MEtoMEComparitor.cc.

294  {
295 }
void MEtoMEComparitor::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file MEtoMEComparitor.cc.

References _lumiInstance.

57 {
58 
59  compare<edm::LuminosityBlock,TH1S>(iLumi,_lumiInstance);
60  compare<edm::LuminosityBlock,TH1F>(iLumi,_lumiInstance);
61  compare<edm::LuminosityBlock,TH1D>(iLumi,_lumiInstance);
62 }
std::string _lumiInstance
void MEtoMEComparitor::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 80 of file MEtoMEComparitor.cc.

References _runInstance.

81 {
82 
83  compare<edm::Run,TH1S>(iRun,_runInstance);
84  compare<edm::Run,TH1F>(iRun,_runInstance);
85  compare<edm::Run,TH1D>(iRun,_runInstance);
86 
87 }
std::string _runInstance
template<class T >
void MEtoMEComparitor::keepBadHistograms ( const std::string &  directory,
const T h_new,
const T h_ref 
)
private

Definition at line 102 of file MEtoMEComparitor.cc.

References book(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by compare().

102  {
103  //put it in a collection rather.
104 
105 
106  std::string d_n(h_new->GetName());
107  d_n+="_diff";
108  T * difference = new T(d_n.c_str(),
109  h_new->GetTitle(),
110  h_new->GetNbinsX(),
111  h_new->GetXaxis()->GetXmin(),
112  h_new->GetXaxis()->GetXmax());
113  difference->Add(h_new);
114  difference->Add(h_ref,-1.);
115 
116  book(directory,"Ref",h_ref);
117  book(directory,"New",h_new);
118  book(directory,"Diff",difference);
119  delete difference;
120 
121 }
void book(const std::string &directory, const std::string &type, const T *h)
long double T

Member Data Documentation

bool MEtoMEComparitor::_autoProcess
private

Definition at line 77 of file MEtoMEComparitor.h.

Referenced by beginRun(), and MEtoMEComparitor().

DQMStore* MEtoMEComparitor::_dbe
private

Definition at line 69 of file MEtoMEComparitor.h.

Referenced by book(), and MEtoMEComparitor().

double MEtoMEComparitor::_diffgoodness
private

Definition at line 80 of file MEtoMEComparitor.h.

Referenced by compare(), and MEtoMEComparitor().

unsigned int MEtoMEComparitor::_dirDepth
private

Definition at line 81 of file MEtoMEComparitor.h.

Referenced by compare(), and MEtoMEComparitor().

double MEtoMEComparitor::_KSgoodness
private

Definition at line 79 of file MEtoMEComparitor.h.

Referenced by compare(), and MEtoMEComparitor().

std::string MEtoMEComparitor::_lumiInstance
private

Definition at line 72 of file MEtoMEComparitor.h.

Referenced by endLuminosityBlock(), and MEtoMEComparitor().

std::string MEtoMEComparitor::_moduleLabel
private

Definition at line 70 of file MEtoMEComparitor.h.

Referenced by compare(), and MEtoMEComparitor().

double MEtoMEComparitor::_overallgoodness
private

Definition at line 82 of file MEtoMEComparitor.h.

Referenced by compare(), and MEtoMEComparitor().

std::string MEtoMEComparitor::_process_new
private

Definition at line 76 of file MEtoMEComparitor.h.

Referenced by beginRun(), compare(), and MEtoMEComparitor().

std::string MEtoMEComparitor::_process_ref
private

Definition at line 75 of file MEtoMEComparitor.h.

Referenced by beginRun(), compare(), and MEtoMEComparitor().

std::string MEtoMEComparitor::_runInstance
private

Definition at line 73 of file MEtoMEComparitor.h.

Referenced by endRun(), and MEtoMEComparitor().