22 #include "classlib/utils/StringList.h"
23 #include "classlib/utils/StringOps.h"
62 template<
class T,
class W>
101 std::type_info
const & tp =
typeid(*h);
102 if (tp ==
typeid(TH1S))
103 _dbe->
book1S(h->GetName(),
dynamic_cast<TH1S*
>(
const_cast<T*
>(
h)));
104 else if (tp ==
typeid(TH1F))
105 _dbe->
book1D(h->GetName(),
dynamic_cast<TH1F*
>(
const_cast<T*
>(
h)));
106 else if (tp ==
typeid(TH1D))
107 _dbe->
book1DD(h->GetName(),
dynamic_cast<TH1D*
>(
const_cast<T*
>(
h)));
114 std::string d_n(h_new->GetName());
116 T * difference =
new T(d_n.c_str(),
119 h_new->GetXaxis()->GetXmin(),
120 h_new->GetXaxis()->GetXmax());
121 difference->Add(h_new);
122 difference->Add(h_ref,-1.);
124 book(directory,
"Ref",h_ref);
125 book(directory,
"New",h_new);
126 book(directory,
"Diff",difference);
149 edm::LogError(
"ProductNotFound")<<
"MEtoMEComparitor did not find his products.";
155 const std::vector<MEtoEDMObject> & metoedmobject_ref = metoedm_ref->getMEtoEdmObject();
156 const std::vector<MEtoEDMObject> & metoedmobject_new = metoedm_new->getMEtoEdmObject();
158 typedef std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> > Mapping;
159 typedef typename std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> >::iterator Mapping_iterator;
163 LogDebug(
"MEtoMEComparitor")<<
"going to do the mapping from "<<metoedmobject_ref.size()<<
" x "<<metoedmobject_new.size();
164 unsigned int countMe=0;
165 for (
unsigned int i_new=0; i_new!= metoedmobject_new.size(); ++i_new){
166 const std::string & pathname = metoedmobject_new[i_new].name;
167 if (metoedmobject_new[i_new].
object.GetEntries()==0 ||
168 metoedmobject_new[i_new].object.Integral()==0){
172 mapping[pathname]=std::make_pair(&metoedmobject_new[i_new],(
const MEtoEDMObject*)0);
174 for (
unsigned int i_ref=0; i_ref!= metoedmobject_ref.size() ; ++i_ref){
175 const std::string & pathname = metoedmobject_ref[i_ref].name;
176 Mapping_iterator there = mapping.find(pathname);
177 if (there != mapping.end()){
178 there->second.second = &metoedmobject_ref[i_ref];
182 LogDebug(
"MEtoMEComparitor")<<
"found "<<mapping.size()<<
" pairs of plots";
185 unsigned int nNoMatch=0;
186 unsigned int nEmpty=0;
187 unsigned int nHollow=0;
188 unsigned int nGoodKS=0;
189 unsigned int nBadKS=0;
190 unsigned int nBadDiff=0;
191 unsigned int nGoodDiff=0;
193 typedef std::map<std::string, std::pair<unsigned int,unsigned int> > Subs;
196 for (Mapping_iterator it = mapping.begin();
199 if (!it->second.second){
204 const T * h_ref = &it->second.second->object;
205 const T * h_new = &it->second.first->object;
210 for (
unsigned int iD=1;iD!=
_dirDepth;++iD) subsystem+=
"/"+dir[iD];
213 if (h_ref->GetEntries()!=0 && h_ref->Integral()!=0){
215 bool cannotComputeKS=
false;
217 KS = h_new->KolmogorovTest(h_ref);
220 cannotComputeKS=
true;
224 unsigned int total_ref=0;
225 unsigned int absdiff=0;
226 for (
unsigned int iBin=0;
227 iBin!=(
unsigned int)h_new->GetNbinsX()+1 ;
229 total_ref+=h_ref->GetBinContent(iBin);
230 absdiff=
std::abs(h_new->GetBinContent(iBin) - h_ref->GetBinContent(iBin));
232 double relativediff=1;
234 relativediff=absdiff / (double) total_ref;
239 <<
" the KS is "<<KS*100.<<
" %"
240 <<
" and the relative diff is: "<<relativediff*100.<<
" %"
241 <<
" KS"<<((cannotComputeKS)?
" not valid":
" is valid");
257 if (h_ref->GetEntries()==0)
261 LogDebug(
"MEtoMEComparitor")<<h_new->GetName() <<
" in "<<it->first <<
" is empty";
267 if (mapping.size()!=0){
269 summary<<
" Summary :"
270 <<
"\n not matched : "<<nNoMatch
271 <<
"\n empty : "<<nEmpty
272 <<
"\n integral zero : "<<nHollow
273 <<
"\n good KS : "<<nGoodKS
274 <<
"\n bad KS : "<<nBadKS
275 <<
"\n bad diff : "<<nBadDiff
276 <<
"\n godd diff : "<<nGoodDiff;
278 for (Subs::iterator iSub=subSystems.begin();
279 iSub!=subSystems.end();++iSub){
280 double fraction = 1-(iSub->second.second / (double)iSub->second.first);
281 summary<<std::endl<<
"Subsytem: "<<iSub->first<<
" has "<< fraction*100<<
" % goodness";
T getParameter(std::string const &) const
std::string _lumiInstance
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
MEtoMEComparitor(const edm::ParameterSet &)
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)
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)