23 #include <boost/tokenizer.hpp> 30 TPRegexp
metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
33 typedef std::vector<edm::ParameterSet>
VPSet;
34 typedef std::vector<std::string>
vstring;
35 typedef boost::escaped_list_separator<char> elsc;
37 elsc commonEscapes(
"\\",
" \t",
"\'");
41 for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
44 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
47 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
50 args.push_back(*iToken);
53 if (args.empty()
or args.size() > 2) {
54 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
62 normOptions_.push_back(opt);
66 for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
68 opt.
name = normSet->getUntrackedParameter<
string>(
"name");
69 opt.
normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo", opt.
name);
71 normOptions_.push_back(opt);
76 for (vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd) {
79 boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
82 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
85 args.push_back(*iToken);
88 if (args.size() != 2) {
89 LogInfo(
"DQMRivetClient") <<
"Wrong input to lumiCmds\n";
100 lumiOptions_.push_back(opt);
105 for (vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd) {
106 if (scaleCmd->empty())
108 boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
111 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
114 args.push_back(*iToken);
117 if (args.empty()
or args.size() > 2) {
118 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
124 opt.
scale = atof(args[1].c_str());
125 scaleOptions_.push_back(opt);
133 typedef vector<string>
vstring;
147 LogInfo(
"DQMRivetClient") <<
"Cannot create DQMStore instance\n";
152 set<string> subDirSet;
154 for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
157 if (subDir[subDir.size() - 1] ==
'/')
158 subDir.erase(subDir.size() - 1);
160 subDirSet.insert(subDir);
163 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
164 const string&
dirName = *iSubDir;
165 for (vector<DQMGenericClient::NormOption>::const_iterator normOption = normOptions_.begin();
166 normOption != normOptions_.end();
172 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
173 const string&
dirName = *iSubDir;
174 for (vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin(); lumiOption != lumiOptions_.end();
176 normalizeToLumi(dirName, lumiOption->name, lumiOption->normHistName, lumiOption->xsection);
180 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
181 const string&
dirName = *iSubDir;
182 for (vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
183 scaleOption != scaleOptions_.end();
185 scaleByFactor(dirName, scaleOption->name, scaleOption->scale);
189 if (!outputFileName_.empty())
190 theDQM->save(outputFileName_);
197 LogTrace(
"DQMRivetClient") <<
"inside of DQMGenericClient::endJob()" << endl;
203 if (!theDQM->dirExists(startDir)) {
204 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 205 <<
"Cannot find sub-directory " << startDir << endl;
211 ME* element = theDQM->get(startDir +
"/" + histName);
212 ME* normME = theDQM->get(startDir +
"/" + normHistName);
215 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 216 <<
"No such element '" << histName <<
"' found\n";
221 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 222 <<
"No such element '" << normHistName <<
"' found\n";
226 TH1F*
hist = element->getTH1F();
228 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 229 <<
"Cannot create TH1F from ME\n";
233 TH1F* normHist = normME->getTH1F();
235 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 236 <<
"Cannot create TH1F from ME\n";
240 const double entries = normHist->Integral();
242 hist->Scale(1. / entries,
"width");
244 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 245 <<
"Zero entries in histogram\n";
257 ME* element = theDQM->get(startDir +
"/" + histName);
258 TH1F*
hist = element->getTH1F();
260 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 261 <<
"Cannot create TH1F from ME\n";
264 hist->Scale(xsection);
269 if (!theDQM->dirExists(startDir)) {
270 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 271 <<
"Cannot find sub-directory " << startDir << endl;
277 ME* element = theDQM->get(startDir +
"/" + histName);
280 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 281 <<
"No such element '" << histName <<
"' found\n";
285 TH1F*
hist = element->getTH1F();
287 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 288 <<
"Cannot create TH1F from ME\n";
T getUntrackedParameter(std::string const &, T const &) const
DQMRivetClient(const edm::ParameterSet &pset)
DQMRivetClient::MonitorElement ME
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
#define DEFINE_FWK_MODULE(type)
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)
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)