24 #include <boost/tokenizer.hpp> 31 TPRegexp
metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
36 typedef std::vector<edm::ParameterSet>
VPSet;
37 typedef std::vector<std::string>
vstring;
38 typedef boost::escaped_list_separator<char> elsc;
40 elsc commonEscapes(
"\\",
" \t",
"\'");
44 for ( vstring::const_iterator normCmd = normCmds.begin();
45 normCmd != normCmds.end(); ++normCmd )
47 if ( normCmd->empty() )
continue;
48 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
51 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
52 iToken != tokens.end(); ++iToken) {
53 if ( iToken->empty() )
continue;
54 args.push_back(*iToken);
57 if ( args.empty()
or args.size() > 2 ) {
58 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
66 normOptions_.push_back(opt);
70 for ( VPSet::const_iterator normSet = normSets.begin();
71 normSet != normSets.end(); ++normSet )
74 opt.
name = normSet->getUntrackedParameter<
string>(
"name");
75 opt.
normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo", opt.
name);
77 normOptions_.push_back(opt);
82 for ( vstring::const_iterator lumiCmd = lumiCmds.begin();
83 lumiCmd != lumiCmds.end(); ++lumiCmd )
85 if ( lumiCmd->empty() )
continue;
86 boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
89 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
90 iToken != tokens.end(); ++iToken) {
91 if ( iToken->empty() )
continue;
92 args.push_back(*iToken);
95 if ( args.size() != 2 ) {
96 LogInfo(
"DQMRivetClient") <<
"Wrong input to lumiCmds\n";
107 lumiOptions_.push_back(opt);
112 for ( vstring::const_iterator scaleCmd = scaleCmds.begin();
113 scaleCmd != scaleCmds.end(); ++scaleCmd )
115 if ( scaleCmd->empty() )
continue;
116 boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
119 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
120 iToken != tokens.end(); ++iToken) {
121 if ( iToken->empty() )
continue;
122 args.push_back(*iToken);
125 if ( args.empty()
or args.size() > 2 ) {
126 LogInfo(
"DQMRivetClient") <<
"Wrong input to normCmds\n";
132 opt.
scale = atof(args[1].c_str());
133 scaleOptions_.push_back(opt);
144 typedef vector<string>
vstring;
160 LogInfo(
"DQMRivetClient") <<
"Cannot create DQMStore instance\n";
165 set<string> subDirSet;
167 for(vstring::const_iterator iSubDir = subDirs_.begin();
168 iSubDir != subDirs_.end(); ++iSubDir) {
171 if ( subDir[subDir.size()-1] ==
'/' ) subDir.erase(subDir.size()-1);
173 subDirSet.insert(subDir);
176 for(set<string>::const_iterator iSubDir = subDirSet.begin();
177 iSubDir != subDirSet.end(); ++iSubDir) {
178 const string&
dirName = *iSubDir;
179 for ( vector<DQMGenericClient::NormOption>::const_iterator normOption = normOptions_.begin();
180 normOption != normOptions_.end(); ++normOption ){
181 normalizeToIntegral(dirName, normOption->name, normOption->normHistName);
185 for(set<string>::const_iterator iSubDir = subDirSet.begin();
186 iSubDir != subDirSet.end(); ++iSubDir) {
187 const string&
dirName = *iSubDir;
188 for ( vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin();
189 lumiOption != lumiOptions_.end(); ++lumiOption ){
190 normalizeToLumi(dirName, lumiOption->name, lumiOption->normHistName, lumiOption->xsection);
194 for(set<string>::const_iterator iSubDir = subDirSet.begin();
195 iSubDir != subDirSet.end(); ++iSubDir) {
196 const string&
dirName = *iSubDir;
197 for ( vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
198 scaleOption != scaleOptions_.end(); ++scaleOption ){
199 scaleByFactor(dirName, scaleOption->name, scaleOption->scale);
204 if ( ! outputFileName_.empty() ) theDQM->save(outputFileName_);
214 LogTrace (
"DQMRivetClient") <<
"inside of DQMGenericClient::endJob()" 221 if ( ! theDQM->dirExists(startDir) ) {
222 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 223 <<
"Cannot find sub-directory " << startDir << endl;
229 ME* element = theDQM->get(startDir+
"/"+histName);
230 ME* normME = theDQM->get(startDir+
"/"+normHistName);
233 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 234 <<
"No such element '" << histName <<
"' found\n";
239 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 240 <<
"No such element '" << normHistName <<
"' found\n";
244 TH1F*
hist = element->getTH1F();
246 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 247 <<
"Cannot create TH1F from ME\n";
251 TH1F* normHist = normME->getTH1F();
253 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 254 <<
"Cannot create TH1F from ME\n";
258 const double entries = normHist->Integral();
259 if ( entries != 0 ) {
260 hist->Scale(1./entries,
"width");
263 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 264 <<
"Zero entries in histogram\n";
271 normalizeToIntegral(startDir, histName, normHistName);
273 ME* element = theDQM->get(startDir+
"/"+histName);
274 TH1F*
hist = element->getTH1F();
276 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 277 <<
"Cannot create TH1F from ME\n";
280 hist->Scale(xsection);
285 if ( ! theDQM->dirExists(startDir) ) {
286 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 287 <<
"Cannot find sub-directory " << startDir << endl;
293 ME* element = theDQM->get(startDir+
"/"+histName);
296 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 297 <<
"No such element '" << histName <<
"' found\n";
301 TH1F*
hist = element->getTH1F();
303 LogInfo(
"DQMRivetClient") <<
"normalizeToEntries() : " 304 <<
"Cannot create TH1F from ME\n";
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
DQMRivetClient(const edm::ParameterSet &pset)
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
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 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)