23 #include <boost/cstdint.hpp> 28 #include <sys/types.h> 41 outputFileName_( pset.getUntrackedParameter<
std::
string>(
"OutputRootFile",
"" ) ),
42 collateHistos_( !pset.getUntrackedParameter<
bool>(
"UseClientFile",
false ) ),
43 analyzeHistos_( pset.getUntrackedParameter<
bool>(
"AnalyzeHistos",
true ) ),
44 xmlFile_( (pset.getUntrackedParameter<
edm::FileInPath>(
"SummaryXmlFile",
edm::FileInPath() )).fullPath() ),
45 createSummaryPlots_(
false ),
46 clientHistos_(
false ),
50 partitionName_(pset.existsAs<
std::
string>(
"PartitionName") ? pset.getParameter<
std::
string>(
"PartitionName") :
""),
56 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 57 <<
" Constructing object...";
69 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 70 <<
" Destructing object...";
77 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 78 <<
" Analyzing root file(s)...";
83 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 84 <<
" NULL pointer to DQMStore!" 93 std::ifstream root_file;
94 root_file.open( ifile->c_str() );
95 if( !root_file.is_open() ) {
97 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 98 <<
" The input root file \"" << *ifile
99 <<
"\" could not be opened!" 100 <<
" Please check the path and filename!";
106 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 107 <<
" The input root files appear to be a mixture" 108 <<
" of \"Source\" and \"Client\" files!" 112 if ( found != std::string::npos &&
inputFiles_.size() != 1 ) {
114 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 115 <<
" There appear to be multiple input \"Client\" root files!" 124 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 125 <<
" Collated histograms found in input root file \"" 131 std::ifstream xml_file;
133 if( !xml_file.is_open() ) {
135 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 136 <<
" The SummaryPlot XML file \"" <<
xmlFile_ 137 <<
"\" could not be opened!" 138 <<
" Please check the path and filename!" 150 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 151 <<
" No input root files specified!";
156 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 157 <<
" Opening root files. This may take some time!...";
161 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 162 <<
" Opening root file \"" << *jfile
163 <<
"\"... (This may take some time.)";
170 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 171 <<
" Opened root file \"" << *jfile <<
"\"!";
174 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 175 <<
" Opened " <<
inputFiles_.size() <<
" root files!";
179 bei_->getContents( contents );
183 std::vector<std::string>
temp;
184 std::vector<std::string>::iterator istr = contents.begin();
185 for ( ; istr != contents.end(); istr++ ) {
187 temp.push_back( *istr );
196 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 197 <<
" Found " << contents.size()
198 <<
" directories containing MonitorElements";
202 std::stringstream ss;
203 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 204 <<
" Directories found: " << std::endl;
205 std::vector<std::string>::iterator istr = contents.begin();
206 for ( ; istr != contents.end(); istr++ ) { ss <<
" " << *istr << std::endl; }
222 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 223 <<
" Unknown commissioning runType: " 229 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 238 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 239 <<
" Parsing summary plot XML file...";
244 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 245 <<
" Parsed summary plot XML file and found " 246 <<
plots_.size() <<
" plots defined!";
249 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 250 <<
" Null string for SummaryPlotXmlFile!" 251 <<
" No summary plots will be created!";
255 std::stringstream ss;
256 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" << std::endl
257 <<
" Input root files : ";
260 std::vector<std::string>::const_iterator ifile =
inputFiles_.begin();
263 ss << std::setw(25) << std::setfill(
' ') <<
": ";
265 ss <<
"\"" << *ifile <<
"\"" << std::endl;
268 ss <<
" Run type : \"" 270 <<
" Run number : " <<
runNumber_ << std::endl
271 <<
" Summary plot XML file : ";
272 if (
xmlFile_.empty() ) { ss <<
"(none)"; }
273 else { ss <<
"\"" <<
xmlFile_ <<
"\""; }
278 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 279 <<
" Creating CommissioningHistogram object...";
283 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 284 <<
" Created CommissioningHistogram object!";
287 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 288 <<
" NULL pointer to CommissioningHistogram object!" 301 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 302 <<
" Analyzing histograms...";
305 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 306 <<
" Analyzed histograms!";
309 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 310 <<
" No histogram analysis performed!";
316 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 317 <<
" Generating summary plots...";
318 std::vector<SummaryPlot>::const_iterator iplot =
plots_.begin();
319 for ( ; iplot !=
plots_.end(); iplot++ ) {
322 iplot->presentation(),
324 iplot->granularity() );
328 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 329 <<
" Generated summary plots!";
332 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 333 <<
" No summary plots generated!";
347 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 348 <<
" Client file not saved!";
365 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 366 <<
" Finished analyzing root file(s)...";
374 if ( !(event.
id().
event()%10) ) {
376 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 377 <<
" Empty event loop! User can kill job...";
392 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 393 <<
" CommissioningHistogram object already exists!" 401 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 402 <<
" NULL pointer to DQMStore!";
426 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 427 <<
" Undefined run type!";
432 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 433 <<
" Unknown run type!";
445 bool collate_histos ) {
448 std::stringstream ss;
449 ss << std::setfill(
'0') << std::setw(8) << run_number;
453 if ( !collate_histos ) { nameStr =
"SiStripCommissioningClient_"; }
454 else { nameStr =
"SiStripCommissioningSource_"; }
456 LogTrace(
"TEST") <<
" runStr " << runStr;
461 if ( (dp = opendir(path.c_str())) ==
nullptr ) {
463 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 464 <<
" Error locating directory \"" << path
465 <<
"\". No such directory!";
470 while ( (dirp = readdir(dp)) !=
nullptr ) {
472 bool goodName = ( fileName.find(nameStr) != std::string::npos );
473 bool goodRun = ( fileName.find(runStr) != std::string::npos );
474 bool rootFile = ( fileName.find(
".root") != std::string::npos );
475 bool goodPartition =
true;
476 if(not partitionName.empty()){
477 goodPartition = ( fileName.find(partitionName) != std::string::npos );
481 if ( goodName && goodRun && rootFile && goodPartition ){
485 files.push_back(entry);
491 if ( !collate_histos && files.size() > 1 ) {
492 std::stringstream ss;
493 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 494 <<
" Found more than one client file!";
495 std::vector<std::string>::const_iterator
ifile = files.begin();
496 std::vector<std::string>::const_iterator
jfile = files.end();
499 }
else if ( files.empty() ) {
501 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 502 <<
" No input files found!" ;
static const char runNumber_[]
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void save(std::string &filename, uint32_t run_number=0, std::string partitionName="")
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
sistrip::RunType runType_
static const char dqmClientFileName_[]
void parseXML(const std::string &xml_file)
def setup(process, global_tag, zero_tesla=False)
static const char mlDqmClient_[]
virtual void printAnalyses()
std::string outputFileName_
virtual void printSummary()
virtual void configure(const edm::ParameterSet &, const edm::EventSetup &)
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 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 > &)
static const char collate_[]
void remove(std::string pattern="")
void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void histoAnalysis(bool debug)