22 #include "classlib/utils/StringList.h"
23 #include "classlib/utils/StringOps.h"
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)));
108 T * difference =
new T(d_n.c_str(),
111 h_new->GetXaxis()->GetXmin(),
112 h_new->GetXaxis()->GetXmax());
113 difference->Add(h_new);
114 difference->Add(h_ref,-1.);
116 book(directory,
"Ref",h_ref);
117 book(directory,
"New",h_new);
118 book(directory,
"Diff",difference);
141 edm::LogError(
"ProductNotFound")<<
"MEtoMEComparitor did not find his products.";
147 const std::vector<MEtoEDMObject> & metoedmobject_ref = metoedm_ref->getMEtoEdmObject();
148 const std::vector<MEtoEDMObject> & metoedmobject_new = metoedm_new->getMEtoEdmObject();
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;
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){
159 if (metoedmobject_new[i_new].
object.GetEntries()==0 ||
160 metoedmobject_new[i_new].object.Integral()==0){
164 mapping[
pathname]=std::make_pair(&metoedmobject_new[i_new],(
const MEtoEDMObject*)0);
166 for (
unsigned int i_ref=0; i_ref!= metoedmobject_ref.size() ; ++i_ref){
168 Mapping_iterator there = mapping.find(pathname);
169 if (there != mapping.end()){
170 there->second.second = &metoedmobject_ref[i_ref];
174 LogDebug(
"MEtoMEComparitor")<<
"found "<<mapping.size()<<
" pairs of plots";
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;
185 typedef std::map<std::string, std::pair<unsigned int,unsigned int> > Subs;
188 for (Mapping_iterator it = mapping.begin();
191 if (!it->second.second){
196 const T * h_ref = &it->second.second->object;
197 const T * h_new = &it->second.first->object;
202 for (
unsigned int iD=1;iD!=
_dirDepth;++iD) subsystem+=
"/"+dir[iD];
205 if (h_ref->GetEntries()!=0 && h_ref->Integral()!=0){
207 bool cannotComputeKS=
false;
209 KS = h_new->KolmogorovTest(h_ref);
212 cannotComputeKS=
true;
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 ;
221 total_ref+=h_ref->GetBinContent(iBin);
222 absdiff=
std::abs(h_new->GetBinContent(iBin) - h_ref->GetBinContent(iBin));
224 double relativediff=1;
226 relativediff=absdiff / (double) total_ref;
231 <<
" the KS is "<<KS*100.<<
" %"
232 <<
" and the relative diff is: "<<relativediff*100.<<
" %"
233 <<
" KS"<<((cannotComputeKS)?
" not valid":
" is valid");
249 if (h_ref->GetEntries()==0)
253 LogDebug(
"MEtoMEComparitor")<<h_new->GetName() <<
" in "<<it->first <<
" is empty";
259 if (mapping.size()!=0){
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;
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";
const_reverse_iterator rbegin() const
T getParameter(std::string const &) const
std::string _lumiInstance
collection_type::const_reverse_iterator const_reverse_iterator
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
static PFTauRenderPlugin instance
MEtoMEComparitor(const edm::ParameterSet &)
virtual void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
void compare(const W &where, const std::string &instance)
void book(const std::string &directory, const std::string &type, const T *h)
virtual void endRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
ProcessHistory const & processHistory() const
void keepBadHistograms(const std::string &directory, const T *h_new, const T *h_ref)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
void setCurrentFolder(const std::string &fullpath)