21 #include <boost/cstdint.hpp> 26 #include <sys/types.h> 39 outputFileName_( pset.getUntrackedParameter<
std::
string>(
"OutputRootFile",
"" ) ),
40 collateHistos_( !pset.getUntrackedParameter<bool>(
"UseClientFile",
false ) ),
41 analyzeHistos_( pset.getUntrackedParameter<bool>(
"AnalyzeHistos",
true ) ),
42 xmlFile_( (pset.getUntrackedParameter<
edm::FileInPath>(
"SummaryXmlFile",
edm::FileInPath() )).fullPath() ),
43 createSummaryPlots_(
false ),
44 clientHistos_(
false ),
53 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 54 <<
" Constructing object...";
65 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 66 <<
" Destructing object...";
73 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 74 <<
" Analyzing root file(s)...";
79 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 80 <<
" NULL pointer to DQMStore!" 89 std::ifstream root_file;
90 root_file.open( ifile->c_str() );
91 if( !root_file.is_open() ) {
93 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 94 <<
" The input root file \"" << *ifile
95 <<
"\" could not be opened!" 96 <<
" Please check the path and filename!";
102 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 103 <<
" The input root files appear to be a mixture" 104 <<
" of \"Source\" and \"Client\" files!" 108 if ( found != std::string::npos &&
inputFiles_.size() != 1 ) {
110 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 111 <<
" There appear to be multiple input \"Client\" root files!" 120 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 121 <<
" Collated histograms found in input root file \"" 127 std::ifstream xml_file;
129 if( !xml_file.is_open() ) {
131 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 132 <<
" The SummaryPlot XML file \"" <<
xmlFile_ 133 <<
"\" could not be opened!" 134 <<
" Please check the path and filename!" 146 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 147 <<
" No input root files specified!";
152 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 153 <<
" Opening root files. This may take some time!...";
157 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 158 <<
" Opening root file \"" << *jfile
159 <<
"\"... (This may take some time.)";
166 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 167 <<
" Opened root file \"" << *jfile <<
"\"!";
170 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 171 <<
" Opened " <<
inputFiles_.size() <<
" root files!";
175 bei_->getContents( contents );
179 std::vector<std::string>
temp;
180 std::vector<std::string>::iterator istr = contents.begin();
181 for ( ; istr != contents.end(); istr++ ) {
183 temp.push_back( *istr );
192 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 193 <<
" Found " << contents.size()
194 <<
" directories containing MonitorElements";
198 std::stringstream ss;
199 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 200 <<
" Directories found: " << std::endl;
201 std::vector<std::string>::iterator istr = contents.begin();
202 for ( ; istr != contents.end(); istr++ ) { ss <<
" " << *istr << std::endl; }
218 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 219 <<
" Unknown commissioning runType: " 225 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 234 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 235 <<
" Parsing summary plot XML file...";
240 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 241 <<
" Parsed summary plot XML file and found " 242 <<
plots_.size() <<
" plots defined!";
245 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 246 <<
" Null string for SummaryPlotXmlFile!" 247 <<
" No summary plots will be created!";
251 std::stringstream ss;
252 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" << std::endl
253 <<
" Input root files : ";
256 std::vector<std::string>::const_iterator ifile =
inputFiles_.begin();
259 ss << std::setw(25) << std::setfill(
' ') <<
": ";
261 ss <<
"\"" << *ifile <<
"\"" << std::endl;
264 ss <<
" Run type : \"" 266 <<
" Run number : " <<
runNumber_ << std::endl
267 <<
" Summary plot XML file : ";
268 if (
xmlFile_.empty() ) { ss <<
"(none)"; }
269 else { ss <<
"\"" <<
xmlFile_ <<
"\""; }
274 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 275 <<
" Creating CommissioningHistogram object...";
279 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 280 <<
" Created CommissioningHistogram object!";
283 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 284 <<
" NULL pointer to CommissioningHistogram object!" 297 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 298 <<
" Analyzing histograms...";
301 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 302 <<
" Analyzed histograms!";
305 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 306 <<
" No histogram analysis performed!";
312 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 313 <<
" Generating summary plots...";
314 std::vector<SummaryPlot>::const_iterator iplot =
plots_.begin();
315 for ( ; iplot !=
plots_.end(); iplot++ ) {
318 iplot->presentation(),
320 iplot->granularity() );
324 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 325 <<
" Generated summary plots!";
328 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 329 <<
" No summary plots generated!";
338 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 339 <<
" Client file not saved!";
356 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 357 <<
" Finished analyzing root file(s)...";
365 if ( !(event.
id().
event()%10) ) {
367 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 368 <<
" Empty event loop! User can kill job...";
383 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 384 <<
" CommissioningHistogram object already exists!" 392 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 393 <<
" NULL pointer to DQMStore!";
415 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 416 <<
" Undefined run type!";
421 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 422 <<
" Unknown run type!";
433 bool collate_histos ) {
436 std::stringstream ss;
437 ss << std::setfill(
'0') << std::setw(8) << run_number;
441 if ( !collate_histos ) { nameStr =
"SiStripCommissioningClient_"; }
442 else { nameStr =
"SiStripCommissioningSource_"; }
444 LogTrace(
"TEST") <<
" runStr " << runStr;
449 if ( (dp = opendir(path.c_str())) ==
NULL ) {
451 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 452 <<
" Error locating directory \"" << path
453 <<
"\". No such directory!";
458 while ( (dirp = readdir(dp)) !=
NULL ) {
460 bool goodName = ( fileName.find(nameStr) != std::string::npos );
461 bool goodRun = ( fileName.find(runStr) != std::string::npos );
462 bool rootFile = ( fileName.find(
".root") != std::string::npos );
464 if ( goodName && goodRun && rootFile ) {
468 files.push_back(entry);
474 if ( !collate_histos && files.size() > 1 ) {
475 std::stringstream ss;
476 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 477 <<
" Found more than one client file!";
478 std::vector<std::string>::const_iterator
ifile = files.begin();
479 std::vector<std::string>::const_iterator
jfile = files.end();
482 }
else if ( files.empty() ) {
484 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 485 <<
" No input files found!" ;
static const char runNumber_[]
virtual void analyze(const edm::Event &, const edm::EventSetup &)
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
sistrip::RunType runType_
static const char dqmClientFileName_[]
void parseXML(const std::string &xml_file)
virtual ~SiStripCommissioningOfflineClient()
def setup(process, global_tag, zero_tesla=False)
static const char mlDqmClient_[]
virtual void printAnalyses()
std::string outputFileName_
void save(std::string &filename, uint32_t run_number=0)
virtual void printSummary()
virtual void configure(const edm::ParameterSet &, const edm::EventSetup &)
virtual void setInputFiles(std::vector< std::string > &, const std::string, uint32_t, bool)
static std::string runType(const sistrip::RunType &)
edm::ParameterSet parameters_
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 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 beginRun(const edm::Run &, const edm::EventSetup &)
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 > &)
static const char collate_[]
void remove(std::string pattern="")
virtual void histoAnalysis(bool debug)