#include "TString.h" #include "TH1F.h" #include "TFile.h" #include "TClass.h" #include "TROOT.h" #include "TKey.h" #include "TCollection.h" //#include ".h" #include using namespace std; void Smoother(TString infile, TString outfile="", int NSMOOTH=1) { TH1F::SetDefaultSumw2(); TFile *f = new TFile(infile, "read"); if (outfile == "") outfile = "upd_"+infile; TFile *fout = new TFile(outfile, "recreate"); TIter next(f->GetListOfKeys()); TKey *key; while ((key = (TKey*)next())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; TH1F *h = (TH1F*)key->ReadObj(); TString hname = TString(h->GetName()); double the_integral = h->Integral(); cout << hname << endl; if (hname.Contains("Sig_LL") && the_integral > 0) { cout << "Smoothing histo " << hname << endl; h->Smooth(NSMOOTH); h->Scale(the_integral/h->Integral()); } h->Write(hname); } fout->Close(); }