26 #include <boost/tokenizer.hpp>
33 TPRegexp
metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
38 typedef std::vector<edm::ParameterSet> VPSet;
39 typedef std::vector<std::string>
vstring;
40 typedef boost::escaped_list_separator<char> elsc;
42 elsc commonEscapes(
"\\",
" \t",
"\'");
46 for ( vstring::const_iterator normCmd = normCmds.begin();
47 normCmd != normCmds.end(); ++normCmd )
49 if ( normCmd->empty() )
continue;
50 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
53 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
54 iToken != tokens.end(); ++iToken) {
55 if ( iToken->empty() )
continue;
56 args.push_back(*iToken);
59 if ( args.empty()
or args.size() > 2 ) {
60 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
68 normOptions_.push_back(opt);
72 for ( VPSet::const_iterator normSet = normSets.begin();
73 normSet != normSets.end(); ++normSet )
76 opt.
name = normSet->getUntrackedParameter<
string>(
"name");
77 opt.
normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo", opt.
name);
79 normOptions_.push_back(opt);
84 for ( vstring::const_iterator lumiCmd = lumiCmds.begin();
85 lumiCmd != lumiCmds.end(); ++lumiCmd )
87 if ( lumiCmd->empty() )
continue;
88 boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
91 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
92 iToken != tokens.end(); ++iToken) {
93 if ( iToken->empty() )
continue;
94 args.push_back(*iToken);
97 if ( args.size() != 2 ) {
98 LogInfo(
"DQMRivetClient") <<
"Wrong input to lumiCmds\n";
109 lumiOptions_.push_back(opt);
114 for ( vstring::const_iterator scaleCmd = scaleCmds.begin();
115 scaleCmd != scaleCmds.end(); ++scaleCmd )
117 if ( scaleCmd->empty() )
continue;
118 boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
121 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
122 iToken != tokens.end(); ++iToken) {
123 if ( iToken->empty() )
continue;
124 args.push_back(*iToken);
127 if ( args.empty()
or args.size() > 2 ) {
128 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
134 opt.
scale = atof(args[1].c_str());
135 scaleOptions_.push_back(opt);
146 typedef vector<string>
vstring;
162 LogInfo(
"DQMRivetClient") <<
"Cannot create DQMStore instance\n";
167 set<string> subDirSet;
169 for(vstring::const_iterator iSubDir = subDirs_.begin();
170 iSubDir != subDirs_.end(); ++iSubDir) {
171 string subDir = *iSubDir;
173 if ( subDir[subDir.size()-1] ==
'/' ) subDir.erase(subDir.size()-1);
175 subDirSet.insert(subDir);
178 for(set<string>::const_iterator iSubDir = subDirSet.begin();
179 iSubDir != subDirSet.end(); ++iSubDir) {
180 const string&
dirName = *iSubDir;
181 for ( vector<DQMGenericClient::NormOption>::const_iterator normOption = normOptions_.begin();
182 normOption != normOptions_.end(); ++normOption ){
183 normalizeToIntegral(dirName, normOption->name, normOption->normHistName);
187 for(set<string>::const_iterator iSubDir = subDirSet.begin();
188 iSubDir != subDirSet.end(); ++iSubDir) {
189 const string&
dirName = *iSubDir;
190 for ( vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin();
191 lumiOption != lumiOptions_.end(); ++lumiOption ){
192 normalizeToLumi(dirName, lumiOption->name, lumiOption->normHistName, lumiOption->xsection);
196 for(set<string>::const_iterator iSubDir = subDirSet.begin();
197 iSubDir != subDirSet.end(); ++iSubDir) {
198 const string&
dirName = *iSubDir;
199 for ( vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
200 scaleOption != scaleOptions_.end(); ++scaleOption ){
201 scaleByFactor(dirName, scaleOption->name, scaleOption->scale);
206 if ( ! outputFileName_.empty() ) theDQM->save(outputFileName_);
216 LogTrace (
"DQMRivetClient") <<
"inside of DQMGenericClient::endJob()"
223 if ( ! theDQM->dirExists(startDir) ) {
224 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
225 <<
"Cannot find sub-directory " << startDir << endl;
231 ME* element = theDQM->get(startDir+
"/"+histName);
232 ME* normME = theDQM->get(startDir+
"/"+normHistName);
235 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
236 <<
"No such element '" << histName <<
"' found\n";
241 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
242 <<
"No such element '" << normHistName <<
"' found\n";
246 TH1F*
hist = element->getTH1F();
248 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
249 <<
"Cannot create TH1F from ME\n";
253 TH1F* normHist = normME->getTH1F();
255 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
256 <<
"Cannot create TH1F from ME\n";
260 const double entries = normHist->Integral();
261 if ( entries != 0 ) {
262 hist->Scale(1./entries,
"width");
265 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
266 <<
"Zero entries in histogram\n";
273 normalizeToIntegral(startDir, histName, normHistName);
275 ME* element = theDQM->get(startDir+
"/"+histName);
276 TH1F*
hist = element->getTH1F();
278 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
279 <<
"Cannot create TH1F from ME\n";
282 hist->Scale(xsection);
287 if ( ! theDQM->dirExists(startDir) ) {
288 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
289 <<
"Cannot find sub-directory " << startDir << endl;
295 ME* element = theDQM->get(startDir+
"/"+histName);
298 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
299 <<
"No such element '" << histName <<
"' found\n";
303 TH1F*
hist = element->getTH1F();
305 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : "
306 <<
"Cannot create TH1F from ME\n";
T getUntrackedParameter(std::string const &, T const &) const
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
#define DEFINE_FWK_MODULE(type)
DQMRivetClient(const edm::ParameterSet &pset)
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
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)