#include <DQMRivetClient.h>
Classes | |
struct | LumiOption |
struct | ScaleFactorOption |
Public Member Functions | |
void | analyze (const edm::Event &event, const edm::EventSetup &eventSetup) |
DQMRivetClient (const edm::ParameterSet &pset) | |
void | endJob () |
void | endRun (const edm::Run &r, const edm::EventSetup &c) |
EndRun. | |
void | normalizeToIntegral (const std::string &startDir, const std::string &histName, const std::string &normHistName) |
void | normalizeToLumi (const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection) |
void | scaleByFactor (const std::string &startDir, const std::string &histName, double factor) |
~DQMRivetClient () | |
Private Attributes | |
std::vector< LumiOption > | lumiOptions_ |
std::vector < DQMGenericClient::NormOption > | normOptions_ |
std::string | outputFileName_ |
std::vector< ScaleFactorOption > | scaleOptions_ |
std::vector< std::string > | subDirs_ |
DQMStore * | theDQM |
unsigned int | verbose_ |
Definition at line 15 of file DQMRivetClient.h.
DQMRivetClient::DQMRivetClient | ( | const edm::ParameterSet & | pset | ) |
Definition at line 35 of file DQMRivetClient.cc.
References harvestRelVal::args, edm::ParameterSet::getUntrackedParameter(), DQMGenericClient::NormOption::name, DQMRivetClient::ScaleFactorOption::name, DQMRivetClient::LumiOption::name, DQMGenericClient::NormOption::normHistName, DQMRivetClient::LumiOption::normHistName, DQMRivetClient::ScaleFactorOption::scale, and DQMRivetClient::LumiOption::xsection.
{ typedef std::vector<edm::ParameterSet> VPSet; typedef std::vector<std::string> vstring; typedef boost::escaped_list_separator<char> elsc; elsc commonEscapes("\\", " \t", "\'"); // Parse Normalization commands vstring normCmds = pset.getUntrackedParameter<vstring>("normalizationToIntegral", vstring()); for ( vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd ) { if ( normCmd->empty() ) continue; boost::tokenizer<elsc> tokens(*normCmd, commonEscapes); vector<string> args; for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) { if ( iToken->empty() ) continue; args.push_back(*iToken); } if ( args.empty() or args.size() > 2 ) { LogInfo("DQMRivetClient") << "Wrong input to normCmds\n"; continue; } DQMGenericClient::NormOption opt; opt.name = args[0]; opt.normHistName = args.size() == 2 ? args[1] : args[0]; normOptions_.push_back(opt); } VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationToIntegralSets", VPSet()); for ( VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet ) { DQMGenericClient::NormOption opt; opt.name = normSet->getUntrackedParameter<string>("name"); opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name); normOptions_.push_back(opt); } //normalize to lumi vstring lumiCmds = pset.getUntrackedParameter<vstring>("normalizationToLumi", vstring()); for ( vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd ) { if ( lumiCmd->empty() ) continue; boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes); vector<string> args; for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) { if ( iToken->empty() ) continue; args.push_back(*iToken); } if ( args.size() != 2 ) { LogInfo("DQMRivetClient") << "Wrong input to lumiCmds\n"; continue; } DQMRivetClient::LumiOption opt; opt.name = args[0]; opt.normHistName = args[1] ; opt.xsection = pset.getUntrackedParameter<double>("xsection", -1.); //opt.xsection = atof(args[2].c_str()); //std::cout << opt.name << " " << opt.normHistName << " " << opt.xsection << std::endl; lumiOptions_.push_back(opt); } //multiply by a number vstring scaleCmds = pset.getUntrackedParameter<vstring>("scaleBy", vstring()); for ( vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd ) { if ( scaleCmd->empty() ) continue; boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes); vector<string> args; for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) { if ( iToken->empty() ) continue; args.push_back(*iToken); } if ( args.empty() or args.size() > 2 ) { LogInfo("DQMRivetClient") << "Wrong input to normCmds\n"; continue; } ScaleFactorOption opt; opt.name = args[0]; opt.scale = atof(args[1].c_str()); scaleOptions_.push_back(opt); } outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", ""); subDirs_ = pset.getUntrackedParameter<vstring>("subDirs"); }
DQMRivetClient::~DQMRivetClient | ( | ) | [inline] |
Definition at line 19 of file DQMRivetClient.h.
{};
void DQMRivetClient::analyze | ( | const edm::Event & | event, |
const edm::EventSetup & | eventSetup | ||
) | [inline, virtual] |
void DQMRivetClient::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 210 of file DQMRivetClient.cc.
References LogTrace.
{ // Update 2009-09-23 // Migrated all code from here to endRun LogTrace ("DQMRivetClient") << "inside of DQMGenericClient::endJob()" << endl; }
void DQMRivetClient::endRun | ( | const edm::Run & | r, |
const edm::EventSetup & | c | ||
) | [virtual] |
EndRun.
Reimplemented from edm::EDAnalyzer.
Definition at line 144 of file DQMRivetClient.cc.
References TrackerOfflineValidation_Dqm_cff::dirName, and cppFunctionSkipper::operator.
{ typedef vector<string> vstring; // Update 2009-09-23 // Migrated all code from endJob to this function // endJob is not necessarily called in the proper sequence // and does not necessarily book histograms produced in // that step. // It more robust to do the histogram manipulation in // this endRun function theDQM = 0; theDQM = Service<DQMStore>().operator->(); if ( ! theDQM ) { LogInfo("DQMRivetClient") << "Cannot create DQMStore instance\n"; return; } // Process wildcard in the sub-directory set<string> subDirSet; for(vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) { string subDir = *iSubDir; if ( subDir[subDir.size()-1] == '/' ) subDir.erase(subDir.size()-1); subDirSet.insert(subDir); } for(set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) { const string& dirName = *iSubDir; for ( vector<DQMGenericClient::NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end(); ++normOption ){ normalizeToIntegral(dirName, normOption->name, normOption->normHistName); } } for(set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) { const string& dirName = *iSubDir; for ( vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin(); lumiOption != lumiOptions_.end(); ++lumiOption ){ normalizeToLumi(dirName, lumiOption->name, lumiOption->normHistName, lumiOption->xsection); } } for(set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) { const string& dirName = *iSubDir; for ( vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin(); scaleOption != scaleOptions_.end(); ++scaleOption ){ scaleByFactor(dirName, scaleOption->name, scaleOption->scale); } } if ( ! outputFileName_.empty() ) theDQM->save(outputFileName_); }
void DQMRivetClient::normalizeToIntegral | ( | const std::string & | startDir, |
const std::string & | histName, | ||
const std::string & | normHistName | ||
) |
Definition at line 221 of file DQMRivetClient.cc.
References python::tagInventory::entries, and estimatePileup::hist.
{ if ( ! theDQM->dirExists(startDir) ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot find sub-directory " << startDir << endl; return; } theDQM->cd(); ME* element = theDQM->get(startDir+"/"+histName); ME* normME = theDQM->get(startDir+"/"+normHistName); if ( !element ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "No such element '" << histName << "' found\n"; return; } if ( !normME ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "No such element '" << normHistName << "' found\n"; return; } TH1F* hist = element->getTH1F(); if ( !hist) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot create TH1F from ME\n"; return; } TH1F* normHist = normME->getTH1F(); if ( !normHist ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot create TH1F from ME\n"; return; } const double entries = normHist->Integral(); if ( entries != 0 ) { hist->Scale(1./entries, "width"); } else { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Zero entries in histogram\n"; } return; }
void DQMRivetClient::normalizeToLumi | ( | const std::string & | startDir, |
const std::string & | histName, | ||
const std::string & | normHistName, | ||
double | xsection | ||
) |
Definition at line 272 of file DQMRivetClient.cc.
References estimatePileup::hist.
{ normalizeToIntegral(startDir, histName, normHistName); theDQM->cd(); ME* element = theDQM->get(startDir+"/"+histName); TH1F* hist = element->getTH1F(); if ( !hist) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot create TH1F from ME\n"; return; } hist->Scale(xsection); return; }
void DQMRivetClient::scaleByFactor | ( | const std::string & | startDir, |
const std::string & | histName, | ||
double | factor | ||
) |
Definition at line 286 of file DQMRivetClient.cc.
References estimatePileup::hist.
{ if ( ! theDQM->dirExists(startDir) ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot find sub-directory " << startDir << endl; return; } theDQM->cd(); ME* element = theDQM->get(startDir+"/"+histName); if ( !element ) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "No such element '" << histName << "' found\n"; return; } TH1F* hist = element->getTH1F(); if ( !hist) { LogInfo("DQMRivetClient") << "normalizeToEntries() : " << "Cannot create TH1F from ME\n"; return; } hist->Scale(factor); }
std::vector<LumiOption> DQMRivetClient::lumiOptions_ [private] |
Definition at line 52 of file DQMRivetClient.h.
std::vector<DQMGenericClient::NormOption> DQMRivetClient::normOptions_ [private] |
Definition at line 51 of file DQMRivetClient.h.
std::string DQMRivetClient::outputFileName_ [private] |
Definition at line 49 of file DQMRivetClient.h.
std::vector<ScaleFactorOption> DQMRivetClient::scaleOptions_ [private] |
Definition at line 53 of file DQMRivetClient.h.
std::vector<std::string> DQMRivetClient::subDirs_ [private] |
Definition at line 48 of file DQMRivetClient.h.
DQMStore* DQMRivetClient::theDQM [private] |
Definition at line 47 of file DQMRivetClient.h.
unsigned int DQMRivetClient::verbose_ [private] |
Definition at line 45 of file DQMRivetClient.h.