22 #include <boost/tokenizer.hpp> 30 typedef std::vector<edm::ParameterSet>
VPSet;
31 typedef std::vector<std::string>
vstring;
32 typedef boost::escaped_list_separator<char> elsc;
34 elsc commonEscapes(
"\\",
" \t",
"\'");
38 for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
41 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
44 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
47 args.push_back(*iToken);
51 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
59 normOptions_.push_back(
opt);
63 for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
65 opt.name = normSet->getUntrackedParameter<
string>(
"name");
66 opt.normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo",
opt.name);
68 normOptions_.push_back(
opt);
73 for (vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd) {
76 boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
79 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
82 args.push_back(*iToken);
85 if (
args.size() != 2) {
86 LogInfo(
"DQMRivetClient") <<
"Wrong input to lumiCmds\n";
93 opt.xsection =
pset.getUntrackedParameter<
double>(
"xsection", -1.);
97 lumiOptions_.push_back(
opt);
102 for (vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd) {
103 if (scaleCmd->empty())
105 boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
108 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
111 args.push_back(*iToken);
115 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
121 opt.scale = atof(
args[1].c_str());
122 scaleOptions_.push_back(
opt);
125 outputFileName_ =
pset.getUntrackedParameter<
string>(
"outputFileName",
"");
126 subDirs_ =
pset.getUntrackedParameter<
vstring>(
"subDirs");
130 typedef vector<string>
vstring;
144 LogInfo(
"DQMRivetClient") <<
"Cannot create DQMStore instance\n";
149 set<string> subDirSet;
151 for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
160 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
161 const string&
dirName = *iSubDir;
162 for (vector<NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end();
168 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
169 const string&
dirName = *iSubDir;
170 for (vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin(); lumiOption != lumiOptions_.end();
176 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
177 const string&
dirName = *iSubDir;
178 for (vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
179 scaleOption != scaleOptions_.end();
181 scaleByFactor(
dirName, scaleOption->name, scaleOption->scale);
185 if (!outputFileName_.empty())
186 theDQM->save(outputFileName_);
193 LogTrace(
"DQMRivetClient") <<
"inside of ::endJob()" << endl;
199 if (!theDQM->dirExists(startDir)) {
200 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 201 <<
"Cannot find sub-directory " << startDir << endl;
207 ME* element = theDQM->get(startDir +
"/" + histName);
208 ME* normME = theDQM->get(startDir +
"/" + normHistName);
211 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 212 <<
"No such element '" << histName <<
"' found\n";
217 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 218 <<
"No such element '" << normHistName <<
"' found\n";
222 TH1F*
hist = element->getTH1F();
224 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 225 <<
"Cannot create TH1F from ME\n";
229 TH1F* normHist = normME->getTH1F();
231 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 232 <<
"Cannot create TH1F from ME\n";
236 const double entries = normHist->Integral();
238 hist->Scale(1. / entries,
"width");
240 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 241 <<
"Zero entries in histogram\n";
253 ME* element = theDQM->get(startDir +
"/" + histName);
254 TH1F*
hist = element->getTH1F();
256 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 257 <<
"Cannot create TH1F from ME\n";
265 if (!theDQM->dirExists(startDir)) {
266 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 267 <<
"Cannot find sub-directory " << startDir << endl;
273 ME* element = theDQM->get(startDir +
"/" + histName);
276 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 277 <<
"No such element '" << histName <<
"' found\n";
281 TH1F*
hist = element->getTH1F();
283 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 284 <<
"Cannot create TH1F from ME\n";
#define DEFINE_FWK_MODULE(type)
DQMRivetClient(const edm::ParameterSet &pset)
DQMRivetClient::MonitorElement ME
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void normalizeToIntegral(const std::string &startDir, const std::string &histName, const std::string &normHistName)
Log< level::Info, false > LogInfo
void endRun(const edm::Run &r, const edm::EventSetup &c) override
EndRun.
void normalizeToLumi(const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection)