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 usesResource(
"DQMStore");
36 elsc commonEscapes(
"\\",
" \t",
"\'");
40 for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
43 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
46 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
49 args.push_back(*iToken);
53 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
61 normOptions_.push_back(
opt);
65 for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
67 opt.name = normSet->getUntrackedParameter<
string>(
"name");
68 opt.normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo",
opt.name);
70 normOptions_.push_back(
opt);
75 for (vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd) {
78 boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
81 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
84 args.push_back(*iToken);
87 if (
args.size() != 2) {
88 LogInfo(
"DQMRivetClient") <<
"Wrong input to lumiCmds\n";
95 opt.xsection =
pset.getUntrackedParameter<
double>(
"xsection", -1.);
99 lumiOptions_.push_back(
opt);
104 for (vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd) {
105 if (scaleCmd->empty())
107 boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
110 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
113 args.push_back(*iToken);
117 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
123 opt.scale = atof(
args[1].c_str());
124 scaleOptions_.push_back(
opt);
127 outputFileName_ =
pset.getUntrackedParameter<
string>(
"outputFileName",
"");
128 subDirs_ =
pset.getUntrackedParameter<
vstring>(
"subDirs");
132 typedef vector<string>
vstring;
146 LogInfo(
"DQMRivetClient") <<
"Cannot create DQMStore instance\n";
151 set<string> subDirSet;
153 for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
162 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
163 const string&
dirName = *iSubDir;
164 for (vector<NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end();
170 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
171 const string&
dirName = *iSubDir;
172 for (vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin(); lumiOption != lumiOptions_.end();
178 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
179 const string&
dirName = *iSubDir;
180 for (vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
181 scaleOption != scaleOptions_.end();
183 scaleByFactor(
dirName, scaleOption->name, scaleOption->scale);
187 if (!outputFileName_.empty())
188 theDQM->save(outputFileName_);
195 LogTrace(
"DQMRivetClient") <<
"inside of ::endJob()" << endl;
201 if (!theDQM->dirExists(startDir)) {
202 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 203 <<
"Cannot find sub-directory " << startDir << endl;
209 ME* element = theDQM->get(startDir +
"/" + histName);
210 ME* normME = theDQM->get(startDir +
"/" + normHistName);
213 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 214 <<
"No such element '" << histName <<
"' found\n";
219 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 220 <<
"No such element '" << normHistName <<
"' found\n";
224 TH1F*
hist = element->getTH1F();
226 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 227 <<
"Cannot create TH1F from ME\n";
231 TH1F* normHist = normME->getTH1F();
233 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 234 <<
"Cannot create TH1F from ME\n";
238 const double entries = normHist->Integral();
240 hist->Scale(1. / entries,
"width");
242 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 243 <<
"Zero entries in histogram\n";
255 ME* element = theDQM->get(startDir +
"/" + histName);
256 TH1F*
hist = element->getTH1F();
258 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 259 <<
"Cannot create TH1F from ME\n";
267 if (!theDQM->dirExists(startDir)) {
268 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 269 <<
"Cannot find sub-directory " << startDir << endl;
275 ME* element = theDQM->get(startDir +
"/" + histName);
278 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 279 <<
"No such element '" << histName <<
"' found\n";
283 TH1F*
hist = element->getTH1F();
285 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 286 <<
"Cannot create TH1F from ME\n";
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
#define DEFINE_FWK_MODULE(type)
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
void normalizeToLumi(const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection)