26 #include <sys/types.h> 40 outputFileName_(
pset.getUntrackedParameter<
std::
string>(
"OutputRootFile",
"")),
41 collateHistos_(!
pset.getUntrackedParameter<
bool>(
"UseClientFile",
false)),
42 analyzeHistos_(
pset.getUntrackedParameter<
bool>(
"AnalyzeHistos",
true)),
43 xmlFile_((
pset.getUntrackedParameter<
edm::FileInPath>(
"SummaryXmlFile",
edm::FileInPath())).
fullPath()),
44 createSummaryPlots_(
false),
55 <<
" Constructing object...";
56 usesResource(
"DQMStore");
60 pset.getUntrackedParameter<uint32_t>(
"RunNumber"),
68 <<
" Destructing object...";
75 <<
" Analyzing root file(s)...";
80 <<
" NULL pointer to DQMStore!" 88 std::ifstream root_file;
89 root_file.open(
ifile->c_str());
90 if (!root_file.is_open()) {
92 <<
" The input root file \"" << *
ifile <<
"\" could not be opened!" 93 <<
" Please check the path and filename!";
99 <<
" The input root files appear to be a mixture" 100 <<
" of \"Source\" and \"Client\" files!" 106 <<
" There appear to be multiple input \"Client\" root files!" 110 if (
found != std::string::npos) {
117 <<
" Collated histograms found in input root file \"" <<
inputFiles_[0] <<
"\"";
122 std::ifstream xml_file;
124 if (!xml_file.is_open()) {
126 <<
" The SummaryPlot XML file \"" <<
xmlFile_ <<
"\" could not be opened!" 127 <<
" Please check the path and filename!" 139 <<
" No input root files specified!";
144 <<
" Opening root files. This may take some time!...";
148 <<
" Opening root file \"" << *
jfile <<
"\"... (This may take some time.)";
155 <<
" Opened root file \"" << *
jfile <<
"\"!";
158 <<
" Opened " <<
inputFiles_.size() <<
" root files!";
166 std::set<std::string>
temp;
167 for (
auto me : allmes) {
168 const auto&
name =
me->getPathname();
174 for (
const auto&
s :
temp) {
182 <<
" Found " <<
contents.size() <<
" directories containing MonitorElements";
186 std::stringstream
ss;
187 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 188 <<
" Directories found: " << std::endl;
189 std::vector<std::string>::iterator istr =
contents.begin();
190 for (; istr !=
contents.end(); istr++) {
191 ss <<
" " << *istr << std::endl;
220 <<
" Parsing summary plot XML file...";
225 <<
" Parsed summary plot XML file and found " <<
plots_.size() <<
" plots defined!";
228 <<
" Null string for SummaryPlotXmlFile!" 229 <<
" No summary plots will be created!";
233 std::stringstream
ss;
234 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" << std::endl <<
" Input root files : ";
241 ss << std::setw(25) << std::setfill(
' ') <<
": ";
243 ss <<
"\"" << *
ifile <<
"\"" << std::endl;
247 <<
" Run number : " <<
runNumber_ << std::endl
248 <<
" Summary plot XML file : ";
258 <<
" Creating CommissioningHistogram object...";
262 <<
" Created CommissioningHistogram object!";
265 <<
" NULL pointer to CommissioningHistogram object!" 278 <<
" Analyzing histograms...";
283 <<
" Analyzed histograms!";
286 <<
" No histogram analysis performed!";
292 <<
" Generating summary plots...";
293 std::vector<SummaryPlot>::const_iterator iplot =
plots_.begin();
294 for (; iplot !=
plots_.end(); iplot++) {
300 <<
" Generated summary plots!";
303 <<
" No summary plots generated!";
321 <<
" Client file not saved!";
340 <<
" Finished analyzing root file(s)...";
346 if (!(
event.id().event() % 10)) {
348 <<
" Empty event loop! User can kill job...";
362 <<
" CommissioningHistogram object already exists!" 370 <<
" NULL pointer to DQMStore!";
403 <<
" Undefined run type!";
408 <<
" Unknown run type!";
420 bool collate_histos) {
422 std::stringstream
ss;
427 if (!collate_histos) {
428 nameStr =
"SiStripCommissioningClient_";
430 nameStr =
"SiStripCommissioningSource_";
433 LogTrace(
"TEST") <<
" runStr " << runStr;
438 if ((
dp = opendir(
path.c_str())) ==
nullptr) {
440 <<
" Error locating directory \"" <<
path <<
"\". No such directory!";
445 while ((dirp = readdir(
dp)) !=
nullptr) {
447 bool goodName = (
fileName.find(nameStr) != std::string::npos);
448 bool goodRun = (
fileName.find(runStr) != std::string::npos);
449 bool rootFile = (
fileName.find(
".root") != std::string::npos);
450 bool goodPartition =
true;
456 if (goodName && goodRun && rootFile && goodPartition) {
466 if (!collate_histos &&
files.size() > 1) {
467 std::stringstream
ss;
468 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 469 <<
" Found more than one client file!";
470 std::vector<std::string>::const_iterator
ifile =
files.begin();
471 std::vector<std::string>::const_iterator
jfile =
files.end();
476 }
else if (
files.empty()) {
478 <<
" No input files found!";
static const char runNumber_[]
Log< level::Info, true > LogVerbatim
void save(std::string &filename, uint32_t run_number=0, std::string partitionName="")
sistrip::RunType runType_
static const char dqmClientFileName_[]
void parseXML(const std::string &xml_file)
static const char mlDqmClient_[]
virtual void printAnalyses()
std::string outputFileName_
Log< level::Error, false > LogError
virtual void printSummary()
virtual void configure(const edm::ParameterSet &, const edm::EventSetup &)
T getUntrackedParameter(std::string const &, T const &) const
static std::string runType(const sistrip::RunType &)
~SiStripCommissioningOfflineClient() override
edm::ParameterSet parameters_
std::string partitionName_
Parses the "summary plot" xml configuration file.
void extractHistograms(const std::vector< std::string > &)
static sistrip::RunType runType(DQMStore *const, const std::vector< std::string > &)
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
virtual void createHistos(const edm::ParameterSet &, const edm::EventSetup &)
SiStripCommissioningOfflineClient(const edm::ParameterSet &)
static uint32_t runNumber(DQMStore *const, const std::vector< std::string > &)
virtual void uploadToConfigDb()
CommissioningHistograms * histos_
virtual void setInputFiles(std::vector< std::string > &, const std::string, const std::string, uint32_t, bool)
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< SummaryPlot > summaryPlots(const sistrip::RunType &)
std::vector< SummaryPlot > plots_
virtual void createSummaryHisto(const sistrip::Monitorable &, const sistrip::Presentation &, const std::string &top_level_dir, const sistrip::Granularity &)
std::vector< std::string > inputFiles_
static void copyCustomInformation(DQMStore *const, const std::vector< std::string > &)
Log< level::Warning, false > LogWarning
static const char collate_[]
void remove(std::string pattern="")
DQM_DEPRECATED bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void histoAnalysis(bool debug)