22 #include "classlib/utils/StringList.h" 23 #include "classlib/utils/StringOps.h" 94 std::type_info
const & tp =
typeid(*h);
95 if (tp ==
typeid(TH1S))
96 _dbe->
book1S(h->GetName(),
dynamic_cast<TH1S*
>(
const_cast<T*
>(
h)));
97 else if (tp ==
typeid(TH1F))
98 _dbe->
book1D(h->GetName(),
dynamic_cast<TH1F*
>(
const_cast<T*
>(
h)));
99 else if (tp ==
typeid(TH1D))
100 _dbe->
book1DD(h->GetName(),
dynamic_cast<TH1D*
>(
const_cast<T*
>(
h)));
109 T * difference =
new T(d_n.c_str(),
112 h_new->GetXaxis()->GetXmin(),
113 h_new->GetXaxis()->GetXmax());
114 difference->Add(h_new);
115 difference->Add(h_ref,-1.);
117 book(directory,
"Ref",h_ref);
118 book(directory,
"New",h_new);
119 book(directory,
"Diff",difference);
142 edm::LogError(
"ProductNotFound")<<
"MEtoMEComparitor did not find his products.";
148 const std::vector<MEtoEDMObject> & metoedmobject_ref = metoedm_ref->getMEtoEdmObject();
149 const std::vector<MEtoEDMObject> & metoedmobject_new = metoedm_new->getMEtoEdmObject();
151 typedef std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> > Mapping;
152 typedef typename std::map<std::string, std::pair<const MEtoEDMObject*, const MEtoEDMObject*> >::iterator Mapping_iterator;
156 LogDebug(
"MEtoMEComparitor")<<
"going to do the mapping from "<<metoedmobject_ref.size()<<
" x "<<metoedmobject_new.size();
157 unsigned int countMe=0;
158 for (
unsigned int i_new=0; i_new!= metoedmobject_new.size(); ++i_new){
159 const std::string & pathname = metoedmobject_new[i_new].name;
160 if (metoedmobject_new[i_new].
object.GetEntries()==0 ||
161 metoedmobject_new[i_new].object.Integral()==0){
165 mapping[pathname]=std::make_pair(&metoedmobject_new[i_new],(
const MEtoEDMObject*)
nullptr);
167 for (
unsigned int i_ref=0; i_ref!= metoedmobject_ref.size() ; ++i_ref){
168 const std::string & pathname = metoedmobject_ref[i_ref].name;
169 Mapping_iterator there = mapping.find(pathname);
170 if (there != mapping.end()){
171 there->second.second = &metoedmobject_ref[i_ref];
175 LogDebug(
"MEtoMEComparitor")<<
"found "<<mapping.size()<<
" pairs of plots";
178 unsigned int nNoMatch=0;
179 unsigned int nEmpty=0;
180 unsigned int nHollow=0;
181 unsigned int nGoodKS=0;
182 unsigned int nBadKS=0;
183 unsigned int nBadDiff=0;
184 unsigned int nGoodDiff=0;
186 typedef std::map<std::string, std::pair<unsigned int,unsigned int> > Subs;
189 for (Mapping_iterator it = mapping.begin();
192 if (!it->second.second){
197 const T * h_ref = &it->second.second->object;
198 const T * h_new = &it->second.first->object;
203 for (
unsigned int iD=1;iD!=
_dirDepth;++iD) subsystem+=
"/"+dir[iD];
204 subSystems[subsystem].first++;
206 if (h_ref->GetEntries()!=0 && h_ref->Integral()!=0){
208 bool cannotComputeKS=
false;
210 KS = h_new->KolmogorovTest(h_ref);
213 cannotComputeKS=
true;
217 unsigned int total_ref=0;
218 unsigned int absdiff=0;
219 for (
unsigned int iBin=0;
220 iBin!=(
unsigned int)h_new->GetNbinsX()+1 ;
222 total_ref+=h_ref->GetBinContent(iBin);
223 absdiff=
std::abs(h_new->GetBinContent(iBin) - h_ref->GetBinContent(iBin));
225 double relativediff=1;
227 relativediff=absdiff / (double) total_ref;
232 <<
" the KS is "<<KS*100.<<
" %" 233 <<
" and the relative diff is: "<<relativediff*100.<<
" %" 234 <<
" KS"<<((cannotComputeKS)?
" not valid":
" is valid");
240 subSystems[subsystem].second++;
250 if (h_ref->GetEntries()==0)
254 LogDebug(
"MEtoMEComparitor")<<h_new->GetName() <<
" in "<<it->first <<
" is empty";
260 if (!mapping.empty()){
262 summary<<
" Summary :" 263 <<
"\n not matched : "<<nNoMatch
264 <<
"\n empty : "<<nEmpty
265 <<
"\n integral zero : "<<nHollow
266 <<
"\n good KS : "<<nGoodKS
267 <<
"\n bad KS : "<<nBadKS
268 <<
"\n bad diff : "<<nBadDiff
269 <<
"\n godd diff : "<<nGoodDiff;
271 for (Subs::iterator iSub=subSystems.begin();
272 iSub!=subSystems.end();++iSub){
273 double fraction = 1-(iSub->second.second / (double)iSub->second.first);
274 summary<<std::endl<<
"Subsytem: "<<iSub->first<<
" has "<< fraction*100<<
" % goodness";
const_reverse_iterator rbegin() const
T getParameter(std::string const &) const
std::string _lumiInstance
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
void endRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
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)
Abs< T >::type abs(const T &t)
ProcessHistory const & processHistory() const
~MEtoMEComparitor() override
void keepBadHistograms(const std::string &directory, const T *h_new, const T *h_ref)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
void setCurrentFolder(const std::string &fullpath)